|
safec
3.1
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_mem_lib.h"
Include dependency graph for timingsafe_memcmp.c:Functions | |
| EXPORT int | timingsafe_memcmp (const void *b1, const void *b2, size_t len) |
| Compare all memory bytes. More... | |
| EXPORT int timingsafe_memcmp | ( | const void * | b1, |
| const void * | b2, | ||
| size_t | len | ||
| ) |
Compare all memory bytes.
Return their difference sign (-1,0,1).
The running time is independent of the byte sequences compared, making them safe to use for comparing secret values such as cryptographic MACs. In contrast, bcmp(3) and memcmp(3) may short-circuit after finding the first differing byte.
| b1 | pointer to memory to compare against |
| b2 | pointer to the source memory to compare with b1 |
| len | number of bytes to compare in both buffers |
| -1,0,or | 1 |