From: zhaozg Date: Fri, 12 Nov 2021 15:12:46 +0000 (+0800) Subject: evp: fix EVP_PKEY_get0_EC_KEY when EC_KEY is SM2 X-Git-Tag: OpenSSL_1_1_1m~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c28bcc507be1b035237892181bbbb28383c3f2be;p=thirdparty%2Fopenssl.git evp: fix EVP_PKEY_get0_EC_KEY when EC_KEY is SM2 EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2) will change pkey->type to EVP_PKEY_SM2 CLA: trivial Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/17015) --- diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 7e262c573b2..eb3e117b52f 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -525,7 +525,7 @@ int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key) EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey) { - if (pkey->type != EVP_PKEY_EC) { + if (EVP_PKEY_base_id(pkey) != EVP_PKEY_EC) { EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY); return NULL; }