Commit
+5 -5 +/-1 browse
1 | diff --git a/src/common/crypto/ring_impls.rs b/src/common/crypto/ring_impls.rs |
2 | index 7c454b6..284bf1c 100644 |
3 | --- a/src/common/crypto/ring_impls.rs |
4 | +++ b/src/common/crypto/ring_impls.rs |
5 | @@ -120,9 +120,9 @@ impl SigningKey for Ed25519Key { |
6 | type Hasher = Sha256; |
7 | |
8 | fn sign(&self, input: impl Writable) -> Result<Vec<u8>> { |
9 | - let mut data = Vec::with_capacity(256); |
10 | + let mut data = Sha256::hasher(); |
11 | input.write(&mut data); |
12 | - Ok(self.inner.sign(&data).as_ref().to_vec()) |
13 | + Ok(self.inner.sign(data.complete().as_ref()).as_ref().to_vec()) |
14 | } |
15 | |
16 | fn algorithm(&self) -> Algorithm { |
17 | @@ -250,10 +250,10 @@ impl VerifyingKey for Ed25519PublicKey { |
18 | return Err(Error::IncompatibleAlgorithms); |
19 | } |
20 | |
21 | - let mut data = Vec::with_capacity(256); |
22 | - canonicalization.canonicalize_headers(headers, &mut data); |
23 | + let mut hasher = Sha256::hasher(); |
24 | + canonicalization.canonicalize_headers(headers, &mut hasher); |
25 | self.inner |
26 | - .verify(&data, signature) |
27 | + .verify(hasher.complete().as_ref(), signature) |
28 | .map_err(|err| Error::CryptoError(err.to_string())) |
29 | } |
30 | } |