@@ -335,28 +335,23 @@ static int wp_drbg_reseed(wp_DrbgCtx* ctx, int predResist,
335335{
336336 int ok = 1 ;
337337
338+ int rc ;
339+
338340 WOLFPROV_ENTER (WP_LOG_COMP_RNG , "wp_drbg_reseed" );
339341
340- #if 0
341- /* Calling Hash_DRBG_Instantiate would be better. */
342- int rc ;
343- rc = wc_RNG_DRBG_Reseed (ctx -> rng , entropy , entropyLen );
342+ rc = wc_RNG_DRBG_Reseed (ctx -> rng , entropy , (word32 )entropyLen );
344343 if (rc != 0 ) {
344+ WOLFPROV_MSG_DEBUG_RETCODE (WP_LOG_COMP_RNG , "wc_RNG_DRBG_Reseed" , rc );
345345 ok = 0 ;
346346 }
347347 if (ok && (addInLen > 0 )) {
348- rc = wc_RNG_DRBG_Reseed (ctx -> rng , addIn , addInLen );
348+ rc = wc_RNG_DRBG_Reseed (ctx -> rng , addIn , ( word32 ) addInLen );
349349 if (rc != 0 ) {
350+ WOLFPROV_MSG_DEBUG_RETCODE (WP_LOG_COMP_RNG ,
351+ "wc_RNG_DRBG_Reseed" , rc );
350352 ok = 0 ;
351353 }
352354 }
353- #else
354- (void )ctx ;
355- (void )entropy ;
356- (void )entropyLen ;
357- (void )addIn ;
358- (void )addInLen ;
359- #endif
360355
361356 (void )predResist ;
362357
@@ -388,6 +383,7 @@ static int wp_drbg_enable_locking(wp_DrbgCtx* ctx)
388383 if (rc != 0 ) {
389384 WOLFPROV_MSG_DEBUG_RETCODE (WP_LOG_COMP_RNG , "wc_InitMutex" , rc );
390385 OPENSSL_free (ctx -> mutex );
386+ ctx -> mutex = NULL ;
391387 ok = 0 ;
392388 }
393389 }
@@ -547,11 +543,16 @@ static int wp_drbg_set_ctx_params(wp_DrbgCtx* ctx, const OSSL_PARAM params[])
547543 */
548544static int wp_drbg_verify_zeroization (wp_DrbgCtx * ctx )
549545{
546+ int ok ;
547+
550548 WOLFPROV_ENTER (WP_LOG_COMP_RNG , "wp_drbg_verify_zeroization" );
551549
552- (void )ctx ;
553- WOLFPROV_LEAVE (WP_LOG_COMP_RNG , __FILE__ ":" WOLFPROV_STRINGIZE (__LINE__ ), 1 );
554- return 1 ;
550+ /* After uninstantiate, ctx->rng is freed (with internal state zeroized
551+ * by wolfSSL) and set to NULL. Verify that cleanup occurred. */
552+ ok = (ctx -> rng == NULL );
553+
554+ WOLFPROV_LEAVE (WP_LOG_COMP_RNG , __FILE__ ":" WOLFPROV_STRINGIZE (__LINE__ ), ok );
555+ return ok ;
555556}
556557
557558/**
0 commit comments