From 80a6af6ab59f88d6ebd01287135ccb7bc54d04c8 Mon Sep 17 00:00:00 2001 From: Tuvshinzaya Erdenekhuu Date: Fri, 5 Aug 2022 15:31:57 +0100 Subject: [PATCH] Re-introduce ENUM validation in cipher.c Signed-off-by: Tuvshinzaya Erdenekhuu --- library/cipher.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/library/cipher.c b/library/cipher.c index 3fbb96730..752d1fea2 100644 --- a/library/cipher.c +++ b/library/cipher.c @@ -70,11 +70,6 @@ #define mbedtls_free free #endif -#define CIPHER_VALIDATE_RET( cond ) \ - MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ) -#define CIPHER_VALIDATE( cond ) \ - MBEDTLS_INTERNAL_VALIDATE( cond ) - static int supported_init = 0; const int *mbedtls_cipher_list( void ) @@ -255,8 +250,8 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, int key_bitlen, const mbedtls_operation_t operation ) { - CIPHER_VALIDATE_RET( operation == MBEDTLS_ENCRYPT || - operation == MBEDTLS_DECRYPT ); + if( operation != MBEDTLS_ENCRYPT && operation != MBEDTLS_DECRYPT ) + return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );