summaryrefslogtreecommitdiffstats
path: root/crypto/x509/x_pubkey.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-04-27 16:01:13 +0200
committerTomas Mraz <tomas@openssl.org>2021-05-13 13:30:07 +0200
commitb4c4a2c68817ea0b2df8012673fa4e0712681704 (patch)
tree0e9ef2698c96e048dda681af0aadc9f7daac384a /crypto/x509/x_pubkey.c
parentReplace EVP_PKEY_supports_digest_nid (diff)
downloadopenssl-b4c4a2c68817ea0b2df8012673fa4e0712681704.tar.xz
openssl-b4c4a2c68817ea0b2df8012673fa4e0712681704.zip
Implement pem_read_key directly through OSSL_DECODER
Using OSSL_STORE is too heavy and breaks things. There were also needed various fixes mainly for missing proper handling of the SM2 keys in the OSSL_DECODER. Fixes #14788 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15045)
Diffstat (limited to 'crypto/x509/x_pubkey.c')
-rw-r--r--crypto/x509/x_pubkey.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c
index 9b846a8bc2..966a1a534b 100644
--- a/crypto/x509/x_pubkey.c
+++ b/crypto/x509/x_pubkey.c
@@ -678,12 +678,14 @@ EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length)
EVP_PKEY *pkey;
EC_KEY *key = NULL;
const unsigned char *q;
+ int type;
q = *pp;
pkey = d2i_PUBKEY_legacy(NULL, &q, length);
if (pkey == NULL)
return NULL;
- if (EVP_PKEY_id(pkey) == EVP_PKEY_EC)
+ type = EVP_PKEY_id(pkey);
+ if (type == EVP_PKEY_EC || type == EVP_PKEY_SM2)
key = EVP_PKEY_get1_EC_KEY(pkey);
EVP_PKEY_free(pkey);
if (key == NULL)