Skip to content

Commit

Permalink
Switch from encyrption to decryption in loop
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Kaitchuck <[email protected]>
  • Loading branch information
tkaitchuck committed Oct 23, 2023
1 parent 22ae115 commit 60ed4f3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/aes_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ impl AHasher {

#[inline(always)]
fn hash_in(&mut self, new_value: u128) {
self.enc = aesenc(self.enc, new_value);
self.enc = aesdec(self.enc, new_value);
self.sum = shuffle_and_add(self.sum, new_value);
}

#[inline(always)]
fn hash_in_2(&mut self, v1: u128, v2: u128) {
self.enc = aesenc(self.enc, v1);
self.enc = aesdec(self.enc, v1);
self.sum = shuffle_and_add(self.sum, v1);
self.enc = aesenc(self.enc, v2);
self.enc = aesdec(self.enc, v2);
self.sum = shuffle_and_add(self.sum, v2);
}

Expand Down Expand Up @@ -174,10 +174,10 @@ impl Hasher for AHasher {
sum[1] = shuffle_and_add(sum[1], tail[3]);
while data.len() > 64 {
let (blocks, rest) = data.read_u128x4();
current[0] = aesenc(current[0], blocks[0]);
current[1] = aesenc(current[1], blocks[1]);
current[2] = aesenc(current[2], blocks[2]);
current[3] = aesenc(current[3], blocks[3]);
current[0] = aesdec(current[0], blocks[0]);
current[1] = aesdec(current[1], blocks[1]);
current[2] = aesdec(current[2], blocks[2]);
current[3] = aesdec(current[3], blocks[3]);
sum[0] = shuffle_and_add(sum[0], blocks[0]);
sum[1] = shuffle_and_add(sum[1], blocks[1]);
sum[0] = shuffle_and_add(sum[0], blocks[2]);
Expand Down

0 comments on commit 60ed4f3

Please sign in to comment.