Skip to content

Support wasm32-unknown-emscripten #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
#[cfg(feature="serde1")] extern crate serde;
#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;

#[cfg(all(target_arch = "wasm32", feature = "stdweb"))]
#[cfg(all(target_arch="wasm32", not(target_os="emscripten"), feature="stdweb"))]
#[macro_use]
extern crate stdweb;

Expand Down
7 changes: 5 additions & 2 deletions src/rngs/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ use rand_core::{CryptoRng, RngCore, Error, impls};
/// otherwise from `/dev/urandom`.
/// - macOS, iOS: calls `SecRandomCopyBytes`.
/// - Windows: calls `RtlGenRandom`.
/// - WASM: calls `window.crypto.getRandomValues` in browsers,
/// and in Node.js `require("crypto").randomBytes`.
/// - WASM (with `stdweb` feature): calls `window.crypto.getRandomValues` in
/// browsers, and in Node.js `require("crypto").randomBytes`.
/// - Emscripten: reads from emulated `/dev/urandom`, which maps to the same
/// interfaces as `stdweb`, but falls back to the insecure `Math.random()` if
/// unavailable.
/// - OpenBSD: calls `getentropy(2)`.
/// - FreeBSD: uses the `kern.arandom` `sysctl(2)` mib.
/// - Fuchsia: calls `cprng_draw`.
Expand Down