about summary refs log tree commit diff
path: root/library/std/src/sys/random/teeos.rs
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2024-08-15 13:28:02 +0200
committerjoboet <jonasboettiger@icloud.com>2024-09-23 10:29:51 +0200
commit5c1c72572479afe98734d5f78fa862abe662c41a (patch)
tree4f43788d776b0b1dfc423ef8d9852ece3960f9b3 /library/std/src/sys/random/teeos.rs
parent702987f75b74f789ba227ee04a3d7bb1680c2309 (diff)
downloadrust-5c1c72572479afe98734d5f78fa862abe662c41a.tar.gz
rust-5c1c72572479afe98734d5f78fa862abe662c41a.zip
std: implement the `random` feature
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
Diffstat (limited to 'library/std/src/sys/random/teeos.rs')
-rw-r--r--library/std/src/sys/random/teeos.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/std/src/sys/random/teeos.rs b/library/std/src/sys/random/teeos.rs
new file mode 100644
index 00000000000..fd6b24e19e9
--- /dev/null
+++ b/library/std/src/sys/random/teeos.rs
@@ -0,0 +1,7 @@
+extern "C" {
+    fn TEE_GenerateRandom(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t);
+}
+
+pub fn fill_bytes(bytes: &mut [u8]) {
+    unsafe { TEE_GenerateRandom(bytes.as_mut_ptr().cast(), bytes.len()) }
+}