Skip to content

Commit 22faded

Browse files
authored
Merge pull request #444 from pitdicker/emscripten
Support wasm32-unknown-emscripten
2 parents b3225bd + 36b6cff commit 22faded

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
#[cfg(feature="serde1")] extern crate serde;
189189
#[cfg(feature="serde1")] #[macro_use] extern crate serde_derive;
190190

191-
#[cfg(all(target_arch = "wasm32", feature = "stdweb"))]
191+
#[cfg(all(target_arch="wasm32", not(target_os="emscripten"), feature="stdweb"))]
192192
#[macro_use]
193193
extern crate stdweb;
194194

src/rngs/os.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ use rand_core::{CryptoRng, RngCore, Error, impls};
3737
/// otherwise from `/dev/urandom`.
3838
/// - macOS, iOS: calls `SecRandomCopyBytes`.
3939
/// - Windows: calls `RtlGenRandom`.
40-
/// - WASM: calls `window.crypto.getRandomValues` in browsers,
41-
/// and in Node.js `require("crypto").randomBytes`.
40+
/// - WASM (with `stdweb` feature): calls `window.crypto.getRandomValues` in
41+
/// browsers, and in Node.js `require("crypto").randomBytes`.
42+
/// - Emscripten: reads from emulated `/dev/urandom`, which maps to the same
43+
/// interfaces as `stdweb`, but falls back to the insecure `Math.random()` if
44+
/// unavailable.
4245
/// - OpenBSD: calls `getentropy(2)`.
4346
/// - FreeBSD: uses the `kern.arandom` `sysctl(2)` mib.
4447
/// - Fuchsia: calls `cprng_draw`.

0 commit comments

Comments
 (0)