/dev/urandom
or it might not be suitable for cryptographic applications. These systems might provide a different way to gather random numbers.randombytes_set_implementation()
function defines the set of functions required by the randombytes_*
interface.sodium_init()
.randombytes
implementation based on the ChaCha20 stream cipher in randombytes_internal_random.c
file./dev/urandom
or /dev/random
(or to RtlGenRandom()
on Windows) once, during sodium_init()
.sodium_init()
.randombytes_stir()
also has to be called to rekey the generator after fork()ing.randombytes_*
interface.randombytes_*
functions as well as functions generating keys and nonces.randombytes_stir()
nor randombytes_close()
if they are not required (for example if the data comes from a system call). These can be NULL
pointers instead. randombytes_uniform()
doesn't have to be defined either: a default implementation will be used if a NULL
pointer is given.