]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
evp: fix EVP_PKEY_get0_EC_KEY when EC_KEY is SM2
authorzhaozg <zhaozg@gmail.com>
Fri, 12 Nov 2021 15:12:46 +0000 (23:12 +0800)
committerPauli <pauli@openssl.org>
Tue, 16 Nov 2021 22:51:55 +0000 (08:51 +1000)
EVP_PKEY_set_alias_type(pkey, EVP_PKEY_SM2) will change pkey->type to EVP_PKEY_SM2

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17015)

crypto/evp/p_lib.c

index 7e262c573b27e7133263108aaece44d261133138..eb3e117b52f9d8be6e84c5163c6b0b3b53866383 100644 (file)
@@ -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;
     }