Path: blob/main/secure/lib/libpkgecc/pkg_libecc_rand.c
39507 views
/* SPDX-License-Identifier: Unlicense */1#include <sys/types.h>2#include <stdlib.h>34#include <libecc/external_deps/rand.h>56int7get_random(unsigned char *buf, uint16_t len)8{910/*11* We need random numbers even in a sandbox, so we can't use12* /dev/urandom as the external_deps version of get_random() does on13* FreeBSD. arc4random_buf() is a better choice because it uses the14* underlying getrandom(2) instead of needing to open a device handle.15*16* We don't have any guarantees that this won't open a device on other17* platforms, but we also don't do any sandboxing on those platforms.18*/19arc4random_buf(buf, len);20return 0;21}222324