From b3906d8829a44b850bd8b908f03b546d6a65aa6a Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 18 Dec 2018 11:35:00 +0000 Subject: [PATCH] Minor fixes to implementation of SHA1 parameter validation --- library/sha1.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/sha1.c b/library/sha1.c index e9521e391..0eaedcfe6 100644 --- a/library/sha1.c +++ b/library/sha1.c @@ -72,9 +72,9 @@ #endif #define MBEDTLS_SHA1_VALIDATE_RET(cond) \ - MBEDTLS_VALIDATE_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, cond ) + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA1_BAD_INPUT_DATA ) -#define MBEDTLS_SHA1_VALIDATE(cond) MBEDTLS_VALIDATE( cond ) +#define MBEDTLS_SHA1_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) void mbedtls_sha1_init( mbedtls_sha1_context *ctx ) { @@ -309,12 +309,12 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, size_t fill; uint32_t left; + MBEDTLS_SHA1_VALIDATE_RET( ctx != NULL ); + MBEDTLS_SHA1_VALIDATE_RET( ilen == 0 || input != NULL ); + if( ilen == 0 ) return( 0 ); - MBEDTLS_SHA1_VALIDATE_RET( ctx != NULL ); - MBEDTLS_SHA1_VALIDATE_RET( input != NULL ); - left = ctx->total[0] & 0x3F; fill = 64 - left;