mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 17:06:25 +08:00
14 lines
335 B
C
14 lines
335 B
C
#include "randombytes.h"
|
|
|
|
#include <fcntl.h>
|
|
#include <sys/types.h>
|
|
#include <sys/uio.h>
|
|
#include <unistd.h>
|
|
|
|
/* lazy unsafe emulation of SUPERCOP's randombytes() */
|
|
void randombytes (unsigned char *x, unsigned long long xlen) {
|
|
static int fd = -1;
|
|
if (fd == -1) fd = open ("/dev/urandom", O_RDONLY);
|
|
read (fd, x, xlen);
|
|
}
|