In development. It changes without notice.
Topic
Random Numbers
Random bytes from the chip's hardware generator.
What makes them unpredictable depends on the board at that moment. ESP-IDF states true randomness while a radio is on, while the converter that feeds the generator is switched on for it, or in the bootloader; this facade does not establish any of those. So a secret that outlives a session is not drawn here: VaultCrypto::
On a computer the tests use another generator, which must never make a key.
- See also
- Cryptography
Files | |
| file | src/ |
| Hardware-backed random byte generator. | |
| file | src/ |
| Random-number facade backed by the ESP hardware RNG. | |
Functions | |
| void | kleidos:: |
| Fill a buffer with random bytes. | |
| uint32_t | kleidos:: |
| Uniform random 32-bit value. | |
| uint32_t | kleidos:: |
| Unbiased random value in [0, upperExclusive). | |
| uint32_t | kleidos:: |
| Unbiased random value in the inclusive range [minInclusive, maxInclusive]. | |
Function Documentation
bounded() #
Unbiased random value in [0, upperExclusive).
- Parameters
-
Name Meaning upperExclusive Exclusive upper bound; must be > 0.
- Returns
- Random value in [0, upperExclusive).
fill() #
Fill a buffer with random bytes.
- Parameters
-
Name Meaning buffer Destination buffer; must not be nullptr. length Number of bytes to fill.
range() #
Unbiased random value in the inclusive range [minInclusive, maxInclusive].
- Parameters
-
Name Meaning minInclusive Lower bound (inclusive). maxInclusive Upper bound (inclusive); must be >= minInclusive.
- Returns
- Random value in [minInclusive, maxInclusive].
u32() #
Uniform random 32-bit value.
- Returns
- Uniformly distributed random uint32_t.