Re-introduce ENUM validation in sha256.c
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
diff --git a/library/sha256.c b/library/sha256.c
index 24be8ea..4819ba3 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -149,10 +149,6 @@
#endif /* MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT */
-#define SHA256_VALIDATE_RET(cond) \
- MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA )
-#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
-
#if !defined(MBEDTLS_SHA256_ALT)
#define SHA256_BLOCK_SIZE 64
@@ -182,9 +178,11 @@
int mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
{
#if defined(MBEDTLS_SHA224_C)
- SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
+ if( is224 != 0 && is224 != 1 )
+ return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
#else
- SHA256_VALIDATE_RET( is224 == 0 );
+ if( is224 != 0 )
+ return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
#endif
ctx->total[0] = 0;
@@ -689,9 +687,11 @@
mbedtls_sha256_context ctx;
#if defined(MBEDTLS_SHA224_C)
- SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
+ if( is224 != 0 && is224 != 1 )
+ return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
#else
- SHA256_VALIDATE_RET( is224 == 0 );
+ if( is224 != 0 )
+ return MBEDTLS_ERR_SHA256_BAD_INPUT_DATA;
#endif
mbedtls_sha256_init( &ctx );