Files
sss/randombytes.c
2017-04-13 13:15:49 +02:00

20 lines
379 B
C

#include "randombytes.h"
#include <assert.h>
#ifdef __linux__
# define _GNU_SOURCE
# include <sys/syscall.h>
#endif
void randombytes(void *buf, const size_t n)
{
int tmp;
#ifdef __linux__
tmp = syscall(SYS_getrandom, buf, n, 0);
#else
# error "randombytes not supported on this platform"
#endif /* __linux__ */
assert(tmp == n); /* Failure indicates a bug in the code */
}