From 0a63f18e2f065dac6c09b88e575f69b760b945db Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Mon, 5 Sep 2022 13:11:56 +0800 Subject: [PATCH 1/2] Support random file of AIX --- src/lib.rs | 2 +- src/use_file.rs | 1 + src/util_libc.rs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 39262580..c163515d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,7 +209,7 @@ pub use crate::error::Error; // The function MUST NOT ever write uninitialized bytes into `dest`, // regardless of what value it returns. cfg_if! { - if #[cfg(any(target_os = "haiku", target_os = "redox"))] { + if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "aix"))] { mod util_libc; #[path = "use_file.rs"] mod imp; } else if #[cfg(any(target_os = "android", target_os = "linux"))] { diff --git a/src/use_file.rs b/src/use_file.rs index facd8fad..13f306d1 100644 --- a/src/use_file.rs +++ b/src/use_file.rs @@ -25,6 +25,7 @@ use core::{ #[cfg(any(target_os = "solaris", target_os = "illumos"))] const FILE_PATH: &str = "/dev/random\0"; #[cfg(any( + target_os = "aix", target_os = "android", target_os = "linux", target_os = "redox", diff --git a/src/util_libc.rs b/src/util_libc.rs index 6c80b3fe..4ed9403f 100644 --- a/src/util_libc.rs +++ b/src/util_libc.rs @@ -32,6 +32,8 @@ cfg_if! { fn __errno() -> *mut libc::c_int; } use __errno as errno_location; + } else if #[cfg(target_os = "aix")] { + use libc::_Errno as errno_location; } } From 78ffdf9ccea685de091b464b0901fccd60a8a42e Mon Sep 17 00:00:00 2001 From: Qiu Chaofan Date: Mon, 21 Nov 2022 11:32:56 +0800 Subject: [PATCH 2/2] Add IBM document for /dev/urandom device --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index c163515d..02c3f258 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,6 +33,7 @@ //! | Web Browser and Node.js | `wasm*‑*‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js, see [WebAssembly support] //! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes` //! | Nintendo 3DS | `armv6k-nintendo-3ds` | [`getrandom`][1] +//! | AIX | `*-ibm-aix` | [`/dev/urandom`][14] //! //! There is no blanket implementation on `unix` targets that reads from //! `/dev/urandom`. This ensures all supported targets are using the recommended @@ -160,6 +161,7 @@ //! [11]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html //! [12]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html //! [13]: https://github.com/emscripten-core/emscripten/pull/12240 +//! [14]: https://www.ibm.com/docs/en/aix/7.3?topic=files-random-urandom-devices //! //! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom //! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues