diff --git a/Cargo.toml b/Cargo.toml index 0297fb68a7..32dc5edd0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -197,6 +197,7 @@ cc = { version = "1.0.83", default-features = false } default = ["alloc", "dev_urandom_fallback"] alloc = [] dev_urandom_fallback = [] +less-safe-getrandom-custom-or-rdrand = [] slow_tests = [] std = ["alloc"] unstable-testing-arm-no-hw = [] diff --git a/src/lib.rs b/src/lib.rs index c7ff22efeb..8f0b4e49d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,16 @@ //!
alloc (default)
//! less-safe-getrandom-custom-or-rdrand
+//! getrandom
+//! implementations as secure random number generators (see
+//! SecureRandom
). This feature only works with
+//! os = "none"
targets. See
+//!
+//! register_custom_getrandom
+//! and
+//! RDRAND on x86
+//! for additional details.
//! std
//! std::error::Error
integration. Implies `alloc`.
diff --git a/src/rand.rs b/src/rand.rs
index 603b01450b..809791c79c 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -125,6 +125,7 @@ impl crate::sealed::Sealed for SystemRandom {}
// system's) CSPRNG. Avoid using it on targets where it uses the `rdrand`
// implementation.
#[cfg(any(
+ all(feature = "less-safe-getrandom-custom-or-rdrand", target_os = "none"),
target_os = "aix",
target_os = "android",
target_os = "dragonfly",