about summary refs log tree commit diff
path: root/src/libstd/sys/unix/rand.rs
diff options
context:
space:
mode:
authorEd Barnard <eabarnard@gmail.com>2019-04-11 13:47:27 +0100
committerEdward Barnard <eabarnard@gmail.com>2019-04-16 13:58:44 +0100
commitf1da89a66705a34936a6dbfcd617d8adc76fefd0 (patch)
treef4316b8c3dc7799573fa0634988fb228fd9812b2 /src/libstd/sys/unix/rand.rs
parenta7cef0bf0810d04da3101fe079a0625d2756744a (diff)
downloadrust-f1da89a66705a34936a6dbfcd617d8adc76fefd0.tar.gz
rust-f1da89a66705a34936a6dbfcd617d8adc76fefd0.zip
Add a comment explaining why SecRandomCopyBytes is not used on MacOS
Diffstat (limited to 'src/libstd/sys/unix/rand.rs')
-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;