// Binding to the Windows.Win32.Security.Cryptography.ProcessPrng API. As // bcryptprimitives.dll lacks an import library, we use "raw-dylib". This // was added in Rust 1.65 for x86_64/aarch64 and in Rust 1.71 for x86. // We don't need MSRV 1.71, as we only use this backend on Rust 1.78 and later. #[cfg_attr(
target_arch = "x86",
link(
name = "bcryptprimitives",
kind = "raw-dylib",
import_name_type = "undecorated"
)
)] #[cfg_attr(
not(target_arch = "x86"),
link(name = "bcryptprimitives", kind = "raw-dylib")
)] extern"system" { fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL;
} #[allow(clippy::upper_case_acronyms)] type BOOL = core::ffi::c_int; // MSRV 1.64, similarly OK for this backend. constTRUE: BOOL = 1;
#[inline] pubfn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> { let result = unsafe { ProcessPrng(dest.as_mut_ptr().cast::<u8>(), dest.len()) }; // Since Windows 10, calls to the user-mode RNG are guaranteed to never // fail during runtime (rare windows W); `ProcessPrng` will only ever // return 1 (which is how windows represents TRUE). // See the bottom of page 6 of the aforementioned Windows RNG // whitepaper for more information.
debug_assert!(result == TRUE);
Ok(())
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet am 2026-08-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.