From b9479e912f5de80e154d0e646a4d03aeef145384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 30 Oct 2026 05:53:02 +0300 Subject: [PATCH 1/3] Use `libc::getrandom` on Redox --- Cargo.toml | 6 +++++- src/backends.rs | 2 +- src/backends/use_file.rs | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c585e4f1..930ee9d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,8 +68,12 @@ libc = { version = "0.2.176", default-features = false } [target.'cfg(target_os = "solaris")'.dependencies] libc = { version = "0.2.176", default-features = false } +# redox +[target.'cfg(target_os = "redox")'.dependencies] +libc = { version = "0.2.190", default-features = false } + # use_file -[target.'cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))'.dependencies] +[target.'cfg(any(target_os = "haiku", target_os = "nto", target_os = "aix"))'.dependencies] libc = { version = "0.2.176", default-features = false } # vxworks diff --git a/src/backends.rs b/src/backends.rs index ef40894d..d644ab62 100644 --- a/src/backends.rs +++ b/src/backends.rs @@ -43,7 +43,6 @@ cfg_if! { pub use esp_idf::*; } else if #[cfg(any( target_os = "haiku", - target_os = "redox", target_os = "nto", target_os = "aix", ))] { @@ -114,6 +113,7 @@ cfg_if! { target_os = "illumos", target_os = "cygwin", target_os = "nuttx", + target_os = "redox", // Check for target_arch = "arm" to only include the 3DS. Does not // include the Nintendo Switch (which is target_arch = "aarch64"). all(target_os = "horizon", target_arch = "arm"), diff --git a/src/backends/use_file.rs b/src/backends/use_file.rs index b5562532..020e769e 100644 --- a/src/backends/use_file.rs +++ b/src/backends/use_file.rs @@ -15,7 +15,6 @@ pub(super) mod utils; /// For all platforms, we use `/dev/urandom` rather than `/dev/random`. /// For more information see the linked man pages in lib.rs. /// - On Linux, "/dev/urandom is preferred and sufficient in all use cases". -/// - On Redox, only /dev/urandom is provided. /// - On AIX, /dev/urandom will "provide cryptographically secure output". /// - On Haiku and QNX Neutrino they are identical. const FILE_PATH: &CStr = c"/dev/urandom"; From 8f9021cdb85bd4bc2352fb74f8d0f55c1e30b498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 30 Oct 2026 05:55:27 +0300 Subject: [PATCH 2/3] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5177d0e8..ea6eddd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Bumped `r-efi` dependency to v7 ([#869]) +- Use `libc::getrandom` on Redox instead of reading `/dev/urandom` ([#871]) [0.4.4]: https://github.com/rust-random/getrandom/compare/v0.4.3...master [#861]: https://github.com/rust-random/getrandom/pull/861 [#868]: https://github.com/rust-random/getrandom/pull/868 [#869]: https://github.com/rust-random/getrandom/pull/869 +[#871]: https://github.com/rust-random/getrandom/pull/871 ## [0.4.3] - 2026-06-17 ### Added From 6a32d45863f7046b73209ae9c629693301cbb78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 30 Oct 2026 05:57:30 +0300 Subject: [PATCH 3/3] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f4aad0d..17a0c905 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ fn get_random_u128() -> Result { | Solaris | `*‑solaris` | [`getrandom`][11] with `GRND_RANDOM` | illumos | `*‑illumos` | [`getrandom`][12] | Fuchsia OS | `*‑fuchsia` | [`cprng_draw`] -| Redox | `*‑redox` | `/dev/urandom` +| Redox | `*‑redox` | `getrandom` | Haiku | `*‑haiku` | `/dev/urandom` (identical to `/dev/random`) | Hermit | `*-hermit` | [`sys_read_entropy`] | Hurd | `*-hurd-*` | [`getrandom`][17]