diff --git a/crypto/fipsmodule/evp/evp.c b/crypto/fipsmodule/evp/evp.c index 06e84738b29..386b9895388 100644 --- a/crypto/fipsmodule/evp/evp.c +++ b/crypto/fipsmodule/evp/evp.c @@ -582,10 +582,15 @@ int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **out_md) { void *EVP_PKEY_get0(const EVP_PKEY *pkey) { SET_DIT_AUTO_DISABLE; GUARD_PTR(pkey); - if (pkey->type == EVP_PKEY_NONE) { - return NULL; + switch (pkey->type) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA_PSS: + case EVP_PKEY_DSA: + case EVP_PKEY_EC: + return pkey->pkey.ptr; + default: + return NULL; } - return pkey->pkey.ptr; } void OpenSSL_add_all_algorithms(void) {} diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 53719f3d094..3232ba8c621 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -928,6 +928,9 @@ OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_kem_new_raw_key(int nid, // to the secret key in |key|. OPENSSL_EXPORT int EVP_PKEY_kem_check_key(EVP_PKEY *key); +// EVP_PKEY_get0_KEM_KEY returns a non-owning pointer to the contained KEM_KEY. +OPENSSL_EXPORT KEM_KEY *EVP_PKEY_get0_KEM_KEY(const EVP_PKEY *pkey); + // Deprecated functions. // EVP_PKEY_RSA2 was historically an alternate form for RSA public keys (OID @@ -1144,12 +1147,13 @@ OPENSSL_EXPORT EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *engine, // Deprecated functions -// EVP_PKEY_get0 returns the consumed key. The type of value returned differs -// depending on the type of the |EVP_PKEY|. +// EVP_PKEY_get0 returns the consumed key. The type of value returned will be +// one of the following, depending on the type of the |EVP_PKEY|: +// |RSA|, |DSA| or |EC_KEY|. // // This function is provided only for compatibility with OpenSSL. // Prefer the use the typed |EVP_PKEY_get0_*| functions instead. -OPENSSL_EXPORT OPENSSL_DEPRECATED void *EVP_PKEY_get0(const EVP_PKEY *pkey); +OPENSSL_EXPORT OPENSSL_DEPRECATED void *EVP_PKEY_get0(EVP_PKEY *pkey); // General No-op Functions [Deprecated].