RtlGenRandom()
function is used.arc4random()
function is used.getrandom
system call is used./dev/urandom
device is used.randombytes_random()
function returns an unpredictable value between 0
and 0xffffffff
(included).randombytes_uniform()
function returns an unpredictable value between 0
and upper_bound
(excluded). Unlike randombytes_random() % upper_bound
, it guarantees a uniform distribution of the possible output values even when upper_bound
is not a power of 2. Note that an upper_bound < 2
leaves only a single element to be chosen, namely 0
randombytes_buf()
function fills size
bytes starting at buf
with an unpredictable sequence of bytes.randombytes_buf_deterministic
function stores size
bytes into buf
indistinguishable from random bytes without knowing seed
.seed
, this function will always output the same sequence. size
can be up to 2^38 (256 GB).seed
is randombytes_SEEDBYTES
bytes long./dev/urandom
device is used, it closes the descriptor. Explicitly calling this function is almost never required.randombytes_stir()
function reseeds the pseudo-random number generator if it supports this operation. Calling this function is not required with the default generator, even after a fork()
call, unless the descriptor for /dev/urandom
was closed using randombytes_close()
.randombytes_set_implementation()
), randombytes_stir()
must be called by the child after a fork()
call.