Reputation: 343
I am trying to use RSA to decrypt some stuff using OpenSSL. I want to load a public key. The default function provided to do this is PEM_read_RSA_PUBKEY() which requires a file descriptor.
I would like to embed the keys into the program as strings. Is there any way to achieve this?
Upvotes: 1
Views: 839
Reputation: 239011
Use d2i_RSA_PUBKEY
to load directly from a buffer containing binary DER format:
const unsigned char *p = key;
RSA *r = d2i_RSA_PUBKEY(NULL, &p, keylen);
Upvotes: 1