diff --git a/sasl/Cargo.toml b/sasl/Cargo.toml index 7a5782b6..0ff2033f 100644 --- a/sasl/Cargo.toml +++ b/sasl/Cargo.toml @@ -21,7 +21,7 @@ scram = ["base64", "getrandom", "sha-1", "sha2", "hmac", "pbkdf2"] [dependencies] base64 = { version = "0.13", optional = true } getrandom = { version = "0.2", optional = true } -sha-1 = { version = "0.9", optional = true } -sha2 = { version = "0.9", optional = true } -hmac = { version = "0.10", optional = true } -pbkdf2 = { version = "0.6", default-features = false, optional = true } +sha-1 = { version = "0.10", optional = true } +sha2 = { version = "0.10", optional = true } +hmac = { version = "0.12", optional = true } +pbkdf2 = { version = "0.10", default-features = false, optional = true } diff --git a/sasl/src/client/mod.rs b/sasl/src/client/mod.rs index 621de878..8bf078f6 100644 --- a/sasl/src/client/mod.rs +++ b/sasl/src/client/mod.rs @@ -1,6 +1,6 @@ use crate::common::scram::DeriveError; use crate::common::Credentials; -use hmac::crypto_mac::InvalidKeyLength; +use hmac::digest::InvalidLength; use std::fmt; #[derive(Debug, PartialEq)] @@ -19,7 +19,7 @@ pub enum MechanismError { NoServerSalt, NoServerIterations, DeriveError(DeriveError), - InvalidKeyLength(InvalidKeyLength), + InvalidKeyLength(InvalidLength), InvalidState, CannotDecodeSuccessResponse, @@ -33,8 +33,8 @@ impl From for MechanismError { } } -impl From for MechanismError { - fn from(err: InvalidKeyLength) -> MechanismError { +impl From for MechanismError { + fn from(err: InvalidLength) -> MechanismError { MechanismError::InvalidKeyLength(err) } } diff --git a/sasl/src/common/scram.rs b/sasl/src/common/scram.rs index 6ac52f12..b39f2914 100644 --- a/sasl/src/common/scram.rs +++ b/sasl/src/common/scram.rs @@ -1,5 +1,5 @@ use getrandom::{getrandom, Error as RngError}; -use hmac::{crypto_mac::InvalidKeyLength, Hmac, Mac, NewMac}; +use hmac::{digest::InvalidLength, Hmac, Mac}; use pbkdf2::pbkdf2; use sha1::{Digest, Sha1 as Sha1_hash}; use sha2::Sha256 as Sha256_hash; @@ -52,7 +52,7 @@ pub trait ScramProvider { fn hash(data: &[u8]) -> Vec; /// A function which performs an HMAC using the hash function. - fn hmac(data: &[u8], key: &[u8]) -> Result, InvalidKeyLength>; + fn hmac(data: &[u8], key: &[u8]) -> Result, InvalidLength>; /// A function which does PBKDF2 key derivation using the hash function. fn derive(data: &Password, salt: &[u8], iterations: u32) -> Result, DeriveError>; @@ -75,9 +75,9 @@ impl ScramProvider for Sha1 { vec } - fn hmac(data: &[u8], key: &[u8]) -> Result, InvalidKeyLength> { + fn hmac(data: &[u8], key: &[u8]) -> Result, InvalidLength> { type HmacSha1 = Hmac; - let mut mac = HmacSha1::new_varkey(key)?; + let mut mac = HmacSha1::new_from_slice(key)?; mac.update(data); let result = mac.finalize(); let mut vec = Vec::with_capacity(Sha1_hash::output_size()); @@ -135,9 +135,9 @@ impl ScramProvider for Sha256 { vec } - fn hmac(data: &[u8], key: &[u8]) -> Result, InvalidKeyLength> { + fn hmac(data: &[u8], key: &[u8]) -> Result, InvalidLength> { type HmacSha256 = Hmac; - let mut mac = HmacSha256::new_varkey(key)?; + let mut mac = HmacSha256::new_from_slice(key)?; mac.update(data); let result = mac.finalize(); let mut vec = Vec::with_capacity(Sha256_hash::output_size()); diff --git a/sasl/src/server/mod.rs b/sasl/src/server/mod.rs index c144235c..8d1bece7 100644 --- a/sasl/src/server/mod.rs +++ b/sasl/src/server/mod.rs @@ -61,7 +61,7 @@ pub enum MechanismError { ProviderError(ProviderError), CannotDecodeResponse, - InvalidKeyLength(hmac::crypto_mac::InvalidKeyLength), + InvalidKeyLength(hmac::digest::InvalidLength), NoProof, CannotDecodeProof, AuthenticationFailed, @@ -92,8 +92,8 @@ impl From for MechanismError { } } -impl From for MechanismError { - fn from(err: hmac::crypto_mac::InvalidKeyLength) -> MechanismError { +impl From for MechanismError { + fn from(err: hmac::digest::InvalidLength) -> MechanismError { MechanismError::InvalidKeyLength(err) } }