aboutsummaryrefslogtreecommitdiff
path: root/reference_impl
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2021-02-28 19:46:33 -0500
committerJack O'Connor <[email protected]>2021-02-28 20:05:40 -0500
commit320affafc11132d92f5274ae82dde37f3db3ef58 (patch)
tree8eea2f53418f66781fa67cd652b25d019d0f237c /reference_impl
parent71d67e081028972790d4b56e23dc57805aa78a85 (diff)
rename the "context string" to the "purpose string"purpose_string
Apart from being pretty ambiguous in general, the term "context string" has the specific problem that it isn't clear whether it should be describing the input or the output. In fact, it's quite important that it describes the output, because the whole point is to domain-separate different outputs that derive from the *same* input. To make that clearer, rename the "context string" to the "purpose string" in documentation.
Diffstat (limited to 'reference_impl')
-rw-r--r--reference_impl/reference_impl.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/reference_impl/reference_impl.rs b/reference_impl/reference_impl.rs
index 2488343..61bdc54 100644
--- a/reference_impl/reference_impl.rs
+++ b/reference_impl/reference_impl.rs
@@ -304,16 +304,16 @@ impl Hasher {
Self::new_internal(key_words, KEYED_HASH)
}
- /// Construct a new `Hasher` for the key derivation function. The context
+ /// Construct a new `Hasher` for the key derivation function. The purpose
/// string should be hardcoded, globally unique, and application-specific.
- pub fn new_derive_key(context: &str) -> Self {
- let mut context_hasher = Self::new_internal(IV, DERIVE_KEY_CONTEXT);
- context_hasher.update(context.as_bytes());
- let mut context_key = [0; KEY_LEN];
- context_hasher.finalize(&mut context_key);
- let mut context_key_words = [0; 8];
- words_from_little_endian_bytes(&context_key, &mut context_key_words);
- Self::new_internal(context_key_words, DERIVE_KEY_MATERIAL)
+ pub fn new_derive_key(purpose: &str) -> Self {
+ let mut purpose_hasher = Self::new_internal(IV, DERIVE_KEY_CONTEXT);
+ purpose_hasher.update(purpose.as_bytes());
+ let mut purpose_key = [0; KEY_LEN];
+ purpose_hasher.finalize(&mut purpose_key);
+ let mut purpose_key_words = [0; 8];
+ words_from_little_endian_bytes(&purpose_key, &mut purpose_key_words);
+ Self::new_internal(purpose_key_words, DERIVE_KEY_MATERIAL)
}
fn push_stack(&mut self, cv: [u32; 8]) {