Go to the source code of this file.
|
static unsigned int | const_time_eq (unsigned int a, unsigned int b) |
|
static unsigned int | const_time_eq_bin (const void *a, const void *b, size_t len) |
| const_time_eq_bin - Constant time memory comparison More...
|
|
static unsigned char | const_time_eq_u8 (unsigned int a, unsigned int b) |
|
static unsigned int | const_time_fill_msb (unsigned int val) |
| const_time_fill_msb - Fill all bits with MSB value More...
|
|
static unsigned int | const_time_is_zero (unsigned int val) NO_UBSAN_UINT_OVERFLOW |
|
static int | const_time_memcmp (const void *a, const void *b, size_t len) |
|
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 More...
|
|
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 More...
|
|
static int | const_time_select_int (unsigned int mask, int true_val, int false_val) |
| const_time_select_int - Constant time int selection More...
|
|
static char | const_time_select_s8 (char mask, char true_val, char false_val) |
| const_time_select_s8 - Constant time s8 selection More...
|
|
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 More...
|
|
◆ NO_UBSAN_UINT_OVERFLOW
#define NO_UBSAN_UINT_OVERFLOW |
◆ const_time_eq()
static unsigned int const_time_eq |
( |
unsigned int |
a, |
|
|
unsigned int |
b |
|
) |
| |
|
inlinestatic |
◆ const_time_eq_bin()
static unsigned int const_time_eq_bin |
( |
const void * |
a, |
|
|
const void * |
b, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
const_time_eq_bin - Constant time memory comparison
- Parameters
-
a | First buffer to compare |
b | Second buffer to compare |
len | Number of octets to compare |
- Returns
- -1 if buffers are equal, 0 if not
This function is meant for comparing passwords or hash values where difference in execution time or memory access pattern could provide external observer information about the location of the difference in the memory buffers. The return value does not behave like memcmp(), i.e., const_time_eq_bin() cannot be used to sort items into a defined order. Unlike memcmp(), the execution time of const_time_eq_bin() does not depend on the contents of the compared memory buffers, but only on the total compared length.
Definition at line 76 of file const_time.h.
◆ const_time_eq_u8()
static unsigned char const_time_eq_u8 |
( |
unsigned int |
a, |
|
|
unsigned int |
b |
|
) |
| |
|
inlinestatic |
◆ const_time_fill_msb()
static unsigned int const_time_fill_msb |
( |
unsigned int |
val | ) |
|
|
inlinestatic |
const_time_fill_msb - Fill all bits with MSB value
- Parameters
-
- Returns
- Value with all the bits set to the MSB of the input val
Definition at line 30 of file const_time.h.
◆ const_time_is_zero()
static unsigned int const_time_is_zero |
( |
unsigned int |
val | ) |
|
|
inlinestatic |
◆ const_time_memcmp()
static int const_time_memcmp |
( |
const void * |
a, |
|
|
const void * |
b, |
|
|
size_t |
len |
|
) |
| |
|
inlinestatic |
◆ const_time_select()
static unsigned int const_time_select |
( |
unsigned int |
mask, |
|
|
unsigned int |
true_val, |
|
|
unsigned int |
false_val |
|
) |
| |
|
inlinestatic |
const_time_select - Constant time unsigned int selection
- Parameters
-
mask | 0 (false) or -1 (true) to identify which value to select |
true_val | Value to select for the true case |
false_val | Value to select for the false case |
- Returns
- true_val if mask == -1, false_val if mask == 0
Definition at line 98 of file const_time.h.
◆ const_time_select_bin()
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 |
|
) |
| |
|
inlinestatic |
const_time_select_bin - Constant time binary buffer selection copy
- Parameters
-
mask | 0 (false) or -1 (true) to identify which value to copy |
true_val | Buffer to copy for the true case |
false_val | Buffer to copy for the false case |
len | Number of octets to copy |
dst | Destination buffer for the copy |
This function copies the specified buffer into the destination buffer using operations with identical memory access pattern regardless of which buffer is being copied.
Definition at line 160 of file const_time.h.
◆ const_time_select_int()
static int const_time_select_int |
( |
unsigned int |
mask, |
|
|
int |
true_val, |
|
|
int |
false_val |
|
) |
| |
|
inlinestatic |
const_time_select_int - Constant time int selection
- Parameters
-
mask | 0 (false) or -1 (true) to identify which value to select |
true_val | Value to select for the true case |
false_val | Value to select for the false case |
- Returns
- true_val if mask == -1, false_val if mask == 0
Definition at line 113 of file const_time.h.
◆ const_time_select_s8()
static char const_time_select_s8 |
( |
char |
mask, |
|
|
char |
true_val, |
|
|
char |
false_val |
|
) |
| |
|
inlinestatic |
const_time_select_s8 - Constant time s8 selection
- Parameters
-
mask | 0 (false) or -1 (true) to identify which value to select |
true_val | Value to select for the true case |
false_val | Value to select for the false case |
- Returns
- true_val if mask == -1, false_val if mask == 0
Definition at line 141 of file const_time.h.
◆ const_time_select_u8()
static unsigned char const_time_select_u8 |
( |
unsigned char |
mask, |
|
|
unsigned char |
true_val, |
|
|
unsigned char |
false_val |
|
) |
| |
|
inlinestatic |
const_time_select_u8 - Constant time u8 selection
- Parameters
-
mask | 0 (false) or -1 (true) to identify which value to select |
true_val | Value to select for the true case |
false_val | Value to select for the false case |
- Returns
- true_val if mask == -1, false_val if mask == 0
Definition at line 128 of file const_time.h.