diff options
| author | Jack O'Connor <[email protected]> | 2021-02-28 15:16:25 -0500 |
|---|---|---|
| committer | Jack O'Connor <[email protected]> | 2021-02-28 15:28:39 -0500 |
| commit | ece17deb7420c6db177f00a3a4a191cc4133443f (patch) | |
| tree | a4c82534e43aaf116796e23abd4b9edb46e2da04 /src/lib.rs | |
| parent | 0359065018e2bafa31d319010ec5cebc35ad4393 (diff) | |
EXPERIMENTAL: change derive_key() to use const genericsderive_key_array
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -841,11 +841,13 @@ pub fn keyed_hash(key: &[u8; KEY_LEN], input: &[u8]) -> Hash { /// [`Hasher::finalize_xof`]: struct.Hasher.html#method.finalize_xof /// [Argon2]: https://en.wikipedia.org/wiki/Argon2 /// [`Hasher::update_with_join`]: struct.Hasher.html#method.update_with_join -pub fn derive_key(context: &str, key_material: &[u8], output: &mut [u8]) { +pub fn derive_key<const N: usize>(context: &str, key_material: &[u8]) -> [u8; N] { let context_key = hash_all_at_once(context.as_bytes(), IV, DERIVE_KEY_CONTEXT).root_hash(); let context_key_words = platform::words_from_le_bytes_32(context_key.as_bytes()); let inner_output = hash_all_at_once(key_material, &context_key_words, DERIVE_KEY_MATERIAL); - OutputReader::new(inner_output).fill(output); + let mut ret = [0; N]; + OutputReader::new(inner_output).fill(&mut ret); + ret } fn parent_node_output( |
