safec
3.2
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_str_lib.h"
Functions | |
EXPORT int | timingsafe_bcmp (const void *b1, const void *b2, size_t n) |
Compare all memory bytes. More... | |
EXPORT int timingsafe_bcmp | ( | const void * | b1, |
const void * | b2, | ||
size_t | n | ||
) |
Compare all memory bytes.
Return 0 or not zero.
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 |
n | number of bytes to compare in both buffers |
0 | if the buffers are equal, or not zero if they are not equal. |