Code style fixups

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-03-04 14:34:50 +00:00
parent 0c0f9adab1
commit cd65b62f21

View file

@ -98,9 +98,9 @@ static const unsigned char base64_dec_map[128] =
/* /*
* Constant flow conditional assignment to unsigned char * Constant flow conditional assignment to unsigned char
*/ */
static void mbedtls_base64_cond_assign_uchar(unsigned char * dest, const unsigned char * const src, static void mbedtls_base64_cond_assign_uchar( unsigned char * dest, const unsigned char * const src,
unsigned char condition) unsigned char condition )
{ {
/* MSVC has a warning about unary minus on unsigned integer types, /* MSVC has a warning about unary minus on unsigned integer types,
* but this is well-defined and precisely what we want to do here. */ * but this is well-defined and precisely what we want to do here. */
@ -123,9 +123,9 @@ static void mbedtls_base64_cond_assign_uchar(unsigned char * dest, const unsigne
/* /*
* Constant flow conditional assignment to uint_32 * Constant flow conditional assignment to uint_32
*/ */
static void mbedtls_base64_cond_assign_uint32(uint32_t * dest, const uint32_t src, static void mbedtls_base64_cond_assign_uint32( uint32_t * dest, const uint32_t src,
uint32_t condition) uint32_t condition )
{ {
/* MSVC has a warning about unary minus on unsigned integer types, /* MSVC has a warning about unary minus on unsigned integer types,
* but this is well-defined and precisely what we want to do here. */ * but this is well-defined and precisely what we want to do here. */
@ -148,8 +148,8 @@ static void mbedtls_base64_cond_assign_uint32(uint32_t * dest, const uint32_t sr
/* /*
* Constant flow check for equality * Constant flow check for equality
*/ */
static unsigned char mbedtls_base64_eq(size_t in_a, size_t in_b) static unsigned char mbedtls_base64_eq( size_t in_a, size_t in_b )
{ {
size_t difference = in_a ^ in_b; size_t difference = in_a ^ in_b;
@ -174,16 +174,16 @@ static unsigned char mbedtls_base64_eq(size_t in_a, size_t in_b)
/* /*
* Constant flow lookup into table. * Constant flow lookup into table.
*/ */
static unsigned char mbedtls_base64_table_lookup(const unsigned char * const table, static unsigned char mbedtls_base64_table_lookup( const unsigned char * const table,
const size_t table_size, const size_t table_index) const size_t table_size, const size_t table_index )
{ {
size_t i; size_t i;
unsigned char result = 0; unsigned char result = 0;
for( i = 0; i < table_size; ++i ) for( i = 0; i < table_size; ++i )
{ {
mbedtls_base64_cond_assign_uchar(&result, &table[i], mbedtls_base64_eq(i, table_index)); mbedtls_base64_cond_assign_uchar( &result, &table[i], mbedtls_base64_eq( i, table_index ) );
} }
return result; return result;
@ -342,7 +342,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
if( *src == '\r' || *src == '\n' || *src == ' ' ) if( *src == '\r' || *src == '\n' || *src == ' ' )
continue; continue;
dec_map_lookup = mbedtls_base64_table_lookup(base64_dec_map, sizeof( base64_dec_map ), *src ); dec_map_lookup = mbedtls_base64_table_lookup( base64_dec_map, sizeof( base64_dec_map ), *src );
mbedtls_base64_cond_assign_uint32( &j, j - 1, mbedtls_base64_eq( dec_map_lookup, 64 ) ); mbedtls_base64_cond_assign_uint32( &j, j - 1, mbedtls_base64_eq( dec_map_lookup, 64 ) );
x = ( x << 6 ) | ( dec_map_lookup & 0x3F ); x = ( x << 6 ) | ( dec_map_lookup & 0x3F );