about summary refs log tree commit diff
path: root/library/std/src/sys/unix/rand.rs
AgeCommit message (Collapse)AuthorLines
2024-01-11std: begin moving platform support modules into `pal`joboet-301/+0
2023-12-08std: getrandom simplification for freebsd.David Carlier-11/+1
it is in the libcs' crate too now.
2023-10-23Remove Apple RNG fallbacks and simplify implementationBlackHoleFox-57/+52
2023-07-30rand use getrandom for freebsd (available since 12.x)David Carlier-9/+7
2023-07-26Rollup merge of #101994 - devnexen:rand_fbsd_update, r=workingjubileeMatthias Krüger-4/+18
rand: freebsd update, using getrandom. supported since the 12th release, while 11.4 is EOL since 2021.
2023-06-21wip: Support Apple tvOS in libstdThom Chiovoloni-1/+2
2023-05-07PS Vita std supportNikolay Arhipov-2/+3
2023-03-14Use getentropy() instead of /dev/urandom on EmscriptenKleis Auke Wolthuizen-2/+3
`/dev/urandom` is usually available on Emscripten, except when using the special `NODERAWFS` filesystem backend, which replaces all normal filesystem access with direct Node.js operations. Since this filesystem backend directly access the filesystem on the OS, it is not recommended to depend on `/dev/urandom`, especially when trying to run the Wasm binary on OSes that are not Unix-based. This can be considered a non-functional change, since Emscripten implements `/dev/urandom` in the same way as `getentropy()` when not linking with `-sNODERAWFS`.
2023-03-08rand: freebsd update, using getrandom.David CARLIER-4/+18
supported since the 12th release, while 11.4 is EOL since 2021.
2022-10-05Revert "Use getentropy when possible on all Apple platforms"BlackHoleFox-56/+38
This reverts commit 3fc35b5b935e390c61ea2bbf744838b2632b2df1.
2022-08-25Use getentropy when possible on all Apple platformsBlackHoleFox-38/+56
2022-08-08Replace pointer casting in hashmap_random_keys with safe codeBlackHoleFox-9/+9
The old code was unnecessarily unsafe and relied on the layout of tuples always being the same as an array of the same size.
2022-07-20Library changes for Apple WatchOSVladimir Michael Eatwell-1/+2
2022-06-13Horizon OS STD supportMeziu-3/+13
Co-authored-by: Ian Chamberlain <ian.h.chamberlain@gmail.com> Co-authored-by: Mark Drobnak <mark.drobnak@gmail.com>
2022-05-21Use GRND_INSECURE instead of /dev/urandom when possibleJason A. Donenfeld-0/+15
From reading the source code, it appears like the desired semantic of std::unix::rand is to always provide some bytes and never block. For that reason GRND_NONBLOCK is checked before calling getrandom(0), so that getrandom(0) won't block. If it would block, then the function falls back to using /dev/urandom, which for the time being doesn't block. There are some drawbacks to using /dev/urandom, however, and so getrandom(GRND_INSECURE) was created as a replacement for this exact circumstance. getrandom(GRND_INSECURE) is the same as /dev/urandom, except: - It won't leave a warning in dmesg if used at early boot time, which is a common occurance (and the reason why I found this issue); - It won't introduce a tiny delay at early boot on newer kernels when /dev/urandom tries to opportunistically create jitter entropy; - It only requires 1 syscall, rather than 3. Other than that, it returns the same "quality" of randomness as /dev/urandom, and never blocks. It's only available on kernels ≥5.6, so we try to use it, cache the result of that attempt, and fall back to to the previous code if it didn't work.
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-1/+1
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2021-08-10STD support for the ESP-IDF frameworkivmarkov-2/+7
2021-07-10Change `weak!` and `linkat!` to macros 2.0Aris Merchant-0/+4
`weak!` is needed in a test in another module. With macros 1.0, importing `weak!` would require reordering module declarations in `std/src/lib.rs`, which is a bit too evil.
2021-04-19Move `sys::vxworks` code to `sys::unix`Christiaan Dirkx-1/+28
2020-11-16Try weak symbols for all linux syscall! wrappersJosh Stone-1/+1
2020-11-16linux: try to use libc getrandom to allow interpositionJosh Stone-3/+12
We'll try to use a weak `getrandom` symbol first, because that allows things like `LD_PRELOAD` interposition. For example, perf measurements might want to disable randomness to get reproducible results. If the weak symbol is not found, we fall back to a raw `SYS_getrandom` call.
2020-07-27mv std libs to library/mark-0/+230