Fix DH serializer import calls to use correct selection flags.
authorShane Lontis <shane.lontis@oracle.com>
Fri, 21 Aug 2020 01:13:09 +0000 (11:13 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Sun, 30 Aug 2020 06:17:17 +0000 (16:17 +1000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12698)

providers/implementations/encode_decode/encoder_dh_param.c
providers/implementations/encode_decode/encoder_dh_priv.c
providers/implementations/encode_decode/encoder_dh_pub.c

index 23cda024c48c8ee224af8ac0d7b66637baf829b2..32c8769b5e71be06e721353f0e35abdc038cf49d 100644 (file)
@@ -63,7 +63,7 @@ static int dh_param_der_data(void *ctx, const OSSL_PARAM params[],
 
         /* ctx == provctx */
         if ((dh = dh_new(ctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_ALL_PARAMETERS, params)
+            && dh_import(dh, OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS, params)
             && dh_param_der(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
@@ -100,7 +100,7 @@ static int dh_param_pem_data(void *ctx, const OSSL_PARAM params[],
 
         /* ctx == provctx */
         if ((dh = dh_new(ctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_ALL_PARAMETERS, params)
+            && dh_import(dh, OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS, params)
             && dh_param_pem(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
@@ -137,7 +137,7 @@ static int dh_param_print_data(void *ctx, const OSSL_PARAM params[],
 
         /* ctx == provctx */
         if ((dh = dh_new(ctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_ALL_PARAMETERS, params)
+            && dh_import(dh, OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS, params)
             && dh_param_print(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
index a9373df96aef02db78d8fc7e2f4ae867febd4803..dd9422308465c0bc03bfc7c600c3e1596d39f3ca 100644 (file)
@@ -25,6 +25,9 @@
 #include "prov/provider_ctx.h"
 #include "encoder_local.h"
 
+#define DH_SELECT_PRIVATE_IMPORTABLE                                           \
+    (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)
+
 static OSSL_FUNC_encoder_newctx_fn dh_priv_newctx;
 static OSSL_FUNC_encoder_freectx_fn dh_priv_freectx;
 static OSSL_FUNC_encoder_set_ctx_params_fn dh_priv_set_ctx_params;
@@ -132,7 +135,7 @@ static int dh_priv_der_data(void *vctx, const OSSL_PARAM params[],
         DH *dh;
 
         if ((dh = dh_new(ctx->provctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params)
+            && dh_import(dh, DH_SELECT_PRIVATE_IMPORTABLE, params)
             && dh_priv_der(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
@@ -178,7 +181,7 @@ static int dh_pem_priv_data(void *vctx, const OSSL_PARAM params[],
         DH *dh;
 
         if ((dh = dh_new(ctx->provctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params)
+            && dh_import(dh, DH_SELECT_PRIVATE_IMPORTABLE, params)
             && dh_pem_priv(ctx->provctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
@@ -235,7 +238,7 @@ static int dh_priv_print_data(void *vctx, const OSSL_PARAM params[],
         DH *dh;
 
         if ((dh = dh_new(ctx->provctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params)
+            && dh_import(dh, DH_SELECT_PRIVATE_IMPORTABLE, params)
             && dh_priv_print(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
index 99f9532c343e1e644bafb1fe4777c571cd729443..583dcd9c5a54a8f2214e356b0885dc502c88ae95 100644 (file)
@@ -34,6 +34,9 @@ static OSSL_FUNC_encoder_encode_object_fn dh_pub_pem;
 static OSSL_FUNC_encoder_encode_data_fn dh_pub_print_data;
 static OSSL_FUNC_encoder_encode_object_fn dh_pub_print;
 
+#define DH_SELECT_PUBLIC_IMPORTABLE                                            \
+    (OSSL_KEYMGMT_SELECT_PUBLIC_KEY | OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)
+
 /* Public key : context */
 
 /*
@@ -63,7 +66,7 @@ static int dh_pub_der_data(void *ctx, const OSSL_PARAM params[],
 
         /* ctx == provctx */
         if ((dh = dh_new(ctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params)
+            && dh_import(dh, DH_SELECT_PUBLIC_IMPORTABLE, params)
             && dh_pub_der(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
@@ -104,7 +107,7 @@ static int dh_pub_pem_data(void *ctx, const OSSL_PARAM params[],
 
         /* ctx == provctx */
         if ((dh = dh_new(ctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params)
+            && dh_import(dh, DH_SELECT_PUBLIC_IMPORTABLE, params)
             && dh_pub_pem(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);
@@ -144,7 +147,7 @@ static int dh_pub_print_data(void *ctx, const OSSL_PARAM params[],
 
         /* ctx == provctx */
         if ((dh = dh_new(ctx)) != NULL
-            && dh_import(dh, OSSL_KEYMGMT_SELECT_KEYPAIR, params)
+            && dh_import(dh, DH_SELECT_PUBLIC_IMPORTABLE, params)
             && dh_pub_print(ctx, dh, out, cb, cbarg))
             ok = 1;
         dh_free(dh);