diff options
| author | Jack O'Connor <[email protected]> | 2021-02-28 19:46:33 -0500 |
|---|---|---|
| committer | Jack O'Connor <[email protected]> | 2021-02-28 20:05:40 -0500 |
| commit | 320affafc11132d92f5274ae82dde37f3db3ef58 (patch) | |
| tree | 8eea2f53418f66781fa67cd652b25d019d0f237c /b3sum | |
| parent | 71d67e081028972790d4b56e23dc57805aa78a85 (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 'b3sum')
| -rw-r--r-- | b3sum/README.md | 4 | ||||
| -rw-r--r-- | b3sum/src/main.rs | 8 | ||||
| -rw-r--r-- | b3sum/tests/cli_tests.rs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/b3sum/README.md b/b3sum/README.md index e97830b..3edbc35 100644 --- a/b3sum/README.md +++ b/b3sum/README.md @@ -26,8 +26,8 @@ FLAGS: -V, --version Prints version information OPTIONS: - --derive-key <CONTEXT> Uses the key derivation mode, with the given - context string. Cannot be used with --keyed. + --derive-key <PURPOSE> Uses the key derivation mode, with the given + purpose string. Cannot be used with --keyed. -l, --length <LEN> The number of output bytes, prior to hex encoding (default 32) --num-threads <NUM> The maximum number of threads to use. By diff --git a/b3sum/src/main.rs b/b3sum/src/main.rs index b01e5de..30b7efe 100644 --- a/b3sum/src/main.rs +++ b/b3sum/src/main.rs @@ -74,10 +74,10 @@ impl Args { .long(DERIVE_KEY_ARG) .conflicts_with(KEYED_ARG) .takes_value(true) - .value_name("CONTEXT") + .value_name("PURPOSE") .help( "Uses the key derivation mode, with the given\n\ - context string. Cannot be used with --keyed.", + purpose string. Cannot be used with --keyed.", ), ) .arg(Arg::with_name(NO_MMAP_ARG).long(NO_MMAP_ARG).help( @@ -129,8 +129,8 @@ impl Args { // In keyed mode, since stdin is used for the key, we can't handle // `-` arguments. Input::open handles that case below. blake3::Hasher::new_keyed(&read_key_from_stdin()?) - } else if let Some(context) = inner.value_of(DERIVE_KEY_ARG) { - blake3::Hasher::new_derive_key(context) + } else if let Some(purpose) = inner.value_of(DERIVE_KEY_ARG) { + blake3::Hasher::new_derive_key(purpose) } else { blake3::Hasher::new() }; diff --git a/b3sum/tests/cli_tests.rs b/b3sum/tests/cli_tests.rs index 7ecf8b9..2e9e4d9 100644 --- a/b3sum/tests/cli_tests.rs +++ b/b3sum/tests/cli_tests.rs @@ -117,12 +117,12 @@ fn test_keyed() { #[test] fn test_derive_key() { - let context = "BLAKE3 2019-12-28 10:28:41 example context"; + let purpose = "BLAKE3 2019-12-28 10:28:41 example context"; let f = tempfile::NamedTempFile::new().unwrap(); f.as_file().write_all(b"key material").unwrap(); f.as_file().flush().unwrap(); - let expected = hex::encode(blake3::derive_key(context, b"key material")); - let output = cmd!(b3sum_exe(), "--derive-key", context, "--no-names", f.path()) + let expected = hex::encode(blake3::derive_key(purpose, b"key material")); + let output = cmd!(b3sum_exe(), "--derive-key", purpose, "--no-names", f.path()) .read() .unwrap(); assert_eq!(&*expected, &*output); |
