diff --git a/sasl/Cargo.toml b/sasl/Cargo.toml index a1a2e41b6a59a2e4cbdbdc6fd6c73ebc4acb13d8..724a60d22dddca56a7e41774c54643e10cf5fc4f 100644 --- a/sasl/Cargo.toml +++ b/sasl/Cargo.toml @@ -21,7 +21,7 @@ anonymous = ["getrandom"] [dependencies] base64 = { version = "0.22", optional = true } -getrandom = { version = "0.2", optional = true } +getrandom = { version = "0.3", optional = true } sha1 = { version = "0.10", optional = true } sha2 = { version = "0.10", optional = true } hmac = { version = "0.12", optional = true } diff --git a/sasl/src/common/scram.rs b/sasl/src/common/scram.rs index 5747ed1066c515e9c5506b6f42b8a3b7196f0f69..813d37b6f7d44864eca4f6e6bc3d0375bb6c4093 100644 --- a/sasl/src/common/scram.rs +++ b/sasl/src/common/scram.rs @@ -2,7 +2,6 @@ use alloc::string::{String, ToString}; use alloc::vec; use alloc::vec::Vec; use core::fmt; -use getrandom::{getrandom, Error as RngError}; use hmac::{digest::InvalidLength, Hmac, Mac}; use pbkdf2::pbkdf2; use sha1::{Digest, Sha1 as Sha1_hash}; @@ -15,9 +14,9 @@ use crate::secret; use base64::{engine::general_purpose::STANDARD as Base64, Engine}; /// Generate a nonce for SCRAM authentication. -pub fn generate_nonce() -> Result { +pub fn generate_nonce() -> Result { let mut data = [0u8; 32]; - getrandom(&mut data)?; + getrandom::fill(&mut data)?; Ok(Base64.encode(data)) } diff --git a/sasl/src/server/mechanisms/anonymous.rs b/sasl/src/server/mechanisms/anonymous.rs index c171f25d94cd3657cdf3221494307eee0f5e7369..4a503c1e2841ef11c7aa5fd7cc6143b2b2830821 100644 --- a/sasl/src/server/mechanisms/anonymous.rs +++ b/sasl/src/server/mechanisms/anonymous.rs @@ -3,8 +3,6 @@ use crate::server::{Mechanism, MechanismError, Response}; use alloc::format; use alloc::vec::Vec; -use getrandom::getrandom; - pub struct Anonymous; impl Anonymous { @@ -24,7 +22,7 @@ impl Mechanism for Anonymous { return Err(MechanismError::FailedToDecodeMessage); } let mut rand = [0u8; 16]; - getrandom(&mut rand)?; + getrandom::fill(&mut rand)?; let username = format!("{:02x?}", rand); let ident = Identity::Username(username); Ok(Response::Success(ident, Vec::new()))