Thanks. I switched to using d2i_PUBKEY (it really is hard-coded, so I
don't think there's a reason to use BIO – if I'm mistaken, please tell
me) and it now returns a valid address in memory.
On 20-Jul-09, at 4:59 PM, Mounir IDRASSI wrote:
Hi,
The public key in your source is encoded as a SubjectPublicKeyInfo,
so you can't use d2i_PublicKey which only handles RSA public keys
encoded in the PKCS#1 format. In your case, you have to use the
function d2i_PUBKEY_bio to read your hard-coded key.
Here is how you can do it using the same variables of your code :
BIO* keyBio = BIO_new_mem_buf(TESTING_PUBLIC_KEY,
sizeof(TESTING_PUBLIC_KEY));
public_key = d2i_PUBKEY_bio(keyBio, NULL);
That's it!
I hope this will help.
Cheers,
--
Mounir IDRASSI
IDRIX
http://www.idrix.fr
Jeremy R. wrote:
I'm trying to make a simple application which uses a 4096-bit RSA
public key (encoded in DER format, statically compiled into the
program itself. I generated this key with OpenSSL itself and I am
able to do operations with it from the command-line. And I know I
encoded it in the program correctly, because if I ask it to write
TESTING_PUBLIC_KEY to disk, OpenSSL continues to accept it.
However, when I try to use d2i_PublicKey to load it, it returns
NULL. Anyone have any hints that might help me?
My code is at http://pastebin.ca/1501265 and I'm compiling with VC+
+ (in C mode), for what it's worth.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org