summaryrefslogtreecommitdiffstats
path: root/crypto/evp/evp_pkey.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-08-02 16:41:04 +0200
committerRichard Levitte <levitte@openssl.org>2020-09-03 17:48:32 +0200
commitb5275648843ace1a441521823913ccbbebb8769c (patch)
tree6cb050a4f02dfbdca8a0bf6c5ef1698878fcef9c /crypto/evp/evp_pkey.c
parentTEST: Modify test/recipes/90-test_store.t for use with different 'file:' loaders (diff)
downloadopenssl-b5275648843ace1a441521823913ccbbebb8769c.tar.xz
openssl-b5275648843ace1a441521823913ccbbebb8769c.zip
EVP: Downgrade EVP_PKEYs in EVP_PKEY2PKCS8()
EVP_PKEY2PKCS8() relies on the presence of an EVP_PKEY_ASN1_METHOD, which requires "downgrading" the EVP_PKEY to have a legacy internal key. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12587)
Diffstat (limited to 'crypto/evp/evp_pkey.c')
-rw-r--r--crypto/evp/evp_pkey.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c
index 92ae3e5fe8..d435c86087 100644
--- a/crypto/evp/evp_pkey.c
+++ b/crypto/evp/evp_pkey.c
@@ -77,6 +77,11 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey)
return NULL;
}
+ /* Force a key downgrade if that's possible */
+ /* TODO(3.0) Is there a better way for provider-native keys? */
+ if (EVP_PKEY_get0(pkey) == NULL)
+ return NULL;
+
if (pkey->ameth) {
if (pkey->ameth->priv_encode) {
if (!pkey->ameth->priv_encode(p8, pkey)) {