Bump all hash crates

This commit is contained in:
Emmanuel Gil Peyrot 2021-12-25 15:57:41 +01:00
commit 6e22c0fcb4
4 changed files with 17 additions and 17 deletions

View file

@ -21,7 +21,7 @@ scram = ["base64", "getrandom", "sha-1", "sha2", "hmac", "pbkdf2"]
[dependencies] [dependencies]
base64 = { version = "0.13", optional = true } base64 = { version = "0.13", optional = true }
getrandom = { version = "0.2", optional = true } getrandom = { version = "0.2", optional = true }
sha-1 = { version = "0.9", optional = true } sha-1 = { version = "0.10", optional = true }
sha2 = { version = "0.9", optional = true } sha2 = { version = "0.10", optional = true }
hmac = { version = "0.10", optional = true } hmac = { version = "0.12", optional = true }
pbkdf2 = { version = "0.6", default-features = false, optional = true } pbkdf2 = { version = "0.10", default-features = false, optional = true }

View file

@ -1,6 +1,6 @@
use crate::common::scram::DeriveError; use crate::common::scram::DeriveError;
use crate::common::Credentials; use crate::common::Credentials;
use hmac::crypto_mac::InvalidKeyLength; use hmac::digest::InvalidLength;
use std::fmt; use std::fmt;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -19,7 +19,7 @@ pub enum MechanismError {
NoServerSalt, NoServerSalt,
NoServerIterations, NoServerIterations,
DeriveError(DeriveError), DeriveError(DeriveError),
InvalidKeyLength(InvalidKeyLength), InvalidKeyLength(InvalidLength),
InvalidState, InvalidState,
CannotDecodeSuccessResponse, CannotDecodeSuccessResponse,
@ -33,8 +33,8 @@ impl From<DeriveError> for MechanismError {
} }
} }
impl From<InvalidKeyLength> for MechanismError { impl From<InvalidLength> for MechanismError {
fn from(err: InvalidKeyLength) -> MechanismError { fn from(err: InvalidLength) -> MechanismError {
MechanismError::InvalidKeyLength(err) MechanismError::InvalidKeyLength(err)
} }
} }

View file

@ -1,5 +1,5 @@
use getrandom::{getrandom, Error as RngError}; use getrandom::{getrandom, Error as RngError};
use hmac::{crypto_mac::InvalidKeyLength, Hmac, Mac, NewMac}; use hmac::{digest::InvalidLength, Hmac, Mac};
use pbkdf2::pbkdf2; use pbkdf2::pbkdf2;
use sha1::{Digest, Sha1 as Sha1_hash}; use sha1::{Digest, Sha1 as Sha1_hash};
use sha2::Sha256 as Sha256_hash; use sha2::Sha256 as Sha256_hash;
@ -52,7 +52,7 @@ pub trait ScramProvider {
fn hash(data: &[u8]) -> Vec<u8>; fn hash(data: &[u8]) -> Vec<u8>;
/// A function which performs an HMAC using the hash function. /// A function which performs an HMAC using the hash function.
fn hmac(data: &[u8], key: &[u8]) -> Result<Vec<u8>, InvalidKeyLength>; fn hmac(data: &[u8], key: &[u8]) -> Result<Vec<u8>, InvalidLength>;
/// A function which does PBKDF2 key derivation using the hash function. /// A function which does PBKDF2 key derivation using the hash function.
fn derive(data: &Password, salt: &[u8], iterations: u32) -> Result<Vec<u8>, DeriveError>; fn derive(data: &Password, salt: &[u8], iterations: u32) -> Result<Vec<u8>, DeriveError>;
@ -75,9 +75,9 @@ impl ScramProvider for Sha1 {
vec vec
} }
fn hmac(data: &[u8], key: &[u8]) -> Result<Vec<u8>, InvalidKeyLength> { fn hmac(data: &[u8], key: &[u8]) -> Result<Vec<u8>, InvalidLength> {
type HmacSha1 = Hmac<Sha1_hash>; type HmacSha1 = Hmac<Sha1_hash>;
let mut mac = HmacSha1::new_varkey(key)?; let mut mac = HmacSha1::new_from_slice(key)?;
mac.update(data); mac.update(data);
let result = mac.finalize(); let result = mac.finalize();
let mut vec = Vec::with_capacity(Sha1_hash::output_size()); let mut vec = Vec::with_capacity(Sha1_hash::output_size());
@ -135,9 +135,9 @@ impl ScramProvider for Sha256 {
vec vec
} }
fn hmac(data: &[u8], key: &[u8]) -> Result<Vec<u8>, InvalidKeyLength> { fn hmac(data: &[u8], key: &[u8]) -> Result<Vec<u8>, InvalidLength> {
type HmacSha256 = Hmac<Sha256_hash>; type HmacSha256 = Hmac<Sha256_hash>;
let mut mac = HmacSha256::new_varkey(key)?; let mut mac = HmacSha256::new_from_slice(key)?;
mac.update(data); mac.update(data);
let result = mac.finalize(); let result = mac.finalize();
let mut vec = Vec::with_capacity(Sha256_hash::output_size()); let mut vec = Vec::with_capacity(Sha256_hash::output_size());

View file

@ -61,7 +61,7 @@ pub enum MechanismError {
ProviderError(ProviderError), ProviderError(ProviderError),
CannotDecodeResponse, CannotDecodeResponse,
InvalidKeyLength(hmac::crypto_mac::InvalidKeyLength), InvalidKeyLength(hmac::digest::InvalidLength),
NoProof, NoProof,
CannotDecodeProof, CannotDecodeProof,
AuthenticationFailed, AuthenticationFailed,
@ -92,8 +92,8 @@ impl From<ValidatorError> for MechanismError {
} }
} }
impl From<hmac::crypto_mac::InvalidKeyLength> for MechanismError { impl From<hmac::digest::InvalidLength> for MechanismError {
fn from(err: hmac::crypto_mac::InvalidKeyLength) -> MechanismError { fn from(err: hmac::digest::InvalidLength) -> MechanismError {
MechanismError::InvalidKeyLength(err) MechanismError::InvalidKeyLength(err)
} }
} }