Skip to content

Commit 96c47cd

Browse files
committed
wolfcrypt/test/test.c: in _rng_test(), inhibit the WC_RESEED_INTERVAL subtest if an rng callback is installed.
1 parent bbc3a72 commit 96c47cd

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

wolfcrypt/test/test.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19748,14 +19748,23 @@ static wc_test_ret_t _rng_test(WC_RNG* rng)
1974819748
!defined(HAVE_SELFTEST) && (!defined(HAVE_FIPS) || FIPS_VERSION3_GE(5,0,0))
1974919749
/* Test periodic reseed dynamics. */
1975019750

19751-
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
19751+
#ifdef WOLF_CRYPTO_CB
19752+
if (wc_CryptoCb_RandomBlock(rng, block, sizeof(block)) ==
19753+
WC_NO_ERR_TRACE(CRYPTOCB_UNAVAILABLE))
19754+
{
19755+
#endif
19756+
((struct DRBG_internal *)rng->drbg)->reseedCtr = WC_RESEED_INTERVAL;
1975219757

19753-
ret = wc_RNG_GenerateBlock(rng, block, sizeof(block));
19754-
if (ret != 0)
19755-
return WC_TEST_RET_ENC_EC(ret);
19758+
ret = wc_RNG_GenerateBlock(rng, block, sizeof(block));
19759+
if (ret != 0)
19760+
return WC_TEST_RET_ENC_EC(ret);
19761+
19762+
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
19763+
return WC_TEST_RET_ENC_NC;
19764+
#ifdef WOLF_CRYPTO_CB
19765+
}
19766+
#endif
1975619767

19757-
if (((struct DRBG_internal *)rng->drbg)->reseedCtr == WC_RESEED_INTERVAL)
19758-
return WC_TEST_RET_ENC_NC;
1975919768
#endif /* HAVE_HASHDRBG && !CUSTOM_RAND_GENERATE_BLOCK && !HAVE_SELFTEST */
1976019769

1976119770
#if defined(WOLFSSL_TRACK_MEMORY) && defined(WOLFSSL_SMALL_STACK_CACHE)

wolfssl/wolfcrypt/cryptocb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ WOLFSSL_LOCAL int wc_CryptoCb_Kdf_TwostepCmac(const byte * salt, word32 saltSz,
737737
#endif /* HAVE_CMAC_KDF */
738738

739739
#ifndef WC_NO_RNG
740-
WOLFSSL_LOCAL int wc_CryptoCb_RandomBlock(WC_RNG* rng, byte* out, word32 sz);
740+
WOLFSSL_TEST_VIS int wc_CryptoCb_RandomBlock(WC_RNG* rng, byte* out, word32 sz);
741741
WOLFSSL_LOCAL int wc_CryptoCb_RandomSeed(OS_Seed* os, byte* seed, word32 sz);
742742
#endif
743743

0 commit comments

Comments
 (0)