23#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
24#include <sys/random.h>
25#elif defined(__OpenBSD__)
28#error "Couldn't identify the OS"
37static int fill_random(
unsigned char* data,
size_t size) {
39 NTSTATUS res = BCryptGenRandom(NULL, data, size, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
40 if (res != STATUS_SUCCESS || size > ULONG_MAX) {
45#elif defined(__linux__) || defined(__FreeBSD__)
47 ssize_t res = getrandom(data, size, 0);
48 if (res < 0 || (
size_t)res != size ) {
53#elif defined(__APPLE__) || defined(__OpenBSD__)
56 int res = getentropy(data, size);
66static void print_hex(
unsigned char* data,
size_t size) {
69 for (i = 0; i < size; i++) {
LOGGING_API void printf(Category category, const char *format,...)