Expand description
A cryptographically secure source of randomness.
The randomness is provided by a global, cryptographically secure
pseudorandom number generator. More specifically,
rand_chacha::ChaCha20Rng
.
The CSPRNG is instantiated using lazy_static
and hence it is initialized
lazily on the first request for randomness. It attempts to obtains a seed
from the following sources in order:
RDSEED
RDRAND
TSC
An error will be logged if the TSC
is used as it is not a high quality
source of randomness.
If a consumer requires one-off randomness, next_u32
, next_u64
, or
fill_bytes
should be used. Otherwise, init_rng
should be used to
seed a local PRNG, which can then be used as a source of randomness. Using a
local PRNG avoids contention on the global CSPRNG and allows for PRNGs
better suited for the task (e.g. non-crypto PRNGs).
Structs
- Error type of random number generators