#include "rng.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
Go to the source code of this file.
◆ randombytes()
void randombytes |
( |
void * | x, |
|
|
size_t | l ) |
Definition at line 13 of file rng.c.
14{
15 static __thread int fd = -1;
17 if (fd < 0 && 0 > (fd = open("/dev/urandom", O_RDONLY)))
18 exit(1);
19 for (
size_t i = 0;
i < l;
i +=
n)
20 if (0 >= (n = read(fd, (
char *) x +
i, l -
i)))
21 exit(2);
22#ifdef ENABLE_CT_TESTING
23 VALGRIND_MAKE_MEM_UNDEFINED(x, l);
24#endif
25}
References i.