Skip to content

Commit 0621615

Browse files
committed
wolfcrypt/src/random.c: remove WC_VERBOSE_RNG messaging from wc_RNG_TestSeed(), which is called by test code with expected failure, and move it to _InitRng() and PollAndReSeed(), where it's always expected to succeed.
1 parent 299ca1c commit 0621615

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

wolfcrypt/src/random.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,6 @@ int wc_RNG_TestSeed(const byte* seed, word32 seedSz)
752752
if (ConstantCompare(seed + seedIdx,
753753
seed + seedIdx + scratchSz,
754754
(int)scratchSz) == 0) {
755-
756-
#ifdef WC_VERBOSE_RNG
757-
WOLFSSL_DEBUG_PRINTF("wc_RNG_TestSeed() returning DRBG_CONT_FAILURE on duplicate word32,");
758-
#endif
759755
ret = DRBG_CONT_FAILURE;
760756
}
761757
seedIdx += SEED_BLOCK_SZ;
@@ -985,7 +981,12 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
985981
if (ret != 0) {
986982
WOLFSSL_MSG_EX("wc_RNG_TestSeed failed... %d", ret);
987983
}
984+
#elif defined(WC_VERBOSE_RNG)
985+
if (ret != DRBG_SUCCESS) {
986+
WOLFSSL_DEBUG_PRINTF("wc_RNG_TestSeed() in _InitRng() returned err %d.", ret);
987+
}
988988
#endif
989+
989990
if (ret == DRBG_SUCCESS)
990991
ret = Hash_DRBG_Instantiate((DRBG_internal *)rng->drbg,
991992
#if defined(HAVE_FIPS) || !defined(WOLFSSL_RNG_USE_FULL_SEED)
@@ -1176,9 +1177,13 @@ static int PollAndReSeed(WC_RNG* rng)
11761177
}
11771178
#endif
11781179
}
1179-
if (ret == DRBG_SUCCESS)
1180+
if (ret == DRBG_SUCCESS) {
11801181
ret = wc_RNG_TestSeed(newSeed, SEED_SZ + SEED_BLOCK_SZ);
1181-
1182+
#ifdef WC_VERBOSE_RNG
1183+
if (ret != DRBG_SUCCESS)
1184+
WOLFSSL_DEBUG_PRINTF("wc_RNG_TestSeed() in PollAndReSeed() returned err %d.", ret);
1185+
#endif
1186+
}
11821187
if (ret == DRBG_SUCCESS)
11831188
ret = Hash_DRBG_Reseed((DRBG_internal *)rng->drbg,
11841189
newSeed + SEED_BLOCK_SZ, SEED_SZ);

0 commit comments

Comments
 (0)