mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-03 03:40:36 +02:00
caps, ecaps2: Update to RustCrypto 0.8.
This commit is contained in:
parent
8e26095fd3
commit
9cb4f00341
10
Cargo.toml
10
Cargo.toml
|
@ -16,11 +16,11 @@ license = "MPL-2.0"
|
||||||
minidom = "0.9.1"
|
minidom = "0.9.1"
|
||||||
jid = { version = "0.5.2", features = ["minidom"] }
|
jid = { version = "0.5.2", features = ["minidom"] }
|
||||||
base64 = "0.9.2"
|
base64 = "0.9.2"
|
||||||
digest = "0.7.5"
|
digest = "0.8"
|
||||||
sha-1 = "0.7.0"
|
sha-1 = "0.8"
|
||||||
sha2 = "0.7.1"
|
sha2 = "0.8"
|
||||||
sha3 = "0.7.3"
|
sha3 = "0.8"
|
||||||
blake2 = "0.7.1"
|
blake2 = "0.8"
|
||||||
chrono = "0.4.5"
|
chrono = "0.4.5"
|
||||||
try_from = "0.2.2"
|
try_from = "0.2.2"
|
||||||
|
|
||||||
|
|
16
src/caps.rs
16
src/caps.rs
|
@ -19,8 +19,8 @@ use base64;
|
||||||
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};
|
||||||
use blake2::Blake2b;
|
use blake2::VarBlake2b;
|
||||||
use digest::{Digest, VariableOutput};
|
use digest::{Digest, VariableOutput, Input};
|
||||||
|
|
||||||
/// Represents a capability hash for a given client.
|
/// Represents a capability hash for a given client.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -182,18 +182,14 @@ 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 = Blake2b::default();
|
let mut hasher = VarBlake2b::new(32).unwrap();
|
||||||
hasher.input(data);
|
hasher.input(data);
|
||||||
let mut buf: [u8; 32] = [0; 32];
|
hasher.vec_result()
|
||||||
let hash = hasher.variable_result(&mut buf).unwrap();
|
|
||||||
get_hash_vec(hash)
|
|
||||||
},
|
},
|
||||||
Algo::Blake2b_512 => {
|
Algo::Blake2b_512 => {
|
||||||
let mut hasher = Blake2b::default();
|
let mut hasher = VarBlake2b::new(64).unwrap();
|
||||||
hasher.input(data);
|
hasher.input(data);
|
||||||
let mut buf: [u8; 64] = [0; 64];
|
hasher.vec_result()
|
||||||
let hash = hasher.variable_result(&mut buf).unwrap();
|
|
||||||
get_hash_vec(hash)
|
|
||||||
},
|
},
|
||||||
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),
|
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,8 +14,8 @@ use base64;
|
||||||
|
|
||||||
use sha2::{Sha256, Sha512};
|
use sha2::{Sha256, Sha512};
|
||||||
use sha3::{Sha3_256, Sha3_512};
|
use sha3::{Sha3_256, Sha3_512};
|
||||||
use blake2::Blake2b;
|
use blake2::VarBlake2b;
|
||||||
use digest::{Digest, VariableOutput};
|
use digest::{Digest, VariableOutput, Input};
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Represents a set of capability hashes, all of them must correspond to
|
/// 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())
|
get_hash_vec(hash.as_slice())
|
||||||
},
|
},
|
||||||
Algo::Blake2b_256 => {
|
Algo::Blake2b_256 => {
|
||||||
let mut hasher = Blake2b::default();
|
let mut hasher = VarBlake2b::new(32).unwrap();
|
||||||
hasher.input(data);
|
hasher.input(data);
|
||||||
let mut buf: [u8; 32] = [0; 32];
|
hasher.vec_result()
|
||||||
let hash = hasher.variable_result(&mut buf).unwrap();
|
|
||||||
get_hash_vec(hash)
|
|
||||||
},
|
},
|
||||||
Algo::Blake2b_512 => {
|
Algo::Blake2b_512 => {
|
||||||
let mut hasher = Blake2b::default();
|
let mut hasher = VarBlake2b::new(64).unwrap();
|
||||||
hasher.input(data);
|
hasher.input(data);
|
||||||
let mut buf: [u8; 64] = [0; 64];
|
hasher.vec_result()
|
||||||
let hash = hasher.variable_result(&mut buf).unwrap();
|
|
||||||
get_hash_vec(hash)
|
|
||||||
},
|
},
|
||||||
Algo::Sha_1 => return Err(String::from("Disabled algorithm sha-1: unsafe.")),
|
Algo::Sha_1 => return Err(String::from("Disabled algorithm sha-1: unsafe.")),
|
||||||
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),
|
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user