Skip to content

Commit b07bc74

Browse files
committed
wolfcrypt/test/test.c: skip nist_sp80056c_kdf_test() and nist_sp800108_cmac() on FIPS <7.0.0.
1 parent 818d1e3 commit b07bc74

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
@@ -633,10 +633,11 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t hpke_test(void);
633633
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t srtpkdf_test(void);
634634
#endif
635635

636-
#ifdef WC_KDF_NIST_SP_800_56C
636+
#if defined(WC_KDF_NIST_SP_800_56C) && \
637+
(!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
637638
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_kdf_test(void);
638639
#endif
639-
#ifdef HAVE_CMAC_KDF
640+
#if defined(HAVE_CMAC_KDF) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
640641
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp800108_cmac(void);
641642
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t nist_sp80056c_twostep_cmac(void);
642643
#endif
@@ -1143,7 +1144,8 @@ static int rng_crypto_cb(int thisDevId, wc_CryptoInfo* info, void* ctx)
11431144
}
11441145
#endif
11451146

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

14801482
return 0;
14811483
}
1482-
#endif /* WC_KDF_NIST_SP_800_56C */
1484+
#endif /* WC_KDF_NIST_SP_800_56C && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
14831485

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

17961798
return 0;
17971799
}
1798-
#endif /* HAVE_CMAC_KDF */
1800+
#endif /* HAVE_CMAC_KDF && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
17991801

18001802
/* optional macro to add sleep between tests */
18011803
#ifndef TEST_SLEEP
@@ -2307,14 +2309,15 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
23072309
PRIVATE_KEY_LOCK();
23082310
#endif
23092311

2310-
#if defined(WC_KDF_NIST_SP_800_56C)
2312+
#if defined(WC_KDF_NIST_SP_800_56C) && \
2313+
(!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
23112314
if ( (ret = nist_sp80056c_kdf_test()) != 0)
23122315
TEST_FAIL("NIST SP 800-56C KDF test failed!\n", ret);
23132316
else
23142317
TEST_PASS("NIST SP 800-56C KDF test passed!\n");
23152318
#endif
23162319

2317-
#if defined(HAVE_CMAC_KDF)
2320+
#if defined(HAVE_CMAC_KDF) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0))
23182321
if ( (ret = nist_sp800108_cmac()) != 0)
23192322
TEST_FAIL("NIST SP 800-108 KDF test failed!\n", ret);
23202323
else
@@ -2323,7 +2326,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\
23232326
TEST_FAIL("NIST SP 800-56C two-step KDF test failed!\n", ret);
23242327
else
23252328
TEST_PASS("NIST SP 800-56C two-step KDF test passed!\n");
2326-
#endif /* HAVE_CMAC_KDF */
2329+
#endif /* HAVE_CMAC_KDF && (!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) */
23272330

23282331
#if defined(HAVE_AESGCM) && defined(WOLFSSL_AES_128) && \
23292332
!defined(WOLFSSL_AFALG_XILINX_AES) && !defined(WOLFSSL_XILINX_CRYPT) && \

0 commit comments

Comments
 (0)