Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/libecc/pkg_libecc_rand.c
2065 views
1
/* SPDX-License-Identifier: Unlicense */
2
#include <sys/types.h>
3
#include <stdlib.h>
4
5
#include <libecc/external_deps/rand.h>
6
#include <bsd_compat.h>
7
8
int
9
get_random(unsigned char *buf, uint16_t len)
10
{
11
12
/*
13
* We need random numbers even in a sandbox, so we can't use
14
* /dev/urandom as the external_deps version of get_random() does on
15
* FreeBSD. arc4random_buf() is a better choice because it uses the
16
* underlying getrandom(2) instead of needing to open a device handle.
17
*
18
* We don't have any guarantees that this won't open a device on other
19
* platforms, but we also don't do any sandboxing on those platforms.
20
*/
21
arc4random_buf(buf, len);
22
return 0;
23
}
24
25