Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: cargo
directory: "/"
versioning-strategy: lockfile-only
allow:
- dependency-type: "all"
schedule:
interval: weekly
groups:
all-deps:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ jobs:
- name: Test rand
run: |
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,os_rng,small_rng,unbiased
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,os_rng,small_rng
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,sys_rng,small_rng,unbiased
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,sys_rng,small_rng
cargo test --target ${{ matrix.target }} --examples
- name: Test rand (all stable features)
run: |
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
- Remove fns `SeedableRng::from_os_rng`, `try_from_os_rng` (#1674)
- Remove `Clone` support for `StdRng`, `ReseedingRng` (#1677)
- Use `postcard` instead of `bincode` to test the serde feature (#1693)
- Rename `os_rng` -> `sys_rng`, `OsRng` -> `SysRng`, `OsError` -> `SysError` ([#1697])

### Additions
- Add fns `IndexedRandom::choose_iter`, `choose_weighted_iter` (#1632)
- Pub export `Xoshiro128PlusPlus`, `Xoshiro256PlusPlus` prngs (#1649)
- Pub export `ChaCha8Rng`, `ChaCha12Rng`, `ChaCha20Rng` behind `chacha` feature (#1659)

[#1697]: https://github.com/rust-random/rand/pull/1697

## [0.9.2] - 2025-07-20
### Deprecated
- Deprecate `rand::rngs::mock` module and `StepRng` generator (#1634)
Expand Down
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ features = ["small_rng", "serde"]

[features]
# Meta-features:
default = ["std", "std_rng", "os_rng", "small_rng", "thread_rng"]
default = ["std", "std_rng", "sys_rng", "small_rng", "thread_rng"]
nightly = [] # some additions requiring nightly Rust
serde = ["dep:serde"]

Expand All @@ -39,8 +39,8 @@ std = ["alloc", "getrandom?/std"]
# Option: "alloc" enables support for Vec and Box when not using "std"
alloc = []

# Option: enable OsRng
os_rng = ["dep:getrandom"]
# Option: enable SysRng
sys_rng = ["dep:getrandom", "getrandom/sys_rng"]

# Option (requires nightly Rust): experimental SIMD support
simd_support = []
Expand All @@ -52,7 +52,7 @@ std_rng = ["dep:chacha20"]
small_rng = []

# Option: enable ThreadRng and rng()
thread_rng = ["std", "std_rng", "os_rng"]
thread_rng = ["std", "std_rng", "sys_rng"]

# Option: enable rand::rngs::ChaCha*Rng
chacha = ["dep:chacha20"]
Expand All @@ -73,11 +73,11 @@ members = [
exclude = ["benches", "distr_test"]

[dependencies]
rand_core = { version = "0.10.0-rc-2", default-features = false }
rand_core = { version = "0.10.0-rc-3", default-features = false }
log = { version = "0.4.4", optional = true }
serde = { version = "1.0.103", features = ["derive"], optional = true }
chacha20 = { version = "0.10.0-rc.5", default-features = false, features = ["rng"], optional = true }
getrandom = { version = "0.3.0", optional = true }
chacha20 = { version = "0.10.0-rc.6", default-features = false, features = ["rng"], optional = true }
getrandom = { version = "0.4.0-rc.0", optional = true }

[dev-dependencies]
rand_pcg = { path = "rand_pcg", version = "0.10.0-rc.1" }
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Rand is built with these features enabled by default:

- `std` enables functionality dependent on the `std` lib
- `alloc` (implied by `std`) enables functionality requiring an allocator
- `os_rng` (implied by `std`) enables `rngs::OsRng`, using the [getrandom] crate
- `sys_rng` (implied by `std`) enables `rngs::SysRng`, using the [getrandom] crate
- `std_rng` enables inclusion of `StdRng`, `ThreadRng`
- `small_rng` enables inclusion of the `SmallRng` PRNG

Expand All @@ -89,8 +89,8 @@ compiler versions will be compatible. This is especially true of Rand's
experimental `simd_support` feature.

Rand supports limited functionality in `no_std` mode (enabled via
`default-features = false`). In this case, `OsRng` is
unavailable (unless `os_rng` is enabled), large parts of `seq` are
`default-features = false`). In this case, `SysRng` is
unavailable (unless `sys_rng` is enabled), large parts of `seq` are
unavailable (unless `alloc` is enabled), and `ThreadRng` is unavailable.

## Portability and platform support
Expand All @@ -105,7 +105,7 @@ The [WASI](https://github.com/WebAssembly/WASI/tree/main) and Emscripten
targets are directly supported. The `wasm32-unknown-unknown` target is not
*automatically* supported. To enable support for this target, refer to the
[`getrandom` documentation for WebAssembly](https://docs.rs/getrandom/latest/getrandom/#webassembly-support).
Alternatively, the `os_rng` feature may be disabled.
Alternatively, the `sys_rng` feature may be disabled.

# License

Expand Down
10 changes: 5 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ used according to these additional constraints:
- The generator may be constructed using `std::default::Default` where the
generator supports this trait. Note that generators should *only* support
`Default` where the `default()` instance is appropriately seeded: for
example `OsRng` has no state and thus has a trivial `default()` instance
example `SysRng` has no state and thus has a trivial `default()` instance
while `ThreadRng::default()` returns a handle to a thread-local instance
seeded using `OsRng`.
seeded using `SysRng`.
- The generator may be constructed using `rand_core::SeedableRng` in any of
the following ways where the generator supports this trait:

- Via `SeedableRng::from_seed` using a cryptographically secure seed value
- Via `SeedableRng::from_rng` or `try_from_rng` using a cryptographically
secure source `rng` such as `OsRng` or `ThreadRng`.
secure source `rng` such as `SysRng` or `ThreadRng`.
- The state (memory) of the generator and its seed value (or source `rng`) are
not exposed

Expand All @@ -42,7 +42,7 @@ are expected to provide the following:

### Specific generators

`OsRng` is a stateless "generator" implemented via [getrandom]. As such, it has
`SysRng` is a stateless "generator" implemented via [getrandom]. As such, it has
no possible state to leak and cannot be improperly seeded.

`StdRng` is a `CryptoRng` and `SeedableRng` using a pseudo-random algorithm
Expand All @@ -55,7 +55,7 @@ trait and implement `SeedableRng` with a commitment to reproducibility of
results.

`ThreadRng` is a conveniently-packaged generator over `StdRng` offering
automatic seeding from `OsRng`, periodic reseeding and thread locality.
automatic seeding from `SysRng`, periodic reseeding and thread locality.
This random source is intended to offer a good compromise between cryptographic
security, fast generation with reasonably low memory and initialization cost
overheads, and robustness against misuse.
Expand Down
13 changes: 7 additions & 6 deletions benches/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions benches/benches/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use core::time::Duration;
use criterion::measurement::WallTime;
use criterion::{BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main};
use rand::prelude::*;
use rand::rngs::OsRng;
use rand::rngs::ReseedingRng;
use rand::rngs::SysRng;
use rand_chacha::rand_core::UnwrapErr;
use rand_chacha::{ChaCha8Rng, ChaCha12Rng, ChaCha20Core, ChaCha20Rng};
use rand_pcg::{Pcg32, Pcg64, Pcg64Dxsm, Pcg64Mcg};
Expand Down Expand Up @@ -48,7 +48,7 @@ pub fn random_bytes(c: &mut Criterion) {
bench(&mut g, "chacha20", ChaCha20Rng::from_rng(&mut rand::rng()));
bench(&mut g, "std", StdRng::from_rng(&mut rand::rng()));
bench(&mut g, "small", SmallRng::from_rng(&mut rand::rng()));
bench(&mut g, "os", UnwrapErr(OsRng));
bench(&mut g, "os", UnwrapErr(SysRng));
bench(&mut g, "thread", rand::rng());

g.finish()
Expand Down Expand Up @@ -76,7 +76,7 @@ pub fn random_u32(c: &mut Criterion) {
bench(&mut g, "chacha20", ChaCha20Rng::from_rng(&mut rand::rng()));
bench(&mut g, "std", StdRng::from_rng(&mut rand::rng()));
bench(&mut g, "small", SmallRng::from_rng(&mut rand::rng()));
bench(&mut g, "os", UnwrapErr(OsRng));
bench(&mut g, "os", UnwrapErr(SysRng));
bench(&mut g, "thread", rand::rng());

g.finish()
Expand Down Expand Up @@ -104,7 +104,7 @@ pub fn random_u64(c: &mut Criterion) {
bench(&mut g, "chacha20", ChaCha20Rng::from_rng(&mut rand::rng()));
bench(&mut g, "std", StdRng::from_rng(&mut rand::rng()));
bench(&mut g, "small", SmallRng::from_rng(&mut rand::rng()));
bench(&mut g, "os", UnwrapErr(OsRng));
bench(&mut g, "os", UnwrapErr(SysRng));
bench(&mut g, "thread", rand::rng());

g.finish()
Expand Down Expand Up @@ -198,7 +198,7 @@ pub fn reseeding_bytes(c: &mut Criterion) {
fn bench(g: &mut BenchmarkGroup<WallTime>, thresh: u64) {
let name = format!("chacha20_{thresh}k");
g.bench_function(name.as_str(), |b| {
let mut rng = ReseedingRng::<ChaCha20Core, _>::new(thresh * 1024, OsRng).unwrap();
let mut rng = ReseedingRng::<ChaCha20Core, _>::new(thresh * 1024, SysRng).unwrap();
let mut buf = [0u8; 1024 * 1024];
b.iter(|| {
rng.fill_bytes(&mut buf);
Expand Down
4 changes: 2 additions & 2 deletions rand_chacha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ all-features = true
rustdoc-args = ["--generate-link-to-definition"]

[dependencies]
rand_core = { version = "0.10.0-rc-2" }
rand_core = { version = "0.10.0-rc-3" }
ppv-lite86 = { version = "0.2.14", default-features = false, features = ["simd"] }
serde = { version = "1.0", features = ["derive"], optional = true }

[dev-dependencies]
# Only to test serde
serde_json = "1.0.120"
rand = { path = "..", version = "0.10.0-rc.0" }
getrandom = { version = "0.4.0-rc.0", features = ["sys_rng"] }

[features]
default = ["std"]
Expand Down
Loading