Skip to content

Commit

Permalink
Additional test cases for s2n_constant_time_equals() (#4559)
Browse files Browse the repository at this point in the history
  • Loading branch information
rod-chapman authored May 21, 2024
1 parent 61263b0 commit 5f29e4c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/unit/s2n_safety_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(success_ct_pkcs1());
EXPECT_SUCCESS(success_ct_pkcs1_negative());

/* Check the special case where one parameter refers to an array of N bytes */
/* where all elements are 0x00, and the other parameter is NULL */
uint8_t all_zero[4] = { 0, 0, 0, 0 };

EXPECT_FALSE(s2n_constant_time_equals(all_zero, NULL, sizeof(all_zero)));
EXPECT_FALSE(s2n_constant_time_equals(NULL, all_zero, sizeof(all_zero)));

uint8_t a[4] = { 1, 2, 3, 4 };
uint8_t b[4] = { 1, 2, 3, 4 };
uint8_t c[4] = { 5, 6, 7, 8 };
Expand Down

0 comments on commit 5f29e4c

Please sign in to comment.