diff --git a/src/lib.rs b/src/lib.rs index bd7882cd33b..882ff73e0fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/rngs/os.rs b/src/rngs/os.rs index 75cee9073de..96b8d90f85b 100644 --- a/src/rngs/os.rs +++ b/src/rngs/os.rs @@ -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`.