Files
boc/aamos-ledger-rust/target/debug/deps/libgetrandom-3af6da94d21ddbad.rmeta
T

557 lines
62 KiB
Plaintext
Raw Normal View History

rust
’ö#rustc 1.96.0 (ac68faa20 2026-05-25)ÁíàÄTËŸ ÜJîÄ)'ß\¥!-3d1337db07d0b3aeÁcfg_ifÁf©¾/ô)c§{õa“â‘-a3906971a93fd1b8Á¤°ð ¾ä-±($²ï=©Ã-7e98a21bfd32b0edÁÀ뉊]!ÜÛê(¹Þ—šên-5be7b69c3ff7b5b8Á¤²XctÔ'ÐÓ©z¨ɽÓ-a4945860e1c53b00ÁòÖÀH•‘PIÓHã#£-055f30b747f859b6Árustc_std_workspace_coreÁ­Cçß^ò½èÝ$­Çÿ+Cé-c4878ee60b2242c9ÁŸÃï+Ñ]ŠqB<ÏïW#-8dd1dd90e70d0b6aÁ miniz_oxideÁ€š»J(P>àö÷g\K-1eb618da2918ab7fÁadler2ÁÆ;+Þ®5¥Ìýݰ¦ÛLˆ-f7919172d268e069Á hashbrownÁPäV9ÒÆèÜ"ÊÖVŽ\-0fc2184a5da6723aÁrustc_std_workspace_allocÁs&ØòØy¯s•bæ!‰ýŠ-97e4bf30be240674Á
std_detectÁhŠBîÙºÌI®ËÅš-9dbbf8346ba7ac8bÁrustc_demangleÁûë9´Ç×@Œ’ùXFº-f33013f239bf9f14Á_ÜLhž§Œaã¯>­-0a71c8f33a838301Á addr2lineÁ׎Þ!]8V$É@@-e618e6be60e87ba2ÁgimliÁ¸
°µ~Î1‹Ñt ðÁ€w-1f7768a68858f670ÁobjectÁ
áPÃ?­À¶¼QHJ¥-914cd6a4dbe590d1ÁmemchrÁ›º«8Ór­2Ù $¨ûib-cf21ca6f2bb15dcdÁë
‹ás«LÖ€îâƒ×ɯŒ-ee6f3747e38367f0Áæ\‹±ÔcdùÀTƒ-f86f80b348d33b13Á8 inner_u32ÁLüúandroidÁ¬·úlinuxÁœÎü¶,ü²18 inner_u64ÁL‡ú®=úÁ64138çú®¬Ã úÁœÚ ü ,ü¾ 1í_backendsÁerrorÁÀ  UNSUPPORTEDÁ ERRNO_NOT_POSITIVEÁ 
UNEXPECTEDÁ INTERNAL_STARTÁ  CUSTOM_STARTÁ from_neg_error_codeÁ  raw_os_errorÁ 
new_customÁ  new_internalÁ 
internal_descÁ××utilÁslice_assume_init_mutÁ¥uninit_slice_fill_zeroÁslice_as_uninitÁ!¥slice_as_uninit_mutÁ#¥ ptr_from_mutÁ%¥¼ '¥ÚtruncateÁerror_std_implsÁ,À,,,0÷,fillÁ fill_uninitÁÔÚuse_fileÁ88888888 util_libcÁ@@@
last_os_errorÁ@sys_fill_exactÁD0impl Fn(&mut [MaybeUninit<u8>]) -> libc::ssize_tÁD 8 FILE_PATHÁ8 FD_UNINITÁ8FD_ONGOING_INITÁ8FDÁ8
fill_innerÁK 8
open_readonlyÁ8 open_or_waitÁ8open_fdÁ8çPPPPPPPwaitÁPwakeÁPwait_until_rng_readyÁlinux_android_with_fallbackÁZZZZZZZZZZ Z
Z Z Z
ZZZZ GetRandomFnÁZ
NOT_AVAILABLEÁZ GETRANDOM_FNÁZinitÁoNAMEÁZuse_file_fallbackÁZr  sanitizerÁttunpoisonÁtunpoison_linux_getrandom_resultÁ@@ get_errnoÁ
RawOsErrorÁNonZeroRawOsErrorÁErrorÁ}
}ˆƒÖ








!
#
%
'
4
5
D
D
K
M
q
r
v
w
ƒ

ˆ
ˆ
Š }}~ˆ <pxìôQŒÛ¹Ø¹¹Ð칵߹¹¿c¹Äc¹éßßà ¬
ÑøÿËO Ÿ¹¾¹}}‚}„}†}‡}}}0ß2}Š 9ÛØÐìµß¿cÄc龌ì 
5B 
ˆ üüÓ+G³Š2b"/dev/urandom\0"Áÿÿÿÿ-1Áþÿÿÿ¥-2ÁÌÙ—Õ Ë4Ì4Í4
__variant1ÁÎ4Ï4
__variant2Áë òg üÂ1

´Â
žâ+ òü’dm§ ïíe¼îËè¿*âáùYó—Õ¬µ 
 ”µ 
 È 
0ü– 5
¹,­ $¬»

 ”»
÷ Î
ˆ
.ü•
< ¹
$
 ”Å÷ ؈
.ü§4 ¹$Ã¥) Â9  ¾¥I¥e*¥q¥ü›+
¥Â°1<­²¥Â) Â9  ­¥I¥e*¥q¥üŒ)¥Â°1$ƒ*Œ * ¡*¥ °*üŠ*'œŠ*¥  ¥=¥TüÁ*1$ë*üÊ*&

üÊ* 
´
¥7, ï*ü»*8 } ò* ø*ù*üð(‰üÿ)z¹,“)ˆ ˆ)¥@¥@ˆ@¥"ô ô õ ¨÷ ˆÐ  mjçítoé¥
¥ ¹qcodeÁ¹¬¥Œ¥$ñ,Œ- -¥  -üø,)¬ø,
¥  
¥=¥Tü±-1$Û-üº-&

üº- ‰$1& ß-ü«-8 } â- è-é-üÓ+–üí,|¹,ÿ+ˆ ô+¥:¥:ˆ:Ÿ%ª%ϥ͹:ý$xq@
¥K
¥„¡  }~#¹.ª%5<,4567í_4½ MaybeUninitÁ\ÕÑÛ}3ü9äü9,) [`Error::UNEXPECTED`]: Error::UNEXPECTEDÁüf  [`fill_uninit`]: fill_uninitÁøý“ü®&ý“# getrandom: system's random number generator
[![Build Status]][GitHub Actions]
[![Crate]][crates.io]
[![Documentation]][docs.rs]
[![Dependency Status]][deps.rs]
[![Downloads]][crates.io]
[![License]][LICENSE-MIT]
`getrandom` is a Rust library for retrieving random data from (operating) system sources.
It is assumed that the system always provides high-quality, cryptographically secure random
data, ideally backed by hardware entropy sources. This crate derives its name from
the Linux `getrandom` syscall but is cross-platform, roughly supporting the same set
of platforms as Rust's `std` library.
This is a low-level API. Most users should prefer using a higher-level random-number
library like [`rand`].
[`rand`]: https://crates.io/crates/rand
## Usage
Add the `getrandom` dependency to your `Cargo.toml` file:
```toml
[dependencies]
getrandom = "0.3"
```
Then invoke the `fill` function on a byte buffer to fill it with random data:
```rust
fn get_random_u128() -> Result<u128, getrandom::Error> {
let mut buf = [0u8; 16];
getrandom::fill(&mut buf)?;
Ok(u128::from_ne_bytes(buf))
}
```
## Supported targets
| Target | Target Triple | Implementation
| ------------------ | ------------------ | --------------
| Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random`
| Windows 10+ | `*‑windows‑*` | [`ProcessPrng`] on Rust 1.78+, [`RtlGenRandom`] otherwise
| Windows 7, 8 | `*-win7‑windows‑*` | [`RtlGenRandom`]
| macOS | `*‑apple‑darwin` | [`getentropy`][3]
| iOS, tvOS, watchOS | `*‑apple‑{ios,tvos,watchos}` | [`CCRandomGenerateBytes`]
| FreeBSD | `*‑freebsd` | [`getrandom`][5]
| OpenBSD | `*‑openbsd` | [`getentropy`][7]
| NetBSD | `*‑netbsd` | [`getrandom`][16] if available, otherwise [`kern.arandom`][8]
| Dragonfly BSD | `*‑dragonfly` | [`getrandom`][9]
| Solaris | `*‑solaris` | [`getrandom`][11] with `GRND_RANDOM`
| illumos | `*‑illumos` | [`getrandom`][12]
| Fuchsia OS | `*‑fuchsia` | [`cprng_draw`]
| Redox | `*‑redox` | `/dev/urandom`
| Haiku | `*‑haiku` | `/dev/urandom` (identical to `/dev/random`)
| Hermit | `*-hermit` | [`sys_read_entropy`]
| Hurd | `*-hurd-*` | [`getrandom`][17]
| SGX | `x86_64‑*‑sgx` | [`RDRAND`]
| VxWorks | `*‑wrs‑vxworks‑*` | `randABytes` after checking entropy pool initialization with `randSecure`
| Emscripten | `*‑emscripten` | [`getentropy`][13]
| WASI 0.1 | `wasm32‑wasip1` | [`random_get`]
| WASI 0.2 | `wasm32‑wasip2` | [`get-random-u64`]
| SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
| Nintendo 3DS | `*-nintendo-3ds` | [`getrandom`][18]
| ESP-IDF | `*‑espidf` | [`esp_fill_random`] WARNING: see "Early Boot" section below
| PS Vita | `*-vita-*` | [`getentropy`][19]
| QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`)
| AIX | `*-ibm-aix` | [`/dev/urandom`][15]
| Cygwin | `*-cygwin` | [`getrandom`][20] (based on [`RtlGenRandom`])
Pull Requests that add support for new targets to `getrandom` are always welcome.
### Opt-in backends
`getrandom` also provides optional (opt-in) backends, which allow users to customize the source
of randomness based on their specific needs:
| Backend name | Target | Target Triple | Implementation
| ----------------- | -------------------- | ------------------------ | --------------
| `linux_getrandom` | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call (without `/dev/urandom` fallback). Bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow).
| `linux_raw` | Linux, Android | `*‑linux‑*` | Same as `linux_getrandom`, but uses raw `asm!`-based syscalls instead of `libc`.
| `rdrand` | x86, x86-64 | `x86_64-*`, `i686-*` | [`RDRAND`] instruction
| `rndr` | AArch64 | `aarch64-*` | [`RNDR`] register
| `wasm_js` | Web Browser, Node.js | `wasm32‑unknown‑unknown`, `wasm32v1-none` | [`Crypto.getRandomValues`]. Enabled by the `wasm_js` feature ([see below](#webassembly-support)).
| `efi_rng` | UEFI | `*-unknown‑uefi` | [`EFI_RNG_PROTOCOL`] with `EFI_RNG_ALGORITHM_RAW` (requires `std` and Nightly compiler)
| `windows_legacy` | Windows | `*-windows-*` | [`RtlGenRandom`]
| `custom` | All targets | `*` | User-provided custom implementation (see [custom backend])
| `unsupported` | All targets | `*` | Always returns `Err(Error::UNSUPPORTED)` (see [unsupported backend])
Opt-in backends can be enabled using the `getrandom_backend` configuration flag.
The flag can be set either by specifying the `rustflags` field in [`.cargo/config.toml`]:
```toml
# It's recommended to set the flag on a per-target basis:
[target.wasm32-unknown-unknown]
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
```
Or by using the `RUSTFLAGS` environment variable:
```sh
RUSTFLAGS='--cfg getrandom_backend="linux_getrandom"' cargo build
```
Enabling an opt-in backend will replace the backend used by default. Doing this for
an incorrect target (e.g. using `linux_getrandom` while compiling for a Windows target)
will result in a compilation error. Be extremely careful while using opt-in backends,
as incorrect configuration may result in vulnerable applications or applications
that always panic.
Note that using an opt-in backend in a library (e.g. for tests or benchmarks)
WILL NOT have any effect on its downstream users.
[`.cargo/config.toml`]: https://doc.rust-lang.org/cargo/reference/config.html
### Raw Linux syscall support
Currently the `linux_raw` backend supports only targets with stabilized `asm!` macro,
i.e. `arm`, `aarch64`, `loongarch64`, `riscv32`, `riscv64`, `s390x`, `x86`, and `x86_64`.
Note that the raw syscall backend may be slower than backends based on `libc::getrandom`,
e.g. it does not implement vDSO optimizations and on `x86` it uses the infamously slow
`int 0x80` instruction to perform syscall.
### WebAssembly support
This crate fully supports the [WASI] and [Emscripten] targets. However,
the `wasm32-unknown-unknown` target (i.e. the target used by `wasm-pack`)
is not automatically supported since, from the target name alone, we cannot deduce
which JavaScript interface should be used (or if JavaScript is available at all).
We do not include support for this target in the default configuration because
our JS backend (supporting web browsers, web workers and Node.js v19 or later)
requires [`wasm-bindgen`], **bloating `Cargo.lock`** and
**potentially breaking builds** on non-web WASM platforms.
To enable `getrandom`'s functionality on `wasm32-unknown-unknown` using the Web
Crypto methods [described above][opt-in] via [`wasm-bindgen`], enable the
`wasm_js` feature flag. Setting `RUSTFLAGS='--cfg getrandom_backend="wasm_js"'`
is allowed but is no longer required and does nothing (it was required in a
prior version of this crate).
WARNING: enabling the `wasm_js` feature will bloat `Cargo.lock` on all platforms
(where [`wasm-bindgen`] is not an existing dependency) and is known to cause
build issues on some non-web WASM platforms, even when a different backend is
selected via `getrandom_backend`.
### Custom backend
If this crate does not support your target out of the box or you have to use
a non-default entropy source, then you can provide a custom implementation.
You need to enable the custom backend as described in the
[opt-in backends][opt-in] section.
Next, you need to define an `extern` function with the following signature:
```rust
use getrandom::Error;
#[no_mangle]
unsafe extern "Rust" fn __getrandom_v03_custom(
dest: *mut u8,
len: usize,
) -> Result<(), Error> {
todo!()
}
```
This function should, ideally, be defined in the root crate of your project,
e.g. in your `main.rs`. This function MUST be defined only once for your
project, i.e. upstream library crates SHOULD NOT define it outside of
tests and benchmarks. Improper configuration of this backend may result
in linking errors.
The function accepts a pointer to a buffer that should be filled with random
data and its length in bytes. Note that the buffer MAY be uninitialized.
On success, the function should return `Ok(())` and fully fill the input buffer;
otherwise, it should return an error value.
While wrapping functions which work with byte slices you should fully initialize
the buffer before passing it to the function:
```rust
use getrandom::Error;
fn my_entropy_source(buf: &mut [u8]) -> Result<(), getrandom::Error> {
// ...
Ok(())
}
#[no_mangle]
unsafe extern "Rust" fn __getrandom_v03_custom(
dest: *mut u8,
len: usize,
) -> Result<(), Error> {
let buf = unsafe {
// fill the buffer with zeros
core::ptr::write_bytes(dest, 0, len);
// create mutable byte slice
core::slice::from_raw_parts_mut(dest, len)
};
my_entropy_source(buf)
}
```
### Unsupported backend
In some rare scenarios, you might be compiling this crate for an unsupported
target (e.g. `wasm32-unknown-unknown`), but this crate's functionality
is not actually used by your code. If you are confident that `getrandom` is
not used in your project, but it gets pulled nevertheless by one of your
dependencies, then you can enable the `unsupported` backend, which always
returns `Err(Error::UNSUPPORTED)`.
### Platform Support
This crate generally supports the same operating system and platform versions
that the Rust standard library does. Additional targets may be supported using
the opt-in custom backend.
This means that as Rust drops support for old versions of operating systems
(such as old Linux kernel versions, Android API levels, etc.) in stable releases,
`getrandom` may create new patch releases that remove support for
outdated platform versions.
### `/dev/urandom` fallback on Linux and Android
On Linux targets, the `/dev/urandom` fallback is present only if either `target_env`
is `musl`, or `target_arch` is one of the following: `aarch64`, `arm`, `powerpc`,
`powerpc64`, `s390x`, `x86`, `x86_64`. Other supported targets [require][platform-support]
kernel versions that support the `getrandom` system call, so the fallback is not needed.
On Android targets the fallback is present only for the following `target_arch`es:
`aarch64`, `arm`, `x86`, `x86_64`. Other `target_arch`es (e.g. RISC-V) require
sufficiently high API levels.
The fallback can be disabled by enabling the `linux_getrandom` opt-in backend.
Note that doing so will bump minimum supported Linux kernel version to 3.17
and Android API level to 23 (Marshmallow).
### Early boot
Sometimes, early in the boot process, the OS has not collected enough
entropy to securely seed its RNG. This is especially common on virtual
machines, where standard "random" events are hard to come by.
Some operating system interfaces always block until the RNG is securely
seeded. This can take anywhere from a few seconds to more than a minute.
A few (Linux, NetBSD and Solaris) offer a choice between blocking and
getting an error; in these cases, we always choose to block.
On Linux (when the `getrandom` system call is not available), reading from
`/dev/urandom` never blocks, even when the OS hasn't collected enough
entropy yet. To avoid returning low-entropy bytes, we first poll
`/dev/random` and only switch to `/dev/urandom` once this has succeeded.
On OpenBSD, this kind of entropy accounting isn't available, and on
NetBSD, blocking on it is discouraged. On these platforms, nonblocking
interfaces are used, even when reliable entropy may not be available.
On the platforms where it is used, the reliability of entropy accounting
itself isn't free from controversy. This library provides randomness
sourced according to the platform's best practices, but each platform has
its own limits on the grade of randomness it can promise in environments
with few sources of entropy.
On ESP-IDF, if `esp_fill_random` is used before enabling WiFi, BT, or the
voltage noise entropy source (SAR ADC), the Hardware RNG will only be seeded
via RC_FAST_CLK. This can occur during early boot unless
`bootloader_random_enable()` is called. For more information see the
[ESP-IDF RNG Docs][esp-idf-rng] or the
[RNG section of the ESP32 Technical Reference Manual][esp-trng-docs].
## Error handling
We always prioritize failure over returning known insecure "random" bytes.
Generally, on supported platforms, failure is highly unlikely, though not
impossible. If an error does occur, it is likely that it will occur
on every call to `getrandom`. Therefore, after the first successful call,
one can be reasonably confident that no errors will occur.
## Panic handling
We strive to eliminate all potential panics from our backend implementations.
In other words, when compiled with optimizations enabled, the generated
binary code for `getrandom` functions should not contain any panic branches.
Even if the platform misbehaves and returns an unexpected result,
our code should correctly handle it and return an error, e.g.
[`Error::UNEXPECTED`].
## Sanitizer support
If your code uses [`fill_uninit`] and you enable
[MemorySanitizer](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#memorysanitizer)
(i.e. `-Zsanitizer=memory`), we will automatically handle unpoisoning
of the destination buffer filled by `fill_uninit`.
You can run sanitizer tests for your crate dependent on `getrandom` like this:
```sh
RUSTFLAGS="-Zsanitizer=memory" cargo test -Zbuild-std --target=x86_64-unknown-linux-gnu
```
## Minimum Supported Rust Version
This crate requires Rust 1.63 or later.
## License
The `getrandom` library is distributed under either of
* [Apache License, Version 2.0][LICENSE-APACHE]
* [MIT license][LICENSE-MIT]
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
[//]: # (badges)
[GitHub Actions]: https://github.com/rust-random/getrandom/actions?query=branch:master
[Build Status]: https://github.com/rust-random/getrandom/actions/workflows/tests.yml/badge.svg?branch=master
[crates.io]: https://crates.io/crates/getrandom
[Crate]: https://img.shields.io/crates/v/getrandom
[docs.rs]: https://docs.rs/getrandom
[Documentation]: https://docs.rs/getrandom/badge.svg
[deps.rs]: https://deps.rs/repo/github/rust-random/getrandom
[Dependency Status]: https://deps.rs/repo/github/rust-random/getrandom/status.svg
[Downloads]: https://img.shields.io/crates/d/getrandom
[License]: https://img.shields.io/crates/l/getrandom
[//]: # (supported targets)
[1]: https://manned.org/getrandom.2
[2]: https://manned.org/urandom.4
[3]: https://www.unix.com/man-page/mojave/2/getentropy/
[4]: https://www.unix.com/man-page/mojave/4/urandom/
[5]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable
[7]: https://man.openbsd.org/getentropy.2
[8]: https://man.netbsd.org/sysctl.7
[9]: https://leaf.dragonflybsd.org/cgi/web-man?command=getrandom
[11]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html
[12]: https://illumos.org/man/2/getrandom
[13]: https://github.com/emscripten-core/emscripten/pull/12240
[14]: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/r/random.html
[15]: https://www.ibm.com/docs/en/aix/7.3?topic=files-random-urandom-devices
[16]: https://man.netbsd.org/getrandom.2
[17]: https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-getrandom
[18]: https://github.com/rust3ds/shim-3ds/commit/b01d2568836dea2a65d05d662f8e5f805c64389d
[19]: https://github.com/vitasdk/newlib/blob/2d869fe47aaf02b8e52d04e9a2b79d5b210fd016/newlib/libc/sys/vita/getentropy.c
[20]: https://github.com/cygwin/cygwin/blob/main/winsup/cygwin/libc/getentropy.cc
[`ProcessPrng`]: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
[`RtlGenRandom`]: https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom
[`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
[`RDRAND`]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
[`RNDR`]: https://developer.arm.com/documentation/ddi0601/2024-06/AArch64-Registers/RNDR--Random-Number
[`CCRandomGenerateBytes`]: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/include/CommonRandom.h.auto.html
[`cprng_draw`]: https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_draw
[`esp_fill_random`]: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.html#functions
[esp-idf-rng]: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.html
[esp-trng-docs]: https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf#rng
[`EFI_RNG_PROTOCOL`]: https://uefi.org/specs/UEFI/2.10/37_Secure_Technologies.html#efi-rng-protocol
[`random_get`]: https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#-random_getbuf-pointeru8-buf_len-size---errno
[`get-random-u64`]: https://github.com/WebAssembly/WASI/blob/v0.2.1/wasip2/random/random.wit#L23-L28
[configuration flags]: #configuration-flags
[custom backend]: #custom-backend
[unsupported backend]: #unsupported-backend
[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen
[`module`]: https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-js-imports/module.html
[`sys_read_entropy`]: https://github.com/hermit-os/kernel/blob/315f58ff5efc81d9bf0618af85a59963ff55f8b1/src/syscalls/entropy.rs#L47-L55
[platform-support]: https://doc.rust-lang.org/stable/rustc/platform-support.html
[WASI]: https://github.com/WebAssembly/WASI
[Emscripten]: https://emscripten.org
[opt-in]: #opt-in-backends
[//]: # (licenses)
[LICENSE-APACHE]: https://github.com/rust-random/getrandom/blob/master/LICENSE-APACHE
[LICENSE-MIT]: https://github.com/rust-random/getrandom/blob/master/LICENSE-MIT
[`Error::UNEXPECTED`]: https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.UNEXPECTED
[`fill_uninit`]: https://docs.rs/getrandom/latest/getrandom/fn.fill_uninit.html
Á%https://www.rust-lang.org/favicon.icoÁ„ð9https://www.rust-lang.org/logos/rust-logo-128x128-blk.pngÁlŸ,4567í¦_µÅ)ÒÑÛæ}3¦¦¦œ°µ´ÊÒ8Zt )xjÚ *xk rxLñ}~{|À%×5 `#L/ ¹
ä– üØ 96 This target/platform is not supported by `getrandom`.Á\    ¹ü•
#üÐ @= The platform-specific `errno` returned a non-positive value.Á”Ÿ
  ¹ܧüÖ
LI Encountered an unexpected situation which should not happen in practice.ÁT±  ¹ü›   ¥ôŒd’  ¥üÀ;úuefiÁ”ޤü„œÎ¥¹ 
ý$$âü²/üßB? Extract the raw OS error code (if this error came from the OS)Á¦úü®MJ This method is identical to [`std::io::Error::raw_os_error()`][1], exceptÁü€KH that it works in `no_std` contexts. On most targets this method returnsÁüÐOL `Option<i32>`, but some platforms (e.g. UEFI) may use a different primitiveÁü¤QN type like `usize`. Consult with the [`RawOsError`] docs for more information.Áúúü‚MJ If this method returns `None`, the error value can still be formatted viaÁüÔ! the `Display` implementation.Áúúü‚OL [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_errorÁüÖIF [`RawOsError`]: https://doc.rust-lang.org/std/io/type.RawOsError.htmlÁd¹¹Û¼ݼÞ¼©ß¼à¼ÛἈcSñŸ«‡zÙ¥ 
üð((üž(MJ Creates a new instance of an `Error` from a particular custom error code.ÁTý(ˆ¹ 
¹üÓ+1dç+ˆ¹  ÷¹àüï-/lò- ¹Û¼ݼÞ¼©ß¼à¼ÛἈcSñŸ«‡zÙ   €.
$.Ìä;¹Àcü„<8‡<ŠŒ й  c cˆ¢cµ
 `£cbufÁ `àB¤GS
ŒÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
ŸÈŸÈ È éBL <
$Œ<± <ÜÎ@¹Åcüð@8ó@Ž ¹ Ž c cˆ¢cµ
 `£c—Р`àB¤GS
¾Ñ ÷@
$ø@± þ@$€ !#%')*+, }3Å)\7ÑÛµ Dž,I‰fdK$+„2?.0 "ü°P¬¾ 
ÑÛÑÛÅ)ÓÛuninitÁÝÔÛ»ÝÍõƒ«%9¥ 
Ö¥ ÞÍìÖ Ô
Öžü¼I´Ã 
ÑÛÑÛÅ)ÓÛáÔÝÔÛ»ÝÍõƒ«%9ˆ µ á
žüŽ;|• žÖ ÊÕ¥"" ¯ÀÖ ¥
!Öžü…
Nœ“
 žÖ ÊÕ¥$$ ±
ÀÖ §

#Öž
üÀ /  Ö Ö¥&& Þ ÎìÖ Ð 
%Ö½ Û ü¶
-
 Ö Ö¥(( Ô
ÙÚ Æ

'Ö½ Ñ
ü»(Ö¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
¹
)üç(Ö¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
¹
*ü‚'DÂ
+¹œŸ»À|¼‡À
,-,},.3ioÁ.¦,/„9d-<)ô3¸1ë1ÜX$[¹¸00
1errÁ`ü« ¹œ½æüŸ1üÓSP Fill `dest` with random bytes from the system's preferred random number source.Á§ úü« NK This function returns an error on any failure, including partial reads. WeÁüú NK make no guarantees regarding the contents of `dest` on error. If `dest` isÁüÉ
JG empty, `getrandom` immediately returns success, making no calls to theÁü”  underlying operating system.Áµ úü¹ OL Blocking is possible, at least during early boot; see module documentation.Á úü MJ In general, `getrandom` will be fast enough for interactive usage, thoughÁüÛ JG significantly slower than a user-space CSPRNG; for the latter considerÁü¦
IF [`rand::thread_rng`](https://docs.rs/rand/*/rand/fn.thread_rng.html).Áð
ú
 # ExamplesÁƒú<‡ ```Áü1. # fn main() -> Result<(), getrandom::Error> {ÁäÁ let mut buf = [0u8; 32];ÁüÞ getrandom::fill(&mut buf)?;Á # Ok(()) }Á<Öå µÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
¹ ±
4destÁ$«ü´Lü½GD Fill potentially uninitialized buffer `dest` with random bytes fromÁü…DA the system's preferred random number source and return a mutableÁìÊ reference to those bytes.ÁèúüìJG On successful completion this function is guaranteed to return a sliceÁü·FC which points to the same memory as `dest` and has the same length.ÁüþHE In other words, it's safe to assume that `dest` is initialized afterÁüÇ$! this function has returned `Ok`.ÁìúüðJG No part of `dest` will ever be de-initialized at any point, regardlessÁÄ» of what is returned.ÁÔú³åçú
```ignoreÁüù>; # // We ignore this test since `uninit_array` is unstable.Áü¸*' #![feature(maybe_uninit_uninit_array)]Áüã1çåü•A> let mut buf = core::mem::MaybeUninit::uninit_array::<1024>();Áü×;8 let buf: &mut [u8] = getrandom::fill_uninit(&mut buf)?;Át“ïæÖå š×Ö¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
 µ¹ Í
5œèü¼"üÝFC Get random `u32` from the system's preferred random number source.Á¤ú³å·úÖåüÃ1çåüõ%" let rng_seed = getrandom::u32()?;ÁtïæÖåÞÜ
6üÝ"üþFC Get random `u64` from the system's preferred random number source.ÁÅú³åØúÖåüä1çåü–%" let rng_seed = getrandom::u64()?;ÁïæÖåäŸÝ
7dÕ"DÙ"@GHIJKMNOP,B}893Ð4^Ë48;Å)\oÑÛ8< AtomicI32ÁLñÁ8>®¼À8?d;j$M\Y^„jQüM?;=+-İL¿CDz, }@A3Å)\!ÑÛ@Berrno_locationÁtˆ ±0@ydH´9ü÷
&l… ¹
Cüí˜ ˜š×´èEE ˜Íì­ùü¾0"­ù š×üÃ+­ùôù˜"
D­ù—Ðsys_fillÁD´gi±D<closure_kind>ÁF<closure_signature>ÁF<upvars>ÁFFDF­ù¥€“€“TryFromIntErrorÁ‚“ˆ Z} Ràvq¹´Ó8 µäÞ8¥ü"|‡8¥¤ž¥8¤]¤]V¦]Á‚]üß3ø¤”&¥BÿÿÿÿüÛDš šš×´è ó
KœèKïùL‡úL¤úLLKL š× ¥ü…;8 µÖ¿Ù¿Ú¿«Û¿ˆÜ¿Ý¿Þ¿ˆ‚†f|Â
¥¹ œ
Mõ
$–üÁ/8§ÿ
Nü×*8§ÿ
OD»&ú®¬&úÁœ¤&üŒ&,üƒ&7$¿&8WXYšlÖ& MPRâlð& CPS,ÿ&}PT93ü†'JPUæ|Š' IPV,Î&egÄå&[KM79&(¤÷)$…*8
W¤Ï.$Ý.8
XüÄ<9¤Ò<8´è
Yüë"Üï"lmnoqr÷LPtZ\ŸD[8Z],q}Z^3Ð4Ë4Z` ÐZbÅ)\ªÑÛZc§Zd AtomicPtrÁLݯ]Zf®¼ÀZgÊL„@Zh¶! )jÚ²! *k,HãåÖØdjÌ$|Áü| ´¥§d¼™ü|^ƒtvœúh\˜""""„¾ZáÂü’$Züø&dÿZ¤]¤]V¦]Á‚]üß3ø¤”&áÃäâZ
oZ­ü
ÿÿüëGŒîZœ œš×´è 
qœè$€üáDY# š×´è ù
rœè,–rïùs‡ús¤ússrsØþ ”†l”#L˜#vwÅ)\ ÑÛtu´ üÐ3 DÞ ž žš× ì
v—Ðç üV ú®¬â úÁœù üá, üØ7 üž Ÿ Ÿš× Ã
w—о retÁÛ ܳ#´îÛ ü³
$
@¥
z|T”¥´®Œ³ª%Süè.+ A small and `no_std` compatible error typeÁúü›PM The [`Error::raw_os_error()`] will indicate if the error is from the OS, andÁüìLI if so, which error code the OS gave the application. If such an error isÁü¹?< encountered, please consult with your system documentation.Áùúüý=: *If this crate's `"std"` Cargo feature is enabled*, then:Áü»,) - [`getrandom::Error`][Error] implementsÁüèQN [`std::error::Error`](https://doc.rust-lang.org/std/error/trait.Error.html)ÁüºWT - [`std::io::Error`](https://doc.rust-lang.org/std/io/struct.Error.html) implementsÁü’ XU [`From<getrandom::Error>`](https://doc.rust-lang.org/std/convert/trait.From.html).Á ¹<pxìôQŒ~ª%¹S2ª%¹}}
~Œ² }}ª% G„ N¹(HŠ 
O¹/3O¹ƒÙƒMO   ¹¹ 
ƒ˜I‘ P¹!'<¡ ¡¹I‘ 
…HJ• Q¹Q¹ˆ·ßˆ57¢£ ¢¹ £¹J• 
ˆ¹
#Y" •<
©< ! A•A!&Ð+n0ó5:?KD¾IN ÆTú Yò ^¯cehšm&rªw(|Ÿ /dev/urandomÁ(https://github.com/rustwasm/wasm-bindgenÁopt-in backendsÁhttps://man.netbsd.org/sysctl.7Á/https://www.unix.com/man-page/mojave/4/urandom/Á)https://img.shields.io/crates/v/getrandomÁLhttps://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.mdÁ Build StatusÁ#https://www.w3.org/TR/WebCryptoAPI/Áhttps://crates.io/crates/randÁ
getentropyÁ¤—µ—"https://man.netbsd.org/getrandom.2Áö—š˜8https://github.com/emscripten-core/emscripten/pull/12240Áü˜]https://developer.arm.com/documentation/ddi0601/2024-06/AArch64-Registers/RNDR--Random-NumberÁÞ™†š¨šhttps://emscripten.orgÁµ—ÚChttps://github.com/rust-random/getrandom/blob/master/LICENSE-APACHEÁš˜öš getrandomÁ¹›LicenseÁ†š¨š­œOhttps://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stableÁÚÔœRDRANDÁöš¨Khttps://github.com/cygwin/cygwin/blob/main/winsup/cygwin/libc/getentropy.ccÁ¹›¼#https://github.com/WebAssembly/WASIÁ­œÚJhttps://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.htmlÁÔœºž¨Ñž1https://deps.rs/repo/github/rust-random/getrandomÁ¼­ŸCCRandomGenerateBytesÁÚáŸúihttps://github.com/hermit-os/kernel/blob/315f58ff5efc81d9bf0618af85a59963ff55f8b1/src/syscalls/entropy.rsÁºž2https://www.qnx.com/developers/docs/7.1/index.htmlÁўȠ5https://doc.rust-lang.org/cargo/reference/config.htmlÁ­ŸŠ¡Error::UNEXPECTEDÁ៵¡úVhttps://rustwasm.github.io/wasm-bindgen/reference/attributes/on-js-imports/module.htmlÁ©¢https://docs.rs/getrandomÁÈ ì¢Uhttps://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandomÁŠ¡²£:https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_drawÁúµ¡Ù£\https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/random.htmlÁ©¢º¤unsupported backendÁì¢ä¤3RNG section of the ESP32 Technical Reference ManualÁ²£Ê¥)https://img.shields.io/crates/d/getrandomÁÙ£š¦"https://crates.io/crates/getrandomÁº¤Œ§Bhttps://learn.microsoft.com/en-us/windows/win32/seccng/processprngÁ䤰§#https://illumos.org/man/2/getrandomÁÊ¥ô§Shttps://github.com/rust3ds/shim-3ds/commit/b01d2568836dea2a65d05d662f8e5f805c64389dÁ𦮍<https://uefi.org/specs/UEFI/2.10/37_Secure_Technologies.htmlÁ}Œ§æ¨<https://doc.rust-lang.org/stable/rustc/platform-support.htmlÁ°§¹©<https://deps.rs/repo/github/rust-random/getrandom/status.svgÁô§í©Dhttps://github.com/rust-random/getrandom/actions?query=branch:masterÁ®¨Ѫhttps://manned.org/urandom.4Á樧«;https://leaf.dragonflybsd.org/cgi/web-man?command=getrandomÁ¹©ô«get-random-u64Áí©Á¬ see belowÁѪ­described aboveÁ§«í\https://github.com/rust-random/getrandom/actions/workflows/tests.yml/badge.svg?branch=masterÁrandÁô«®Á¬®®https://manned.org/getrandom.2Á­È® kern.arandomÁíɯè®
random_getÁ®Crypto.getRandomValuesÁ®®ê¯ wasm-bindgenÁÈ®™° MIT licenseÁè®ɯ¼°Ѱ@https://github.com/rust-random/getrandom/blob/master/LICENSE-MITÁê¯ø°$https://man.openbsd.org/getentropy.2ÁŒ ™°•±rhttps://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guideÁ¼°RNDRÁѰ½±
EmscriptenÁø°ÿ
޲Apache License, Version 2.0ÁŒ •±Ȳų DownloadsÁ½±Ú³dhttps://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/include/CommonRandom.h.auto.htmlÁÿ
 5޲Œ ú³<https://www.gnu.org/software/libc/manual/html_mono/libc.htmlÁȲFhttps://www.ibm.com/docs/en/aix/7.3?topic=files-random-urandom-devicesÁų±´WASIÁڳ˴ÿ
MemorySanitizerÁú³ε.https://docs.rs/rand/*/rand/fn.thread_rng.htmlÁ•¶Dependency StatusÁ±´ì¶2https://www.unix.com/man-page/mojave/2/getentropy/ÁË´†·sys_read_entropyÁε¦·qhttps://github.com/vitasdk/newlib/blob/2d869fe47aaf02b8e52d04e9a2b79d5b210fd016/newlib/libc/sys/vita/getentropy.cÁ•¶ß·.cargo/config.tomlÁ춸chttps://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdfÁ†·ĸ)https://img.shields.io/crates/l/getrandomÁrand::thread_rngÁ¦·å¸
DocumentationÁß·ç¹ RtlGenRandomÁ¸Šº
cprng_drawÁĸþº¬»esp_fill_randomÁå¸Í»custom backendÁç¹ë»ESP-IDF RNG DocsÁŠºˆ¼#https://docs.rs/getrandom/badge.svgÁþº¬»©¼CrateÁÍ»ɼ ProcessPrngÁë»è¼Ahttps://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.htmlÁˆ¼‰½Hhttps://github.com/WebAssembly/WASI/blob/v0.2.1/wasip2/random/random.witÁ©¼ýEFI_RNG_PROTOCOLÁɼÙ½â—è¼õ½Θ‰½ǾÍ™ý ¿¤—Ù½â—ö—õ½Θü˜Ǿ͙ޙ ¿6std::error::ErrorÁ¾}Error::raw_os_errorÁgetrandom::ErrorÁFrom<getrandomÁ5https://doc.rust-lang.org/std/convert/trait.From.htmlÁstd::io::Error::raw_os_error()Á5https://doc.rust-lang.org/std/io/type.RawOsError.htmlÁ¨Àstd::ioÁ2https://doc.rust-lang.org/std/io/struct.Error.htmlÁError::raw_os_error()ÁFrom<getrandom::Error>Á
std::errorÁÞÀöÀ4https://doc.rust-lang.org/std/error/trait.Error.htmlÁ‹Ástd::io::ErrorÁºÀžÁØÁØûÁ¨ÀÀ¦ÌÂÃøÃÞÀ‹ÁØÓÃöÀºÀ’ÄžÁØÁûÁ¨ÀÀẪÃÃØ{¸ÃÓÃ’ÄßÃLðìŠ  غãàéæ³Œ""“""Û Þ ã ŒMÃMÐLÇLùMÌìÍì“íµßíßÃLðìŠ  غãàéæ³Œ""“""Û Þ ã ŒMÃMÐLÇLùMÌìÍì“íµßíß
/dev/urandom
getrandom
¾ÇÒÇ&ÅÈëú£ÚZâÆm·JÊX×,¦ë÷¬Œçq4ÉÔá{'G8Ô ì´µ®@¹\\w´‘™gö.Jˆû¦»FôÐ9LWÎ~=ì†*М¿YøÞ€d'A>Uúä×LK·ªýcþ Ç $ò¹ÅýfX¨•ŒŽQ^–P5VW»ÿÖ¤Â3yExæ6¸öö1aaÓž8¬„ˆäμ* (E¦4-{ÝŒ²6¼3ä³ß½žB¢7<t6•;Þ<ÅK)!õ¬•ãÉÀ›Ý,•›~‚