diff --git a/crypto/sm2/sm2_sign.c b/crypto/sm2/sm2_sign.c index 09e542990bcb3e062b70f0686f3f792435fae1b6..e297353abb9413227a803b512d6426ff111cc8b8 100644 --- a/crypto/sm2/sm2_sign.c +++ b/crypto/sm2/sm2_sign.c @@ -210,6 +210,10 @@ static ECDSA_SIG *sm2_sig_gen(const EC_KEY *key, const BIGNUM *e) BIGNUM *tmp = NULL; OSSL_LIB_CTX *libctx = ossl_ec_key_get_libctx(key); + if (dA == NULL) { + ERR_raise(ERR_LIB_SM2, SM2_R_INVALID_PRIVATE_KEY); + goto done; + } kG = EC_POINT_new(group); ctx = BN_CTX_new_ex(libctx); if (kG == NULL || ctx == NULL) {