diff options
author | Richard Levitte <levitte@openssl.org> | 2020-08-02 16:41:04 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-03 17:48:32 +0200 |
commit | b5275648843ace1a441521823913ccbbebb8769c (patch) | |
tree | 6cb050a4f02dfbdca8a0bf6c5ef1698878fcef9c /crypto/evp/evp_pkey.c | |
parent | 7620d89c3f2f420ea951fb5b48f976079bfc7429 (diff) |
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.c | 5 |
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)) { |