From 3efd7d9cfbd330ebb45f39648ee96a3e429a06f9 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 7 Apr 2025 18:14:20 -0400 Subject: Move core libraries into their own folder --- lib/random/sysrandom.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/random/sysrandom.h (limited to 'lib/random/sysrandom.h') diff --git a/lib/random/sysrandom.h b/lib/random/sysrandom.h new file mode 100644 index 00000000..ea29296b --- /dev/null +++ b/lib/random/sysrandom.h @@ -0,0 +1,14 @@ +#pragma once + +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) +static ssize_t getrandom(void *buf, size_t buflen, unsigned int flags) { + (void)flags; + arc4random_buf(buf, buflen); + return buflen; +} +#elif defined(__linux__) +// Use getrandom() +# include +#else + #error "Unsupported platform for secure random number generation" +#endif -- cgit v1.2.3