summaryrefslogtreecommitdiff
path: root/src/lib/random.c
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-08-17 14:51:47 +0000
committerSander Vrijders <[email protected]>2017-08-17 14:51:47 +0000
commitc7cb10810c447579cb20a8bc99049baeeb8e2065 (patch)
treedf6a08516b7215dddb024ab1e44f23121d616487 /src/lib/random.c
parent44327027e32f5853995984a5bad9869b443898ca (diff)
parentdb218bbe19b66a382df5f665981b7b16f1901bc9 (diff)
downloadouroboros-c7cb10810c447579cb20a8bc99049baeeb8e2065.tar.gz
ouroboros-c7cb10810c447579cb20a8bc99049baeeb8e2065.zip
Merged in dstaesse/ouroboros/be-llc-bpf (pull request #556)
Be llc bpf
Diffstat (limited to 'src/lib/random.c')
-rw-r--r--src/lib/random.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/random.c b/src/lib/random.c
index 5d6763ca..66aefaa3 100644
--- a/src/lib/random.c
+++ b/src/lib/random.c
@@ -47,18 +47,18 @@
int random_buffer(void * buf,
size_t len)
{
-#if defined(HAVE_SYS_RANDOM)
- return getrandom(buf, len, GRND_NONBLOCK); /* glibc 2.25 */
-#elif defined(HAVE_LIBGCRYPT)
- return gcry_randomize(buf, len, GCRY_STRONG_RANDOM);
+#if defined(__APPLE__)
+ return getentropy(buf, len);
#elif defined(__FreeBSD__)
arc4random_buf(buf, len);
return 0;
+#elif defined(HAVE_SYS_RANDOM)
+ return getrandom(buf, len, GRND_NONBLOCK); /* glibc 2.25 */
+#elif defined(HAVE_LIBGCRYPT)
+ return gcry_randomize(buf, len, GCRY_STRONG_RANDOM);
#elif defined(HAVE_OPENSSL)
if (len > 0 && len < INT_MAX)
return RAND_bytes((unsigned char *) buf, (int) len);
return -1;
-#elif defined(__APPLE__)
- return getentropy(buf, len);
#endif
}