1
0
mirror of https://gitlab.com/xmpp-rs/xmpp-rs.git synced 2024-06-29 01:48:42 +02:00

caps, ecaps2: Update to RustCrypto 0.8.

This commit is contained in:
Emmanuel Gil Peyrot 2018-10-12 17:23:34 +02:00
parent 8e26095fd3
commit 9cb4f00341
3 changed files with 17 additions and 25 deletions

View File

@ -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"

View File

@ -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<Hash, String> {
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)),
},

View File

@ -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<Hash, String> {
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)),