Fixed SHA ctx and ilen parameters checking

pull/11046/head
Kostiantyn Tkachov 2019-08-16 17:21:26 +03:00 committed by Roman Okhrimenko
parent 7cbfa84625
commit 50a8592104
3 changed files with 15 additions and 3 deletions

View File

@ -55,7 +55,8 @@ void mbedtls_sha1_init( mbedtls_sha1_context *ctx )
void mbedtls_sha1_free( mbedtls_sha1_context *ctx )
{
SHA1_VALIDATE( ctx != NULL );
if (ctx == NULL)
return;
cy_hw_sha_free(ctx, sizeof( mbedtls_sha1_context ));
}
@ -88,6 +89,9 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
SHA1_VALIDATE_RET( ctx != NULL );
SHA1_VALIDATE_RET( ilen == 0 || input != NULL );
if (ilen == 0)
return;
return cy_hw_sha_update(&ctx->obj, &ctx->hashState, input, ilen);
}

View File

@ -54,7 +54,8 @@ void mbedtls_sha256_init( mbedtls_sha256_context *ctx )
void mbedtls_sha256_free( mbedtls_sha256_context *ctx )
{
SHA256_VALIDATE ( ctx != NULL );
if (ctx == NULL)
return;
cy_hw_sha_free(ctx, sizeof( mbedtls_sha256_context ));
}
@ -88,6 +89,9 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, const unsigned char
SHA256_VALIDATE_RET( ctx != NULL );
SHA256_VALIDATE_RET( ilen == 0 || input != NULL );
if (ilen == 0)
return;
return cy_hw_sha_update(&ctx->obj, &ctx->hashState, (uint8_t *)input, ilen);
}

View File

@ -54,7 +54,8 @@ void mbedtls_sha512_init( mbedtls_sha512_context *ctx )
void mbedtls_sha512_free( mbedtls_sha512_context *ctx )
{
SHA512_VALIDATE( ctx != NULL );
if (ctx == NULL)
return;
cy_hw_sha_free(ctx, sizeof( mbedtls_sha512_context ));
}
@ -87,6 +88,9 @@ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, const unsigned char
{
SHA512_VALIDATE_RET( ctx != NULL );
SHA512_VALIDATE_RET( ilen == 0 || input != NULL );
if (ilen == 0)
return;
return cy_hw_sha_update(&ctx->obj, &ctx->hashState, input, ilen);
}