EVP_PKEY_get_*_param should work with legacy
authorTomas Mraz <tomas@openssl.org>
Thu, 18 Mar 2021 13:22:20 +0000 (14:22 +0100)
committerTomas Mraz <tomas@openssl.org>
Fri, 19 Mar 2021 14:09:55 +0000 (15:09 +0100)
Also do not shortcut the pkey == NULL case
to allow EVP_PKEY_get_params() to raise an error.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14606)

crypto/evp/p_lib.c

index 620c8281591a5913e2a37a75e8df43af77949fcf..4abecdf30c356629632e80754c9c28bfd11eaf12 100644 (file)
@@ -1980,9 +1980,7 @@ int EVP_PKEY_get_bn_param(const EVP_PKEY *pkey, const char *key_name,
     size_t buf_sz = 0;
 
     if (key_name == NULL
-        || bn == NULL
-        || pkey == NULL
-        || !evp_pkey_is_provided(pkey))
+        || bn == NULL)
         return 0;
 
     memset(buffer, 0, sizeof(buffer));
@@ -2021,9 +2019,7 @@ int EVP_PKEY_get_octet_string_param(const EVP_PKEY *pkey, const char *key_name,
     OSSL_PARAM params[2];
     int ret1 = 0, ret2 = 0;
 
-    if (key_name == NULL
-        || pkey == NULL
-        || !evp_pkey_is_provided(pkey))
+    if (key_name == NULL)
         return 0;
 
     params[0] = OSSL_PARAM_construct_octet_string(key_name, buf, max_buf_sz);