xmpp-parsers: Bump all hash crates.

This commit is contained in:
Emmanuel Gil Peyrot 2021-12-25 14:55:45 +01:00
parent edba9c9f5d
commit 1a03588bdb
3 changed files with 19 additions and 19 deletions

View file

@ -17,11 +17,11 @@ edition = "2018"
minidom = "0.13" minidom = "0.13"
jid = { version = "0.9", features = ["minidom"] } jid = { version = "0.9", features = ["minidom"] }
base64 = "0.13" base64 = "0.13"
digest = "0.9" digest = "0.10"
sha-1 = "0.9" sha-1 = "0.10"
sha2 = "0.9" sha2 = "0.10"
sha3 = "0.9" sha3 = "0.10"
blake2 = "0.9" blake2 = "0.10"
chrono = { version = "0.4.5", default-features = false, features = ["std"] } chrono = { version = "0.4.5", default-features = false, features = ["std"] }
[features] [features]

View file

@ -11,7 +11,7 @@ use crate::ns;
use crate::presence::PresencePayload; use crate::presence::PresencePayload;
use crate::util::error::Error; use crate::util::error::Error;
use crate::Element; use crate::Element;
use blake2::VarBlake2b; use blake2::Blake2bVar;
use digest::{Digest, Update, VariableOutput}; use digest::{Digest, Update, VariableOutput};
use sha1::Sha1; use sha1::Sha1;
use sha2::{Sha256, Sha512}; use sha2::{Sha256, Sha512};
@ -187,17 +187,17 @@ pub fn hash_caps(data: &[u8], algo: Algo) -> Result<Hash, String> {
get_hash_vec(hash.as_slice()) get_hash_vec(hash.as_slice())
} }
Algo::Blake2b_256 => { Algo::Blake2b_256 => {
let mut hasher = VarBlake2b::new(32).unwrap(); let mut hasher = Blake2bVar::new(32).unwrap();
hasher.update(data); hasher.update(data);
let mut vec = Vec::with_capacity(32); let mut vec = vec![0u8; 32];
hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); hasher.finalize_variable(&mut vec).unwrap();
vec vec
} }
Algo::Blake2b_512 => { Algo::Blake2b_512 => {
let mut hasher = VarBlake2b::new(64).unwrap(); let mut hasher = Blake2bVar::new(64).unwrap();
hasher.update(data); hasher.update(data);
let mut vec = Vec::with_capacity(64); let mut vec = vec![0u8; 64];
hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); hasher.finalize_variable(&mut vec).unwrap();
vec vec
} }
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)), Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),

View file

@ -10,7 +10,7 @@ use crate::hashes::{Algo, Hash};
use crate::ns; use crate::ns;
use crate::presence::PresencePayload; use crate::presence::PresencePayload;
use crate::util::error::Error; use crate::util::error::Error;
use blake2::VarBlake2b; use blake2::Blake2bVar;
use digest::{Digest, Update, VariableOutput}; use digest::{Digest, Update, VariableOutput};
use sha2::{Sha256, Sha512}; use sha2::{Sha256, Sha512};
use sha3::{Sha3_256, Sha3_512}; use sha3::{Sha3_256, Sha3_512};
@ -146,17 +146,17 @@ pub fn hash_ecaps2(data: &[u8], algo: Algo) -> Result<Hash, Error> {
get_hash_vec(hash.as_slice()) get_hash_vec(hash.as_slice())
} }
Algo::Blake2b_256 => { Algo::Blake2b_256 => {
let mut hasher = VarBlake2b::new(32).unwrap(); let mut hasher = Blake2bVar::new(32).unwrap();
hasher.update(data); hasher.update(data);
let mut vec = Vec::with_capacity(32); let mut vec = vec![0u8; 32];
hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); hasher.finalize_variable(&mut vec).unwrap();
vec vec
} }
Algo::Blake2b_512 => { Algo::Blake2b_512 => {
let mut hasher = VarBlake2b::new(64).unwrap(); let mut hasher = Blake2bVar::new(64).unwrap();
hasher.update(data); hasher.update(data);
let mut vec = Vec::with_capacity(64); let mut vec = vec![0u8; 64];
hasher.finalize_variable(|slice| vec.extend_from_slice(slice)); hasher.finalize_variable(&mut vec).unwrap();
vec vec
} }
Algo::Sha_1 => return Err(Error::ParseError("Disabled algorithm sha-1: unsafe.")), Algo::Sha_1 => return Err(Error::ParseError("Disabled algorithm sha-1: unsafe.")),