diff options
author | Daniel Schadt <kingdread@gmx.de> | 2025-07-12 17:02:56 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2025-07-12 17:02:56 +0200 |
commit | b43c8ea324fcf484191b7fcf097b1b0dd6234c1d (patch) | |
tree | bdbeffc2e0760dfbdc537f0dda629086a0513c88 /src/lib.rs | |
parent | 749a79d9325a1242c9e7246352ee1930a7d5eb70 (diff) | |
download | zears-b43c8ea324fcf484191b7fcf097b1b0dd6234c1d.tar.gz zears-b43c8ea324fcf484191b7fcf097b1b0dd6234c1d.tar.bz2 zears-b43c8ea324fcf484191b7fcf097b1b0dd6234c1d.zip |
manually implement addition-by-one
The int conversion is quite costly, so this is a lot faster (especially
in the non-simd build).
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -705,17 +705,17 @@ fn aez_hash(aez: &Aez, tweaks: Tweak) -> Block { /// XOR's the result of aez_prf into the given buffer fn aez_prf(aez: &Aez, tweaks: Tweak, buffer: &mut [u8]) { - let mut index = 0u128; + let mut index = Block::null(); let delta = aez_hash(aez, tweaks); for chunk in buffer.chunks_exact_mut(16) { let chunk: &mut [u8; 16] = chunk.try_into().unwrap(); - let block = e(-1, 3, aez, delta ^ Block::from_int(index)); + let block = e(-1, 3, aez, delta ^ index); (block ^ Block::from(*chunk)).write_to(chunk); - index += 1; + index.count_up(); } let suffix_start = buffer.len() - buffer.len() % 16; let chunk = &mut buffer[suffix_start..]; - let block = e(-1, 3, aez, delta ^ Block::from_int(index)); + let block = e(-1, 3, aez, delta ^ index); for (a, b) in chunk.iter_mut().zip(block.bytes().iter()) { *a ^= *b; } |