mirror of https://github.com/ARMmbed/mbed-os.git
Fixed SHA ctx and ilen parameters checking
parent
7cbfa84625
commit
50a8592104
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue