Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,27 @@ use rand_core::{RngCore, Error, ErrorKind, impls};
///
/// Platform sources:
///
/// - Unix-like systems (Linux, Android, Mac OSX): read directly from
/// `/dev/urandom`, or from `getrandom(2)` system call if available.
/// - OpenBSD: calls `getentropy(2)`
/// - FreeBSD: uses the `kern.arandom` `sysctl(2)` mib
/// - Linux, Android: read from `getrandom(2)` system call if available,
/// otherwise from` /dev/urandom`.
/// - MacOS, iOS: calls SecRandomCopyBytes.
/// - Windows: calls `RtlGenRandom`, exported from `advapi32.dll` as
/// `SystemFunction036`.
/// - iOS: calls SecRandomCopyBytes as /dev/(u)random is sandboxed.
/// - WASM: calls `window.crypto.getRandomValues` in browsers,
/// `require("crypto").randomBytes` in Node.js.
/// - OpenBSD: calls `getentropy(2)`.
/// - FreeBSD: uses the `kern.arandom` `sysctl(2)` mib.
/// - Fuchsia: calls `cprng_draw`.
/// - Redox: reads from `rand:` device.
/// - CloudABI: calls `random_get`.
/// - Other Unix-like systems: read directly from `/dev/urandom`.
///
/// This usually does not block. On some systems (e.g. FreeBSD, OpenBSD,
/// Max OS X, and modern Linux) this may block very early in the init
/// process, if the CSPRNG has not been seeded yet.[1]
///
/// [1] See <https://www.python.org/dev/peps/pep-0524/> for a more
/// in-depth discussion.

#[allow(unused)] // not used by all targets
pub struct OsRng(imp::OsRng);

Expand Down Expand Up @@ -186,7 +193,7 @@ impl ReadRng {
not(target_os = "freebsd"),
not(target_os = "fuchsia"),
not(target_os = "ios"),
not(target_os = "nacl"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed because nacl is dead? Seems reasonable to me, but it is not mentioned in the commit message.

Copy link
Contributor Author

@pitdicker pitdicker Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NaCl was removed in #225, but this was my original PR dhardy#19. Basically Rust no longer supports PNaCl, the primary use case, and we don't know of any use of Rust with NaCl.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, my only point was that this is not mentioned in the commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then you have a good point 😄. But the actual commit that removed nacl was two months ago (this is just one line that was forgotten), so not much to do here.

not(target_os = "macos"),
not(target_os = "openbsd"),
not(target_os = "redox")))]
mod imp {
Expand Down Expand Up @@ -369,7 +376,7 @@ mod imp {
}
}

#[cfg(target_os = "ios")]
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod imp {
extern crate libc;

Expand Down