xmpp-parsers: Bump RustCrypto crates

This commit is contained in:
Emmanuel Gil Peyrot 2020-06-22 01:25:16 +02:00 committed by Link Mauve
parent b85aa29377
commit db86aa9d5a
3 changed files with 23 additions and 15 deletions

View file

@ -17,11 +17,11 @@ edition = "2018"
minidom = "0.12.0" minidom = "0.12.0"
jid = { version = "0.9", features = ["minidom"] } jid = { version = "0.9", features = ["minidom"] }
base64 = "0.12" base64 = "0.12"
digest = "0.8" digest = "0.9"
sha-1 = "0.8" sha-1 = "0.9"
sha2 = "0.8" sha2 = "0.9"
sha3 = "0.8" sha3 = "0.9"
blake2 = "0.8" blake2 = "0.9"
chrono = "0.4.5" chrono = "0.4.5"
[features] [features]

View file

@ -12,7 +12,7 @@ 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::VarBlake2b;
use digest::{Digest, Input, VariableOutput}; use digest::{Digest, Update, VariableOutput};
use sha1::Sha1; use sha1::Sha1;
use sha2::{Sha256, Sha512}; use sha2::{Sha256, Sha512};
use sha3::{Sha3_256, Sha3_512}; use sha3::{Sha3_256, Sha3_512};
@ -190,13 +190,17 @@ pub fn hash_caps(data: &[u8], algo: Algo) -> Result<Hash, String> {
} }
Algo::Blake2b_256 => { Algo::Blake2b_256 => {
let mut hasher = VarBlake2b::new(32).unwrap(); let mut hasher = VarBlake2b::new(32).unwrap();
hasher.input(data); hasher.update(data);
hasher.vec_result() let mut vec = Vec::with_capacity(32);
hasher.finalize_variable(|slice| vec.extend_from_slice(slice));
vec
} }
Algo::Blake2b_512 => { Algo::Blake2b_512 => {
let mut hasher = VarBlake2b::new(64).unwrap(); let mut hasher = VarBlake2b::new(64).unwrap();
hasher.input(data); hasher.update(data);
hasher.vec_result() let mut vec = Vec::with_capacity(64);
hasher.finalize_variable(|slice| vec.extend_from_slice(slice));
vec
} }
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)), Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),
}, },

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 blake2::VarBlake2b; use blake2::VarBlake2b;
use digest::{Digest, Input, 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};
@ -147,13 +147,17 @@ pub fn hash_ecaps2(data: &[u8], algo: Algo) -> Result<Hash, Error> {
} }
Algo::Blake2b_256 => { Algo::Blake2b_256 => {
let mut hasher = VarBlake2b::new(32).unwrap(); let mut hasher = VarBlake2b::new(32).unwrap();
hasher.input(data); hasher.update(data);
hasher.vec_result() let mut vec = Vec::with_capacity(32);
hasher.finalize_variable(|slice| vec.extend_from_slice(slice));
vec
} }
Algo::Blake2b_512 => { Algo::Blake2b_512 => {
let mut hasher = VarBlake2b::new(64).unwrap(); let mut hasher = VarBlake2b::new(64).unwrap();
hasher.input(data); hasher.update(data);
hasher.vec_result() let mut vec = Vec::with_capacity(64);
hasher.finalize_variable(|slice| vec.extend_from_slice(slice));
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.")),
Algo::Unknown(_algo) => return Err(Error::ParseError("Unknown algorithm in ecaps2.")), Algo::Unknown(_algo) => return Err(Error::ParseError("Unknown algorithm in ecaps2.")),