Skip to content

Commit 7e6c86a

Browse files
authored
Merge pull request #9326 from douzzer/20251021-KDF-FIPS-gate-tweaks
20251021-KDF-FIPS-gate-tweaks
2 parents 9c3a0e3 + b07bc74 commit 7e6c86a

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

wolfcrypt/test/test.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,11 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hpke_test(void);
634634
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t srtpkdf_test(void);
635635
#endif
636636

637-
#ifdef WC_KDF_NIST_SP_800_56C
637+
#if defined(WC_KDF_NIST_SP_800_56C) && \
638+
(!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
638639
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_kdf_test(void);
639640
#endif
640-
#ifdef HAVE_CMAC_KDF
641+
#if defined(HAVE_CMAC_KDF) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
641642
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp800108_cmac(void);
642643
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_twostep_cmac(void);
643644
#endif
@@ -1144,7 +1145,8 @@ static int rng_crypto_cb(int thisDevId, wc_CryptoInfo* info, void* ctx)
11441145
}
11451146
#endif
11461147

1147-
#if defined(WC_KDF_NIST_SP_800_56C)
1148+
#if defined(WC_KDF_NIST_SP_800_56C) && \
1149+
(!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
11481150
#define INIT_SP80056C_TEST_VECTOR(_z, _fixedInfo, _derivedKey, _hashType) \
11491151
{ \
11501152
.z = (const byte*)(_z), .zSz = sizeof(_z) - 1, \
@@ -1480,9 +1482,9 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_kdf_test(void)
14801482

14811483
return 0;
14821484
}
1483-
#endif /* WC_KDF_NIST_SP_800_56C */
1485+
#endif /* WC_KDF_NIST_SP_800_56C && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
14841486

1485-
#if defined(HAVE_CMAC_KDF)
1487+
#if defined(HAVE_CMAC_KDF) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
14861488
/* test vectors from:
14871489
* "SP 800-108 Key Derivation Using Pseudorandom Functions - Key-Based"
14881490
* - https://csrc.nist.rip/groups/STM/cavp/key-derivation.html
@@ -1796,7 +1798,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_twostep_cmac(void)
17961798

17971799
return 0;
17981800
}
1799-
#endif /* HAVE_CMAC_KDF */
1801+
#endif /* HAVE_CMAC_KDF && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
18001802

18011803
/* optional macro to add sleep between tests */
18021804
#ifndef TEST_SLEEP
@@ -2313,14 +2315,15 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
23132315
PRIVATE_KEY_LOCK();
23142316
#endif
23152317

2316-
#if defined(WC_KDF_NIST_SP_800_56C)
2318+
#if defined(WC_KDF_NIST_SP_800_56C) && \
2319+
(!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
23172320
if ( (ret = nist_sp80056c_kdf_test()) != 0)
23182321
TEST_FAIL("NIST SP 800-56C KDF test failed!\n", ret);
23192322
else
23202323
TEST_PASS("NIST SP 800-56C KDF test passed!\n");
23212324
#endif
23222325

2323-
#if defined(HAVE_CMAC_KDF)
2326+
#if defined(HAVE_CMAC_KDF) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
23242327
if ( (ret = nist_sp800108_cmac()) != 0)
23252328
TEST_FAIL("NIST SP 800-108 KDF test failed!\n", ret);
23262329
else
@@ -2329,7 +2332,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
23292332
TEST_FAIL("NIST SP 800-56C two-step KDF test failed!\n", ret);
23302333
else
23312334
TEST_PASS("NIST SP 800-56C two-step KDF test passed!\n");
2332-
#endif /* HAVE_CMAC_KDF */
2335+
#endif /* HAVE_CMAC_KDF && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
23332336

23342337
#if defined(HAVE_AESGCM) && defined(WOLFSSL_AES_128) && \
23352338
!defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT) && \

0 commit comments

Comments
 (0)