mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 12:15:38 +01:00
Fixes for MSVC warnings
Also added a couple of missing comment blocks. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
8d265f75a4
commit
f13a47bbb2
@ -96,6 +96,9 @@ static const unsigned char base64_dec_map[128] =
|
||||
|
||||
#define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
|
||||
|
||||
/*
|
||||
* Constant flow conditional assignment
|
||||
*/
|
||||
static void mbedtls_base64_cond_assign(unsigned char * dest, const unsigned char * const src,
|
||||
unsigned char condition)
|
||||
{
|
||||
@ -106,19 +109,31 @@ static void mbedtls_base64_cond_assign(unsigned char * dest, const unsigned char
|
||||
}
|
||||
|
||||
/*
|
||||
* Constant time check for equality
|
||||
* Constant flow check for equality
|
||||
*/
|
||||
static unsigned char mbedtls_base64_eq(uint32_t in_a, uint32_t in_b)
|
||||
static unsigned char mbedtls_base64_eq(size_t in_a, size_t in_b)
|
||||
{
|
||||
uint32_t difference = in_a ^ in_b;
|
||||
|
||||
/* MSVC has a warning about unary minus on unsigned integer types,
|
||||
* but this is well-defined and precisely what we want to do here. */
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4146 )
|
||||
#endif
|
||||
|
||||
difference |= -difference;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
||||
difference >>= 31;
|
||||
return (unsigned char) ( 1 ^ difference );
|
||||
}
|
||||
|
||||
/*
|
||||
* Constant time lookup into table.
|
||||
* Constant flow lookup into table.
|
||||
*/
|
||||
static unsigned char mbedtls_base64_table_lookup(const unsigned char * const table,
|
||||
const size_t table_size, const size_t table_index)
|
||||
|
Loading…
Reference in New Issue
Block a user