Index: source/lib/sysdep/os/unix/unix.cpp =================================================================== --- source/lib/sysdep/os/unix/unix.cpp +++ source/lib/sysdep/os/unix/unix.cpp @@ -38,6 +38,10 @@ #include +#if OS_LINUX +#include +#endif + #if OS_MACOSX #define URL_OPEN_COMMAND "open" #else @@ -322,6 +326,20 @@ Status sys_generate_random_bytes(u8* buf, size_t count) { +#if OS_LINUX + while (count) + { + ssize_t numread = getrandom(buf, count, GRND_NONBLOCK); + if (numread == count) + return INFO::OK; + if (numread < 0 && errno != EINTR) + // If anything happens here, fall back to the /dev/urandom codepath. + break; + buf += numread; + count -= numread; + } +#endif + FILE* f = fopen("/dev/urandom", "rb"); if (!f) WARN_RETURN(ERR::FAIL);