There are a lot of ugly things in your code, but that strlen(firma) has no sense. I think you are confusing the size of the private key RSA struct with the size of the buffer you want to sign. Also, you are using strlen with a buffer (firma) with any content and probaly not ended with 0, so it will crash your application.
I suggest you to look at the OpenSSL apps directory to see some examples.(the "rsa" example will help you). ----- Original Message ----- From: "Angel Martinez Gonzalez" <[EMAIL PROTECTED]> To: <openssl-users@openssl.org> Sent: Wednesday, April 13, 2005 1:54 PM Subject: Error to sign with OpenSSL > Hello: > > I want sign with OpenSSL, and I use the RSA_sign fuction: > > > void Firmar(char *mdigest, int longmdigest, RSA *claveRSA) > { > int error; > char *firma; > > firma = malloc(RSA_size(claveRSA)); > > error = RSA_sign(NID_sha1, mdigest, longmdigest, firma, strlen(firma), > claveRSA); > > if (error == 1) > printf ("Firma realizada con exito\n"); > else > printf ("Error en el firmado\n"); > > } > > And I call to this funcion "Firmar" with this code: > > Firmar(messagedigest, longitudMensajeDigest, parClaves); > > Where: > unsigned char messagedigest[EVP_MAX_MD_SIZE]; > int longitudMensajeDigest; > RSA *parClaves; > > and this variables have a valid value. > > But I have an error in execution time. What is wrong?. > > Thanks. > > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager [EMAIL PROTECTED] > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]