aboutsummaryrefslogtreecommitdiff
path: root/c/blake3_c_rust_bindings
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_rust_bindings
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_rust_bindings')
-rw-r--r--c/blake3_c_rust_bindings/src/lib.rs18
-rw-r--r--c/blake3_c_rust_bindings/src/test.rs8
2 files changed, 13 insertions, 13 deletions
diff --git a/c/blake3_c_rust_bindings/src/lib.rs b/c/blake3_c_rust_bindings/src/lib.rs
index f18fe12..cad093d 100644
--- a/c/blake3_c_rust_bindings/src/lib.rs
+++ b/c/blake3_c_rust_bindings/src/lib.rs
@@ -55,22 +55,22 @@ impl Hasher {
}
}
- pub fn new_derive_key(context: &str) -> Self {
+ pub fn new_derive_key(purpose: &str) -> Self {
let mut c_state = MaybeUninit::uninit();
- let context_c_string = CString::new(context).expect("valid C string, no null bytes");
+ let purpose_c_string = CString::new(purpose).expect("valid C string, no null bytes");
unsafe {
- ffi::blake3_hasher_init_derive_key(c_state.as_mut_ptr(), context_c_string.as_ptr());
+ ffi::blake3_hasher_init_derive_key(c_state.as_mut_ptr(), purpose_c_string.as_ptr());
Self(c_state.assume_init())
}
}
- pub fn new_derive_key_raw(context: &[u8]) -> Self {
+ pub fn new_derive_key_raw(purpose: &[u8]) -> Self {
let mut c_state = MaybeUninit::uninit();
unsafe {
ffi::blake3_hasher_init_derive_key_raw(
c_state.as_mut_ptr(),
- context.as_ptr() as *const _,
- context.len(),
+ purpose.as_ptr() as *const _,
+ purpose.len(),
);
Self(c_state.assume_init())
}
@@ -122,12 +122,12 @@ pub mod ffi {
pub fn blake3_hasher_init_keyed(self_: *mut blake3_hasher, key: *const u8);
pub fn blake3_hasher_init_derive_key(
self_: *mut blake3_hasher,
- context: *const ::std::os::raw::c_char,
+ purpose: *const ::std::os::raw::c_char,
);
pub fn blake3_hasher_init_derive_key_raw(
self_: *mut blake3_hasher,
- context: *const ::std::os::raw::c_void,
- context_len: usize,
+ purpose: *const ::std::os::raw::c_void,
+ purpose_len: usize,
);
pub fn blake3_hasher_update(
self_: *mut blake3_hasher,
diff --git a/c/blake3_c_rust_bindings/src/test.rs b/c/blake3_c_rust_bindings/src/test.rs
index b989ae9..81b3abe 100644
--- a/c/blake3_c_rust_bindings/src/test.rs
+++ b/c/blake3_c_rust_bindings/src/test.rs
@@ -390,21 +390,21 @@ fn test_compare_reference_impl() {
// derive_key
{
- let context = "BLAKE3 2019-12-27 16:13:59 example context (not the test vector one)";
- let mut reference_hasher = reference_impl::Hasher::new_derive_key(context);
+ let purpose = "BLAKE3 2019-12-27 16:13:59 example context (not the test vector one)";
+ let mut reference_hasher = reference_impl::Hasher::new_derive_key(purpose);
reference_hasher.update(input);
let mut expected_out = [0; OUT];
reference_hasher.finalize(&mut expected_out);
// the regular C string API
- let mut test_hasher = crate::Hasher::new_derive_key(context);
+ let mut test_hasher = crate::Hasher::new_derive_key(purpose);
test_hasher.update(input);
let mut test_out = [0; OUT];
test_hasher.finalize(&mut test_out);
assert_eq!(test_out[..], expected_out[..]);
// the raw bytes API
- let mut test_hasher_raw = crate::Hasher::new_derive_key_raw(context.as_bytes());
+ let mut test_hasher_raw = crate::Hasher::new_derive_key_raw(purpose.as_bytes());
test_hasher_raw.update(input);
let mut test_out_raw = [0; OUT];
test_hasher_raw.finalize(&mut test_out_raw);