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])
| 12 | /// It is also possible (though highly unlikely) for OsRng to fail on some platforms, |
| 13 | /// most likely due to system mis-configuration. |
| 14 | pub 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. |
| 22 | pub const SEED_SIZE: usize = 16; |