mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 10:05:46 +01:00
Fix style issues
This commit is contained in:
parent
5aee8cab2a
commit
0ff7109b7c
@ -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 );
|
||||
|
||||
|
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user