From d9cdfda24fd140f3e4c7b4afd9b46a7929841c69 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Fri, 21 Aug 2020 11:15:10 +1000 Subject: [PATCH] Fix RSA serializer import calls to use correct selection flags. Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/12698) --- .../implementations/encode_decode/encoder_rsa_priv.c | 9 ++++++--- .../implementations/encode_decode/encoder_rsa_pub.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/providers/implementations/encode_decode/encoder_rsa_priv.c b/providers/implementations/encode_decode/encoder_rsa_priv.c index 3ba648f3600..7be37dd49ae 100644 --- a/providers/implementations/encode_decode/encoder_rsa_priv.c +++ b/providers/implementations/encode_decode/encoder_rsa_priv.c @@ -28,6 +28,9 @@ #include "prov/provider_ctx.h" #include "encoder_local.h" +#define RSA_SELECT_PRIVATE_IMPORTABLE \ + (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) + static OSSL_FUNC_encoder_newctx_fn rsa_priv_newctx; static OSSL_FUNC_encoder_freectx_fn rsa_priv_freectx; static OSSL_FUNC_encoder_set_ctx_params_fn rsa_priv_set_ctx_params; @@ -134,7 +137,7 @@ static int rsa_priv_der_data(void *vctx, const OSSL_PARAM params[], RSA *rsa; if ((rsa = rsa_new(ctx->provctx)) != NULL - && rsa_import(rsa, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && rsa_import(rsa, RSA_SELECT_PRIVATE_IMPORTABLE, params) && rsa_priv_der(ctx, rsa, out, cb, cbarg)) ok = 1; rsa_free(rsa); @@ -180,7 +183,7 @@ static int rsa_pem_priv_data(void *vctx, const OSSL_PARAM params[], RSA *rsa; if ((rsa = rsa_new(ctx->provctx)) != NULL - && rsa_import(rsa, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && rsa_import(rsa, RSA_SELECT_PRIVATE_IMPORTABLE, params) && rsa_pem_priv(ctx, rsa, out, cb, cbarg)) ok = 1; rsa_free(rsa); @@ -237,7 +240,7 @@ static int rsa_priv_print_data(void *vctx, const OSSL_PARAM params[], RSA *rsa; if ((rsa = rsa_new(ctx->provctx)) != NULL - && rsa_import(rsa, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && rsa_import(rsa, RSA_SELECT_PRIVATE_IMPORTABLE, params) && rsa_priv_print(ctx, rsa, out, cb, cbarg)) ok = 1; rsa_free(rsa); diff --git a/providers/implementations/encode_decode/encoder_rsa_pub.c b/providers/implementations/encode_decode/encoder_rsa_pub.c index 29e71cc093b..73bb466767e 100644 --- a/providers/implementations/encode_decode/encoder_rsa_pub.c +++ b/providers/implementations/encode_decode/encoder_rsa_pub.c @@ -24,6 +24,9 @@ #include "prov/provider_ctx.h" #include "encoder_local.h" +#define RSA_SELECT_PUBLIC_IMPORTABLE \ + (OSSL_KEYMGMT_SELECT_PUBLIC_KEY | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) + static OSSL_FUNC_encoder_newctx_fn rsa_pub_newctx; static OSSL_FUNC_encoder_freectx_fn rsa_pub_freectx; static OSSL_FUNC_encoder_encode_data_fn rsa_pub_der_data; @@ -63,7 +66,7 @@ static int rsa_pub_der_data(void *ctx, const OSSL_PARAM params[], /* ctx == provctx */ if ((rsa = rsa_new(ctx)) != NULL - && rsa_import(rsa, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && rsa_import(rsa, RSA_SELECT_PUBLIC_IMPORTABLE, params) && rsa_pub_der(ctx, rsa, out, cb, cbarg)) ok = 1; rsa_free(rsa); @@ -104,7 +107,7 @@ static int rsa_pub_pem_data(void *ctx, const OSSL_PARAM params[], /* ctx == provctx */ if ((rsa = rsa_new(ctx)) != NULL - && rsa_import(rsa, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && rsa_import(rsa, RSA_SELECT_PUBLIC_IMPORTABLE, params) && rsa_pub_pem(ctx, rsa, out, cb, cbarg)) ok = 1; rsa_free(rsa); @@ -144,7 +147,7 @@ static int rsa_pub_print_data(void *ctx, const OSSL_PARAM params[], /* ctx == provctx */ if ((rsa = rsa_new(ctx)) != NULL - && rsa_import(rsa, OSSL_KEYMGMT_SELECT_KEYPAIR, params) + && rsa_import(rsa, RSA_SELECT_PUBLIC_IMPORTABLE, params) && rsa_pub_print(ctx, rsa, out, cb, cbarg)) ok = 1; rsa_free(rsa); -- 2.47.2