mirror of
https://github.com/AtHeartEngineer/sss.git
synced 2026-01-09 12:47:57 -05:00
20 lines
379 B
C
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 */
|
|
}
|