mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-27 06:15:59 +00: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
b4e4bfdd00
commit
3e7908189a
|
@ -65,6 +65,9 @@ static const unsigned char base64_dec_map[128] =
|
||||||
|
|
||||||
#define BASE64_SIZE_T_MAX ( (size_t) -1 ) /* SIZE_T_MAX is not standard */
|
#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,
|
static void mbedtls_base64_cond_assign(unsigned char * dest, const unsigned char * const src,
|
||||||
unsigned char condition)
|
unsigned char condition)
|
||||||
{
|
{
|
||||||
|
@ -75,19 +78,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;
|
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;
|
difference |= -difference;
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning( pop )
|
||||||
|
#endif
|
||||||
|
|
||||||
difference >>= 31;
|
difference >>= 31;
|
||||||
return (unsigned char) ( 1 ^ difference );
|
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,
|
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)
|
||||||
|
|
Loading…
Reference in a new issue