random.h¶
The source a sampler draws from: the entropy stream, or a stream a seed reproduces.
Every sampler in vfhe takes a Random. NULL is the entropy stream: seeds come from RDRAND where the engine has it and from getentropy otherwise, and expand through AES-128 in counter mode on an AES-NI engine and through BLAKE3 elsewhere, so the stream differs between engines; requests under 512 bytes come from the calling thread’s pool, larger ones expand a fresh seed of their own, and a forked child discards the pool it inherits. When the seed source fails, the process prints the reason to stderr and exits with EXIT_FAILURE: a predictable value is never returned. A seeded source is a BLAKE3 XOF of its seed, the same bytes on every engine, read in order; it belongs to one thread at a time, and two sources from one seed give the same bytes in the same order.
Note
Thread-safe for NULL; a seeded source is not shared between threads.
Functions
-
Random random_seeded(const uint8_t *seed, uint64_t seed_len)¶
Creates a source every draw of which is a function of
seed.Warning
Exits the process with
EXIT_FAILUREif the allocation is refused.- Parameters:
seed – [in] The seed; a secret, when the draws are.
seed_len – [in] Its length in bytes.
- Returns:
A source to release with random_free().
-
void random_free(Random source)¶
Releases a seeded source, wiping its state.
- Parameters:
source – [in] From random_seeded(), or
NULL, which does nothing.