PROV: Ensure that EC keys have a default digest
authorRichard Levitte <levitte@openssl.org>
Mon, 20 Apr 2020 19:35:03 +0000 (21:35 +0200)
committerMatt Caswell <matt@openssl.org>
Thu, 23 Apr 2020 09:44:37 +0000 (10:44 +0100)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11576)

providers/implementations/keymgmt/ec_kmgmt.c

index 467004c7834efa3db4544b0262e4ab2fd1c983ee..9466b4fd0b6320460d85a0db87dd5faab0b24e06 100644 (file)
@@ -49,6 +49,7 @@ static OSSL_OP_keymgmt_export_fn ec_export;
 static OSSL_OP_keymgmt_export_types_fn ec_export_types;
 static OSSL_OP_keymgmt_query_operation_name_fn ec_query_operation_name;
 
+#define EC_DEFAULT_MD "SHA256"
 #define EC_POSSIBLE_SELECTIONS                                                 \
     (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS)
 
@@ -491,6 +492,10 @@ int ec_get_params(void *key, OSSL_PARAM params[])
             return 0;
     }
 
+    if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
+        && !OSSL_PARAM_set_utf8_string(p, EC_DEFAULT_MD))
+        return 0;
+
     p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH);
     if (p != NULL) {
         int ecdh_cofactor_mode = 0;