0
votes

I am using RSA_public_encrypt function to send the encrypted data to socket. I am reading the public key from .PEM file using "pkey = PEM_read_PUBKEY(f, NULL, NULL, NULL);" function. 'pkey' retrieved from above function is of type EVP_PKEY* which I can not use in function RSA_public_encrypt. (RSA_public_encrypt uses RSA* type key)

How to convert EVP_PKEY *pkey to RSA *rsa?

1
which language are you using??? - wandos
I am doing this in C language - Andrew

1 Answers

1
votes

Use RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey) to get RSA type key from EVP_PKEY.

Example:

EVP_PKEY    *evp;
RSA         *pubkey

evp = ...; /* some way to get the public key */
pubkey = EVP_PKEY_get1_RSA(evp);
if (pubkey == NULL) {
    /* error handling */
}