I have installed OpenSSL 9.7.g on a HP-UX B.11.0 A 9000/800 server (with Ansi 
C). I know it's not the newest version of OpenSSL but I have installed this 
version in a similar server 2 years ago and it worked fine...
The installation went ok, but I try to compile a simple C program (where I 
generate a digital signature, so I only use the cryptographic library, nothing 
of ssl), and I can't make my program to find these libraries:
 
This is how I compile:
cc -o firma +DD64 -I/usr/local/ssl/include -L/usr/local/ssl/lib -lcrypto firma.c
 
where:
+DD64 is to assure an 64 bit compilation
-L to indicate the path where I have libcrypto.a file
-lcrypto to indicate that I want to use the crytpographic library
 
But It seems that the compiler cannot find the libcrypto.a file because I have 
errors like:
ld: Unsatisfied symbol "EVP_DigestInit_ex" in file firma.o
ld: Unsatisfied symbol "BIO_new_fp" in file firma.old: Unsatisfied symbol 
"EVP_PKEY_size" in file firma.o... an so on (just errors like this ones)
 
Any clues of what I am missing??? Thanks in advance for your recommendations.
 
 
Silvia Pavón
 
 
If you need it, here's my program, so you see, It's simple (and I know it works 
because it's working in the server I installed openssl 2 yearas ago):
 
#include <openssl/evp.h>#include <openssl/rsa.h>#include 
<openssl/pem.h>#include <openssl/err.h>#include <openssl/bio.h>
#include <stdlib.h>
#define TAM_BUF 1024
int main(int argc, char **argv){
  ERR_load_crypto_strings();
 
   // Carga de llave en archivo en formato PEM   // previamente abri la llave 
en PKCS8 con linea de comando   FILE *fp_key_pem;   EVP_PKEY *clave_EVP;
   printf("Iniciando lectura de llave en archivo\n");   if( (fp_key_pem = 
fopen("key.pem","rb")) == NULL ){     ERR_print_errors_fp (stderr);     
exit(1);   } //if   PEM_read_PrivateKey(fp_key_pem, &clave_EVP, NULL, NULL);   
fclose(fp_key_pem);
   printf("Llave cargada\n");   printf("Tamanio de llave es %d 
bytes\n",EVP_PKEY_size(clave_EVP));
 
   // Carga el archivo a firmar   FILE *fp_ext;
   if( (fp_ext = fopen("ale_cadena_original.xml","rb")) == NULL ){     
perror("ERROR: Abriendo el archivo a firmar\n");     exit(1);   }//if
 
   // Comienza firma   unsigned char *firma;   int           bytes_leidos;   
unsigned int  bytes_firma;   EVP_MD_CTX    ctx;   char          buf[TAM_BUF];   
int           err;
   printf("Firmando...\n");   firma = (unsigned char *) 
malloc(EVP_PKEY_size(clave_EVP));
   EVP_SignInit_ex(&ctx, EVP_md5(), NULL);   while (!feof(fp_ext)){     
bytes_leidos = fread( (void *) buf, sizeof(char), TAM_BUF, fp_ext);     
EVP_SignUpdate(&ctx, (void *) buf, bytes_leidos);   }//while
   bytes_firma = EVP_PKEY_size(clave_EVP);   err = EVP_SignFinal(&ctx, firma, 
&bytes_firma, clave_EVP);   if (err != 1){     ERR_print_errors_fp(stderr);     
exit (1);   }//if
   printf("Ya firme y tamano firma es %d %d\n",bytes_firma, strlen(firma));
 
   // Conversion a base 64   BIO *bio;   BIO *b64;   FILE *fp_out;
   if( (fp_out = fopen("firma_b64.txt","w")) == NULL ){     perror("ERROR: 
Abriendo el archivo de salida\n");     exit(1);   }//if
   b64 = BIO_new(BIO_f_base64());   bio = BIO_new_fp(fp_out, BIO_NOCLOSE);   
bio = BIO_push(b64, bio);   BIO_write(bio, firma, bytes_firma);   
BIO_flush(bio);
   fclose(fp_out);   printf("Liberando espacio utilizado\n");   
BIO_free_all(bio);   free(firma);   EVP_PKEY_free(clave_EVP);
   exit(0);
}//main
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Reply via email to