aboutsummaryrefslogtreecommitdiff
path: root/src/test.rs
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2020-02-12 10:22:54 -0500
committerJack O'Connor <[email protected]>2020-02-12 10:22:54 -0500
commit1c5d4eea6a93f241bfd2b3eb4d5c525444766045 (patch)
tree6882a0b0acd95115958ca2c20862ba7d5fe6dc58 /src/test.rs
parente0dc4d932ed81a985a1793251b5f61a3227d2dac (diff)
test a couple more reset() cases
Diffstat (limited to 'src/test.rs')
-rw-r--r--src/test.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test.rs b/src/test.rs
index b8e5ce3..5a2b480 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -469,6 +469,25 @@ fn test_reset() {
hasher.reset();
hasher.update(&[42; CHUNK_LEN + 3]);
assert_eq!(hasher.finalize(), crate::hash(&[42; CHUNK_LEN + 3]));
+
+ let key = &[99; crate::KEY_LEN];
+ let mut keyed_hasher = crate::Hasher::new_keyed(key);
+ keyed_hasher.update(&[42; 3 * CHUNK_LEN + 7]);
+ keyed_hasher.reset();
+ keyed_hasher.update(&[42; CHUNK_LEN + 3]);
+ assert_eq!(
+ keyed_hasher.finalize(),
+ crate::keyed_hash(key, &[42; CHUNK_LEN + 3]),
+ );
+
+ let context = "BLAKE3 2020-02-12 10:20:58 reset test";
+ let mut kdf = crate::Hasher::new_derive_key(context);
+ kdf.update(&[42; 3 * CHUNK_LEN + 7]);
+ kdf.reset();
+ kdf.update(&[42; CHUNK_LEN + 3]);
+ let mut expected = [0; crate::OUT_LEN];
+ crate::derive_key(context, &[42; CHUNK_LEN + 3], &mut expected);
+ assert_eq!(kdf.finalize(), expected);
}
#[test]