PrivateKey Decrypt Failure

Chitrang Srivastava chitrang.srivastava at
Wed Sep 11 10:31:15 UTC 2019


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);
and on system startup reading using the following way
 if(!*PEM_read_bio_PrivateKey*(keyBIO, &user_s_key, NULL,

Upon debugging I found it is failing in PKCS12_pbe_crypt >
Please suggest where I am doing wrong?
Could this be appear to related to padding ?
Without encryption of key , it works fine , which clear other code is all


         * The following assumes that the ciphertext has been authenticated.
         * Otherwise it provides a padding oracle.
        n = ctx->final[b - 1];
        if (n == 0 || n > (int)b) {

    return 0;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the openssl-users mailing list