From de0877188cbb3692c3ce0d9a72f6e96d515cde1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 23 Jul 2025 17:37:12 +0400 Subject: [PATCH] build(deps): bump rand to 0.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- Cargo.lock | 4 ++-- crates/ironrdp-connector/Cargo.toml | 2 +- crates/ironrdp-connector/src/license_exchange.rs | 7 ++++--- crates/ironrdp/Cargo.toml | 2 +- crates/ironrdp/examples/server.rs | 16 ++++++++-------- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f4aa264..0dd03cfe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2345,7 +2345,7 @@ dependencies = [ "ironrdp-svc", "opus", "pico-args", - "rand 0.8.5", + "rand 0.9.2", "sspi", "tokio-rustls", "tracing", @@ -2494,7 +2494,7 @@ dependencies = [ "picky", "picky-asn1-der", "picky-asn1-x509", - "rand_core 0.6.4", + "rand 0.9.2", "sspi", "tracing", "url", diff --git a/crates/ironrdp-connector/Cargo.toml b/crates/ironrdp-connector/Cargo.toml index b74ee82b..906bb33e 100644 --- a/crates/ironrdp-connector/Cargo.toml +++ b/crates/ironrdp-connector/Cargo.toml @@ -26,7 +26,7 @@ ironrdp-pdu = { path = "../ironrdp-pdu", version = "0.5", features = ["std"] } # arbitrary = { version = "1", features = ["derive"], optional = true } # public sspi = "0.16" # public url = "2.5" # public -rand_core = { version = "0.6", features = ["std"] } # TODO: dependency injection? +rand = { version = "0.9", features = ["std"] } # TODO: dependency injection? tracing = { version = "0.1", features = ["log"] } picky-asn1-der = "0.5" picky-asn1-x509 = "0.14" diff --git a/crates/ironrdp-connector/src/license_exchange.rs b/crates/ironrdp-connector/src/license_exchange.rs index d90384c7..0e9dedfa 100644 --- a/crates/ironrdp-connector/src/license_exchange.rs +++ b/crates/ironrdp-connector/src/license_exchange.rs @@ -7,7 +7,7 @@ use std::sync::Arc; use ironrdp_core::WriteBuf; use ironrdp_pdu::rdp::server_license::{self, LicenseInformation, LicensePdu, ServerLicenseError}; use ironrdp_pdu::PduHint; -use rand_core::{OsRng, RngCore as _}; +use rand::prelude::*; use super::{legacy, ConnectorError, ConnectorErrorExt}; use crate::{encode_send_data_request, ConnectorResult, ConnectorResultExt as _, Sequence, State, Written}; @@ -134,11 +134,12 @@ impl Sequence for LicenseExchangeSequence { match license_pdu { LicensePdu::ServerLicenseRequest(license_request) => { + let mut rng = rand::rng(); let mut client_random = [0u8; server_license::RANDOM_NUMBER_SIZE]; - OsRng.fill_bytes(&mut client_random); + rng.fill_bytes(&mut client_random); let mut premaster_secret = [0u8; server_license::PREMASTER_SECRET_SIZE]; - OsRng.fill_bytes(&mut premaster_secret); + rng.fill_bytes(&mut premaster_secret); let license_info = license_request .scope_list diff --git a/crates/ironrdp/Cargo.toml b/crates/ironrdp/Cargo.toml index cdfcb117..e44d44e6 100644 --- a/crates/ironrdp/Cargo.toml +++ b/crates/ironrdp/Cargo.toml @@ -63,7 +63,7 @@ sspi = { version = "0.16", features = ["network_client"] } tracing = { version = "0.1", features = ["log"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } tokio-rustls = "0.26" -rand = "0.8" +rand = "0.9" opus = "0.3" [package.metadata.docs.rs] diff --git a/crates/ironrdp/examples/server.rs b/crates/ironrdp/examples/server.rs index 78c90ba0..1b3686e3 100644 --- a/crates/ironrdp/examples/server.rs +++ b/crates/ironrdp/examples/server.rs @@ -157,12 +157,12 @@ struct DisplayUpdates; impl RdpServerDisplayUpdates for DisplayUpdates { async fn next_update(&mut self) -> Option { sleep(Duration::from_millis(100)).await; - let mut rng = thread_rng(); + let mut rng = rand::rng(); - let y: u16 = rng.gen_range(0..HEIGHT); - let height = NonZeroU16::new(rng.gen_range(1..=HEIGHT.checked_sub(y).unwrap())).unwrap(); - let x: u16 = rng.gen_range(0..WIDTH); - let width = NonZeroU16::new(rng.gen_range(1..=WIDTH.checked_sub(x).unwrap())).unwrap(); + let y: u16 = rng.random_range(0..HEIGHT); + let height = NonZeroU16::new(rng.random_range(1..=HEIGHT.checked_sub(y).unwrap())).unwrap(); + let x: u16 = rng.random_range(0..WIDTH); + let width = NonZeroU16::new(rng.random_range(1..=WIDTH.checked_sub(x).unwrap())).unwrap(); let capacity = usize::from(width.get()) .checked_mul(usize::from(height.get())) .unwrap() @@ -170,9 +170,9 @@ impl RdpServerDisplayUpdates for DisplayUpdates { .unwrap(); let mut data = Vec::with_capacity(capacity); for _ in 0..(data.capacity() / 4) { - data.push(rng.r#gen()); - data.push(rng.r#gen()); - data.push(rng.r#gen()); + data.push(rng.random()); + data.push(rng.random()); + data.push(rng.random()); data.push(255); }