The code looks right... except you really need to check the epkey returned. There are 
lots of environmental reasons why this function may fail (token the privkey is in 
isn't logged int, the token doesn't support wrapping private keys, token the privkey 
lives in can't generate the PBE, etc). If you check the error code and look at the 
secerr returned you would get a better idea of what went wrong.

bob


Emil Assarsson wrote on Wed, 28 Apr 04, 8:54 AM:
> I just have to check... 
> 
> Is it possible to export a private (pkcs#8) key with 
> --- snipp --- 
> epkey = PK11_ExportEncryptedPrivKeyInfo( NULL, 
>     SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC, 
>     pwitem, privkey, 3, NULL); 
> 
> expkey = SEC_ASN1EncodeItem(arena, NULL, epkey, 
>     SEC_ASN1_GET(SECKEY_EncryptedPrivateKeyInfoTemplate)); 
> --- /snipp --- 
> ? 
> 
> I was trying to do this but I got segmentation faults... ;-) 
> Very, very possible my misstake though. 
> 
> Emil Assarsson 
> _______________________________________________ 
> mozilla-crypto mailing list 
> [EMAIL PROTECTED] 
> http://mail.mozilla.org/listinfo/mozilla-crypto 

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to