diff --git a/dhcp/Cargo.toml b/dhcp/Cargo.toml index 312c523d..e0eaaaca 100644 --- a/dhcp/Cargo.toml +++ b/dhcp/Cargo.toml @@ -23,7 +23,7 @@ log = { version = "0.4", optional = true } [dev-dependencies] dhcproto = "0.12" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } stderrlog = "0.6" w5500-hl.path = "../hl" w5500-regsim.path = "../regsim" diff --git a/dhcp/src/lib.rs b/dhcp/src/lib.rs index eeffa5e7..b11b5656 100644 --- a/dhcp/src/lib.rs +++ b/dhcp/src/lib.rs @@ -78,7 +78,7 @@ pub enum State { /// # Example /// /// ```no_run -/// use rand_core::RngCore; +/// use rand_core::TryRngCore; /// use w5500_dhcp::{ /// ll::{net::Eui48Addr, Sn}, /// Client, Hostname, @@ -97,7 +97,7 @@ pub enum State { /// /// this_is_where_you_setup_the_w5500_int_pin_for_a_falling_edge_trigger(); /// -/// let seed: u64 = rng.next_u64(); +/// let seed: u64 = rng.try_next_u64().unwrap(); /// /// let mut dhcp: Client = Client::new(DHCP_SN, seed, MAC_ADDRESS, HOSTNAME); /// @@ -156,7 +156,7 @@ impl<'a> Client<'a> { /// # Example /// /// ``` - /// use rand_core::RngCore; + /// use rand_core::TryRngCore; /// use w5500_dhcp::{ /// ll::{net::Eui48Addr, Sn}, /// Client, Hostname, @@ -167,7 +167,7 @@ impl<'a> Client<'a> { /// // locally administered MAC address /// const MAC_ADDRESS: Eui48Addr = Eui48Addr::new(0x02, 0x00, 0x11, 0x22, 0x33, 0x44); /// const HOSTNAME: Hostname = Hostname::new_unwrapped("example"); - /// let seed: u64 = rng.next_u64(); + /// let seed: u64 = rng.try_next_u64().unwrap(); /// /// let dhcp: Client = Client::new(DHCP_SN, seed, MAC_ADDRESS, HOSTNAME); /// ``` @@ -206,7 +206,7 @@ impl<'a> Client<'a> { /// Set a 10 second timeout. /// /// ``` - /// use rand_core::RngCore; + /// use rand_core::TryRngCore; /// use w5500_dhcp::{ /// ll::{net::Eui48Addr, Sn}, /// Client, Hostname, @@ -216,7 +216,7 @@ impl<'a> Client<'a> { /// const HOSTNAME: Hostname = Hostname::new_unwrapped("example"); /// let mut dhcp: Client = Client::new( /// Sn::Sn0, - /// rng.next_u64(), + /// rng.try_next_u64().unwrap(), /// Eui48Addr::new(0x02, 0x00, 0x11, 0x22, 0x33, 0x44), /// HOSTNAME, /// ); @@ -231,7 +231,7 @@ impl<'a> Client<'a> { /// # Example /// /// ``` - /// use rand_core::RngCore; + /// use rand_core::TryRngCore; /// use w5500_dhcp::{ /// ll::{net::Eui48Addr, Sn}, /// Client, Hostname, @@ -241,7 +241,7 @@ impl<'a> Client<'a> { /// const HOSTNAME: Hostname = Hostname::new_unwrapped("example"); /// let dhcp: Client = Client::new( /// Sn::Sn0, - /// rng.next_u64(), + /// rng.try_next_u64().unwrap(), /// Eui48Addr::new(0x02, 0x00, 0x11, 0x22, 0x33, 0x44), /// HOSTNAME, /// ); diff --git a/dns/Cargo.toml b/dns/Cargo.toml index ec0247cf..d7cf504f 100644 --- a/dns/Cargo.toml +++ b/dns/Cargo.toml @@ -23,7 +23,7 @@ log = { version = "0.4", optional = true } [dev-dependencies] log = "0.4" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } stderrlog = "0.6" w5500-regsim.path = "../regsim" diff --git a/dns/examples/simple.rs b/dns/examples/simple.rs index 8e93ff5b..2a02945a 100644 --- a/dns/examples/simple.rs +++ b/dns/examples/simple.rs @@ -4,7 +4,7 @@ //! //! **Note:** This will communicate with external network services. -use rand_core::{OsRng, RngCore}; +use rand_core::{OsRng, TryRngCore}; use std::time::{Duration, Instant}; use w5500_dns::{ hl::{Error, Udp}, @@ -34,7 +34,9 @@ fn main() { .udp_bind(DNS_SOCKET, DNS_SOURCE_PORT) .expect("failed to bind"); - let random_number: u64 = OsRng.next_u64(); + let random_number: u64 = OsRng + .try_next_u64() + .expect("Failed to generate random number"); let mut dns_client: Client = Client::new( Sn::Sn3, diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 167b8ed8..af467747 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -6,5 +6,5 @@ publish = false edition = "2021" [dependencies] -rand_core = "0.6" +rand_core = { version = "0.9", features = ["os_rng"] } w5500-ll.path = "../ll" diff --git a/fuzz/src/lib.rs b/fuzz/src/lib.rs index 5ed2d750..65c2eae8 100644 --- a/fuzz/src/lib.rs +++ b/fuzz/src/lib.rs @@ -108,12 +108,6 @@ impl rand_core::RngCore for NotRng { fn fill_bytes(&mut self, dest: &mut [u8]) { dest.iter_mut().for_each(|b| *b = self.next_byte()); } - - #[inline] - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> { - dest.iter_mut().for_each(|b| *b = self.next_byte()); - Ok(()) - } } impl rand_core::CryptoRng for NotRng {} diff --git a/testsuite/Cargo.toml b/testsuite/Cargo.toml index b33ff78a..22ef5fac 100644 --- a/testsuite/Cargo.toml +++ b/testsuite/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] ftdi-embedded-hal = { version = "0.22.0", features = ["libftd2xx", "libftd2xx-static"] } log = "0.4" -rand_core = { version = "0.6.3", features = ["getrandom"] } +rand_core = { version = "0.6", features = ["getrandom"] } stderrlog = "0.6" w5500-dhcp = { path = "../dhcp", features = ["eh1", "log"] } diff --git a/tls/afl/Cargo.toml b/tls/afl/Cargo.toml index f3ad2fe4..38233c26 100644 --- a/tls/afl/Cargo.toml +++ b/tls/afl/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] afl = "0.15" -rand_core = "0.6" +rand_core = "0.9" stderrlog = "0.6" w5500-fuzz.path = "../../fuzz" w5500-regsim.path = "../../regsim"