diff --git a/Cargo.toml b/Cargo.toml index 6f27f34a..7b425d44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,6 @@ digest = "0.6.0" sha-1 = "0.4.0" sha2 = "0.6.0" sha3 = "0.6.0" -blake2 = "0.6.0" +blake2 = "0.6.1" chrono = "0.4.0" try_from = "0.2.2" diff --git a/src/caps.rs b/src/caps.rs index aad50eb2..a2bdd11b 100644 --- a/src/caps.rs +++ b/src/caps.rs @@ -15,11 +15,12 @@ use error::Error; use ns; use base64; +use digest::Digest; use sha_1::Sha1; use sha2::{Sha256, Sha512}; use sha3::{Sha3_256, Sha3_512}; -use blake2::Blake2b; -use digest::{Digest, VariableOutput}; +//use blake2::Blake2b; +//use digest::{Digest, VariableOutput}; #[derive(Debug, Clone)] pub struct Caps { @@ -173,6 +174,9 @@ pub fn hash_caps(data: &[u8], algo: Algo) -> Result { let hash = hasher.result(); get_hash_vec(hash.as_slice()) }, + Algo::Blake2b_256 + | Algo::Blake2b_512 => panic!("See https://github.com/RustCrypto/hashes/issues/34"), + /* Algo::Blake2b_256 => { let mut hasher = Blake2b::default(); hasher.input(data); @@ -187,6 +191,7 @@ pub fn hash_caps(data: &[u8], algo: Algo) -> Result { let hash = hasher.variable_result(&mut buf).unwrap(); get_hash_vec(hash) }, + */ Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)), }, algo: algo, diff --git a/src/ecaps2.rs b/src/ecaps2.rs index be80ffd5..593acec0 100644 --- a/src/ecaps2.rs +++ b/src/ecaps2.rs @@ -15,10 +15,11 @@ use error::Error; use ns; use base64; +use digest::Digest; use sha2::{Sha256, Sha512}; use sha3::{Sha3_256, Sha3_512}; -use blake2::Blake2b; -use digest::{Digest, VariableOutput}; +//use blake2::Blake2b; +//use digest::{Digest, VariableOutput}; #[derive(Debug, Clone)] pub struct ECaps2 { @@ -151,6 +152,9 @@ pub fn hash_ecaps2(data: &[u8], algo: Algo) -> Result { let hash = hasher.result(); get_hash_vec(hash.as_slice()) }, + Algo::Blake2b_256 + | Algo::Blake2b_512 => panic!("See https://github.com/RustCrypto/hashes/issues/34"), + /* Algo::Blake2b_256 => { let mut hasher = Blake2b::default(); hasher.input(data); @@ -165,6 +169,7 @@ pub fn hash_ecaps2(data: &[u8], algo: Algo) -> 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::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)), }, @@ -455,6 +460,7 @@ mod tests { } #[test] + #[ignore] fn test_blake2b_512() { let hash = ecaps2::hash_ecaps2("abc".as_bytes(), Algo::Blake2b_512).unwrap(); let known_hash: Vec = vec!(