From 6e5bfa65d21d64591d4fe8f285d311abf20a344b Mon Sep 17 00:00:00 2001 From: Tom Kaitchuck Date: Fri, 29 Mar 2024 00:39:56 -0700 Subject: [PATCH] Fix two problems with the short_finish * If on ARM where the xor happens first the same value cannot be used for both parameters. * XOR the two halfs of the output to avoid the possibility that two bit diffs can cancel Signed-off-by: Tom Kaitchuck --- src/aes_hash.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aes_hash.rs b/src/aes_hash.rs index 39fd40f..66cd3d1 100644 --- a/src/aes_hash.rs +++ b/src/aes_hash.rs @@ -97,9 +97,9 @@ impl AHasher { #[inline] #[cfg(feature = "specialize")] fn short_finish(&self) -> u64 { - let combined = aesenc(self.sum, self.enc); - let result: [u64; 2] = aesdec(combined, combined).convert(); - result[0] + let combined = aesdec(self.enc, self.sum); + let result: [u64; 2] = aesdec(combined, self.key).convert(); + result[0] ^ result[1] } #[inline]