wolfcrypt/test/test.c: in _rng_test(), inhibit the WC_RESEED_INTERVAL subtest if an rng callback is installed.

This commit is contained in:
Daniel Pouzzner
2025-12-19 08:55:35 -06:00
parent bbc3a72ea8
commit 96c47cd18c
2 changed files with 16 additions and 7 deletions

View File

@@ -19748,14 +19748,23 @@ static wc_test_ret_t _rng_test(WC_RNG* rng)
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(5,0,0))
/* Test periodic reseed dynamics. */
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
#ifdef WOLF_CRYPTO_CB
if (wc_CryptoCb_RandomBlock(rng, block, sizeof(block)) ==
WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
{
#endif
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
ret = wc_RNG_GenerateBlock(rng, block, sizeof(block));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RNG_GenerateBlock(rng, block, sizeof(block));
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
return WC_TEST_RET_ENC_NC;
#ifdef WOLF_CRYPTO_CB
}
#endif
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
return WC_TEST_RET_ENC_NC;
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK && !HAVE_SELFTEST */
#if defined(WOLFSSL_TRACK_MEMORY) && defined(WOLFSSL_SMALL_STACK_CACHE)

View File

@@ -737,7 +737,7 @@ WOLFSSL_LOCAL int wc_CryptoCb_Kdf_TwostepCmac(const byte * salt, word32 saltSz,
#endif /* HAVE_CMAC_KDF */
#ifndef WC_NO_RNG
WOLFSSL_LOCAL int wc_CryptoCb_RandomBlock(WC_RNG* rng, byte* out, word32 sz);
WOLFSSL_TEST_VIS int wc_CryptoCb_RandomBlock(WC_RNG* rng, byte* out, word32 sz);
WOLFSSL_LOCAL int wc_CryptoCb_RandomSeed(OS_Seed* os, byte* seed, word32 sz);
#endif