Skip to content

Commit

Permalink
Fix two problems with the short_finish
Browse files Browse the repository at this point in the history
* 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 <Tom.Kaitchuck@gmail.com>
  • Loading branch information
tkaitchuck committed Mar 29, 2024
1 parent 98ee5b2 commit 6e5bfa6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/aes_hash.rs
Expand Up @@ -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]
Expand Down

0 comments on commit 6e5bfa6

Please sign in to comment.