ccm.c: Return early when ccm* is used without tag.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
diff --git a/tf-psa-crypto/drivers/builtin/src/ccm.c b/tf-psa-crypto/drivers/builtin/src/ccm.c
index 2503e9f..68af903 100644
--- a/tf-psa-crypto/drivers/builtin/src/ccm.c
+++ b/tf-psa-crypto/drivers/builtin/src/ccm.c
@@ -167,11 +167,12 @@
}
/* CCM expects non-empty tag.
- * CCM* allows empty tag. For CCM* without tag, ignore plaintext length.
+ * CCM* allows empty tag. For CCM* without tag, the tag calculation is skipped.
*/
if (ctx->tag_len == 0) {
if (ctx->mode == MBEDTLS_CCM_STAR_ENCRYPT || ctx->mode == MBEDTLS_CCM_STAR_DECRYPT) {
ctx->plaintext_len = 0;
+ return 0;
} else {
return MBEDTLS_ERR_CCM_BAD_INPUT;
}