diff options
-rw-r--r-- | src/lib/random.c | 12 |
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 } |