Crate random
random only.Expand description
Provides a seeded random number generator depending on Ariel OS’s configuration.
The module provides functions for use by applications, fast_rng() and crypto_rng(),
which produce owned types that provide the rand_core::RngCore and
rand_core::CryptoRng traits, respectively.
The crate abstracts over multiple aspects of RNGs:
- Where do we take a valid seed for the RNG from?
- What’s the type of RNG that we take along?
- Is RNG state shared across cores, threads, tasks or not at all?
No matter the choices taken (eventually through the application’s setup), all is hidden behind
the FastRng and CryptoRng types.
Before accessing the RNG, it needs to be initialized through the [construct_rng()] function.
This is taken care of by the ariel-os-embassy initialization functions. Applications can
ensure that this has happened by depending on the laze feature random.
Currently, this provides very little choice, and little fanciness: It (more or less
arbitrarily) uses the rand_chacha::ChaCha20Rng generator as a shared global RNG, and
rand_pcg::Pcg32 is decided yet for the fast one. Neither the algorithm nor the size of
FastRng or CryptoRng is guaranteed.
Structs§
- Crypto
Rng csprng - The OS provided cryptographically secure random number generator.
- FastRng
- The OS provided fast random number generator.
Functions§
- crypto_
rng csprng - Returns a suitably initialized cryptographically secure random number generator.
- fast_
rng - Returns a suitably initialized fast random number generator.