Skip to content

Commit 124501e

Browse files
committed
Rewrite RNG
1 parent 39d1e11 commit 124501e

Some content is hidden

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

55 files changed

+933
-428
lines changed

esp-hal/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- A reimplemntation of the `assign_resources!` macro (#3809)
13+
- `TrngSource` to manage random number generator entropy (#3829)
1314

1415
### Changed
1516

17+
- The `rng` module has been rewritten (#3829)
1618

1719
### Fixed
1820

@@ -21,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2123

2224
### Removed
2325

26+
- `Trng::new` (replaced by `Trng::try_new`) (#3829)
2427

2528
## [v1.0.0-rc.0] - 2025-07-16
2629

esp-hal/MIGRATING-1.0.0-rc.0.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Migration Guide from 1.0.0-rc.0 to {{currentVersion}}
2+
3+
## RNG changes
4+
5+
Random number generator objects can now be created anywhere. The `RNG` peripheral singleton
6+
is only necessary to enable the cryptographically secure random number generator.
7+
8+
- `Rng` can be constructed without any constraints.
9+
- `Trng` can only be constructed when it can be ensured to generate true random numbers.
10+
11+
A new `TrngSource` object has been added. Users can use `TrngSource::new` to create the object,
12+
and as long as it is alive, `Trng::try_new` will return `Ok` and will provide a true random number
13+
generator interface.
14+
15+
The previous way to obtain RNG object has changed like so:
16+
17+
```diff
18+
-let mut rng = Rng::new(peripherals.RNG);
19+
+let rng = Rng::new();
20+
21+
-let mut trng = Trng::new(peripherals.RNG, peripherals.ADC1);
22+
+// Once:
23+
+let trng_source = TrngSource::new(peripherals.RNG, peripherals.ADC1);
24+
+// As long as `trng_source` is alive:
25+
+let trng = Tnrg::try_new().unrwap();
26+
```

esp-hal/src/rng.rs

Lines changed: 0 additions & 271 deletions
This file was deleted.

0 commit comments

Comments
 (0)