Add support for getrandom syscall on NetBSD ≥ 10.0 (#331)
NetBSD supports the getrandom system call since version 10.0 [1]. Use it if available, otherwise fall back to kern.arandom like on FreeBSD. [1] https://man.netbsd.org/getrandom.2
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ fn kern_arnd(buf: &mut [MaybeUninit<u8>]) -> libc::ssize_t {
|
||||
|
||||
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
|
||||
// getrandom(2) was introduced in FreeBSD 12.0 and NetBSD 10.0
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
|
||||
{
|
||||
use crate::util_libc::Weak;
|
||||
static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") };
|
||||
|
||||
+2
-1
@@ -18,7 +18,7 @@
|
||||
//! | iOS, tvOS, watchOS | `*‑apple‑ios`, `*-apple-tvos`, `*-apple-watchos` | [`SecRandomCopyBytes`]
|
||||
//! | FreeBSD | `*‑freebsd` | [`getrandom`][5] if available, otherwise [`kern.arandom`][6]
|
||||
//! | OpenBSD | `*‑openbsd` | [`getentropy`][7]
|
||||
//! | NetBSD | `*‑netbsd` | [`kern.arandom`][8]
|
||||
//! | NetBSD | `*‑netbsd` | [`getrandom`][16] if available, otherwise [`kern.arandom`][8]
|
||||
//! | Dragonfly BSD | `*‑dragonfly` | [`getrandom`][9] if available, otherwise [`/dev/urandom`][10] (identical to `/dev/random`)
|
||||
//! | Solaris, illumos | `*‑solaris`, `*‑illumos` | [`getrandom`][11] if available, otherwise [`/dev/random`][12]
|
||||
//! | Fuchsia OS | `*‑fuchsia` | [`cprng_draw`]
|
||||
@@ -164,6 +164,7 @@
|
||||
//! [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
|
||||
//!
|
||||
//! [`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
|
||||
|
||||
Reference in New Issue
Block a user