Skip to content

Commit 1d78546

Browse files
committed
blake2: re-add tests from upstream crate
These are the original tests from: https://github.com/RustCrypto/hashes/tree/4a2845c226ba6748babdb2e704713fa9103d09f0/blake2/tests They show that the new `blake2_simd` crate is API-compatible with the old one.
1 parent fe77461 commit 1d78546

File tree

9 files changed

+67
-25
lines changed

9 files changed

+67
-25
lines changed

Cargo.lock

Lines changed: 19 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
182 Bytes
Binary file not shown.

blake2/tests/data/blake2b/mac.blb

64.8 KB
Binary file not shown.
53 Bytes
Binary file not shown.

blake2/tests/data/blake2s/mac.blb

48.7 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blobby1absdefghfoobar 8ʧ���Y=��&2}B

blake2/tests/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![no_std]
2+
3+
use digest::dev::{digest_test, variable_test};
4+
use digest::new_test;
5+
6+
new_test!(blake2b_fixed, "blake2b/fixed", blake2::Blake2b, digest_test);
7+
new_test!(
8+
blake2b_variable,
9+
"blake2b/variable",
10+
blake2::VarBlake2b,
11+
variable_test
12+
);
13+
new_test!(
14+
blake2s_variable,
15+
"blake2s/variable",
16+
blake2::VarBlake2s,
17+
variable_test
18+
);

blake2/tests/mac.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![no_std]
2+
3+
use crypto_mac::new_test;
4+
5+
new_test!(blake2b_mac, "blake2b/mac", blake2::Blake2b);
6+
new_test!(blake2s_mac, "blake2s/mac", blake2::Blake2s);

blake2/tests/persona.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use blake2::{Blake2b, Blake2s, Digest};
2+
use hex_literal::hex;
3+
4+
#[test]
5+
fn blake2s_persona() {
6+
let key_bytes = hex!("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f");
7+
let persona = "personal";
8+
let persona_bytes = persona.as_bytes();
9+
let ctx = Blake2s::with_params(&key_bytes, &[], persona_bytes);
10+
assert_eq!(
11+
ctx.finalize().as_slice(),
12+
&hex!("25a4ee63b594aed3f88a971e1877ef7099534f9097291f88fb86c79b5e70d022")[..]
13+
);
14+
}
15+
16+
#[test]
17+
fn blake2b_persona() {
18+
let key_bytes = hex!("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f");
19+
let persona = "personal";
20+
let persona_bytes = persona.as_bytes();
21+
let ctx = Blake2b::with_params(&key_bytes, &[], persona_bytes);
22+
assert_eq!(ctx.finalize().as_slice(), &hex!("03de3b295dcfc3b25b05abb09bc95fe3e9ff3073638badc68101d1e42019d0771dd07525a3aae8318e92c5e5d967ba92e4810d0021d7bf3b49da0b4b4a8a4e1f")[..]);
23+
}

0 commit comments

Comments
 (0)