PrivateKey Decrypt Failure

Wim Lewis wiml at
Wed Sep 11 17:27:45 UTC 2019

On Sep 11, 2019, at 3:31 AM, Chitrang Srivastava <chitrang.srivastava at> wrote:
> I am using openssl 1.1.1b and I am storing private key encrypted.
> I am storing private key as
> PEM_write_bio_PrivateKey(bio, pkey, EVP_aes_128_cbc(), PKeyPassPKCS12, 0, 0, NULL); 

I don't think that PEM_write_bio_PrivateKey() will compute the key length for you if you pass 0. If you pass klen=0 it will encrypt with a 0-byte key. Try passing strlen(PKeyPassPKCS12) for klen and see if that helps.

More information about the openssl-users mailing list