caps, ecaps2: Make Blake2b panic and update the blake2 crate to 0.6.1.

See https://github.com/RustCrypto/hashes/issues/34 for more information.
This commit is contained in:
Emmanuel Gil Peyrot 2017-07-24 23:11:10 +01:00
parent 9e6e84fcb4
commit 83c9713ab9
3 changed files with 16 additions and 5 deletions

View file

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

View file

@ -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<Hash, String> {
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<Hash, String> {
let hash = hasher.variable_result(&mut buf).unwrap();
get_hash_vec(hash)
},
*/
Algo::Unknown(algo) => return Err(format!("Unknown algorithm: {}.", algo)),
},
algo: algo,

View file

@ -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<Hash, String> {
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<Hash, String> {
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<u8> = vec!(