Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not ensure randomness or implement CryptoRng for ESP32-P4/S2 #1267

Merged
merged 3 commits into from
Mar 12, 2024
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
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Do not ensure randomness or implement the `CryptoRng` trait for ESP32-P4/S2 (#1267)

### Removed

## [0.16.0] - 2024-03-08
Expand Down
9 changes: 4 additions & 5 deletions esp-hal/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@

use core::{convert::Infallible, marker::PhantomData};

use rand_core::{CryptoRng, RngCore};

use crate::{peripheral::Peripheral, peripherals::RNG};

/// Random number generator driver
Expand All @@ -78,7 +76,7 @@ pub struct Rng {
impl Rng {
/// Create a new random number generator instance
pub fn new(_rng: impl Peripheral<P = RNG>) -> Self {
#[cfg(not(esp32p4))]
#[cfg(not(any(esp32p4, esp32s2)))]
crate::soc::trng::ensure_randomness();

Self {
Expand Down Expand Up @@ -110,7 +108,7 @@ impl embedded_hal::blocking::rng::Read for Rng {
}
}

impl RngCore for Rng {
impl rand_core::RngCore for Rng {
fn next_u32(&mut self) -> u32 {
// Directly use the existing random method to get a u32 random number
self.random()
Expand Down Expand Up @@ -140,4 +138,5 @@ impl RngCore for Rng {
}
}

impl CryptoRng for Rng {}
#[cfg(not(any(esp32p4, esp32s2)))]
impl rand_core::CryptoRng for Rng {}
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32s2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod peripherals;
#[cfg(psram)]
pub mod psram;
pub mod radio_clocks;
pub mod trng;
// pub mod trng;
pub mod ulp_core;

pub(crate) mod constants {
Expand Down
Loading