From 42ed86d712aee03e7a85ab3b23ee5b7c66570c8a Mon Sep 17 00:00:00 2001 From: henopied Date: Wed, 5 Feb 2025 03:10:25 -0600 Subject: [PATCH 1/2] chore: bump rand_core --- Cargo.lock | 35 ++++++++++++++++++++++++----------- Cargo.toml | 5 ++--- src/trng.rs | 13 +++++-------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 265e278..7e45d34 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -110,7 +110,6 @@ dependencies = [ "embedded-io", "max78000-pac", "paste", - "rand", "rand_core", ] @@ -154,20 +153,14 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.8.5" +name = "rand_core" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" dependencies = [ - "rand_core", + "zerocopy", ] -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" - [[package]] name = "rustc_version" version = "0.2.3" @@ -229,3 +222,23 @@ checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" dependencies = [ "vcell", ] + +[[package]] +name = "zerocopy" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b8c07a70861ce02bad1607b5753ecb2501f67847b9f9ada7c160fff0ec6300c" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5226bc9a9a9836e7428936cde76bb6b22feea1a8bfdbc0d241136e4d13417e25" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index f298c34..854f6b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,12 +21,11 @@ embedded-hal-nb = "1.0.0" embedded-io = "0.6.1" max78000-pac = "0.3.0" paste = "1.0.15" -rand = { version = "0.8.5", default-features = false, optional = true } -rand_core = { version = "0.6.4", default-features = false, optional = true } +rand_core = { version = "0.9.0", default-features = false, optional = true } [features] default = ["rand", "rt"] # Enabling this adds the `.flashprog` section header to critical flash programming functions for custom linkage flashprog-linkage = [] -rand = ["dep:rand", "dep:rand_core"] +rand = ["dep:rand_core"] rt = ["max78000-pac/critical-section", "max78000-pac/rt"] diff --git a/src/trng.rs b/src/trng.rs index eff33b0..bd0f600 100644 --- a/src/trng.rs +++ b/src/trng.rs @@ -2,9 +2,9 @@ //! //! The TRNG is a hardware module that generates random numbers using //! physical entropy sources. -use rand::Error; +use rand_core::CryptoRng; #[cfg(feature = "rand")] -use rand::RngCore; +use rand_core::RngCore; #[cfg(feature = "rand")] use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32}; @@ -76,10 +76,7 @@ impl RngCore for Trng { fn fill_bytes(&mut self, dest: &mut [u8]) { fill_bytes_via_next(self, dest); } +} - #[inline(always)] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.fill_bytes(dest); - Ok(()) - } -} \ No newline at end of file +#[cfg(feature = "rand")] +impl CryptoRng for Trng {} From 3cf71068de872caa604b4e7c4e411acb29eb2f15 Mon Sep 17 00:00:00 2001 From: henopied Date: Wed, 5 Feb 2025 03:12:37 -0600 Subject: [PATCH 2/2] fix: missing feature flag --- src/trng.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/trng.rs b/src/trng.rs index bd0f600..086c748 100644 --- a/src/trng.rs +++ b/src/trng.rs @@ -2,6 +2,7 @@ //! //! The TRNG is a hardware module that generates random numbers using //! physical entropy sources. +#[cfg(feature = "rand")] use rand_core::CryptoRng; #[cfg(feature = "rand")] use rand_core::RngCore;