diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-07 18:14:20 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-07 18:14:20 -0400 |
| commit | 3efd7d9cfbd330ebb45f39648ee96a3e429a06f9 (patch) | |
| tree | 29acb9e2b2370bd155fed24fba79d01b553a24f3 /lib/random/sysrandom.h | |
| parent | 15fabfb9be3e3620e4b96983a49017116cea40e2 (diff) | |
Move core libraries into their own folder
Diffstat (limited to 'lib/random/sysrandom.h')
| -rw-r--r-- | lib/random/sysrandom.h | 14 |
1 files changed, 14 insertions, 0 deletions
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 <sys/random.h> +#else + #error "Unsupported platform for secure random number generation" +#endif |
