openssl-users  

Re: Harcoded Private RSA Key

Douglas Gemignani
Mon, 01 Feb 2010 11:47:57 -0800

Thanks for your help again Stephen, I will try that, if it works I
will post my result.

[]s
Douglas Gemignani



On Fri, Jan 29, 2010 at 11:14 AM, Dr. Stephen Henson <st...@openssl.org> wrote:
> On Fri, Jan 29, 2010, Douglas Gemignani wrote:
>
>> 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?
>>
>
> You can create a BIO from a memory buffer directly using BIO_new_mem_buf().
>
> Steve.
> --
> Dr Stephen N. Henson. OpenSSL project core developer.
> Commercial tech support now available see: http://www.openssl.org
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-us...@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