If it's available, it does the right thing. I think.
dnl Functions used for noise-gathering.
AC_CHECK_FUNCS([setgroups])
AC_CHECK_HEADERS([linux/random.h])
dnl Functions used for noise-gathering.
AC_CHECK_FUNCS([setgroups])
AC_CHECK_HEADERS([linux/random.h])
+AC_CHECK_FUNCS([getentropy])
AC_CACHE_CHECK([whether the freewheel noise generator will work],
[catacomb_cv_freewheel],
[AC_TRY_LINK(
AC_CACHE_CHECK([whether the freewheel noise generator will work],
[catacomb_cv_freewheel],
[AC_TRY_LINK(
fd_set infd;
struct timeval tv = { 0, 0 };
#endif
fd_set infd;
struct timeval tv = { 0, 0 };
#endif
+#ifdef HAVE_GETENTROPY
+ size_t nn;
+#endif
#if defined(HAVE_LINUX_RANDOM_H) && \
defined(GRND_NONBLOCK) && \
#if defined(HAVE_LINUX_RANDOM_H) && \
defined(GRND_NONBLOCK) && \
if (n == sizeof(buf)) goto win;
#endif
if (n == sizeof(buf)) goto win;
#endif
+#ifdef HAVE_GETENTROPY
+ /* --- OpenBSD-flavoured shinies --- */
+
+ while (n < sizeof(buf)) {
+ nn = sizeof(buf) - nn;
+ if (nn > 256) nn = 256;
+ if (getentropy(buf + n, nn)) break;
+ n += nn;
+ }
+ if (n == sizeof(buf)) goto win;
+#endif
+
#ifdef __linux__
/* --- Don't take from `/dev/urandom' if `/dev/random' would block --- */
#ifdef __linux__
/* --- Don't take from `/dev/urandom' if `/dev/random' would block --- */