From: Richard Levitte Date: Fri, 24 Jan 2020 17:14:06 +0000 (+0100) Subject: Make SM3 a mandatory hash function for SM2. X-Git-Tag: openssl-3.0.0-alpha1~572 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ef077ba0d2fa28fd1b481f80335bda723d3d1f20;p=oweals%2Fopenssl.git Make SM3 a mandatory hash function for SM2. Reviewed-by: Matt Caswell Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/10942) --- diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 6105e6b087..f38ab103ab 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c @@ -507,9 +507,9 @@ static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) if (EVP_PKEY_id(pkey) == EVP_PKEY_SM2) { /* For SM2, the only valid digest-alg is SM3 */ *(int *)arg2 = NID_sm3; - } else { - *(int *)arg2 = NID_sha256; + return 2; /* Make it mandatory */ } + *(int *)arg2 = NID_sha256; return 1; case ASN1_PKEY_CTRL_SET1_TLS_ENCPT: