aboutsummaryrefslogtreecommitdiff
path: root/b3sum/tests
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2019-12-27 16:20:38 -0600
committerJack O'Connor <[email protected]>2019-12-28 17:56:29 -0600
commit2fac7447e02aa0f532ebcacbfffc71565b691aea (patch)
treeb8819de7a86b79a41b9104e616418c8cee35d8e2 /b3sum/tests
parentba2806496360aa61cc2aa64204a39d923cb13895 (diff)
make derive_key take a key of any length
The previous version of this API called for a key of exactly 256 bits. That's good for optimal performance, but it would mean losing the use-with-other-algorithms property for applications whose input keys are a different size. There's no way for an abstraction over the previous version to provide reliable domain separation for the "extract" step.
Diffstat (limited to 'b3sum/tests')
-rw-r--r--b3sum/tests/test.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/b3sum/tests/test.rs b/b3sum/tests/test.rs
index a74a1f1..8f2e623 100644
--- a/b3sum/tests/test.rs
+++ b/b3sum/tests/test.rs
@@ -72,13 +72,14 @@ fn test_keyed() {
#[test]
fn test_derive_key() {
- let key = [99; blake3::KEY_LEN];
+ let context = "BLAKE3 2019-12-28 10:28:41 example context";
let f = tempfile::NamedTempFile::new().unwrap();
- f.as_file().write_all(b"context").unwrap();
+ f.as_file().write_all(b"key material").unwrap();
f.as_file().flush().unwrap();
- let expected = hex::encode(blake3::derive_key(&key, b"context"));
- let output = cmd!(b3sum_exe(), "--derive-key", "--no-names", f.path())
- .stdin_bytes(&key[..])
+ let mut derive_key_out = [0; blake3::OUT_LEN];
+ blake3::derive_key(context, b"key material", &mut derive_key_out);
+ let expected = hex::encode(&derive_key_out);
+ let output = cmd!(b3sum_exe(), "--derive-key", context, "--no-names", f.path())
.read()
.unwrap();
assert_eq!(&*expected, &*output);