diff options
| author | Nicole LeGare <legare@google.com> | 2025-02-04 21:59:22 +0000 |
|---|---|---|
| committer | Nicole L <dlegare.1001@gmail.com> | 2025-03-10 10:00:24 -0700 |
| commit | 87ca2dbb0054256a675e18ddb7098406db4e42ed (patch) | |
| tree | b6d8bc32c649b5dfce3d0a764397cb1121d2b902 /library/std/src/sys/random | |
| parent | 2b285cd5f0877e30ad1d83e04f8cc46254e43391 (diff) | |
| download | rust-87ca2dbb0054256a675e18ddb7098406db4e42ed.tar.gz rust-87ca2dbb0054256a675e18ddb7098406db4e42ed.zip | |
Apply rustc-0023-Add-Trusty-OS-support-to-Rust-std.patch
Diffstat (limited to 'library/std/src/sys/random')
| -rw-r--r-- | library/std/src/sys/random/mod.rs | 3 | ||||
| -rw-r--r-- | library/std/src/sys/random/trusty.rs | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/sys/random/mod.rs b/library/std/src/sys/random/mod.rs index f42351deb92..870039602bc 100644 --- a/library/std/src/sys/random/mod.rs +++ b/library/std/src/sys/random/mod.rs @@ -60,6 +60,9 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "teeos")] { mod teeos; pub use teeos::fill_bytes; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + pub use trusty::fill_bytes; } else if #[cfg(target_os = "uefi")] { mod uefi; pub use uefi::fill_bytes; diff --git a/library/std/src/sys/random/trusty.rs b/library/std/src/sys/random/trusty.rs new file mode 100644 index 00000000000..da6ca3eea24 --- /dev/null +++ b/library/std/src/sys/random/trusty.rs @@ -0,0 +1,7 @@ +extern "C" { + fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); +} + +pub fn fill_bytes(bytes: &mut [u8]) { + unsafe { trusty_rng_secure_rand(bytes.as_mut_ptr().cast(), bytes.len()) } +} |
