pub struct DefaultRandomSource;
random
#130703)Expand description
The default random source.
This asks the system for random data suitable for cryptographic purposes such as key generation. If security is a concern, consult the platform documentation below for the specific guarantees your target provides.
The high quality of randomness provided by this source means it can be quite slow on some targets. If you need a large quantity of random numbers and security is not a concern, consider using an alternative random number generator (potentially seeded from this one).
§Underlying sources
Platform | Source |
---|---|
Linux | getrandom or /dev/urandom after polling /dev/random |
Windows | ProcessPrng |
Apple | CCRandomGenerateBytes |
DragonFly | arc4random_buf |
ESP-IDF | esp_fill_random |
FreeBSD | arc4random_buf |
Fuchsia | cprng_draw |
Haiku | arc4random_buf |
Illumos | arc4random_buf |
NetBSD | arc4random_buf |
OpenBSD | arc4random_buf |
Solaris | arc4random_buf |
Vita | arc4random_buf |
Hermit | read_entropy |
Horizon | getrandom shim |
AIX, Hurd, L4Re, QNX | /dev/urandom |
Redox | /scheme/rand |
RTEMS | arc4random_buf |
SGX | rdrand |
SOLID | SOLID_RNG_SampleRandomBytes |
TEEOS | TEE_GenerateRandom |
UEFI | EFI_RNG_PROTOCOL |
VxWorks | randABytes after waiting for randSecure to become ready |
WASI | random_get |
ZKVM | sys_rand |
Note that the sources used might change over time.
Consult the documentation for the underlying operations on your supported targets to determine whether they provide any particular desired properties, such as support for reseeding on VM fork operations.
Trait Implementations§
Source§impl Clone for DefaultRandomSource
impl Clone for DefaultRandomSource
Source§fn clone(&self) -> DefaultRandomSource
fn clone(&self) -> DefaultRandomSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for DefaultRandomSource
impl Debug for DefaultRandomSource
Source§impl Default for DefaultRandomSource
impl Default for DefaultRandomSource
Source§fn default() -> DefaultRandomSource
fn default() -> DefaultRandomSource
Source§impl RandomSource for DefaultRandomSource
impl RandomSource for DefaultRandomSource
Source§fn fill_bytes(&mut self, bytes: &mut [u8])
fn fill_bytes(&mut self, bytes: &mut [u8])
random
#130703)bytes
with random bytes.