@@ -369,6 +369,11 @@ static int Hash_df(DRBG_internal* drbg, byte* out, word32 outSz, byte type,
369369 XFREE (digest , drbg -> heap , DYNAMIC_TYPE_DIGEST );
370370#endif
371371
372+ #ifdef WC_VERBOSE_RNG
373+ if (ret != 0 )
374+ WOLFSSL_DEBUG_PRINTF ("%s failed with err = %d" , __FUNCTION__ , ret );
375+ #endif
376+
372377 return (ret == 0 ) ? DRBG_SUCCESS : DRBG_FAILURE ;
373378}
374379
@@ -406,6 +411,12 @@ static int Hash_DRBG_Reseed(DRBG_internal* drbg, const byte* seed, word32 seedSz
406411#ifndef WOLFSSL_SMALL_STACK_CACHE
407412 WC_FREE_VAR_EX (newV , drbg -> heap , DYNAMIC_TYPE_TMP_BUFFER );
408413#endif
414+
415+ #ifdef WC_VERBOSE_RNG
416+ if (ret != 0 )
417+ WOLFSSL_DEBUG_PRINTF ("Hash_DRBG_Reseed failed with err %d." , ret );
418+ #endif
419+
409420 return ret ;
410421}
411422
@@ -525,6 +536,11 @@ static int Hash_gen(DRBG_internal* drbg, byte* out, word32 outSz, const byte* V)
525536 WC_FREE_VAR_EX (data , drbg -> heap , DYNAMIC_TYPE_TMP_BUFFER );
526537#endif
527538
539+ #ifdef WC_VERBOSE_RNG
540+ if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE ))
541+ WOLFSSL_DEBUG_PRINTF ("Hash_gen failed with err %d." , ret );
542+ #endif
543+
528544 return (ret == 0 ) ? DRBG_SUCCESS : DRBG_FAILURE ;
529545}
530546
@@ -635,6 +651,11 @@ static int Hash_DRBG_Generate(DRBG_internal* drbg, byte* out, word32 outSz)
635651 #endif
636652 }
637653
654+ #ifdef WC_VERBOSE_RNG
655+ if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE ))
656+ WOLFSSL_DEBUG_PRINTF ("Hash_DRBG_Generate failed with err %d." , ret );
657+ #endif
658+
638659 return (ret == 0 ) ? DRBG_SUCCESS : DRBG_FAILURE ;
639660}
640661
@@ -722,6 +743,9 @@ int wc_RNG_TestSeed(const byte* seed, word32 seedSz)
722743 seed + seedIdx + scratchSz ,
723744 (int )scratchSz ) == 0 ) {
724745
746+ #ifdef WC_VERBOSE_RNG
747+ WOLFSSL_DEBUG_PRINTF ("wc_RNG_TestSeed() returning DRBG_CONT_FAILURE on duplicate word32," );
748+ #endif
725749 ret = DRBG_CONT_FAILURE ;
726750 }
727751 seedIdx += SEED_BLOCK_SZ ;
@@ -926,6 +950,9 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
926950 else {
927951 ret = seedCb (& rng -> seed , seed , seedSz );
928952 if (ret != 0 ) {
953+ #ifdef WC_VERBOSE_RNG
954+ WOLFSSL_DEBUG_PRINTF ("seedCb in _InitRng() failed with err = %d" , ret );
955+ #endif
929956 ret = DRBG_FAILURE ;
930957 }
931958 }
@@ -935,6 +962,8 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
935962 if (ret != 0 ) {
936963 #if defined(DEBUG_WOLFSSL )
937964 WOLFSSL_MSG_EX ("Seed generation failed... %d" , ret );
965+ #elif defined(WC_VERBOSE_RNG )
966+ WOLFSSL_DEBUG_PRINTF ("wc_GenerateSeed() in _InitRng() failed with err %d" , ret );
938967 #endif
939968 ret = DRBG_FAILURE ;
940969 rng -> status = DRBG_FAILED ;
@@ -1004,6 +1033,7 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
10041033 ret = RNG_FAILURE_E ;
10051034 }
10061035 else {
1036+ if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE ))
10071037 rng -> status = DRBG_FAILED ;
10081038 }
10091039#endif /* HAVE_HASHDRBG */
@@ -1120,15 +1150,22 @@ static int PollAndReSeed(WC_RNG* rng)
11201150 else {
11211151 ret = seedCb (& rng -> seed , newSeed , SEED_SZ + SEED_BLOCK_SZ );
11221152 if (ret != 0 ) {
1153+ #ifdef WC_VERBOSE_RNG
1154+ WOLFSSL_DEBUG_PRINTF ("seedCb() in PollAndReSeed() failed with err %d" , ret );
1155+ #endif
11231156 ret = DRBG_FAILURE ;
11241157 }
11251158 }
11261159 #else
11271160 ret = wc_GenerateSeed (& rng -> seed , newSeed ,
11281161 SEED_SZ + SEED_BLOCK_SZ );
1129- #endif
1130- if (ret != 0 )
1162+ if (ret != 0 ) {
1163+ #ifdef WC_VERBOSE_RNG
1164+ WOLFSSL_DEBUG_PRINTF ("wc_GenerateSeed() in PollAndReSeed() failed with err %d" , ret );
1165+ #endif
11311166 ret = DRBG_FAILURE ;
1167+ }
1168+ #endif
11321169 }
11331170 if (ret == DRBG_SUCCESS )
11341171 ret = wc_RNG_TestSeed (newSeed , SEED_SZ + SEED_BLOCK_SZ );
@@ -1202,6 +1239,10 @@ int wc_RNG_GenerateBlock(WC_RNG* rng, byte* output, word32 sz)
12021239#ifdef CUSTOM_RAND_GENERATE_BLOCK
12031240 XMEMSET (output , 0 , sz );
12041241 ret = (int )CUSTOM_RAND_GENERATE_BLOCK (output , sz );
1242+ #ifdef WC_VERBOSE_RNG
1243+ if (ret != 0 )
1244+ WOLFSSL_DEBUG_PRINTF ("CUSTOM_RAND_GENERATE_BLOCK failed with err %d." , ret );
1245+ #endif
12051246#else
12061247
12071248#ifdef HAVE_HASHDRBG
0 commit comments