diff --git a/Cargo.toml b/Cargo.toml index 2e5bba5..a438bae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,11 @@ license = "MPL-2.0" minidom = "0.9.1" jid = { version = "0.5.2", features = ["minidom"] } base64 = "0.9.2" -digest = "0.7.5" -sha-1 = "0.7.0" -sha2 = "0.7.1" -sha3 = "0.7.3" -blake2 = "0.7.1" +digest = "0.8" +sha-1 = "0.8" +sha2 = "0.8" +sha3 = "0.8" +blake2 = "0.8" chrono = "0.4.5" try_from = "0.2.2" diff --git a/src/caps.rs b/src/caps.rs index 77901ba..25c851f 100644 --- a/src/caps.rs +++ b/src/caps.rs @@ -19,8 +19,8 @@ use base64; use sha1::Sha1; use sha2::{Sha256, Sha512}; use sha3::{Sha3_256, Sha3_512}; -use blake2::Blake2b; -use digest::{Digest, VariableOutput}; +use blake2::VarBlake2b; +use digest::{Digest, VariableOutput, Input}; /// Represents a capability hash for a given client. #[derive(Debug, Clone)] @@ -182,18 +182,14 @@ pub fn hash_caps(data: &[u8], algo: Algo) -> Result { get_hash_vec(hash.as_slice()) }, Algo::Blake2b_256 => { - let mut hasher = Blake2b::default(); + let mut hasher = VarBlake2b::new(32).unwrap(); hasher.input(data); - let mut buf: [u8; 32] = [0; 32]; - let hash = hasher.variable_result(&mut buf).unwrap(); - get_hash_vec(hash) + hasher.vec_result() }, Algo::Blake2b_512 => { - let mut hasher = Blake2b::default(); + let mut hasher = VarBlake2b::new(64).unwrap(); hasher.input(data); - let mut buf: [u8; 64] = [0; 64]; - let hash = hasher.variable_result(&mut buf).unwrap(); - get_hash_vec(hash) + hasher.vec_result() }, Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)), }, diff --git a/src/ecaps2.rs b/src/ecaps2.rs index 82ab1c4..6e71040 100644 --- a/src/ecaps2.rs +++ b/src/ecaps2.rs @@ -14,8 +14,8 @@ use base64; use sha2::{Sha256, Sha512}; use sha3::{Sha3_256, Sha3_512}; -use blake2::Blake2b; -use digest::{Digest, VariableOutput}; +use blake2::VarBlake2b; +use digest::{Digest, VariableOutput, Input}; generate_element!( /// Represents a set of capability hashes, all of them must correspond to @@ -121,18 +121,14 @@ pub fn hash_ecaps2(data: &[u8], algo: Algo) -> Result { get_hash_vec(hash.as_slice()) }, Algo::Blake2b_256 => { - let mut hasher = Blake2b::default(); + let mut hasher = VarBlake2b::new(32).unwrap(); hasher.input(data); - let mut buf: [u8; 32] = [0; 32]; - let hash = hasher.variable_result(&mut buf).unwrap(); - get_hash_vec(hash) + hasher.vec_result() }, Algo::Blake2b_512 => { - let mut hasher = Blake2b::default(); + let mut hasher = VarBlake2b::new(64).unwrap(); hasher.input(data); - let mut buf: [u8; 64] = [0; 64]; - let hash = hasher.variable_result(&mut buf).unwrap(); - get_hash_vec(hash) + hasher.vec_result() }, Algo::Sha_1 => return Err(String::from("Disabled algorithm sha-1: unsafe.")), Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),