You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/embed/unix/rng.c

18 lines
374 B

#include <stdio.h>
#include <stdlib.h>
#include "common.h"
#include "rng.h"
uint32_t rng_get(void)
{
static FILE *frand = NULL;
if (!frand) {
frand = fopen("/dev/urandom", "r");
}
ensure(sectrue * (frand != NULL), "fopen failed");
uint32_t r;
ensure(sectrue * (sizeof(r) == fread(&r, 1, sizeof(r), frand)), "fread failed");
return r;
}