Hello!
I am really new with programming with OpenSSL, and I have the following
problem. I hope somebody can help me.
I am working with OpenSSL version 0.9.5a, under windows 98. I am using
the borland c++ compiler version 5.5. I have taken the example sign.c
from the demo directory, and I have changed some function calls
(different numbers of parameters), afterwards I have compiled and have
the exe generated. But it just won't work, it appears the following
error:

4294662763:error:0906B072:PEM
routines:PEM_get_EVP_CIPHER_INFO:unsupported
encryption:.\crypto\pem\pem_lib.c:506:

Can anybody tell me, what does this error means, and how can I correct
the programm so that it does work properly? Here is how the program
looks like

//---------------------------------------------------------------------------

# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <openssl/rsa.h>
# include <openssl/evp.h>
# include <openssl/objects.h>
# include <openssl/x509.h>
# include <openssl/err.h>
# include <openssl/pem.h>
# include <openssl/ssl.h>


void main()
{
  int err;
  int sig_len;
  unsigned char sig_buf [4096];
/* I have generated this certificate using OpenSSL */
  static char certfile[] = "certificado.pem";
  static char keyfile[]  = "privada.pem";
  static char data[]     = "This is the signed data";
  EVP_MD_CTX md_ctx;
  EVP_PKEY *pkey;
  FILE *fp;
  X509 *x509;

  /* Just load the crypto library error strings,
   * SSL_load_error_strings() loads the crypto AND the SSL ones */
  /* SSL_load_error_strings();*/
  ERR_load_crypto_strings();
  /* Read private key */
  fp = fopen (keyfile, "r");
  if (fp == NULL)
        exit (1);
 pkey = PEM_read_PrivateKey(fp, NULL,NULL,NULL);
/* I have detected, that the error appears here. I think pkey takes the
value NULL, but I do not know why ! */
if (pkey == NULL)
  {
        ERR_print_errors_fp (stderr);
        exit (1);
  }
  fclose(fp);
  /* Do the signature */

  EVP_SignInit(&md_ctx, EVP_md5());
  EVP_SignUpdate(&md_ctx, data, strlen(data));
  sig_len = sizeof(sig_buf);
  err = EVP_SignFinal(&md_ctx,sig_buf,&sig_len,pkey);
  if (err != 1)
  {
        ERR_print_errors_fp (stderr);
        exit (1);
  }
  EVP_PKEY_free (pkey);
  /* Read public key */
  fp = fopen (certfile, "r");
  if (fp == NULL)
        exit (1);
  x509 = (X509 *)PEM_ASN1_read ((char
*(*)())d2i_X509,PEM_STRING_X509,fp, NULL,NULL,NULL);
  if (x509 == NULL)
  {
        ERR_print_errors_fp (stderr);
        exit (1);
  }
  fclose (fp);
  /* Get public key - eay*/
  pkey=X509_extract_key(x509);
  if (pkey == NULL)
  {
        ERR_print_errors_fp (stderr);
        exit (1);
  }
  /* Verify the signature */
  EVP_VerifyInit   (&md_ctx, EVP_md5());
  EVP_VerifyUpdate (&md_ctx, data, strlen((char*)data));
  err = EVP_VerifyFinal (&md_ctx, sig_buf,sig_len,pkey);
  if (err != 1)
  {
        ERR_print_errors_fp (stderr);
        exit (1);
  }
  EVP_PKEY_free (pkey);
  printf("Signature verified!\n");
}
//---------------------------------------------------------------------------

I also get the following warning while compiling

Warning W8075 signatures.c 60: Suspicious pointer conversion in function
main
 And this correspondes to the following line:

sig_len = sizeof(sig_buf);

Well, I hope you could help me, thanks in advance

Mariana



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to