Don't declare MBEDTLS-namespace identifiers in sha512.c

This commit is contained in:
Hanno Becker 2018-12-18 17:54:00 +00:00
parent 4fbd4bf442
commit 38e15d49f3

View file

@ -88,13 +88,13 @@
} }
#endif /* PUT_UINT64_BE */ #endif /* PUT_UINT64_BE */
#define MBEDTLS_SHA512_VALIDATE_RET(cond) \ #define SHA512_VALIDATE_RET(cond) \
MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA512_BAD_INPUT_DATA ) MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA512_BAD_INPUT_DATA )
#define MBEDTLS_SHA512_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) #define SHA512_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond )
void mbedtls_sha512_init( mbedtls_sha512_context *ctx ) void mbedtls_sha512_init( mbedtls_sha512_context *ctx )
{ {
MBEDTLS_SHA512_VALIDATE( ctx != NULL ); SHA512_VALIDATE( ctx != NULL );
memset( ctx, 0, sizeof( mbedtls_sha512_context ) ); memset( ctx, 0, sizeof( mbedtls_sha512_context ) );
} }
@ -110,8 +110,8 @@ void mbedtls_sha512_free( mbedtls_sha512_context *ctx )
void mbedtls_sha512_clone( mbedtls_sha512_context *dst, void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
const mbedtls_sha512_context *src ) const mbedtls_sha512_context *src )
{ {
MBEDTLS_SHA512_VALIDATE( dst != NULL ); SHA512_VALIDATE( dst != NULL );
MBEDTLS_SHA512_VALIDATE( src != NULL ); SHA512_VALIDATE( src != NULL );
*dst = *src; *dst = *src;
} }
@ -121,8 +121,8 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
*/ */
int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 ) int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 )
{ {
MBEDTLS_SHA512_VALIDATE_RET( ctx != NULL ); SHA512_VALIDATE_RET( ctx != NULL );
MBEDTLS_SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 ); SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 );
ctx->total[0] = 0; ctx->total[0] = 0;
ctx->total[1] = 0; ctx->total[1] = 0;
@ -221,8 +221,8 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
uint64_t temp1, temp2, W[80]; uint64_t temp1, temp2, W[80];
uint64_t A, B, C, D, E, F, G, H; uint64_t A, B, C, D, E, F, G, H;
MBEDTLS_SHA512_VALIDATE_RET( ctx != NULL ); SHA512_VALIDATE_RET( ctx != NULL );
MBEDTLS_SHA512_VALIDATE_RET( (const unsigned char *)data != NULL ); SHA512_VALIDATE_RET( (const unsigned char *)data != NULL );
#define SHR(x,n) (x >> n) #define SHR(x,n) (x >> n)
#define ROTR(x,n) (SHR(x,n) | (x << (64 - n))) #define ROTR(x,n) (SHR(x,n) | (x << (64 - n)))
@ -309,8 +309,8 @@ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx,
size_t fill; size_t fill;
unsigned int left; unsigned int left;
MBEDTLS_SHA512_VALIDATE_RET( ctx != NULL ); SHA512_VALIDATE_RET( ctx != NULL );
MBEDTLS_SHA512_VALIDATE_RET( ilen == 0 || input != NULL ); SHA512_VALIDATE_RET( ilen == 0 || input != NULL );
if( ilen == 0 ) if( ilen == 0 )
return( 0 ); return( 0 );
@ -369,8 +369,8 @@ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
unsigned used; unsigned used;
uint64_t high, low; uint64_t high, low;
MBEDTLS_SHA512_VALIDATE_RET( ctx != NULL ); SHA512_VALIDATE_RET( ctx != NULL );
MBEDTLS_SHA512_VALIDATE_RET( (unsigned char *)output != NULL ); SHA512_VALIDATE_RET( (unsigned char *)output != NULL );
/* /*
* Add padding: 0x80 then 0x00 until 16 bytes remain for the length * Add padding: 0x80 then 0x00 until 16 bytes remain for the length
@ -448,9 +448,9 @@ int mbedtls_sha512_ret( const unsigned char *input,
int ret; int ret;
mbedtls_sha512_context ctx; mbedtls_sha512_context ctx;
MBEDTLS_SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 ); SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 );
MBEDTLS_SHA512_VALIDATE_RET( ilen == 0 || input != NULL ); SHA512_VALIDATE_RET( ilen == 0 || input != NULL );
MBEDTLS_SHA512_VALIDATE_RET( (unsigned char *)output != NULL ); SHA512_VALIDATE_RET( (unsigned char *)output != NULL );
mbedtls_sha512_init( &ctx ); mbedtls_sha512_init( &ctx );