Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random_seed.c: prefer getrandom() / /dev/{,u}random over arc4random() #832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions random_seed.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
#define HAVE_DEV_RANDOM 1
#endif

#ifdef HAVE_ARC4RANDOM
#undef HAVE_GETRANDOM
#undef HAVE_DEV_RANDOM
#undef HAVE_CRYPTGENRANDOM
#endif

#if defined ENABLE_RDRAND

/* cpuid */
Expand Down Expand Up @@ -326,10 +320,6 @@ int json_c_get_random_seed(void)
if (has_rdrand())
return get_rdrand_seed();
#endif
#ifdef HAVE_ARC4RANDOM
/* arc4random never fails, so use it if it's available */
return arc4random();
#else
#ifdef HAVE_GETRANDOM
{
int seed = 0;
Expand All @@ -351,6 +341,10 @@ int json_c_get_random_seed(void)
return seed;
}
#endif
#ifdef HAVE_ARC4RANDOM
/* arc4random never fails, so use it if it's available */
return arc4random();
#else
return get_time_seed();
#endif /* !HAVE_ARC4RANDOM */
}