openssl-users  

Harcoded Private RSA Key

Douglas Gemignani
Fri, 29 Jan 2010 05:00:09 -0800

Hello,

I would like to know if it is possible to embed a RSA private Key on
my code. Yes, I know this is not a very good practice.
I currently use PEM_read_PrivateKey(fp, NULL, NULL, password) for
reading the key from the file.

I tried to call i2d_PrivateKey (pkey, &p) hardcoding the output and
reading it again with d2i_PrivateKey (0, &pkey, &p, certlen) but it
didn't work, it doesn't build the EVP_PKEY structure properly.

My following solution was to create a BIO, exporting the key to it,
dumping the output then calling:
rsa=PEM_read_bio_RSAPrivateKey(bio,NULL,NULL,NULL))
EVP_PKEY_new()
EVP_PKEY_assign_RSA(pkey, rsa)
EVP_PKEY_set1_RSA(CApkey, rsa)

But I guess I missed something here.

Anybody know if a mmap/CreateFileMapping would work with  PEM_read_PrivateKey?

Thanks,

[]s
Douglas Gemignani
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org