sasl: Update pbkdf2 dep to 0.12
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
6efc67a198
commit
0100909a28
2 changed files with 11 additions and 3 deletions
|
@ -25,4 +25,4 @@ getrandom = { version = "0.2", optional = true }
|
||||||
sha-1 = { version = "0.10", optional = true }
|
sha-1 = { version = "0.10", optional = true }
|
||||||
sha2 = { version = "0.10", optional = true }
|
sha2 = { version = "0.10", optional = true }
|
||||||
hmac = { version = "0.12", optional = true }
|
hmac = { version = "0.12", optional = true }
|
||||||
pbkdf2 = { version = "0.11", default-features = false, optional = true }
|
pbkdf2 = { version = "0.12", default-features = false, optional = true }
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub fn generate_nonce() -> Result<String, RngError> {
|
||||||
pub enum DeriveError {
|
pub enum DeriveError {
|
||||||
IncompatibleHashingMethod(String, String),
|
IncompatibleHashingMethod(String, String),
|
||||||
IncorrectSalt,
|
IncorrectSalt,
|
||||||
|
InvalidLength,
|
||||||
IncompatibleIterationCount(u32, u32),
|
IncompatibleIterationCount(u32, u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ impl std::fmt::Display for DeriveError {
|
||||||
write!(fmt, "incompatible hashing method, {} is not {}", one, two)
|
write!(fmt, "incompatible hashing method, {} is not {}", one, two)
|
||||||
}
|
}
|
||||||
DeriveError::IncorrectSalt => write!(fmt, "incorrect salt"),
|
DeriveError::IncorrectSalt => write!(fmt, "incorrect salt"),
|
||||||
|
DeriveError::InvalidLength => write!(fmt, "invalid length"),
|
||||||
DeriveError::IncompatibleIterationCount(one, two) => {
|
DeriveError::IncompatibleIterationCount(one, two) => {
|
||||||
write!(fmt, "incompatible iteration count, {} is not {}", one, two)
|
write!(fmt, "incompatible iteration count, {} is not {}", one, two)
|
||||||
}
|
}
|
||||||
|
@ -40,6 +42,12 @@ impl std::fmt::Display for DeriveError {
|
||||||
|
|
||||||
impl std::error::Error for DeriveError {}
|
impl std::error::Error for DeriveError {}
|
||||||
|
|
||||||
|
impl From<hmac::digest::InvalidLength> for DeriveError {
|
||||||
|
fn from(_err: hmac::digest::InvalidLength) -> DeriveError {
|
||||||
|
DeriveError::InvalidLength
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A trait which defines the needed methods for SCRAM.
|
/// A trait which defines the needed methods for SCRAM.
|
||||||
pub trait ScramProvider {
|
pub trait ScramProvider {
|
||||||
/// The kind of secret this `ScramProvider` requires.
|
/// The kind of secret this `ScramProvider` requires.
|
||||||
|
@ -89,7 +97,7 @@ impl ScramProvider for Sha1 {
|
||||||
match *password {
|
match *password {
|
||||||
Password::Plain(ref plain) => {
|
Password::Plain(ref plain) => {
|
||||||
let mut result = vec![0; 20];
|
let mut result = vec![0; 20];
|
||||||
pbkdf2::<Hmac<Sha1_hash>>(plain.as_bytes(), salt, iterations, &mut result);
|
pbkdf2::<Hmac<Sha1_hash>>(plain.as_bytes(), salt, iterations, &mut result)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
Password::Pbkdf2 {
|
Password::Pbkdf2 {
|
||||||
|
@ -149,7 +157,7 @@ impl ScramProvider for Sha256 {
|
||||||
match *password {
|
match *password {
|
||||||
Password::Plain(ref plain) => {
|
Password::Plain(ref plain) => {
|
||||||
let mut result = vec![0; 32];
|
let mut result = vec![0; 32];
|
||||||
pbkdf2::<Hmac<Sha256_hash>>(plain.as_bytes(), salt, iterations, &mut result);
|
pbkdf2::<Hmac<Sha256_hash>>(plain.as_bytes(), salt, iterations, &mut result)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
Password::Pbkdf2 {
|
Password::Pbkdf2 {
|
||||||
|
|
Loading…
Reference in a new issue