From e3c7595521c88579b9eaf02fc11025a2ecdb6ad5 Mon Sep 17 00:00:00 2001 From: Jon Spillett Date: Thu, 6 May 2021 11:55:42 +1000 Subject: Fix up encoder/decoder issues caused by not passing a library context to the PKCS8 encrypt/decrypt Reviewed-by: Shane Lontis Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14587) --- providers/implementations/encode_decode/decode_der2key.c | 2 +- providers/implementations/encode_decode/encode_key2any.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'providers/implementations/encode_decode') diff --git a/providers/implementations/encode_decode/decode_der2key.c b/providers/implementations/encode_decode/decode_der2key.c index 01c050ccb0..b3fd87ca05 100644 --- a/providers/implementations/encode_decode/decode_der2key.c +++ b/providers/implementations/encode_decode/decode_der2key.c @@ -134,7 +134,7 @@ static void *der2key_decode_p8(const unsigned char **input_der, if (!pw_cb(pbuf, sizeof(pbuf), &plen, NULL, pw_cbarg)) ERR_raise(ERR_LIB_PROV, PROV_R_UNABLE_TO_GET_PASSPHRASE); else - p8inf = PKCS8_decrypt(p8, pbuf, plen); + p8inf = PKCS8_decrypt_ex(p8, pbuf, plen, PROV_LIBCTX_OF(ctx->provctx), NULL); if (p8inf == NULL) ctx->flag_fatal = 1; X509_SIG_free(p8); diff --git a/providers/implementations/encode_decode/encode_key2any.c b/providers/implementations/encode_decode/encode_key2any.c index cd2c3f8daa..f95c785522 100644 --- a/providers/implementations/encode_decode/encode_key2any.c +++ b/providers/implementations/encode_decode/encode_key2any.c @@ -117,8 +117,7 @@ static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info, return NULL; } /* First argument == -1 means "standard" */ - p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info, - libctx, NULL); + p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info, libctx, NULL); OPENSSL_cleanse(kstr, klen); return p8; } -- cgit v1.2.3