@@ -3934,7 +3934,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
39343934 }
39353935#endif
39363936
3937- #ifdef HAVE_INTEL_RDSEED
3937+ #if defined( HAVE_INTEL_RDSEED ) || defined( HAVE_AMD_RDSEED )
39383938 if (IS_INTEL_RDSEED (intel_flags )) {
39393939 if (!wc_GenerateSeed_IntelRD (NULL , output , sz )) {
39403940 /* success, we're done */
@@ -3945,7 +3945,13 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
39453945 return READ_RAN_E ;
39463946 #endif
39473947 }
3948- #endif /* HAVE_INTEL_RDSEED */
3948+ #ifdef FORCE_FAILURE_RDSEED
3949+ else {
3950+ /* Don't fall back to system randomness */
3951+ return MISSING_RNG_E ;
3952+ }
3953+ #endif
3954+ #endif /* HAVE_INTEL_RDSEED || HAVE_AMD_RDSEED */
39493955
39503956#ifdef WIN_REUSE_CRYPT_HANDLE
39513957 /* Check that handle was initialized.
@@ -4914,7 +4920,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
49144920 int wc_GenerateSeed (OS_Seed * os , byte * output , word32 sz )
49154921 {
49164922 (void )os ;
4917- int ret ;
4923+ int ret = WC_NO_ERR_TRACE ( RNG_FAILURE_E ) ;
49184924
49194925 #ifdef HAVE_ENTROPY_MEMUSE
49204926 ret = wc_Entropy_Get (MAX_ENTROPY_BITS , output , sz );
@@ -4934,6 +4940,12 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
49344940 return ret ;
49354941 #endif
49364942 }
4943+ #ifdef FORCE_FAILURE_RDSEED
4944+ else {
4945+ /* Don't fall back to get_random_bytes() */
4946+ return MISSING_RNG_E ;
4947+ }
4948+ #endif
49374949 #endif /* HAVE_INTEL_RDSEED || HAVE_AMD_RDSEED */
49384950
49394951 #ifdef LINUXKM_LKCAPI_REGISTER_HASH_DRBG_DEFAULT
@@ -4957,7 +4969,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
49574969 int wc_GenerateSeed (OS_Seed * os , byte * output , word32 sz )
49584970 {
49594971 (void )os ;
4960- int ret ;
4972+ int ret = WC_NO_ERR_TRACE ( RNG_FAILURE_E ) ;
49614973
49624974 #ifdef HAVE_ENTROPY_MEMUSE
49634975 ret = wc_Entropy_Get (MAX_ENTROPY_BITS , output , sz );
@@ -4980,6 +4992,12 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
49804992 return ret ;
49814993 }
49824994 }
4995+ #ifdef FORCE_FAILURE_RDSEED
4996+ else {
4997+ /* Don't fall back to arc4random_buf() */
4998+ return MISSING_RNG_E ;
4999+ }
5000+ #endif
49835001 #endif /* HAVE_INTEL_RDSEED || HAVE_AMD_RDSEED */
49845002
49855003 (void )ret ;
0 commit comments