Skip to content

Commit 867519c

Browse files
committed
Functional test: Fix build for MLK_CONFIG_NO_RANDOMIZED_API
The reduced-API refactor guarded the randomized round-trip tests in test_mlkem.c on !NO_KEYPAIR_API && !NO_ENCAPS_API && !NO_DECAPS_API, but omitted !NO_RANDOMIZED_API. The public header only exposes crypto_kem_keypair() and crypto_kem_enc() when NO_RANDOMIZED_API is unset (nested inside the keypair/encaps API guards), so a plain CFLAGS="-DMLK_CONFIG_NO_RANDOMIZED_API" make failed to compile test_mlkem.c with implicit-declaration errors. Add the missing !NO_RANDOMIZED_API term to both guard blocks, matching the pattern already used in test_stack.c, test_rng_fail.c and test_alloc.c. The deterministic test_kem_expected_* vectors keep exercising keygen/encaps/decaps under NO_RANDOMIZED_API; only the randomized round-trip loop is compiled out. Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent be70cad commit 867519c

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

test/src/test_mlkem.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030

3131
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) && \
32-
!defined(MLK_CONFIG_NO_ENCAPS_API) && !defined(MLK_CONFIG_NO_DECAPS_API)
32+
!defined(MLK_CONFIG_NO_ENCAPS_API) && \
33+
!defined(MLK_CONFIG_NO_DECAPS_API) && \
34+
!defined(MLK_CONFIG_NO_RANDOMIZED_API)
3335
/* Forbid inlining so stack buffers below stay in short-lived
3436
* frames and don't stack up in main(). This helps testing on
3537
* memory-constrained targets such as AVR. */
@@ -166,7 +168,7 @@ static MLK_NOINLINE int test_invalid_ciphertext(void)
166168
return 0;
167169
}
168170
#endif /* !MLK_CONFIG_NO_KEYPAIR_API && !MLK_CONFIG_NO_ENCAPS_API && \
169-
!MLK_CONFIG_NO_DECAPS_API */
171+
!MLK_CONFIG_NO_DECAPS_API && !MLK_CONFIG_NO_RANDOMIZED_API */
170172

171173
/*
172174
* Test each API operation independently against pre-computed test vectors.
@@ -288,15 +290,17 @@ int main(void)
288290
{
289291
r = 0;
290292
#if !defined(MLK_CONFIG_NO_KEYPAIR_API) && \
291-
!defined(MLK_CONFIG_NO_ENCAPS_API) && !defined(MLK_CONFIG_NO_DECAPS_API)
293+
!defined(MLK_CONFIG_NO_ENCAPS_API) && \
294+
!defined(MLK_CONFIG_NO_DECAPS_API) && \
295+
!defined(MLK_CONFIG_NO_RANDOMIZED_API)
292296
r |= test_keys();
293297
r |= test_keys_unaligned();
294298
r |= test_invalid_pk();
295299
r |= test_invalid_sk_a();
296300
r |= test_invalid_sk_b();
297301
r |= test_invalid_ciphertext();
298302
#endif /* !MLK_CONFIG_NO_KEYPAIR_API && !MLK_CONFIG_NO_ENCAPS_API && \
299-
!MLK_CONFIG_NO_DECAPS_API */
303+
!MLK_CONFIG_NO_DECAPS_API && !MLK_CONFIG_NO_RANDOMIZED_API */
300304
if (r)
301305
{
302306
return 1;

0 commit comments

Comments
 (0)