mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Merge pull request #1482 from dgarske/nourand
Added new define `NO_DEV_URANDOM` to disable the use of `/dev/urandom`
This commit is contained in:
@@ -1729,15 +1729,17 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
/* don't fallback to /dev/urandom */
|
||||
return ret;
|
||||
#else
|
||||
/* fallback to /dev/urandom attempt */
|
||||
/* reset error and fallback to using /dev/urandom */
|
||||
ret = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* HAVE_INTEL_RDSEED */
|
||||
|
||||
#ifndef NO_DEV_URANDOM /* way to disable use of /dev/urandom */
|
||||
os->fd = open("/dev/urandom", O_RDONLY);
|
||||
if (os->fd == -1) {
|
||||
if (os->fd == -1)
|
||||
#endif
|
||||
{
|
||||
/* may still have /dev/random */
|
||||
os->fd = open("/dev/random", O_RDONLY);
|
||||
if (os->fd == -1)
|
||||
@@ -1755,7 +1757,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
|
||||
output += len;
|
||||
|
||||
if (sz) {
|
||||
#ifdef BLOCKING
|
||||
#if defined(BLOCKING) || defined(WC_RNG_BLOCKING)
|
||||
sleep(0); /* context switch */
|
||||
#else
|
||||
ret = RAN_BLOCK_E;
|
||||
|
Reference in New Issue
Block a user