diff --git a/Cargo.toml b/Cargo.toml index 0297fb68a..1b4a2dd53 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 = ["getrandom/custom"] slow_tests = [] std = ["alloc"] unstable-testing-arm-no-hw = [] diff --git a/src/lib.rs b/src/lib.rs index c7ff22efe..ba0081160 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,14 @@ //!
alloc (default)
//! less-safe-getrandom-custom
+//! getrandom
+//! implementation as a secure random number generator (see
+//! SecureRandom
). Only has effect on targets
+//! not supported by getrandom
.
+//! See
+//! register_custom_getrandom
+//! for details.
//! std
//! std::error::Error
integration. Implies `alloc`.
diff --git a/src/rand.rs b/src/rand.rs
index 603b01450..bd2244072 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -125,6 +125,10 @@ impl crate::sealed::Sealed for SystemRandom {}
// system's) CSPRNG. Avoid using it on targets where it uses the `rdrand`
// implementation.
#[cfg(any(
+ // NOTE `getrandom`'s (v0.2.10) docs state that a custom implementation will
+ // NOT override the implementation of supported targets, like the ones
+ // listed below.
+ feature = "less-safe-getrandom-custom",
target_os = "aix",
target_os = "android",
target_os = "dragonfly",