Sorry for the incomplete message...

So using the below code:

   plainTextSize = RSA_size(rsaKey);
    plainText = (unsigned char *)calloc(plainTextSize, sizeof(unsigned
char));
     decryptedBytes = RSA_private_decrypt(secretSize, secret, plainText,
rsaKey, RSA_PKCS1_PADDING);

the rsaKey is the RSA structure pointer that I got back from
RSA_generate_key_ex.
The RSA_private_decrypt fails in this case.

But it works in this scenario:

RSA *keyPair = generateRSAKeyPair();
RSA_public_encrypt
RSA_private_decrypt

Any clue what might be wrong in the first case?

Thanks,
Tarani

On Mon, Nov 5, 2012 at 10:57 AM, Taraniteja Vishwanatha <
taranit...@gmail.com> wrote:

> Hey guys,
>
>  I am generating a RSA key pair (RSA *rsa = RSA_generate_key_ex(key, 3072,
> bn, 0) ) and then extract the Public key using PEM_write_bio_RSA_PUBKEY.
> The server using this public key encrypts the data and send back to me.
>
> Now, to decrypt the data , I am using the below code:
>
> plainTextSize = RSA_size(rsaKey);
>     plainText = (unsigned char *)calloc(plainTextSize, sizeof(unsigned
> char));
>
>     decryptedBytes = RSA_private_decrypt(secretSize, secret, plainText,
> rsaKey, RSA_PKCS1_PADDING);
>
>

Reply via email to