Skip to content

Commit c370309

Browse files
authored
Update getrandom, rand_core; rename OsRngSysRng (#1697)
2 parents 8cb6ab0 + d78703e commit c370309

File tree

25 files changed

+143
-313
lines changed

25 files changed

+143
-313
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "cargo"
4-
directory: "/"
5-
schedule:
6-
interval: "monthly"
7-
open-pull-requests-limit: 10
8-
- package-ecosystem: "github-actions"
9-
directory: "/"
10-
schedule:
11-
interval: "monthly"
3+
- package-ecosystem: cargo
4+
directory: "/"
5+
versioning-strategy: lockfile-only
6+
allow:
7+
- dependency-type: "all"
8+
schedule:
9+
interval: weekly
10+
groups:
11+
all-deps:
12+
patterns:
13+
- "*"
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: weekly

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ jobs:
104104
- name: Test rand
105105
run: |
106106
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features
107-
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,os_rng,small_rng,unbiased
108-
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,os_rng,small_rng
107+
cargo build --target ${{ matrix.target }} --no-default-features --features alloc,sys_rng,small_rng,unbiased
108+
cargo test --target ${{ matrix.target }} --lib --tests --no-default-features --features=alloc,sys_rng,small_rng
109109
cargo test --target ${{ matrix.target }} --examples
110110
- name: Test rand (all stable features)
111111
run: |

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.
1919
- Remove fns `SeedableRng::from_os_rng`, `try_from_os_rng` (#1674)
2020
- Remove `Clone` support for `StdRng`, `ReseedingRng` (#1677)
2121
- Use `postcard` instead of `bincode` to test the serde feature (#1693)
22+
- Rename `os_rng` -> `sys_rng`, `OsRng` -> `SysRng`, `OsError` -> `SysError` ([#1697])
2223

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

29+
[#1697]: https://github.com/rust-random/rand/pull/1697
30+
2831
## [0.9.2] - 2025-07-20
2932
### Deprecated
3033
- Deprecate `rand::rngs::mock` module and `StepRng` generator (#1634)

Cargo.lock

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ features = ["small_rng", "serde"]
2828

2929
[features]
3030
# Meta-features:
31-
default = ["std", "std_rng", "os_rng", "small_rng", "thread_rng"]
31+
default = ["std", "std_rng", "sys_rng", "small_rng", "thread_rng"]
3232
nightly = [] # some additions requiring nightly Rust
3333
serde = ["dep:serde"]
3434

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

42-
# Option: enable OsRng
43-
os_rng = ["dep:getrandom"]
42+
# Option: enable SysRng
43+
sys_rng = ["dep:getrandom", "getrandom/sys_rng"]
4444

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

5454
# Option: enable ThreadRng and rng()
55-
thread_rng = ["std", "std_rng", "os_rng"]
55+
thread_rng = ["std", "std_rng", "sys_rng"]
5656

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

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

8282
[dev-dependencies]
8383
rand_pcg = { path = "rand_pcg", version = "0.10.0-rc.1" }

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Rand is built with these features enabled by default:
6565

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

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

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

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

110110
# License
111111

SECURITY.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ used according to these additional constraints:
1616
- The generator may be constructed using `std::default::Default` where the
1717
generator supports this trait. Note that generators should *only* support
1818
`Default` where the `default()` instance is appropriately seeded: for
19-
example `OsRng` has no state and thus has a trivial `default()` instance
19+
example `SysRng` has no state and thus has a trivial `default()` instance
2020
while `ThreadRng::default()` returns a handle to a thread-local instance
21-
seeded using `OsRng`.
21+
seeded using `SysRng`.
2222
- The generator may be constructed using `rand_core::SeedableRng` in any of
2323
the following ways where the generator supports this trait:
2424

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

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

4343
### Specific generators
4444

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

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

5757
`ThreadRng` is a conveniently-packaged generator over `StdRng` offering
58-
automatic seeding from `OsRng`, periodic reseeding and thread locality.
58+
automatic seeding from `SysRng`, periodic reseeding and thread locality.
5959
This random source is intended to offer a good compromise between cryptographic
6060
security, fast generation with reasonably low memory and initialization cost
6161
overheads, and robustness against misuse.

benches/Cargo.lock

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

benches/benches/generators.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use core::time::Duration;
1010
use criterion::measurement::WallTime;
1111
use criterion::{BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main};
1212
use rand::prelude::*;
13-
use rand::rngs::OsRng;
1413
use rand::rngs::ReseedingRng;
14+
use rand::rngs::SysRng;
1515
use rand_chacha::rand_core::UnwrapErr;
1616
use rand_chacha::{ChaCha8Rng, ChaCha12Rng, ChaCha20Core, ChaCha20Rng};
1717
use rand_pcg::{Pcg32, Pcg64, Pcg64Dxsm, Pcg64Mcg};
@@ -48,7 +48,7 @@ pub fn random_bytes(c: &mut Criterion) {
4848
bench(&mut g, "chacha20", ChaCha20Rng::from_rng(&mut rand::rng()));
4949
bench(&mut g, "std", StdRng::from_rng(&mut rand::rng()));
5050
bench(&mut g, "small", SmallRng::from_rng(&mut rand::rng()));
51-
bench(&mut g, "os", UnwrapErr(OsRng));
51+
bench(&mut g, "os", UnwrapErr(SysRng));
5252
bench(&mut g, "thread", rand::rng());
5353

5454
g.finish()
@@ -76,7 +76,7 @@ pub fn random_u32(c: &mut Criterion) {
7676
bench(&mut g, "chacha20", ChaCha20Rng::from_rng(&mut rand::rng()));
7777
bench(&mut g, "std", StdRng::from_rng(&mut rand::rng()));
7878
bench(&mut g, "small", SmallRng::from_rng(&mut rand::rng()));
79-
bench(&mut g, "os", UnwrapErr(OsRng));
79+
bench(&mut g, "os", UnwrapErr(SysRng));
8080
bench(&mut g, "thread", rand::rng());
8181

8282
g.finish()
@@ -104,7 +104,7 @@ pub fn random_u64(c: &mut Criterion) {
104104
bench(&mut g, "chacha20", ChaCha20Rng::from_rng(&mut rand::rng()));
105105
bench(&mut g, "std", StdRng::from_rng(&mut rand::rng()));
106106
bench(&mut g, "small", SmallRng::from_rng(&mut rand::rng()));
107-
bench(&mut g, "os", UnwrapErr(OsRng));
107+
bench(&mut g, "os", UnwrapErr(SysRng));
108108
bench(&mut g, "thread", rand::rng());
109109

110110
g.finish()
@@ -198,7 +198,7 @@ pub fn reseeding_bytes(c: &mut Criterion) {
198198
fn bench(g: &mut BenchmarkGroup<WallTime>, thresh: u64) {
199199
let name = format!("chacha20_{thresh}k");
200200
g.bench_function(name.as_str(), |b| {
201-
let mut rng = ReseedingRng::<ChaCha20Core, _>::new(thresh * 1024, OsRng).unwrap();
201+
let mut rng = ReseedingRng::<ChaCha20Core, _>::new(thresh * 1024, SysRng).unwrap();
202202
let mut buf = [0u8; 1024 * 1024];
203203
b.iter(|| {
204204
rng.fill_bytes(&mut buf);

rand_chacha/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ all-features = true
2020
rustdoc-args = ["--generate-link-to-definition"]
2121

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

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

3232
[features]
3333
default = ["std"]

0 commit comments

Comments
 (0)