Tracking Issue for secure random data generation in `std`
<!-- homu-ignore:start --> *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/issues/130703)* <!-- homu-ignore:end --> Feature gate: `#![feature(random)]` This is a tracking issue for secure random data generation support in `std`. Central to this feature is the `RandomSource` trait inside `core::random`, which generates random bytes. `std` also exposes the platform's secure random number generator via the `DefaultRandomSource` type. There is a `Distribution<T>` trait for distributions that can `sample` random values of a specific type, and a `random` function for convenience to allow things like `random(1..=6)`. ### Public API ```rust // core::random pub trait Rng { fn fill_bytes(&mut self, bytes: &mut [u8]); } impl<'a, R: Rng + ?Sized> Rng for &'a mut R { ... } pub trait Distribution<T> { fn sample(&self, source: &mut (impl Rng + ?Sized)) -> T; } impl Distribution<bool> for RangeFull { ... } impl Distribution</* all integer types */> for RangeFull { ... } impl Distribution</* all integer types */> for core::range::RangeInclusive<_> { ... } // std::random (additionally) pub struct SystemRng; impl Rng for SystemRng { ... } pub fn random<T>(dist: impl Distribution<T>) -> T; ``` ### Steps / History - [x] ACP: https://github.com/rust-lang/libs-team/issues/393 - [ ] Implementation - [x] #129201 - [x] #143710 (API rework adding `Distribution<T>`) - [x] #157539 - [x] #159435 - [x] #159592 - [ ] #160205 - [ ] FCPs
Posted by joboet on Sep 22, 2024, 2:27 PM
Tags
Related issues
Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments
support (Sysadmin)
Support connecting to remote devcontainers (devcontainer on remote host)
Option to use Waffle menu or links displayed normally
I also attempted to package ROCM on musl.
But why is there no such pushback agains linux kernel?
OpenCode Support
Upcoming changes to the tado° API
Allow Mac users to use Apple native containerization
Support for the Containerization Framework on macOS
Tracking Issue for secure random data generation in `std`
<!-- homu-ignore:start --> *[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/issues/130703)* <!-- homu-ignore:end --> Feature gate: `#![feature(random)]` This is a tracking issue for secure random data generation support in `std`. Central to this feature is the `RandomSource` trait inside `core::random`, which generates random bytes. `std` also exposes the platform's secure random number generator via the `DefaultRandomSource` type. There is a `Distribution<T>` trait for distributions that can `sample` random values of a specific type, and a `random` function for convenience to allow things like `random(1..=6)`. ### Public API ```rust // core::random pub trait Rng { fn fill_bytes(&mut self, bytes: &mut [u8]); } impl<'a, R: Rng + ?Sized> Rng for &'a mut R { ... } pub trait Distribution<T> { fn sample(&self, source: &mut (impl Rng + ?Sized)) -> T; } impl Distribution<bool> for RangeFull { ... } impl Distribution</* all integer types */> for RangeFull { ... } impl Distribution</* all integer types */> for core::range::RangeInclusive<_> { ... } // std::random (additionally) pub struct SystemRng; impl Rng for SystemRng { ... } pub fn random<T>(dist: impl Distribution<T>) -> T; ``` ### Steps / History - [x] ACP: https://github.com/rust-lang/libs-team/issues/393 - [ ] Implementation - [x] #129201 - [x] #143710 (API rework adding `Distribution<T>`) - [x] #157539 - [x] #159435 - [x] #159592 - [ ] #160205 - [ ] FCPs
Comments (0)
No comments yet. Start the discussion.