authorgravatar for erik@erisc.seErik Schlyter <erik@erisc.se> 2025-08-12 12:40:49+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-13 09:00:57+02:00
log7abd62800cde3f42c0ef65126ed478a0c3d3d549
tree6a24bb1a43921e899631f65e7a84850ff9728492
parent113d3dd3f0ff38d9ad870fa7b20de6fe601c6cb3

std.crypto.aegis: Absorb ad instead of encrypting it.

`Aegis256XGeneric` behaves differently than `Aegis128XGeneric` in that it currently encrypts associated data instead of just absorbing it. Even though the end result is the same, there's no point in encrypting and copying the ad into a buffer that gets overwritten anyway. This fix makes `Aegis256XGeneric` behave the same as `Aegis128XGeneric`.

1 files changed, 2 insertions(+), 2 deletions(-)

lib/std/crypto/aegis.zig+2-2
......@@ -585,12 +585,12 @@ fn Aegis256XGeneric(comptime degree: u7, comptime tag_bits: u9) type {
585585 var dst: [block_length]u8 align(alignment) = undefined;
586586 var i: usize = 0;
587587 while (i + block_length <= ad.len) : (i += block_length) {
588 state.enc(&dst, ad[i..][0..block_length]);
588 state.absorb(ad[i..][0..block_length]);
589589 }
590590 if (ad.len % block_length != 0) {
591591 @memset(src[0..], 0);
592592 @memcpy(src[0 .. ad.len % block_length], ad[i..][0 .. ad.len % block_length]);
593 state.enc(&dst, &src);
593 state.absorb(&src);
594594 }
595595 i = 0;
596596 while (i + block_length <= m.len) : (i += block_length) {