aboutsummaryrefslogtreecommitdiff
path: root/c/blake3.c
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 /c/blake3.c
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 'c/blake3.c')
-rw-r--r--c/blake3.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/c/blake3.c b/c/blake3.c
index 9998f75..19f6b5c 100644
--- a/c/blake3.c
+++ b/c/blake3.c
@@ -369,20 +369,20 @@ void blake3_hasher_init_keyed(blake3_hasher *self,
hasher_init_base(self, key_words, KEYED_HASH);
}
-void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *context,
- size_t context_len) {
- blake3_hasher context_hasher;
- hasher_init_base(&context_hasher, IV, DERIVE_KEY_CONTEXT);
- blake3_hasher_update(&context_hasher, context, context_len);
- uint8_t context_key[BLAKE3_KEY_LEN];
- blake3_hasher_finalize(&context_hasher, context_key, BLAKE3_KEY_LEN);
- uint32_t context_key_words[8];
- load_key_words(context_key, context_key_words);
- hasher_init_base(self, context_key_words, DERIVE_KEY_MATERIAL);
+void blake3_hasher_init_derive_key_raw(blake3_hasher *self, const void *purpose,
+ size_t purpose_len) {
+ blake3_hasher purpose_hasher;
+ hasher_init_base(&purpose_hasher, IV, DERIVE_KEY_CONTEXT);
+ blake3_hasher_update(&purpose_hasher, purpose, purpose_len);
+ uint8_t purpose_key[BLAKE3_KEY_LEN];
+ blake3_hasher_finalize(&purpose_hasher, purpose_key, BLAKE3_KEY_LEN);
+ uint32_t purpose_key_words[8];
+ load_key_words(purpose_key, purpose_key_words);
+ hasher_init_base(self, purpose_key_words, DERIVE_KEY_MATERIAL);
}
-void blake3_hasher_init_derive_key(blake3_hasher *self, const char *context) {
- blake3_hasher_init_derive_key_raw(self, context, strlen(context));
+void blake3_hasher_init_derive_key(blake3_hasher *self, const char *purpose) {
+ blake3_hasher_init_derive_key_raw(self, purpose, strlen(purpose));
}
// As described in hasher_push_cv() below, we do "lazy merging", delaying