From: Richard Levitte Date: Wed, 5 Feb 2020 09:18:51 +0000 (+0100) Subject: EVP: Adapt EVP_PKEY_missing_parameters() for provider keys X-Git-Tag: openssl-3.0.0-alpha1~351 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=157ded39ee68c1c00814165f79f9b2f000996884;p=oweals%2Fopenssl.git EVP: Adapt EVP_PKEY_missing_parameters() for provider keys Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/11158) --- diff --git a/crypto/evp/keymgmt_lib.c b/crypto/evp/keymgmt_lib.c index a88d65dc5e..dfa53b849a 100644 --- a/crypto/evp/keymgmt_lib.c +++ b/crypto/evp/keymgmt_lib.c @@ -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); +} diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 621d99d171..f2761823fc 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -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; } diff --git a/include/crypto/evp.h b/include/crypto/evp.h index ddba4083e9..bd624575bb 100644 --- a/include/crypto/evp.h +++ b/include/crypto/evp.h @@ -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); /*