Skip to content

Commit

Permalink
Simplify logic for long strings
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
  • Loading branch information
tkaitchuck committed Oct 20, 2023
1 parent f9acd50 commit 082d440
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/aes_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ impl Hasher for AHasher {
current[2] = aesenc(current[2], tail[2]);
current[3] = aesenc(current[3], tail[3]);
let mut sum: [u128; 2] = [self.key, self.key];
sum[0] = add_by_64s(sum[0].convert(), tail[0].convert()).convert();
sum[1] = add_by_64s(sum[1].convert(), tail[1].convert()).convert();
sum[0] = shuffle_and_add(sum[0], tail[0]);
sum[1] = shuffle_and_add(sum[1], tail[1]);
sum[0] = shuffle_and_add(sum[0], tail[2]);
sum[1] = shuffle_and_add(sum[1], tail[3]);
while data.len() > 64 {
Expand All @@ -184,8 +184,12 @@ impl Hasher for AHasher {
sum[1] = shuffle_and_add(sum[1], blocks[3]);
data = rest;
}
self.hash_in_2(aesenc(current[0], current[1]), aesenc(current[2], current[3]));
self.hash_in(add_by_64s(sum[0].convert(), sum[1].convert()).convert());
self.enc = aesenc(self.enc, current[0]);
self.enc = aesenc(self.enc, current[1]);
self.enc = aesenc(self.enc, current[2]);
self.enc = aesenc(self.enc, current[3]);
self.sum = shuffle_and_add(self.sum, sum[0]);
self.sum = shuffle_and_add(self.sum, sum[1]);
} else {
//len 33-64
let (head, _) = data.read_u128x2();
Expand Down
Empty file added tests/attack.rs
Empty file.

0 comments on commit 082d440

Please sign in to comment.