diff --git a/parsers/Cargo.toml b/parsers/Cargo.toml index 84aba375..d21efae7 100644 --- a/parsers/Cargo.toml +++ b/parsers/Cargo.toml @@ -17,11 +17,11 @@ edition = "2018" minidom = "0.13" jid = { version = "0.9", features = ["minidom"] } base64 = "0.13" -digest = "0.9" -sha-1 = "0.9" -sha2 = "0.9" -sha3 = "0.9" -blake2 = "0.9" +digest = "0.10" +sha-1 = "0.10" +sha2 = "0.10" +sha3 = "0.10" +blake2 = "0.10" chrono = { version = "0.4.5", default-features = false, features = ["std"] } [features] diff --git a/parsers/src/caps.rs b/parsers/src/caps.rs index 24f129a2..9d4d2b40 100644 --- a/parsers/src/caps.rs +++ b/parsers/src/caps.rs @@ -11,7 +11,7 @@ use crate::ns; use crate::presence::PresencePayload; use crate::util::error::Error; use crate::Element; -use blake2::VarBlake2b; +use blake2::Blake2bVar; use digest::{Digest, Update, VariableOutput}; use sha1::Sha1; use sha2::{Sha256, Sha512}; @@ -187,17 +187,17 @@ pub fn hash_caps(data: &[u8], algo: Algo) -> Result { get_hash_vec(hash.as_slice()) } Algo::Blake2b_256 => { - let mut hasher = VarBlake2b::new(32).unwrap(); + let mut hasher = Blake2bVar::new(32).unwrap(); hasher.update(data); - let mut vec = Vec::with_capacity(32); - hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); + let mut vec = vec![0u8; 32]; + hasher.finalize_variable(&mut vec).unwrap(); vec } Algo::Blake2b_512 => { - let mut hasher = VarBlake2b::new(64).unwrap(); + let mut hasher = Blake2bVar::new(64).unwrap(); hasher.update(data); - let mut vec = Vec::with_capacity(64); - hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); + let mut vec = vec![0u8; 64]; + hasher.finalize_variable(&mut vec).unwrap(); vec } Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)), diff --git a/parsers/src/ecaps2.rs b/parsers/src/ecaps2.rs index 4ca1f2a2..d5b6531d 100644 --- a/parsers/src/ecaps2.rs +++ b/parsers/src/ecaps2.rs @@ -10,7 +10,7 @@ use crate::hashes::{Algo, Hash}; use crate::ns; use crate::presence::PresencePayload; use crate::util::error::Error; -use blake2::VarBlake2b; +use blake2::Blake2bVar; use digest::{Digest, Update, VariableOutput}; use sha2::{Sha256, Sha512}; use sha3::{Sha3_256, Sha3_512}; @@ -146,17 +146,17 @@ pub fn hash_ecaps2(data: &[u8], algo: Algo) -> Result { get_hash_vec(hash.as_slice()) } Algo::Blake2b_256 => { - let mut hasher = VarBlake2b::new(32).unwrap(); + let mut hasher = Blake2bVar::new(32).unwrap(); hasher.update(data); - let mut vec = Vec::with_capacity(32); - hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); + let mut vec = vec![0u8; 32]; + hasher.finalize_variable(&mut vec).unwrap(); vec } Algo::Blake2b_512 => { - let mut hasher = VarBlake2b::new(64).unwrap(); + let mut hasher = Blake2bVar::new(64).unwrap(); hasher.update(data); - let mut vec = Vec::with_capacity(64); - hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); + let mut vec = vec![0u8; 64]; + hasher.finalize_variable(&mut vec).unwrap(); vec } Algo::Sha_1 => return Err(Error::ParseError("Disabled algorithm sha-1: unsafe.")),