mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Remove NULL pointer validation in sha256.c
Signed-off-by: Tuvshinzaya Erdenekhuu <tuvshinzaya.erdenekhuu@arm.com>
This commit is contained in:
@ -159,8 +159,6 @@ static int mbedtls_a64_crypto_sha256_determine_support( void )
|
|||||||
|
|
||||||
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
|
void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
|
||||||
{
|
{
|
||||||
SHA256_VALIDATE( ctx != NULL );
|
|
||||||
|
|
||||||
memset( ctx, 0, sizeof( mbedtls_sha256_context ) );
|
memset( ctx, 0, sizeof( mbedtls_sha256_context ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,9 +173,6 @@ void mbedtls_sha256_free( mbedtls_sha256_context *ctx )
|
|||||||
void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
|
void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
|
||||||
const mbedtls_sha256_context *src )
|
const mbedtls_sha256_context *src )
|
||||||
{
|
{
|
||||||
SHA256_VALIDATE( dst != NULL );
|
|
||||||
SHA256_VALIDATE( src != NULL );
|
|
||||||
|
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +181,6 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
|
|||||||
*/
|
*/
|
||||||
int mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
|
int mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
|
||||||
{
|
{
|
||||||
SHA256_VALIDATE_RET( ctx != NULL );
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_SHA224_C)
|
#if defined(MBEDTLS_SHA224_C)
|
||||||
SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
|
SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 );
|
||||||
#else
|
#else
|
||||||
@ -427,9 +420,6 @@ int mbedtls_internal_sha256_process_c( mbedtls_sha256_context *ctx,
|
|||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
SHA256_VALIDATE_RET( ctx != NULL );
|
|
||||||
SHA256_VALIDATE_RET( (const unsigned char *)data != NULL );
|
|
||||||
|
|
||||||
for( i = 0; i < 8; i++ )
|
for( i = 0; i < 8; i++ )
|
||||||
local.A[i] = ctx->state[i];
|
local.A[i] = ctx->state[i];
|
||||||
|
|
||||||
@ -579,9 +569,6 @@ int mbedtls_sha256_update( mbedtls_sha256_context *ctx,
|
|||||||
size_t fill;
|
size_t fill;
|
||||||
uint32_t left;
|
uint32_t left;
|
||||||
|
|
||||||
SHA256_VALIDATE_RET( ctx != NULL );
|
|
||||||
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
|
|
||||||
|
|
||||||
if( ilen == 0 )
|
if( ilen == 0 )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
@ -633,9 +620,6 @@ int mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
|
|||||||
uint32_t used;
|
uint32_t used;
|
||||||
uint32_t high, low;
|
uint32_t high, low;
|
||||||
|
|
||||||
SHA256_VALIDATE_RET( ctx != NULL );
|
|
||||||
SHA256_VALIDATE_RET( (unsigned char *)output != NULL );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add padding: 0x80 then 0x00 until 8 bytes remain for the length
|
* Add padding: 0x80 then 0x00 until 8 bytes remain for the length
|
||||||
*/
|
*/
|
||||||
@ -710,9 +694,6 @@ int mbedtls_sha256( const unsigned char *input,
|
|||||||
SHA256_VALIDATE_RET( is224 == 0 );
|
SHA256_VALIDATE_RET( is224 == 0 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
|
|
||||||
SHA256_VALIDATE_RET( (unsigned char *)output != NULL );
|
|
||||||
|
|
||||||
mbedtls_sha256_init( &ctx );
|
mbedtls_sha256_init( &ctx );
|
||||||
|
|
||||||
if( ( ret = mbedtls_sha256_starts( &ctx, is224 ) ) != 0 )
|
if( ( ret = mbedtls_sha256_starts( &ctx, is224 ) ) != 0 )
|
||||||
|
Reference in New Issue
Block a user