authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2023-05-17 01:51:47+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-05-16 23:51:47+00:00
logc6966486e3d33054f1dfc822704dc48c62466d54
tree98561fabc4bbd1451e6baade34ee81f570055bb4
parentc269e16c3b10afe24856f3ed788479afa34587ed
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

crypto.AegisMac: fix a regression from s/mem.copy/@memcpy/ (#15733)

In an update whose size is not a multiple of the block size, we would end up calling @memcpy() with arguments of different sizes.

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

lib/std/crypto/aegis.zig+7-1
......@@ -470,8 +470,8 @@ fn AegisMac(comptime T: type) type {
470470 self.state.absorb(b[i..][0..block_length]);
471471 }
472472 if (i != b.len) {
473 @memcpy(self.buf[0..], b[i..]);
474473 self.off = b.len - i;
474 @memcpy(self.buf[0..self.off], b[i..]);
475475 }
476476 }
477477
......@@ -653,4 +653,10 @@ test "Aegis MAC" {
653653 const nonce = [_]u8{0x00} ** Aegis128L_256.nonce_length;
654654 Aegis128L_256.encrypt(&empty, &tag, &empty, &msg, nonce, key);
655655 try htest.assertEqual("f8840849602738d81037cbaa0f584ea95759e2ac60263ce77346bcdc79fe4319", &tag);
656
657 // An update whose size is not a multiple of the block size
658 st = st_init;
659 st.update(msg[0..33]);
660 st.final(&tag);
661 try htest.assertEqual("c7cf649a844c1a6676cf6d91b1658e0aee54a4da330b0a8d3bc7ea4067551d1b", &tag);
656662}