|
12 | 12 | //! |
13 | 13 | //! | Target | Target Triple | Implementation |
14 | 14 | //! | ----------------- | ------------------ | -------------- |
15 | | -//! | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random` | |
16 | | -//! | Windows | `*‑windows‑*` | [`BCryptGenRandom`][3] | |
17 | | -//! | macOS | `*‑apple‑darwin` | [`getentropy()`][19] if available, otherwise [`/dev/random`][20] (identical to `/dev/urandom`) |
18 | | -//! | iOS | `*‑apple‑ios` | [`SecRandomCopyBytes`][4] |
19 | | -//! | FreeBSD | `*‑freebsd` | [`getrandom()`][21] if available, otherwise [`kern.arandom`][5] |
20 | | -//! | OpenBSD | `*‑openbsd` | [`getentropy`][6] |
21 | | -//! | NetBSD | `*‑netbsd` | [`kern.arandom`][7] |
22 | | -//! | Dragonfly BSD | `*‑dragonfly` | [`getrandom()`][22] if available, otherwise [`/dev/random`][8] |
23 | | -//! | Solaris, illumos | `*‑solaris`, `*‑illumos` | [`getrandom()`][9] if available, otherwise [`/dev/random`][10] |
24 | | -//! | Fuchsia OS | `*‑fuchsia` | [`cprng_draw`][11] |
25 | | -//! | Redox | `*‑redox` | [`/dev/urandom`][12] |
| 15 | +//! | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random` |
| 16 | +//! | Windows | `*‑windows‑*` | [`BCryptGenRandom`] |
| 17 | +//! | macOS | `*‑apple‑darwin` | [`getentropy`][3] if available, otherwise [`/dev/random`][4] (identical to `/dev/urandom`) |
| 18 | +//! | iOS | `*‑apple‑ios` | [`SecRandomCopyBytes`] |
| 19 | +//! | FreeBSD | `*‑freebsd` | [`getrandom`][5] if available, otherwise [`kern.arandom`][6] |
| 20 | +//! | OpenBSD | `*‑openbsd` | [`getentropy`][7] |
| 21 | +//! | NetBSD | `*‑netbsd` | [`kern.arandom`][8] |
| 22 | +//! | Dragonfly BSD | `*‑dragonfly` | [`getrandom`][9] if available, otherwise [`/dev/random`][10] |
| 23 | +//! | Solaris, illumos | `*‑solaris`, `*‑illumos` | [`getrandom`][11] if available, otherwise [`/dev/random`][12] |
| 24 | +//! | Fuchsia OS | `*‑fuchsia` | [`cprng_draw`] |
| 25 | +//! | Redox | `*‑redox` | `/dev/urandom` |
26 | 26 | //! | Haiku | `*‑haiku` | `/dev/random` (identical to `/dev/urandom`) |
27 | | -//! | Hermit | `x86_64-*-hermit` | [`RDRAND`][18] |
28 | | -//! | SGX | `x86_64‑*‑sgx` | [RDRAND][18] |
| 27 | +//! | Hermit | `x86_64-*-hermit` | [`RDRAND`] |
| 28 | +//! | SGX | `x86_64‑*‑sgx` | [`RDRAND`] |
29 | 29 | //! | VxWorks | `*‑wrs‑vxworks‑*` | `randABytes` after checking entropy pool initialization with `randSecure` |
30 | | -//! | ESP-IDF | `*‑espidf` | [`esp_fill_random()`][23] |
| 30 | +//! | ESP-IDF | `*‑espidf` | [`esp_fill_random`] |
31 | 31 | //! | Emscripten | `*‑emscripten` | `/dev/random` (identical to `/dev/urandom`) |
32 | | -//! | WASI | `wasm32‑wasi` | [`random_get`][17] |
33 | | -//! | Web Browser | `wasm32‑*‑unknown` | [`Crypto.getRandomValues()`][14], see [WebAssembly support][16] |
34 | | -//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomBytes`][15], see [WebAssembly support][16] |
| 32 | +//! | WASI | `wasm32‑wasi` | [`random_get`] |
| 33 | +//! | Web Browser | `wasm32‑*‑unknown` | [`Crypto.getRandomValues`], see [WebAssembly support] |
| 34 | +//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomBytes`], see [WebAssembly support] |
35 | 35 | //! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes` |
36 | 36 | //! |
37 | 37 | //! There is no blanket implementation on `unix` targets that reads from |
|
53 | 53 | //! |
54 | 54 | //! ### RDRAND on x86 |
55 | 55 | //! |
56 | | -//! *If the `"rdrand"` Cargo feature is enabled*, `getrandom` will fallback to using |
57 | | -//! the [`RDRAND`][18] instruction to get randomness on `no_std` `x86`/`x86_64` |
| 56 | +//! *If the `rdrand` Cargo feature is enabled*, `getrandom` will fallback to using |
| 57 | +//! the [`RDRAND`] instruction to get randomness on `no_std` `x86`/`x86_64` |
58 | 58 | //! targets. This feature has no effect on other CPU architectures. |
59 | 59 | //! |
60 | 60 | //! ### WebAssembly support |
|
67 | 67 | //! supported since, from the target name alone, we cannot deduce which |
68 | 68 | //! JavaScript interface is in use (or if JavaScript is available at all). |
69 | 69 | //! |
70 | | -//! Instead, *if the `"js"` Cargo feature is enabled*, this crate will assume |
| 70 | +//! Instead, *if the `js` Cargo feature is enabled*, this crate will assume |
71 | 71 | //! that you are building for an environment containing JavaScript, and will |
72 | 72 | //! call the appropriate methods. Both web browser (main window and Web Workers) |
73 | 73 | //! and Node.js environments are supported, invoking the methods |
|
85 | 85 | //! |
86 | 86 | //! Note that registering a custom implementation only has an effect on targets |
87 | 87 | //! that would otherwise not compile. Any supported targets (including those |
88 | | -//! using `"rdrand"` and `"js"` Cargo features) continue using their normal |
| 88 | +//! using `rdrand` and `js` Cargo features) continue using their normal |
89 | 89 | //! implementations even if a function is registered. |
90 | 90 | //! |
91 | 91 | //! ### Indirect Dependencies |
|
124 | 124 | //! |
125 | 125 | //! [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html |
126 | 126 | //! [2]: http://man7.org/linux/man-pages/man4/urandom.4.html |
127 | | -//! [3]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom |
128 | | -//! [4]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc |
129 | | -//! [5]: https://www.freebsd.org/cgi/man.cgi?query=random&sektion=4 |
130 | | -//! [6]: https://man.openbsd.org/getentropy.2 |
131 | | -//! [7]: https://man.netbsd.org/sysctl.7 |
132 | | -//! [8]: https://leaf.dragonflybsd.org/cgi/web-man?command=random§ion=4 |
133 | | -//! [9]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html |
134 | | -//! [10]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html |
135 | | -//! [11]: https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_draw |
136 | | -//! [12]: https://github.com/redox-os/randd/blob/master/src/main.rs |
137 | | -//! [14]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues |
138 | | -//! [15]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback |
139 | | -//! [16]: #webassembly-support |
140 | | -//! [17]: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-random_getbuf-pointeru8-buf_len-size---errno |
141 | | -//! [18]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide |
142 | | -//! [19]: https://www.unix.com/man-page/mojave/2/getentropy/ |
143 | | -//! [20]: https://www.unix.com/man-page/mojave/4/random/ |
144 | | -//! [21]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable |
145 | | -//! [22]: https://leaf.dragonflybsd.org/cgi/web-man?command=getrandom |
146 | | -//! [23]: https://docs.espressif.com/projects/esp-idf/en/release-v4.1/api-reference/system/system.html?highlight=esp_fill_random#_CPPv415esp_fill_randomPv6size_t |
| 127 | +//! [3]: https://www.unix.com/man-page/mojave/2/getentropy/ |
| 128 | +//! [4]: https://www.unix.com/man-page/mojave/4/random/ |
| 129 | +//! [5]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable |
| 130 | +//! [6]: https://www.freebsd.org/cgi/man.cgi?query=random&sektion=4 |
| 131 | +//! [7]: https://man.openbsd.org/getentropy.2 |
| 132 | +//! [8]: https://man.netbsd.org/sysctl.7 |
| 133 | +//! [9]: https://leaf.dragonflybsd.org/cgi/web-man?command=getrandom |
| 134 | +//! [10]: https://leaf.dragonflybsd.org/cgi/web-man?command=random§ion=4 |
| 135 | +//! [11]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html |
| 136 | +//! [12]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html |
| 137 | +//! |
| 138 | +//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom |
| 139 | +//! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues |
| 140 | +//! [`RDRAND`]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide |
| 141 | +//! [`SecRandomCopyBytes`]: https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc |
| 142 | +//! [`cprng_draw`]: https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_draw |
| 143 | +//! [`crypto.randomBytes`]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback |
| 144 | +//! [`esp_fill_random`]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html#_CPPv415esp_fill_randomPv6size_t |
| 145 | +//! [`random_get`]: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-random_getbuf-pointeru8-buf_len-size---errno |
| 146 | +//! [WebAssembly support]: #webassembly-support |
147 | 147 |
|
148 | 148 | #![doc( |
149 | 149 | html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", |
150 | 150 | html_favicon_url = "https://www.rust-lang.org/favicon.ico", |
151 | | - html_root_url = "https://docs.rs/getrandom/0.2.4" |
| 151 | + html_root_url = "https://docs.rs/getrandom/0.2.5" |
152 | 152 | )] |
153 | 153 | #![no_std] |
154 | 154 | #![warn(rust_2018_idioms, unused_lifetimes, missing_docs)] |
|
0 commit comments