commit | 6f727a1ec85bded7552f725ecd54a5108a7953ba | [log] [tgz] |
---|---|---|
author | Andrew Walbran <[email protected]> | Mon Jun 14 15:00:57 2021 +0000 |
committer | Jorge Moreira Broche <[email protected]> | Tue Nov 02 23:51:03 2021 +0000 |
tree | 98c50f84c0c05abbe12065197057b1dff5622f61 | |
parent | 7816435b2fdccbe65dbe35dd07f411efdc2bde1a [diff] |
Allow use in virt APEX. Bug: 190503456 Test: mm Merged-In: I262cf8fc6b69c8e9719dc580d565ff3621c53fbd Change-Id: I262cf8fc6b69c8e9719dc580d565ff3621c53fbd
A Rust library for retrieving random data from (operating) system source. It is assumed that system always provides high-quality cryptographically secure random data, ideally backed by hardware entropy sources. This crate derives its name from Linux‘s getrandom
function, but is cross platform, roughly supporting the same set of platforms as Rust’s std
lib.
This is a low-level API. Most users should prefer using high-level random-number library like rand
.
Add this to your Cargo.toml
:
[dependencies] getrandom = "0.2"
Then invoke the getrandom
function:
fn get_random_buf() -> Result<[u8; 32], getrandom::Error> { let mut buf = [0u8; 32]; getrandom::getrandom(&mut buf)?; Ok(buf) }
For more information about supported targets, entropy sources, no_std
targets, crate features, WASM support and Custom RNGs see the getrandom
documentation and getrandom::Error
documentation.
This crate requires Rust 1.34.0 or later.
The getrandom
library is distributed under either of
at your option.