Skip to content

Commit a1ee83c

Browse files
committed
tests_exhaustive: check the result of secp256k1_ecdsa_sign
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.
1 parent 253f90c commit a1ee83c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tests_exhaustive.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ void test_exhaustive_sign(const secp256k1_context *ctx, const secp256k1_ge *grou
302302
if (skip_section(&iter)) continue;
303303
for (k = 1; k < EXHAUSTIVE_TEST_ORDER; k++) { /* nonce */
304304
const int starting_k = k;
305+
int ret;
305306
secp256k1_ecdsa_signature sig;
306307
secp256k1_scalar sk, msg, r, s, expected_r;
307308
unsigned char sk32[32], msg32[32];
@@ -310,7 +311,8 @@ void test_exhaustive_sign(const secp256k1_context *ctx, const secp256k1_ge *grou
310311
secp256k1_scalar_get_b32(sk32, &sk);
311312
secp256k1_scalar_get_b32(msg32, &msg);
312313

313-
secp256k1_ecdsa_sign(ctx, &sig, msg32, sk32, secp256k1_nonce_function_smallint, &k);
314+
ret = secp256k1_ecdsa_sign(ctx, &sig, msg32, sk32, secp256k1_nonce_function_smallint, &k);
315+
CHECK(ret == 1);
314316

315317
secp256k1_ecdsa_signature_load(ctx, &r, &s, &sig);
316318
/* Note that we compute expected_r *after* signing -- this is important

0 commit comments

Comments
 (0)