Commit
Author: Dirkjan Ochtman [dirkjan@ochtman.nl]
Hash: dcbce2ebcab7ae11ddf1214e5cacfbfc9d42271c
Timestamp: Wed, 14 Dec 2022 16:39:51 +0000 (1 year ago)

+11 -11 +/-6 browse
Rename HashContext::finish() to avoid being shadowed by inherent impls
1diff --git a/src/arc/seal.rs b/src/arc/seal.rs
2index c61c245..038b147 100644
3--- a/src/arc/seal.rs
4+++ b/src/arc/seal.rs
5 @@ -74,7 +74,7 @@ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, Done> {
6 .duration_since(SystemTime::UNIX_EPOCH)
7 .map(|d| d.as_secs())
8 .unwrap_or(0);
9- set.signature.bh = base64_encode(body_hasher.finish().as_ref())?;
10+ set.signature.bh = base64_encode(body_hasher.complete().as_ref())?;
11 set.signature.t = now;
12 set.signature.x = if set.signature.x > 0 {
13 now + set.signature.x
14 @@ -90,7 +90,7 @@ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, Done> {
15 set.signature.write(&mut header_hasher, false);
16
17 // Sign
18- let b = self.key.sign(header_hasher.finish())?;
19+ let b = self.key.sign(header_hasher.complete())?;
20 set.signature.b = base64_encode(&b)?;
21
22 // Hash ARC chain
23 @@ -115,7 +115,7 @@ impl<T: SigningKey<Hasher = Sha256>> ArcSealer<T, Done> {
24 set.seal.write(&mut header_hasher, false);
25
26 // Seal
27- let b = self.key.sign(header_hasher.finish())?;
28+ let b = self.key.sign(header_hasher.complete())?;
29 set.seal.b = base64_encode(&b)?;
30
31 Ok(set)
32 diff --git a/src/common/base32.rs b/src/common/base32.rs
33index 3b270a7..0a24a60 100644
34--- a/src/common/base32.rs
35+++ b/src/common/base32.rs
36 @@ -93,7 +93,7 @@ mod tests {
37 let mut writer = Base32Writer::with_capacity(10);
38 let mut hash = Sha1::hasher();
39 hash.write(test.as_bytes());
40- writer.write(hash.finish().as_ref());
41+ writer.write(hash.complete().as_ref());
42 assert_eq!(writer.finalize(), expected_result);
43 }
44 }
45 diff --git a/src/common/crypto/mod.rs b/src/common/crypto/mod.rs
46index bfb494d..6c8693d 100644
47--- a/src/common/crypto/mod.rs
48+++ b/src/common/crypto/mod.rs
49 @@ -48,7 +48,7 @@ impl VerifyingKeyType {
50 }
51
52 pub trait HashContext: Writer + Sized {
53- fn finish(self) -> HashOutput;
54+ fn complete(self) -> HashOutput;
55 }
56
57 pub trait HashImpl {
58 diff --git a/src/common/crypto/rust_crypto.rs b/src/common/crypto/rust_crypto.rs
59index dd59436..178fb2d 100644
60--- a/src/common/crypto/rust_crypto.rs
61+++ b/src/common/crypto/rust_crypto.rs
62 @@ -219,13 +219,13 @@ impl HashImpl for Sha256 {
63 }
64
65 impl HashContext for sha1::Sha1 {
66- fn finish(self) -> HashOutput {
67+ fn complete(self) -> HashOutput {
68 HashOutput::Sha1(self.finalize())
69 }
70 }
71
72 impl HashContext for sha2::Sha256 {
73- fn finish(self) -> HashOutput {
74+ fn complete(self) -> HashOutput {
75 HashOutput::Sha256(self.finalize())
76 }
77 }
78 diff --git a/src/dkim/canonicalize.rs b/src/dkim/canonicalize.rs
79index 60ab372..16b6b4f 100644
80--- a/src/dkim/canonicalize.rs
81+++ b/src/dkim/canonicalize.rs
82 @@ -121,7 +121,7 @@ impl Canonicalization {
83 ) -> impl AsRef<[u8]> {
84 let mut hasher = T::hasher();
85 self.canonicalize_headers(headers, &mut hasher);
86- hasher.finish()
87+ hasher.complete()
88 }
89
90 pub fn hash_body<T: HashImpl>(&self, body: &[u8], l: u64) -> impl AsRef<[u8]> {
91 @@ -134,7 +134,7 @@ impl Canonicalization {
92 },
93 &mut hasher,
94 );
95- hasher.finish()
96+ hasher.complete()
97 }
98
99 pub fn serialize_name(&self, writer: &mut impl Writer) {
100 diff --git a/src/dkim/sign.rs b/src/dkim/sign.rs
101index 0e664b2..0cea162 100644
102--- a/src/dkim/sign.rs
103+++ b/src/dkim/sign.rs
104 @@ -46,7 +46,7 @@ impl<T: SigningKey> DkimSigner<T, Done> {
105
106 // Create Signature
107 let mut signature = self.template.clone();
108- signature.bh = base64_encode(&body_hasher.finish().as_ref())?;
109+ signature.bh = base64_encode(&body_hasher.complete().as_ref())?;
110 signature.t = now;
111 signature.x = if signature.x > 0 {
112 now + signature.x
113 @@ -62,7 +62,7 @@ impl<T: SigningKey> DkimSigner<T, Done> {
114 signature.write(&mut header_hasher, false);
115
116 // Sign
117- let b = self.key.sign(header_hasher.finish())?;
118+ let b = self.key.sign(header_hasher.complete())?;
119
120 // Encode
121 signature.b = base64_encode(&b)?;