> I'm trying to use the OpenSSL crypto lib. I've generated a public/private > RSA key pair. Then I wrote some code to try to encrypt an eight-byte random > string. But it crashes in RSA_size(). Here's the code: > > BIO* bp = BIO_new_mem_buf(_publicKey, -1); // > Create a new memory buffer BIO. > RSA* pubKey = PEM_read_bio_RSA_PUBKEY(bp, 0, 0, 0); // > And read the RSA key from it. > BIO_free(bp);
Are you checking the pointer pubKey after PEM_read_bio_RSA_PUBKEY? If it is NULL, RSA_size will die. > // Allocate a string to hold the encrypted result. > unsigned char encryptedRandKey[RSA_size(pubKey)]; John ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org