crypto/evp/pkey_kdf.c: Redo parameter processing
[openssl.git] / crypto / ec / ec_ameth.c
index 54d55ad472038cdf68a25bfb2ee64ba22dcfe830..2beeb82707bbb5f4da8c52f33574b84095665841 100644 (file)
@@ -504,7 +504,12 @@ static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
 #endif
 
     case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
-        *(int *)arg2 = NID_sha256;
+        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 1;
 
     case ASN1_PKEY_CTRL_SET1_TLS_ENCPT: