18 #if defined(__clang__)
19 #define NO_UBSAN_UINT_OVERFLOW \
20 __attribute__((no_sanitize("unsigned-integer-overflow")))
22 #define NO_UBSAN_UINT_OVERFLOW
33 return (val >> (
sizeof(val) * 8 - 1)) * ~0U;
47 static inline unsigned int const_time_eq(
unsigned int a,
unsigned int b)
79 const unsigned char *aa = a;
80 const unsigned char *bb = b;
82 unsigned char res = 0;
84 for (i = 0; i < len; i++)
99 unsigned int true_val,
100 unsigned int false_val)
102 return (
mask & true_val) | (~
mask & false_val);
117 (
unsigned int) false_val);
144 (
unsigned int) false_val);
161 const unsigned char *false_val,
size_t len,
166 for (i = 0; i < len; i++)
173 const unsigned char *aa = a;
174 const unsigned char *bb = b;
182 diff = (int) aa[len] - (
int) bb[len];
#define NO_UBSAN_UINT_OVERFLOW
static int const_time_select_int(unsigned int mask, int true_val, int false_val)
const_time_select_int - Constant time int selection
static char const_time_select_s8(char mask, char true_val, char false_val)
const_time_select_s8 - Constant time s8 selection
static void const_time_select_bin(unsigned char mask, const unsigned char *true_val, const unsigned char *false_val, size_t len, unsigned char *dst)
const_time_select_bin - Constant time binary buffer selection copy
static unsigned char const_time_eq_u8(unsigned int a, unsigned int b)
static unsigned int const_time_is_zero(unsigned int val) NO_UBSAN_UINT_OVERFLOW
static unsigned char const_time_select_u8(unsigned char mask, unsigned char true_val, unsigned char false_val)
const_time_select_u8 - Constant time u8 selection
static unsigned int const_time_eq(unsigned int a, unsigned int b)
static int const_time_memcmp(const void *a, const void *b, size_t len)
static unsigned int const_time_fill_msb(unsigned int val)
const_time_fill_msb - Fill all bits with MSB value
static unsigned int const_time_eq_bin(const void *a, const void *b, size_t len)
const_time_eq_bin - Constant time memory comparison
static unsigned int const_time_select(unsigned int mask, unsigned int true_val, unsigned int false_val)
const_time_select - Constant time unsigned int selection