From ea3a6114e6fd8feada89ba550d563546aa521cc9 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Mon, 29 Jan 2024 10:37:14 +0100 Subject: [PATCH] aria: replace ARIA_VALIDATE_RET() with a simple "if" block Signed-off-by: Valerio Setti --- library/aria.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/library/aria.c b/library/aria.c index 2c365982c..a4d6c5062 100644 --- a/library/aria.c +++ b/library/aria.c @@ -517,8 +517,10 @@ int mbedtls_aria_crypt_cbc(mbedtls_aria_context *ctx, unsigned char *output) { unsigned char temp[MBEDTLS_ARIA_BLOCKSIZE]; - ARIA_VALIDATE_RET(mode == MBEDTLS_ARIA_ENCRYPT || - mode == MBEDTLS_ARIA_DECRYPT); + + if ((mode != MBEDTLS_ARIA_ENCRYPT) && (mode != MBEDTLS_ARIA_DECRYPT)) { + return MBEDTLS_ERR_ARIA_BAD_INPUT_DATA; + } if (length % MBEDTLS_ARIA_BLOCKSIZE) { return MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH; @@ -568,8 +570,10 @@ int mbedtls_aria_crypt_cfb128(mbedtls_aria_context *ctx, { unsigned char c; size_t n; - ARIA_VALIDATE_RET(mode == MBEDTLS_ARIA_ENCRYPT || - mode == MBEDTLS_ARIA_DECRYPT); + + if ((mode != MBEDTLS_ARIA_ENCRYPT) && (mode != MBEDTLS_ARIA_DECRYPT)) { + return MBEDTLS_ERR_ARIA_BAD_INPUT_DATA; + } n = *iv_off; @@ -625,9 +629,6 @@ int mbedtls_aria_crypt_ctr(mbedtls_aria_context *ctx, int c, i; size_t n; - ARIA_VALIDATE_RET(length == 0 || input != NULL); - ARIA_VALIDATE_RET(length == 0 || output != NULL); - n = *nc_off; /* An overly large value of n can lead to an unlimited * buffer overflow. Therefore, guard against this