diff options
Diffstat (limited to 'crypto/pkcs12/p12_p8e.c')
-rw-r--r-- | crypto/pkcs12/p12_p8e.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/crypto/pkcs12/p12_p8e.c b/crypto/pkcs12/p12_p8e.c index e357f310a6..9c27534017 100644 --- a/crypto/pkcs12/p12_p8e.c +++ b/crypto/pkcs12/p12_p8e.c @@ -29,16 +29,20 @@ X509_SIG *PKCS8_encrypt_ex(int pbe_nid, const EVP_CIPHER *cipher, } pbe = PKCS5_pbe2_set_iv_ex(cipher, iter, salt, saltlen, NULL, -1, libctx); - } else if (EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0)) { - if (cipher == NULL) { - ERR_raise(ERR_LIB_PKCS12, ERR_R_PASSED_NULL_PARAMETER); - return NULL; - } - pbe = PKCS5_pbe2_set_iv_ex(cipher, iter, salt, saltlen, NULL, pbe_nid, - libctx); } else { - ERR_clear_error(); - pbe = PKCS5_pbe_set_ex(pbe_nid, iter, salt, saltlen, libctx); + ERR_set_mark(); + if (EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0)) { + ERR_clear_last_mark(); + if (cipher == NULL) { + ERR_raise(ERR_LIB_PKCS12, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + pbe = PKCS5_pbe2_set_iv_ex(cipher, iter, salt, saltlen, NULL, + pbe_nid, libctx); + } else { + ERR_pop_to_mark(); + pbe = PKCS5_pbe_set_ex(pbe_nid, iter, salt, saltlen, libctx); + } } if (pbe == NULL) { ERR_raise(ERR_LIB_PKCS12, ERR_R_ASN1_LIB); |