MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / get_bytes_from_os

Function get_bytes_from_os

ciphercore-base/src/random.rs:14–19  ·  view source on GitHub ↗

It is possible that when used during early boot the first call to OsRng will block until the system’s RNG is initialised. It is also possible (though highly unlikely) for OsRng to fail on some platforms, most likely due to system mis-configuration.

(bytes: &mut [u8])

Source from the content-addressed store, hash-verified

12/// It is also possible (though highly unlikely) for OsRng to fail on some platforms,
13/// most likely due to system mis-configuration.
14pub fn get_bytes_from_os(bytes: &mut [u8]) -> Result<()> {
15 OsRng
16 .try_fill_bytes(bytes)
17 .map_err(|_| runtime_error!("OS random generator failed"))?;
18 Ok(())
19}
20
21/// Byte size of PRNG seed.
22pub const SEED_SIZE: usize = 16;

Callers 1

newMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected