diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h index 64e6666d7..b6c50d574 100644 --- a/include/mbedtls/platform_util.h +++ b/include/mbedtls/platform_util.h @@ -177,7 +177,7 @@ void mbedtls_platform_zeroize( void *buf, size_t len ); * \param ptr Buffer to be set. * \param value Value to be used when setting the buffer. * \param num The length of the buffer in bytes. - * + * */ void mbedtls_platform_memset( void *ptr, int value, size_t num ); diff --git a/library/platform_util.c b/library/platform_util.c index 6868c33fa..13179216c 100644 --- a/library/platform_util.c +++ b/library/platform_util.c @@ -82,15 +82,15 @@ void mbedtls_platform_zeroize( void *buf, size_t len ) void mbedtls_platform_memset( void *ptr, int value, size_t num ) { /* Randomize start offset. */ - size_t startOffset = ( size_t ) mbedtls_platform_random_in_range( num ); + size_t start_offset = (size_t) mbedtls_platform_random_in_range( num ); /* Randomize data */ - size_t data = ( size_t ) mbedtls_platform_random_in_range( 0xff ); + size_t data = (size_t) mbedtls_platform_random_in_range( 0xff ); /* Perform a pair of memset operations from random locations with * random data */ - memset( ( void * ) ( ( unsigned char * ) ptr + startOffset ), value, - ( num - startOffset ) ); - memset( ( void * ) ptr, data, startOffset ); + memset( (void *) ( (unsigned char *) ptr + start_offset ), value, + ( num - start_offset ) ); + memset( (void *) ptr, data, start_offset ); /* Perform the original memset */ memset( ptr, value, num ); @@ -99,15 +99,15 @@ void mbedtls_platform_memset( void *ptr, int value, size_t num ) void mbedtls_platform_memcpy( void *dst, const void *src, size_t num ) { /* Randomize start offset. */ - size_t startOffset = ( size_t ) mbedtls_platform_random_in_range( num ); + size_t start_offset = (size_t) mbedtls_platform_random_in_range( num ); /* Randomize initial data to prevent leakage while copying */ - size_t data = ( size_t ) mbedtls_platform_random_in_range( 0xff ); + size_t data = (size_t) mbedtls_platform_random_in_range( 0xff ); - memset( ( void * ) dst, data, num ); - memcpy( ( void * ) ( ( unsigned char * ) dst + startOffset ), - ( void * ) ( ( unsigned char * ) src + startOffset ), - ( num - startOffset ) ); - memcpy( ( void * ) dst, ( void * ) src, startOffset ); + memset( (void *) dst, data, num ); + memcpy( (void *) ( (unsigned char *) dst + start_offset ), + (void *) ( (unsigned char *) src + start_offset ), + ( num - start_offset ) ); + memcpy( (void *) dst, (void *) src, start_offset ); } int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num ) @@ -116,18 +116,18 @@ int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num ) size_t i = num; - size_t startOffset = ( size_t ) mbedtls_platform_random_in_range( num ); + size_t start_offset = (size_t) mbedtls_platform_random_in_range( num ); - for( i = startOffset; i < num; i++ ) + for( i = start_offset; i < num; i++ ) { - equal += ( ( ( unsigned char * ) buf1 )[i] == - ( ( unsigned char * ) buf2 )[i] ); + equal += ( ( (unsigned char *) buf1 )[i] == + ( (unsigned char *) buf2 )[i] ); } - for( i = 0; i < startOffset; i++ ) + for( i = 0; i < start_offset; i++ ) { - equal += ( ( ( unsigned char * ) buf1 )[i] == - ( ( unsigned char * ) buf2 )[i] ); + equal += ( ( (unsigned char *) buf1 )[i] == + ( (unsigned char *) buf2 )[i] ); } if ( equal == num )