ccm_finish: Only reject tag_len missmatch when it has been set.

Signed-off-by: Minos Galanakis <[email protected]>
This commit is contained in:
Minos Galanakis
2026-03-03 11:24:35 +00:00
parent 53ab8a525b
commit ee9829a32e
+5 -2
View File
@@ -488,8 +488,11 @@ int mbedtls_ccm_finish(mbedtls_ccm_context *ctx,
return MBEDTLS_ERR_CCM_BAD_INPUT;
}
if ((tag_len != 0 && (tag_len < 4 || tag_len > 16 || (tag_len & 1) != 0)) ||
(tag_len != ctx->tag_len)) {
/* Reject invalid tag lengths and mismatches with negotiated length (if set). */
if (tag_len != 0 && (tag_len < 4 || tag_len > 16 || (tag_len & 1) != 0)) {
return MBEDTLS_ERR_CCM_BAD_INPUT;
}
if ((ctx->state & CCM_STATE__LENGTHS_SET) && tag_len != ctx->tag_len) {
return MBEDTLS_ERR_CCM_BAD_INPUT;
}