Skip to content

Commit 0e9c732

Browse files
hanno-beckermkannwischer
authored andcommitted
CBMC: Don't declare arrays in harnesses
When CBMC checks a function contract, it seems that the preconditions set out in the contract are overlayed by the context set out in the harness. For example, if a function takes a pointer to `foo`, and the harness passes `&f` for `foo f`, then the function would never be evaluated for the possibility of an invalid pointer being passed. For that reason, harnesses must be as minimal as possible, merely declaring uninitialized variables of the expected type and calling the function under proof. This commit fixes a few instances in mlkem-native where this was not yet the case. Signed-off-by: Hanno Becker <[email protected]>
1 parent 5112f49 commit 0e9c732

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

proofs/cbmc/poly_permute_bitrev_to_custom/poly_permute_bitrev_to_custom_harness.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ void mlk_poly_permute_bitrev_to_custom(int16_t data[MLKEM_N]);
99

1010
void harness(void)
1111
{
12-
int16_t data[MLKEM_N];
12+
int16_t *data;
1313
mlk_poly_permute_bitrev_to_custom(data);
1414
}

proofs/cbmc/poly_rej_uniform_x4/poly_rej_uniform_x4_harness.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
void harness(void)
99
{
10-
mlk_poly out[4];
11-
uint8_t seed[4][MLK_ALIGN_UP(MLKEM_SYMBYTES + 2)];
10+
mlk_poly *out;
11+
uint8_t(*seed)[MLK_ALIGN_UP(MLKEM_SYMBYTES + 2)];
1212
mlk_poly_rej_uniform_x4(out, seed);
1313
}

0 commit comments

Comments
 (0)