Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/getrandom/src/apple-other.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / getrandom / src / apple-other.rs` 24 lines ยท 1104 bytes Raw Blame History 1 //! Implementation for iOS, tvOS, and watchOS where `getentropy` is unavailable. 2 use crate::Error; 3 use core::{ffi::c_void, mem::MaybeUninit}; 4 5 // libsystem contains the libc of Darwin, and every binary ends up linked against it either way. This 6 // makes it a more lightweight choice compared to `Security.framework`. 7 extern "C" { 8 // This RNG uses a thread-local CSPRNG to provide data, which is seeded by the operating system's root CSPRNG. 9 // Its the best option after `getentropy` on modern Darwin-based platforms that also avoids the 10 // high startup costs and linking of Security.framework. 11 // 12 // While its just an implementation detail, `Security.framework` just calls into this anyway. 13 fn CCRandomGenerateBytes(bytes: *mut c_void, size: usize) -> i32; 14 } 15 16 pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { 17 let ret = unsafe { CCRandomGenerateBytes(dest.as_mut_ptr() as *mut c_void, dest.len()) }; 18 // kCCSuccess (from CommonCryptoError.h) is always zero. 19 if ret != 0 { 20 Err(Error::IOS_SEC_RANDOM) 21 } else { 22 Ok(()) 23 } 24 }