diff options
Diffstat (limited to 'crypto/pkcs12/p12_sbag.c')
-rw-r--r-- | crypto/pkcs12/p12_sbag.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/crypto/pkcs12/p12_sbag.c b/crypto/pkcs12/p12_sbag.c index 2387a8db43..e439372082 100644 --- a/crypto/pkcs12/p12_sbag.c +++ b/crypto/pkcs12/p12_sbag.c @@ -198,29 +198,49 @@ PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8) return bag; } -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, - const char *pass, - int passlen, - unsigned char *salt, - int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8inf) -{ - PKCS12_SAFEBAG *bag; - const EVP_CIPHER *pbe_ciph; +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(int pbe_nid, + const char *pass, + int passlen, + unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8inf, + OSSL_LIB_CTX *ctx, + const char *propq) +{ + PKCS12_SAFEBAG *bag = NULL; + const EVP_CIPHER *pbe_ciph = NULL; + EVP_CIPHER *pbe_ciph_fetch = NULL; X509_SIG *p8; - pbe_ciph = EVP_get_cipherbynid(pbe_nid); - if (pbe_ciph) + pbe_ciph = pbe_ciph_fetch = EVP_CIPHER_fetch(ctx, OBJ_nid2sn(pbe_nid), propq); + if (pbe_ciph == NULL) + pbe_ciph = EVP_get_cipherbynid(pbe_nid); + + if (pbe_ciph != NULL) pbe_nid = -1; - p8 = PKCS8_encrypt(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, - p8inf); + p8 = PKCS8_encrypt_ex(pbe_nid, pbe_ciph, pass, passlen, salt, saltlen, iter, + p8inf, ctx, propq); if (p8 == NULL) - return NULL; + goto err; bag = PKCS12_SAFEBAG_create0_pkcs8(p8); if (bag == NULL) X509_SIG_free(p8); +err: + EVP_CIPHER_free(pbe_ciph_fetch); return bag; } + +PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, + const char *pass, + int passlen, + unsigned char *salt, + int saltlen, int iter, + PKCS8_PRIV_KEY_INFO *p8inf) +{ + return PKCS12_SAFEBAG_create_pkcs8_encrypt_ex(pbe_nid, pass, passlen, + salt, saltlen, iter, p8inf, + NULL, NULL); +} |