Skip to content

Commit f133453

Browse files
committed
tests: fix FIPS-config build failures (cmac _ex, random seed-cb statics)
- test_cmac.c: wc_AesCmacGenerate_ex / wc_AesCmacVerify_ex are absent from the frozen FIPS cmac.h (fips-check freezes cmac.h at WCv4-stable / WCv5.0-RC12 / v5.2.1-stable, none of which declare the _ex variants), so the DecisionCoverage + cryptocb tests calling them fail to compile on the FIPS legs. Add !defined(HAVE_FIPS) to their guards. cmac is NOT frozen under CAVP self-test, so no HAVE_SELFTEST clause is needed. - test_random.c: the WC_RNG_SEED_CB callbacks (test_random_seedCb_ok/_fail) were guarded #ifdef WC_RNG_SEED_CB, but their only caller test_wc_RNG_SeedCb is additionally !HAVE_SELFTEST && !HAVE_FIPS; a fips-ready build with WC_RNG_SEED_CB on compiled the statics but not the caller -> -Werror=unused-function. Match the statics' guard to the caller's.
1 parent 37597b7 commit f133453

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

tests/api/test_cmac.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,11 @@ int test_wc_InitCmac_Label(void)
476476
int test_wc_AesCmacGenerateExDecisionCoverage(void)
477477
{
478478
EXPECT_DECLS;
479-
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128)
479+
/* wc_AesCmacGenerate_ex is absent from the frozen FIPS cmac.h (WCv4-stable,
480+
* WCv5.0-RC12, ...), so exclude FIPS builds. cmac is NOT frozen under CAVP
481+
* self-test, so no HAVE_SELFTEST clause is needed. */
482+
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128) && \
483+
!defined(HAVE_FIPS)
480484
Cmac cmac;
481485
byte key[] = {
482486
0x64, 0x4c, 0xbf, 0x12, 0x85, 0x9d, 0xf0, 0x55,
@@ -551,7 +555,10 @@ int test_wc_AesCmacGenerateExDecisionCoverage(void)
551555
int test_wc_AesCmacVerifyExDecisionCoverage(void)
552556
{
553557
EXPECT_DECLS;
554-
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128)
558+
/* wc_AesCmacVerify_ex is absent from the frozen FIPS cmac.h; exclude FIPS
559+
* (cmac is not frozen under CAVP self-test). */
560+
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128) && \
561+
!defined(HAVE_FIPS)
555562
Cmac cmac;
556563
byte key[] = {
557564
0x64, 0x4c, 0xbf, 0x12, 0x85, 0x9d, 0xf0, 0x55,
@@ -618,7 +625,7 @@ int test_wc_AesCmacVerifyExDecisionCoverage(void)
618625
* dereferences wc_CryptoInfo's cmac member (WOLFSSL_CMAC only) and uses the
619626
* Cmac type / wc_AesCmacGenerate_ex, so WOLF_CRYPTO_CB alone is not enough. */
620627
#if defined(WOLF_CRYPTO_CB) && defined(WOLFSSL_CMAC) && !defined(NO_AES) && \
621-
defined(WOLFSSL_AES_128)
628+
defined(WOLFSSL_AES_128) && !defined(HAVE_FIPS)
622629
#define TEST_CMAC_CRYPTOCB_DEVID 0x434d4143 /* "CMAC" */
623630

624631
/* Toggled by the test function below: when set, the callback fails
@@ -676,7 +683,7 @@ int test_wc_AesCmacVerify_CryptoCb_LenMismatch(void)
676683
{
677684
EXPECT_DECLS;
678685
#if defined(WOLFSSL_CMAC) && !defined(NO_AES) && defined(WOLFSSL_AES_128) && \
679-
defined(WOLF_CRYPTO_CB)
686+
defined(WOLF_CRYPTO_CB) && !defined(HAVE_FIPS)
680687
Cmac cmac;
681688
byte key[] = {
682689
0x64, 0x4c, 0xbf, 0x12, 0x85, 0x9d, 0xf0, 0x55,

tests/api/test_random.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,11 @@ int test_wc_RNG_HealthTest_SHA512_Ext(void)
997997
return EXPECT_RESULT();
998998
}
999999

1000-
#ifdef WC_RNG_SEED_CB
1000+
/* Guard must match test_wc_RNG_SeedCb (the only user) exactly, else these
1001+
* static functions are unused -> -Werror=unused-function in FIPS/self-test builds
1002+
* that define WC_RNG_SEED_CB but compile the test itself out. */
1003+
#if defined(WC_RNG_SEED_CB) && defined(HAVE_HASHDRBG) && \
1004+
!defined(HAVE_SELFTEST) && !defined(HAVE_FIPS)
10011005
/* Varying (non-repeating) pattern so wc_RNG_TestSeed()'s RCT/APT continuous
10021006
* checks (called from _InitRng()/PollAndReSeed() right after the callback
10031007
* runs) do not reject it; a constant fill would legitimately fail those

0 commit comments

Comments
 (0)