]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Complain about a missing digest when doing deterministic ECDSA
authorMatt Caswell <matt@openssl.org>
Wed, 31 Jul 2024 13:08:40 +0000 (14:08 +0100)
committerTomas Mraz <tomas@openssl.org>
Mon, 9 Sep 2024 07:51:50 +0000 (09:51 +0200)
We need a digest for the none when doing deterministic ECDSA. Give a
better error message if one hasn't been supplied.

See openssl/openssl#25012

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25057)

crypto/ec/ecdsa_ossl.c
providers/implementations/signature/ecdsa_sig.c

index 402a5542450725849f9b1618e5fe6f20007a4772..6104e5cbfc96e5b4b1b0d2e711ed3b379cd5b7d0 100644 (file)
@@ -106,6 +106,10 @@ int ossl_ecdsa_deterministic_sign(const unsigned char *dgst, int dlen,
         ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER);
         return 0;
     }
+    if (digestname == NULL) {
+        ERR_raise(ERR_LIB_EC, EC_R_INVALID_DIGEST);
+        return 0;
+    }
 
     *siglen = 0;
     if (!ecdsa_sign_setup(eckey, NULL, &kinv, &r, dgst, dlen,
index 59e02f4cc474828573ecb9a32a78907ea7642dcf..440b176783763f0d02fc3563076c1332c42fc328 100644 (file)
@@ -338,9 +338,13 @@ static int ecdsa_sign_directly(void *vctx,
         return 0;
 
     if (ctx->nonce_type != 0) {
+        const char *mdname = NULL;
+
+        if (ctx->mdname[0] != '\0')
+            mdname = ctx->mdname;
         ret = ossl_ecdsa_deterministic_sign(tbs, tbslen, sig, &sltmp,
                                             ctx->ec, ctx->nonce_type,
-                                            ctx->mdname,
+                                            mdname,
                                             ctx->libctx, ctx->propq);
     } else {
         ret = ECDSA_sign_ex(0, tbs, tbslen, sig, &sltmp, ctx->kinv, ctx->r,