Skip to content

Commit 0680e6d

Browse files
committed
Merge with master and update CHANGELOG
2 parents 44f905c + d3dd415 commit 0680e6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+384
-10413
lines changed

.github/workflows/benches.yml

-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ on:
55
branches: [ master ]
66
paths-ignore:
77
- "**.md"
8-
- "distr_test/**"
98
- "examples/**"
109
pull_request:
1110
branches: [ master ]
1211
paths-ignore:
1312
- "**.md"
14-
- "distr_test/**"
1513
- "examples/**"
1614

1715
defaults:

.github/workflows/distr_test.yml

-43
This file was deleted.

.github/workflows/test.yml

-11
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ on:
66
paths-ignore:
77
- "**.md"
88
- "benches/**"
9-
- "distr_test/**"
109
pull_request:
1110
branches: [ master, '0.[0-9]+' ]
1211
paths-ignore:
1312
- "**.md"
1413
- "benches/**"
15-
- "distr_test/**"
1614

1715
permissions:
1816
contents: read # to fetch code (actions/checkout)
@@ -47,8 +45,6 @@ jobs:
4745
run: cargo doc --all-features --no-deps
4846
- name: rand_core
4947
run: cargo doc --all-features --package rand_core --no-deps
50-
- name: rand_distr
51-
run: cargo doc --all-features --package rand_distr --no-deps
5248
- name: rand_chacha
5349
run: cargo doc --all-features --package rand_chacha --no-deps
5450
- name: rand_pcg
@@ -122,11 +118,6 @@ jobs:
122118
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml
123119
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features
124120
cargo test --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml --no-default-features --features=os_rng
125-
- name: Test rand_distr
126-
run: |
127-
cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --features=serde
128-
cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --no-default-features
129-
cargo test --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --no-default-features --features=std,std_math
130121
- name: Test rand_pcg
131122
run: cargo test --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde
132123
- name: Test rand_chacha
@@ -162,7 +153,6 @@ jobs:
162153
cross test --no-fail-fast --target ${{ matrix.target }} --features=serde,log,small_rng
163154
cross test --no-fail-fast --target ${{ matrix.target }} --examples
164155
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_core/Cargo.toml
165-
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_distr/Cargo.toml --features=serde
166156
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_pcg/Cargo.toml --features=serde
167157
cross test --no-fail-fast --target ${{ matrix.target }} --manifest-path rand_chacha/Cargo.toml
168158
@@ -182,7 +172,6 @@ jobs:
182172
cargo miri test --manifest-path rand_core/Cargo.toml
183173
cargo miri test --manifest-path rand_core/Cargo.toml --features=serde
184174
cargo miri test --manifest-path rand_core/Cargo.toml --no-default-features
185-
#cargo miri test --manifest-path rand_distr/Cargo.toml # no unsafe and lots of slow tests
186175
cargo miri test --manifest-path rand_pcg/Cargo.toml --features=serde
187176
cargo miri test --manifest-path rand_chacha/Cargo.toml --no-default-features
188177

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
88

99
You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
1010

11+
## [Unreleased]
12+
- Fix feature `simd_support` for recent nightly rust (#1586)
13+
- Add `Alphabetic` distribution. (#1587)
14+
- Re-export `rand_core` (#1602)
15+
1116
## [0.9.0] - 2025-01-27
1217
### Security and unsafe
1318
- Policy: "rand is not a crypto library" (#1514)

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ log = ["dep:log"]
6565
[workspace]
6666
members = [
6767
"rand_core",
68-
"rand_distr",
6968
"rand_chacha",
7069
"rand_pcg",
7170
]

README.md

+11-15
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ Rand **is not**:
3939
not simplicity. If you prefer a small-and-simple library, there are
4040
alternatives including [fastrand](https://crates.io/crates/fastrand)
4141
and [oorandom](https://crates.io/crates/oorandom).
42-
- A cryptography library. Rand provides functionality for generating
43-
unpredictable random data (potentially applicable depending on requirements)
44-
but does not provide high-level cryptography functionality.
45-
46-
Rand is a community project and cannot provide legally-binding guarantees of
47-
security.
42+
- Primarily a cryptographic library. `rand` does provide some generators which
43+
aim to support unpredictable value generation under certain constraints;
44+
see [SECURITY.md](SECURITY.md) for details.
45+
Users are expected to determine for themselves
46+
whether `rand`'s functionality meets their own security requirements.
4847

4948
Documentation:
5049

@@ -97,16 +96,13 @@ Many (but not all) algorithms are intended to have reproducible output. Read mor
9796

9897
The Rand library supports a variety of CPU architectures. Platform integration is outsourced to [getrandom].
9998

100-
### WASM support
99+
### WebAssembly support
101100

102-
Seeding entropy from OS on WASM target `wasm32-unknown-unknown` is not
103-
*automatically* supported by `rand` or `getrandom`. If you are fine with
104-
seeding the generator manually, you can disable the `os_rng` feature
105-
and use the methods on the `SeedableRng` trait. To enable seeding from OS,
106-
either use a different target such as `wasm32-wasi` or add a direct
107-
dependency on [getrandom] with the `js` feature (if the target supports
108-
JavaScript). See
109-
[getrandom#WebAssembly support](https://docs.rs/getrandom/latest/getrandom/#webassembly-support).
101+
The [WASI](https://github.com/WebAssembly/WASI/tree/main) and Emscripten
102+
targets are directly supported. The `wasm32-unknown-unknown` target is not
103+
*automatically* supported. To enable support for this target, refer to the
104+
[`getrandom` documentation for WebAssembly](https://docs.rs/getrandom/latest/getrandom/#webassembly-support).
105+
Alternatively, the `os_rng` feature may be disabled.
110106

111107
# License
112108

SECURITY.md

+47-39
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ security.
1010
### Marker traits
1111

1212
Rand provides the marker traits `CryptoRng`, `TryCryptoRng` and
13-
`CryptoBlockRng`. Generators implementing one of these traits and used in a way
14-
which meets the following additional constraints:
15-
16-
- Instances of seedable RNGs (those implementing `SeedableRng`) are
17-
constructed with cryptographically secure seed values
18-
- The state (memory) of the RNG and its seed value are not exposed
13+
`CryptoBlockRng`. Generators (RNGs) implementing one of these traits which are
14+
used according to these additional constraints:
15+
16+
- The generator may be constructed using `std::default::Default` where the
17+
generator supports this trait. Note that generators should *only* support
18+
`Default` where the `default()` instance is appropriately seeded: for
19+
example `OsRng` has no state and thus has a trivial `default()` instance
20+
while `ThreadRng::default()` returns a handle to a thread-local instance
21+
seeded using `OsRng`.
22+
- The generator may be constructed using `rand_core::SeedableRng` in any of
23+
the following ways where the generator supports this trait:
24+
25+
- Via `SeedableRng::from_seed` using a cryptographically secure seed value
26+
- Via `SeedableRng::from_rng` or `try_from_rng` using a cryptographically
27+
secure source `rng`
28+
- Via `SeedableRng::from_os_rng` or `try_from_os_rng`
29+
- The state (memory) of the generator and its seed value (or source `rng`) are
30+
not exposed
1931

2032
are expected to provide the following:
2133

@@ -34,48 +46,44 @@ are expected to provide the following:
3446
`OsRng` is a stateless "generator" implemented via [getrandom]. As such, it has
3547
no possible state to leak and cannot be improperly seeded.
3648

37-
`ThreadRng` will periodically reseed itself, thus placing an upper bound on the
38-
number of bits of output from an instance before any advantage an attacker may
39-
have gained through state-compromising side-channel attacks is lost.
49+
`StdRng` is a `CryptoRng` and `SeedableRng` using a pseudo-random algorithm
50+
selected for good security and performance qualities. Since it does not offer
51+
reproducibility of output, its algorithm may be changed in any release version.
52+
53+
`ChaCha12Rng` and `ChaCha20Rng` are selected pseudo-random generators
54+
distributed by the `rand` project which meet the requirements of the `CryptoRng`
55+
trait and implement `SeedableRng` with a commitment to reproducibility of
56+
results.
57+
58+
`ThreadRng` is a conveniently-packaged generator over `StdRng` offering
59+
automatic seeding from `OsRng`, periodic reseeding and thread locality.
60+
This random source is intended to offer a good compromise between cryptographic
61+
security, fast generation with reasonably low memory and initialization cost
62+
overheads, and robustness against misuse.
4063

4164
[getrandom]: https://crates.io/crates/getrandom
4265

4366
### Distributions
4467

45-
Additionally, derivations from such an RNG (including the `Rng` trait,
46-
implementations of the `Distribution` trait, and `seq` algorithms) should not
47-
introduce significant bias other than that expected from the operation in
48-
question (e.g. bias from a weighted distribution).
68+
Methods of the `Rng` trait, functionality of the `rand::seq` module and
69+
implementators of the `Distribution` trait are expected, while using a
70+
cryptographically secure `CryptoRng` instance meeting the above constraints,
71+
to not introduce significant bias to their operation beyond what would be
72+
expected of the operation. Note that the usage of 'significant' here permits
73+
some bias, as noted for example in the documentation of the `Uniform`
74+
distribution.
4975

5076
## Supported Versions
5177

52-
We will attempt to uphold these premises in the following crate versions,
53-
provided that only the latest patch version is used, and with potential
54-
exceptions for theoretical issues without a known exploit:
55-
56-
| Crate | Versions | Exceptions |
57-
| ----- | -------- | ---------- |
58-
| `rand` | 0.8 | |
59-
| `rand` | 0.7 | |
60-
| `rand` | 0.5, 0.6 | Jitter |
61-
| `rand` | 0.4 | Jitter, ISAAC |
62-
| `rand_core` | 0.2 - 0.6 | |
63-
| `rand_chacha` | 0.1 - 0.3 | |
78+
We aim to provide security fixes in the form of a new patch version for the
79+
latest release version of `rand` and its dependencies `rand_core` and
80+
`rand_chacha`, as well as for prior major and minor releases which were, at some
81+
time during the previous 12 months, the latest release version.
6482

65-
Explanation of exceptions:
66-
67-
- Jitter: `JitterRng` is used as an entropy source when the primary source
68-
fails; this source may not be secure against side-channel attacks, see #699.
69-
- ISAAC: the [ISAAC](https://burtleburtle.net/bob/rand/isaacafa.html) RNG used
70-
to implement `ThreadRng` is difficult to analyse and thus cannot provide
71-
strong assertions of security.
72-
73-
## Known issues
83+
## Reporting a Vulnerability
7484

75-
In `rand` version 0.3 (0.3.18 and later), if `OsRng` fails, `ThreadRng` is
76-
seeded from the system time in an insecure manner.
85+
If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released.
7786

78-
## Reporting a Vulnerability
87+
Please disclose it at [security advisory](https://github.com/rust-random/rand/security/advisories/new).
7988

80-
To report a vulnerability, [open a new issue](https://github.com/rust-random/rand/issues/new).
81-
Once the issue is resolved, the vulnerability should be [reported to RustSec](https://github.com/RustSec/advisory-db/blob/master/CONTRIBUTING.md).
89+
This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure.

benches/Cargo.toml

-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ publish = false
1010
rand = { path = "..", features = ["small_rng", "nightly"] }
1111
rand_pcg = { path = "../rand_pcg" }
1212
rand_chacha = { path = "../rand_chacha" }
13-
rand_distr = { path = "../rand_distr" }
1413
criterion = "0.5"
1514
criterion-cycles-per-byte = "0.6"
1615

@@ -22,10 +21,6 @@ harness = false
2221
name = "bool"
2322
harness = false
2423

25-
[[bench]]
26-
name = "distr"
27-
harness = false
28-
2924
[[bench]]
3025
name = "generators"
3126
harness = false

0 commit comments

Comments
 (0)