@@ -537,8 +537,16 @@ static int Hash_gen(DRBG_internal* drbg, byte* out, word32 outSz, const byte* V)
537537#endif
538538
539539 #ifdef WC_VERBOSE_RNG
540- if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE ))
540+ if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE )) {
541+ /* Note, if we're just going to return DRBG_FAILURE to the caller, then
542+ * there's no point printing it out here because (1) the lower-level
543+ * code that was remapped to DRBG_FAILURE already got printed before the
544+ * remapping, so a DRBG_FAILURE message would just be spamming the log,
545+ * and (2) the caller will actually see the DRBG_FAILURE code, and is
546+ * free to (and probably will) log it itself.
547+ */
541548 WOLFSSL_DEBUG_PRINTF ("Hash_gen failed with err %d." , ret );
549+ }
542550 #endif
543551
544552 return (ret == 0 ) ? DRBG_SUCCESS : DRBG_FAILURE ;
@@ -652,8 +660,10 @@ static int Hash_DRBG_Generate(DRBG_internal* drbg, byte* out, word32 outSz)
652660 }
653661
654662 #ifdef WC_VERBOSE_RNG
655- if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE ))
663+ if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE )) {
664+ /* see note above regarding log spam reduction */
656665 WOLFSSL_DEBUG_PRINTF ("Hash_DRBG_Generate failed with err %d." , ret );
666+ }
657667 #endif
658668
659669 return (ret == 0 ) ? DRBG_SUCCESS : DRBG_FAILURE ;
@@ -1033,7 +1043,6 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
10331043 ret = RNG_FAILURE_E ;
10341044 }
10351045 else {
1036- if ((ret != DRBG_SUCCESS ) && (ret != DRBG_FAILURE ))
10371046 rng -> status = DRBG_FAILED ;
10381047 }
10391048#endif /* HAVE_HASHDRBG */
0 commit comments