crypto.AesGcm: provision ghash for the final block

This commit is contained in:
Frank Denis 2022-11-11 18:04:22 +01:00
parent 4f285d4dac
commit df7223c7f2

View File

@ -35,7 +35,7 @@ fn AesGcm(comptime Aes: anytype) type {
mem.writeIntBig(u32, j[nonce_length..][0..4], 1);
aes.encrypt(&t, &j);
const block_count = (math.divCeil(usize, ad.len, Ghash.block_length) catch unreachable) + (math.divCeil(usize, c.len, Ghash.block_length) catch unreachable);
const block_count = (math.divCeil(usize, ad.len, Ghash.block_length) catch unreachable) + (math.divCeil(usize, c.len, Ghash.block_length) catch unreachable) + 1;
var mac = Ghash.initForBlockCount(&h, block_count);
mac.update(ad);
mac.pad();