summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-04-16 16:04:12 +0000
committerbors <bors@rust-lang.org>2019-04-16 16:04:12 +0000
commit70f130954d6fd36fe3e77f4b5b33e5af50489288 (patch)
treeafcb656d306e236040f00690222892cc627d0992
parent3b27b4f592e0654602d8b81cc471204abc2d563e (diff)
parentf1da89a66705a34936a6dbfcd617d8adc76fefd0 (diff)
downloadrust-70f130954d6fd36fe3e77f4b5b33e5af50489288.tar.gz
Auto merge of #59879 - ebarnard:patch-1, r=alexcrichton
Add a comment explaining why SecRandomCopyBytes is not used on MacOS SecRandomCopyBytes is [available since MacOS 10.7](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc) which is the minimum supported version and which was suggested in https://github.com/rust-lang/rust/pull/58901#issuecomment-470188115 is the earliest version currently in use. This matches the behaviour of other platforms which have a random number generator syscall available.
-rw-r--r--src/libstd/sys/unix/rand.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs
index 122f22b37a2..77f1439e17b 100644
--- a/src/libstd/sys/unix/rand.rs
+++ b/src/libstd/sys/unix/rand.rs
@@ -99,6 +99,13 @@ mod imp {
}
}
+// On iOS and MacOS `SecRandomCopyBytes` calls `CCRandomCopyBytes` with
+// `kCCRandomDefault`. `CCRandomCopyBytes` manages a CSPRNG which is seeded
+// from `/dev/random` and which runs on its own thread accessed via GCD.
+// This seems needlessly heavyweight for the purposes of generating two u64s
+// once per thread in `hashmap_random_keys`. Therefore `SecRandomCopyBytes` is
+// only used on iOS where direct access to `/dev/urandom` is blocked by the
+// sandbox.
#[cfg(target_os = "ios")]
mod imp {
use crate::io;