Skip to content

Commit

Permalink
bppp: Fix test for invalid sign byte
Browse files Browse the repository at this point in the history
The test is supposed to create an invalid sign byte. Before this PR,
the generated sign byte could in fact be valid due to an overflow.

Co-authored-by: Jonas Nick <jonasd.nick@gmail.com>
  • Loading branch information
real-or-random and jonasnick committed Jul 20, 2023
1 parent 58e27bc commit b67bd9e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/bppp/tests_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,15 @@ void test_serialize_two_points(void) {
{
secp256k1_ge X_tmp, R_tmp;
unsigned char buf[65];
unsigned char invalid_sign;
random_group_element_test(&X);
random_group_element_test(&R);
secp256k1_bppp_serialize_points(buf, &X, &R);
buf[0] |= 4 + (unsigned char)secp256k1_testrandi64(4, 255);

buf[0] = 4 + (unsigned char)secp256k1_testrandi64(0, 253);
/* Assert that buf[0] is actually invalid. */
CHECK(buf[0] != 0x02 && buf[0] != 0x03)

CHECK(!secp256k1_bppp_parse_one_of_points(&X_tmp, buf, 0));
CHECK(!secp256k1_bppp_parse_one_of_points(&R_tmp, buf, 0));
}
Expand Down

0 comments on commit b67bd9e

Please sign in to comment.