I found how to do that....

pkcs8privkeyinfo=(PKCS8_PRIV_KEY_INFO *)PEM_ASN1_read_bio((char 
*(*)())d2i_PKCS8_PRIV_KEY_INFO, PEM_STRING_PKCS8INF, in, NULL, NULL, NULL);
pkey=EVP_PKCS82PKEY(pkcs8privkeyinfo);

And then, I can get the RSA private key as usual and sign my stuff...  

On Fri, 10 Dec 1999, Erwann ABALEA wrote:

> Hello,
> 
> Is there a way to read PKCS#8 keys? I need to generate RSA private keys in
> software and store them as PKCS#8, and then later use them, but I can't
> find the function I need to read back my pkey...
> 
> To store my pkey, I use PEM_write_bio_PKCS8PrivateKey(out, pkey, NULL,
> NULL, 0, NULL, NULL);
> 
> When I want to read it, I try 
> pkey=(EVP_PKEY *)PEM_ASN1_read_bio((char *(*)())d2i_PKCS8_PRIV_KEY_INFO,
>      PEM_STRING_PKCS8INF, in, NULL, NULL, NULL);
> 
> But the result is invalid (the *(pkey.rsa) struct is badly filled).
> 
> I tried with both a self generated PKCS#8 key and a converted private key,
> and the result is the same...
> 
> Any idea? 
> 
> 

-- 
Erwann ABALEA
System and Development Engineer - Certplus SA
[EMAIL PROTECTED]
- RSA PGP Key ID: 0x2D0EABD5 -

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to