mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
Merge remote-tracking branch 'public/pr/2269' into development
This commit is contained in:
@ -855,6 +855,8 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
||||
#if defined(MBEDTLS_SHA1_C)
|
||||
if( use_ret == -(MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED) )
|
||||
mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 hardware accelerator failed" );
|
||||
if( use_ret == -(MBEDTLS_ERR_SHA1_BAD_INPUT_DATA) )
|
||||
mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 input data was malformed" );
|
||||
#endif /* MBEDTLS_SHA1_C */
|
||||
|
||||
#if defined(MBEDTLS_SHA256_C)
|
||||
|
@ -46,6 +46,11 @@
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
#endif /* MBEDTLS_SELF_TEST */
|
||||
|
||||
#define SHA1_VALIDATE_RET(cond) \
|
||||
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA1_BAD_INPUT_DATA )
|
||||
|
||||
#define SHA1_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
|
||||
#if !defined(MBEDTLS_SHA1_ALT)
|
||||
|
||||
/*
|
||||
@ -73,6 +78,8 @@
|
||||
|
||||
void mbedtls_sha1_init( mbedtls_sha1_context *ctx )
|
||||
{
|
||||
SHA1_VALIDATE( ctx != NULL );
|
||||
|
||||
memset( ctx, 0, sizeof( mbedtls_sha1_context ) );
|
||||
}
|
||||
|
||||
@ -87,6 +94,9 @@ void mbedtls_sha1_free( mbedtls_sha1_context *ctx )
|
||||
void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
|
||||
const mbedtls_sha1_context *src )
|
||||
{
|
||||
SHA1_VALIDATE( dst != NULL );
|
||||
SHA1_VALIDATE( src != NULL );
|
||||
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
@ -95,6 +105,8 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
|
||||
*/
|
||||
int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx )
|
||||
{
|
||||
SHA1_VALIDATE_RET( ctx != NULL );
|
||||
|
||||
ctx->total[0] = 0;
|
||||
ctx->total[1] = 0;
|
||||
|
||||
@ -120,6 +132,9 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
|
||||
{
|
||||
uint32_t temp, W[16], A, B, C, D, E;
|
||||
|
||||
SHA1_VALIDATE_RET( ctx != NULL );
|
||||
SHA1_VALIDATE_RET( (const unsigned char *)data != NULL );
|
||||
|
||||
GET_UINT32_BE( W[ 0], data, 0 );
|
||||
GET_UINT32_BE( W[ 1], data, 4 );
|
||||
GET_UINT32_BE( W[ 2], data, 8 );
|
||||
@ -294,6 +309,9 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
|
||||
size_t fill;
|
||||
uint32_t left;
|
||||
|
||||
SHA1_VALIDATE_RET( ctx != NULL );
|
||||
SHA1_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
|
||||
if( ilen == 0 )
|
||||
return( 0 );
|
||||
|
||||
@ -352,6 +370,9 @@ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
|
||||
uint32_t used;
|
||||
uint32_t high, low;
|
||||
|
||||
SHA1_VALIDATE_RET( ctx != NULL );
|
||||
SHA1_VALIDATE_RET( (unsigned char *)output != NULL );
|
||||
|
||||
/*
|
||||
* Add padding: 0x80 then 0x00 until 8 bytes remain for the length
|
||||
*/
|
||||
@ -420,6 +441,9 @@ int mbedtls_sha1_ret( const unsigned char *input,
|
||||
int ret;
|
||||
mbedtls_sha1_context ctx;
|
||||
|
||||
SHA1_VALIDATE_RET( ilen == 0 || input != NULL );
|
||||
SHA1_VALIDATE_RET( (unsigned char *)output != NULL );
|
||||
|
||||
mbedtls_sha1_init( &ctx );
|
||||
|
||||
if( ( ret = mbedtls_sha1_starts_ret( &ctx ) ) != 0 )
|
||||
|
Reference in New Issue
Block a user