]> Git Repo - secp256k1.git/commitdiff
tests_exhaustive: check the result of secp256k1_ecdsa_sign
authorNicolas Iooss <[email protected]>
Mon, 28 Jun 2021 13:44:19 +0000 (15:44 +0200)
committerNicolas Iooss <[email protected]>
Fri, 2 Jul 2021 14:22:43 +0000 (16:22 +0200)
If `secp256k1_ecdsa_sign` fails, the signature which is then loaded by
`secp256k1_ecdsa_signature_load` is garbage. Exit early with an error
when this occurs.

src/tests_exhaustive.c

index b7c7828995f2e0123c09384d2d793f4e8869b15d..5b9a3035d9a717e1d2a3f2846ce670ff3e9648b4 100644 (file)
@@ -302,6 +302,7 @@ void test_exhaustive_sign(const secp256k1_context *ctx, const secp256k1_ge *grou
             if (skip_section(&iter)) continue;
             for (k = 1; k < EXHAUSTIVE_TEST_ORDER; k++) {  /* nonce */
                 const int starting_k = k;
+                int ret;
                 secp256k1_ecdsa_signature sig;
                 secp256k1_scalar sk, msg, r, s, expected_r;
                 unsigned char sk32[32], msg32[32];
@@ -310,7 +311,8 @@ void test_exhaustive_sign(const secp256k1_context *ctx, const secp256k1_ge *grou
                 secp256k1_scalar_get_b32(sk32, &sk);
                 secp256k1_scalar_get_b32(msg32, &msg);
 
-                secp256k1_ecdsa_sign(ctx, &sig, msg32, sk32, secp256k1_nonce_function_smallint, &k);
+                ret = secp256k1_ecdsa_sign(ctx, &sig, msg32, sk32, secp256k1_nonce_function_smallint, &k);
+                CHECK(ret == 1);
 
                 secp256k1_ecdsa_signature_load(ctx, &r, &s, &sig);
                 /* Note that we compute expected_r *after* signing -- this is important
This page took 0.025762 seconds and 4 git commands to generate.