devela::all

Function linux_random_bytes

Source
pub fn linux_random_bytes(buffer: &mut [u8])
Available on crate features unsafe_syscall and linux only.
Expand description

Fills the given buffer with random bytes that may not be cryptographically secure.

It makes use of the GRND_NONBLOCK and GRND_INSECURE flags. So when the randomness source is not ready, instead of blocking it may return less secure data in linux >= 5.6 or retry it a certain number of times, or even return 0 in some cases.

ยงPanics

Panics in debug if buffer.len() > isize::MAX