Skip to content

Commit b67bd9e

Browse files
bppp: Fix test for invalid sign byte
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 <[email protected]>
1 parent 58e27bc commit b67bd9e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/modules/bppp/tests_impl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,15 @@ void test_serialize_two_points(void) {
254254
{
255255
secp256k1_ge X_tmp, R_tmp;
256256
unsigned char buf[65];
257+
unsigned char invalid_sign;
257258
random_group_element_test(&X);
258259
random_group_element_test(&R);
259260
secp256k1_bppp_serialize_points(buf, &X, &R);
260-
buf[0] |= 4 + (unsigned char)secp256k1_testrandi64(4, 255);
261+
262+
buf[0] = 4 + (unsigned char)secp256k1_testrandi64(0, 253);
263+
/* Assert that buf[0] is actually invalid. */
264+
CHECK(buf[0] != 0x02 && buf[0] != 0x03)
265+
261266
CHECK(!secp256k1_bppp_parse_one_of_points(&X_tmp, buf, 0));
262267
CHECK(!secp256k1_bppp_parse_one_of_points(&R_tmp, buf, 0));
263268
}

0 commit comments

Comments
 (0)