[PATCH 2/7] cipher-cmac: fix CMAC block-count truncation for 64 GiB writes
Jussi Kivilinna
jussi.kivilinna at iki.fi
Fri Jul 24 20:48:01 CEST 2026
* 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 <Jeremy.Jean at ssi.gouv.fr>
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
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
More information about the Gcrypt-devel
mailing list