EVP: Adapt EVP_PKEY_missing_parameters() for provider keys
authorRichard Levitte <levitte@openssl.org>
Wed, 5 Feb 2020 09:18:51 +0000 (10:18 +0100)
committerRichard Levitte <levitte@openssl.org>
Mon, 2 Mar 2020 02:27:03 +0000 (03:27 +0100)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11158)

crypto/evp/keymgmt_lib.c
crypto/evp/p_lib.c
include/crypto/evp.h

index a88d65dc5eda19ab5a6673f95e3a76e291ef16e2..dfa53b849aa6c3561663aa8f713c9c3cea90c03b 100644 (file)
@@ -214,3 +214,12 @@ void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
 
     return keydata;
 }
+
+int evp_keymgmt_util_has(EVP_PKEY *pk, int selection)
+{
+    /* Check if key is even assigned */
+    if (pk->keymgmt == NULL)
+        return 0;
+
+    return evp_keymgmt_has(pk->keymgmt, pk->keydata, selection);
+}
index 621d99d1713ba105162f6d140819d574b325e80a..f2761823fcf49039b7efa10857c2c6ae01ee7d3e 100644 (file)
@@ -114,8 +114,13 @@ int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
 
 int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)
 {
-    if (pkey != NULL && pkey->ameth && pkey->ameth->param_missing)
-        return pkey->ameth->param_missing(pkey);
+    if (pkey != NULL) {
+        if (pkey->keymgmt != NULL)
+            return !evp_keymgmt_util_has((EVP_PKEY *)pkey,
+                                         OSSL_KEYMGMT_SELECT_ALL_PARAMETERS);
+        else if (pkey->ameth != NULL && pkey->ameth->param_missing != NULL)
+            return pkey->ameth->param_missing(pkey);
+    }
     return 0;
 }
 
index ddba4083e904882424a95f2dde71f906aa1098f3..bd624575bb2e3289ff2dfb1982a5bd13d58dd374 100644 (file)
@@ -619,6 +619,7 @@ int evp_keymgmt_util_cache_keydata(EVP_PKEY *pk, size_t index,
 void evp_keymgmt_util_cache_keyinfo(EVP_PKEY *pk);
 void *evp_keymgmt_util_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
                                 int selection, const OSSL_PARAM params[]);
+int evp_keymgmt_util_has(EVP_PKEY *pk, int selection);
 
 
 /*