Skip to content

Commit 22ff0b7

Browse files
authored
Merge pull request #148 from RustCrypto/rename-result-to-finalize
Rename `*result*` to `finalize`
2 parents 347f13f + d749cb0 commit 22ff0b7

46 files changed

Lines changed: 95 additions & 96 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blake2/examples/blake2b_sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn process<D: Digest + Default, R: Read>(reader: &mut R, name: &str) {
2828
break;
2929
}
3030
}
31-
print_result(&sh.result(), name);
31+
print_result(&sh.finalize(), name);
3232
}
3333

3434
fn main() {

blake2/examples/blake2s_sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn process<D: Digest + Default, R: Read>(reader: &mut R, name: &str) {
2828
break;
2929
}
3030
}
31-
print_result(&sh.result(), name);
31+
print_result(&sh.finalize(), name);
3232
}
3333

3434
fn main() {

blake2/src/blake2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ macro_rules! blake2_impl {
290290
self.n
291291
}
292292

293-
fn variable_result<F: FnOnce(&[u8])>(self, f: F) {
293+
fn finalize_variable<F: FnOnce(&[u8])>(self, f: F) {
294294
let n = self.n;
295295
let res = self.finalize_with_flag(0);
296296
f(&res[..n]);
@@ -343,7 +343,7 @@ macro_rules! blake2_impl {
343343
impl FixedOutput for $fix_state {
344344
type OutputSize = $bytes;
345345

346-
fn fixed_result(self) -> Output {
346+
fn finalize_fixed(self) -> Output {
347347
self.state.finalize_with_flag(0)
348348
}
349349
}
@@ -381,7 +381,7 @@ macro_rules! blake2_impl {
381381
<Self as Reset>::reset(self)
382382
}
383383

384-
fn result(self) -> crypto_mac::Output<Self> {
384+
fn finalize(self) -> crypto_mac::Output<Self> {
385385
crypto_mac::Output::new(self.state.finalize_with_flag(0))
386386
}
387387
}

blake2/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! hasher.update(b"hello world");
1616
//!
1717
//! // read hash digest and consume hasher
18-
//! let res = hasher.result();
18+
//! let res = hasher.finalize();
1919
//! assert_eq!(res[..], hex!("
2020
//! 021ced8799296ceca557832ab941a50b4a11f83478cf141f51f933f653ab9fbc
2121
//! c05a037cddbed06e309bf334942c4e58cdf1a46e237911ccd7fcf9787cbc7fd0
@@ -24,7 +24,7 @@
2424
//! // same example for `Blake2s`:
2525
//! let mut hasher = Blake2s::new();
2626
//! hasher.update(b"hello world");
27-
//! let res = hasher.result();
27+
//! let res = hasher.finalize();
2828
//! assert_eq!(res[..], hex!("
2929
//! 9aec6806794561107e594b1f6a8a6b0c92a0cba9acf5e5e93cca06f781813b0b
3030
//! ")[..]);
@@ -44,7 +44,7 @@
4444
//!
4545
//! let mut hasher = VarBlake2b::new(10).unwrap();
4646
//! hasher.update(b"my_input");
47-
//! hasher.variable_result(|res| {
47+
//! hasher.finalize_variable(|res| {
4848
//! assert_eq!(res, [44, 197, 92, 132, 228, 22, 146, 78, 100, 0])
4949
//! })
5050
//! ```
@@ -62,7 +62,7 @@
6262
//!
6363
//! // `result` has type `crypto_mac::Output` which is a thin wrapper around
6464
//! // a byte array and provides a constant time equality check
65-
//! let result = hasher.result();
65+
//! let result = hasher.finalize();
6666
//! // To get underlying array use the `into_bytes` method, but be careful,
6767
//! // since incorrect use of the code value may permit timing attacks which
6868
//! // defeat the security provided by the `crypto_mac::Output`

blake2/tests/persona.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn blake2s_persona() {
88
let persona_bytes = persona.as_bytes();
99
let ctx = Blake2s::with_params(&key_bytes, &[], persona_bytes);
1010
assert_eq!(
11-
ctx.result().as_slice(),
11+
ctx.finalize().as_slice(),
1212
&hex!("25a4ee63b594aed3f88a971e1877ef7099534f9097291f88fb86c79b5e70d022")[..]
1313
);
1414
}
@@ -19,5 +19,5 @@ fn blake2b_persona() {
1919
let persona = "personal";
2020
let persona_bytes = persona.as_bytes();
2121
let ctx = Blake2b::with_params(&key_bytes, &[], persona_bytes);
22-
assert_eq!(ctx.result().as_slice(), &hex!("03de3b295dcfc3b25b05abb09bc95fe3e9ff3073638badc68101d1e42019d0771dd07525a3aae8318e92c5e5d967ba92e4810d0021d7bf3b49da0b4b4a8a4e1f")[..]);
22+
assert_eq!(ctx.finalize().as_slice(), &hex!("03de3b295dcfc3b25b05abb09bc95fe3e9ff3073638badc68101d1e42019d0771dd07525a3aae8318e92c5e5d967ba92e4810d0021d7bf3b49da0b4b4a8a4e1f")[..]);
2323
}

gost94/examples/gost94_cryptopro_sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn process<D: Digest + Default, R: Read>(reader: &mut R, name: &str) {
2828
break;
2929
}
3030
}
31-
print_result(&sh.result(), name);
31+
print_result(&sh.finalize(), name);
3232
}
3333

3434
fn main() {

gost94/examples/gost94_test_sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn process<D: Digest + Default, R: Read>(reader: &mut R, name: &str) {
2828
break;
2929
}
3030
}
31-
print_result(&sh.result(), name);
31+
print_result(&sh.finalize(), name);
3232
}
3333

3434
fn main() {

gost94/src/gost94.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl Update for Gost94 {
241241
impl FixedOutput for Gost94 {
242242
type OutputSize = U32;
243243

244-
fn fixed_result(mut self) -> GenericArray<u8, U32> {
244+
fn finalize_fixed(mut self) -> GenericArray<u8, U32> {
245245
{
246246
let self_state = &mut self.state;
247247

gost94/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//!
1515
//! // acquire hash digest in the form of GenericArray,
1616
//! // which in this case is equivalent to [u8; 32]
17-
//! let result = hasher.result();
17+
//! let result = hasher.finalize();
1818
//! assert_eq!(result[..], hex!("
1919
//! 1bb6ce69d2e895a78489c87a0712a2f40258d1fae3a4666c23f8f487bef0e22a
2020
//! "));

0 commit comments

Comments
 (0)