From 169eca602c67f37abf0a44e1605998d5e7f04fa6 Mon Sep 17 00:00:00 2001 From: Jon Spillett Date: Mon, 15 Mar 2021 14:26:09 +1000 Subject: Enhance the encoder/decoder tests to allow testing with a non-default library context and configurable providers 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/encode_key2any.c | 4 +++- providers/implementations/encode_decode/encode_key2ms.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'providers') diff --git a/providers/implementations/encode_decode/encode_key2any.c b/providers/implementations/encode_decode/encode_key2any.c index 93f725d906..cd2c3f8daa 100644 --- a/providers/implementations/encode_decode/encode_key2any.c +++ b/providers/implementations/encode_decode/encode_key2any.c @@ -106,6 +106,7 @@ static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info, X509_SIG *p8 = NULL; char kstr[PEM_BUFSIZE]; size_t klen = 0; + OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx); if (ctx->cipher == NULL) return NULL; @@ -116,7 +117,8 @@ static X509_SIG *p8info_to_encp8(PKCS8_PRIV_KEY_INFO *p8info, return NULL; } /* First argument == -1 means "standard" */ - p8 = PKCS8_encrypt(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info); + p8 = PKCS8_encrypt_ex(-1, ctx->cipher, kstr, klen, NULL, 0, 0, p8info, + libctx, NULL); OPENSSL_cleanse(kstr, klen); return p8; } diff --git a/providers/implementations/encode_decode/encode_key2ms.c b/providers/implementations/encode_decode/encode_key2ms.c index 81dfcd0ecc..79012e673e 100644 --- a/providers/implementations/encode_decode/encode_key2ms.c +++ b/providers/implementations/encode_decode/encode_key2ms.c @@ -52,10 +52,11 @@ static int write_pvk(struct key2ms_ctx_st *ctx, OSSL_CORE_BIO *cout, { BIO *out = NULL; int ret = 0; + OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(ctx->provctx); out = ossl_bio_new_from_core_bio(ctx->provctx, cout); - ret = i2b_PVK_bio(out, pkey, ctx->pvk_encr_level, - ossl_pw_pem_password, &ctx->pwdata); + ret = i2b_PVK_bio_ex(out, pkey, ctx->pvk_encr_level, + ossl_pw_pem_password, &ctx->pwdata, libctx, NULL); BIO_free(out); return ret; -- cgit v1.2.3