pub unsafe fn linux_sys_getrandom(
buffer: *mut u8,
size: usize,
flags: c_uint,
) -> isize ⓘ
Available on crate features
unsafe_syscall
and linux
only.Expand description
Performs a getrandom
syscall.
Obtain a series of random bytes.
§Info
§Example
use devela::linux_sys_getrandom;
let mut r = 0u8;
unsafe { linux_sys_getrandom(&mut r as *mut u8, 1, 0) };
§Flags
-
GRND_RANDOM
= 0x001Use the
/dev/random
(blocking) source instead of the/dev/urandom
(non-blocking) source to obtain randomness.If this flag is specified, the call may block, potentially for quite some time, even after the randomness source has been initialized. If it is not specified, the call can only block when the system has just booted and the randomness source has not yet been initialized.
-
GRND_NONBLOCK
= 0x002Instead of blocking, return to the caller immediately if no data is available.
-
GRND_INSECURE
= 0x0004Write random data that may not be cryptographically secure.
§Safety
TODO