From 2a077ca2f12923a89cc270bab5853efd9db0afc0 Mon Sep 17 00:00:00 2001 From: James Zhang Date: Fri, 11 Oct 2024 16:20:13 -0700 Subject: [PATCH] Allow len < 16 for aes256-gcm encryption --- src/aes256.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/aes256.c b/src/aes256.c index dcf716d6..0e4a34dd 100644 --- a/src/aes256.c +++ b/src/aes256.c @@ -128,7 +128,11 @@ aes256_gcm(const fido_blob_t *key, const fido_blob_t *nonce, nonce->len, key->len, aad->len); goto fail; } - if (in->len > UINT_MAX || in->len > SIZE_MAX - 16 || in->len < 16) { + if (in->len > UINT_MAX || in->len > SIZE_MAX - 16) { + fido_log_debug("%s: invalid input len %zu", __func__, in->len); + goto fail; + } + if (!encrypt && in->len < 16) { fido_log_debug("%s: invalid input len %zu", __func__, in->len); goto fail; }