getrandom
is a Rust library for retrieving random data from (operating) system sources. Most users rely on it implicitly via higher-level crates like rand
.
We plan to use getrandom
v0.3 (crate docs) as a dependency for the upcoming rand
v0.9 release. The new getrandom
release includes important changes that may affect downstream users. To ensure that users are aware of these changes, we aim to draw attention to the new release with the release candidate.
The most significant change is the handing of optional backends, particularly for Web WASM. Previously, we used the js
crate feature to enable wasm-bindgen
-based backend. For various reasons, we have replaced it with the getrandom_backend
configuration flag. This new flag not only allows users to select the backend but also permits overwriting the default backend, which was previously restricted for security reasons. For more information, please refer to the relevant documentation section.
Full changelog:
Breaking Changes
Changed
- Bump MSRV to 1.63 #542
- Rename
getrandom
andgetrandom_uninit
functions tofill
andfill_uninit
respectively #532
Removed
wasm32-wasi
target support (usewasm32-wasip1
orwasm32-wasip2
instead) #499linux_disable_fallback
,rdrand
,js
,test-in-browser
, andcustom
crate features
in favor of configuration flags #504register_custom_getrandom!
macro #504- Implementation of
From<NonZeroU32>
forError
andError::code
method #507
Changed
- Use
ProcessPrng
on Windows 10 and up, and use RtlGenRandom on older legacy Windows versions #415 - Do not use locale-specific
strerror_r
for retrieving error code descriptions #440 - Avoid assuming usize is the native word size in the
rdrand
backend #442 - Do not read from
errno
whenlibc
did not indicate error on Solaris #448 - Switch from
libpthread
's mutex tofutex
on Linux and tonanosleep
-based wait loop
on other targets in theuse_file
backend #490 - Do not retry on
EAGAIN
while polling/dev/random
on Linux #522
Added
wasm32-wasip1
andwasm32-wasip2
support #499getrandom_backend
configuration flag for selection of opt-in backends #504Error::new_custom
method #507rndr
opt-in backend #512linux_rustix
opt-in backend #520- Memory sanitizer support gated behind
getrandom_sanitize
configuration flag #521 u32
andu64
functions for generating random values of the respective type #544