[PATCH 2/7] cipher-cmac: fix CMAC block-count truncation for 64 GiB writes
Jussi Kivilinna <[email protected]> Fri, 24 Jul 2026 21:48:01 +0300
| Newsgroups | gmane.comp.encryption.gpg.libgcrypt.devel |
|---|---|
| Message-ID | <[email protected]> |
* cipher/cipher-cmac.c (_gcry_cmac_write): Use size_t for nblocks. -- _gcry_cmac_write derived number of complete blocks from size_t input length but stored it in unsigned int. On 64-bit build, single write of 64 GiB or more truncated block count given to bulk CBC routine, and pointer and length updates used same truncated count. Resulting CMAC covered wrong data and gave wrong tag. Reported-by: JEAN Jeremy <[email protected]> Signed-off-by: Jussi Kivilinna <[email protected]> --- cipher/cipher-cmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cipher/cipher-cmac.c b/cipher/cipher-cmac.c index 4efd1e19..c8bedc08 100644 --- a/cipher/cipher-cmac.c +++ b/cipher/cipher-cmac.c @@ -42,7 +42,7 @@ _gcry_cmac_write (gcry_cipher_hd_t c, gcry_cmac_context_t *ctx, size_t blocksize = 1 << blocksize_shift; byte outbuf[MAX_BLOCKSIZE]; unsigned int burn = 0; - unsigned int nblocks; + size_t nblocks; size_t n; if (ctx->tag) -- 2.53.0