TIMINGSAFE_BCMP(3) Library Functions Manual TIMINGSAFE_BCMP(3)

timingsafe_bcmptiming-safe byte sequence comparisons

#include <string.h>

int
timingsafe_bcmp(const void *b1, const void *b2, size_t len);

The () function compares the first len bytes pointed to by b1 and b2.

Additionally, the running time is independent of the byte sequences compared, making it 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.

The timingsafe_bcmp() function returns 0 or not zero if the byte sequence pointed to by b1 compares equal to or not equal to (respectively) the byte sequence pointed to by b2.

bcmp(3)

The timingsafe_bcmp() function is a non-standard extension.

The timingsafe_bcmp() function first appeared in OpenBSD 4.9, FreeBSD 12.0, and macOS 10.12.1.

August 15, 2016 macOS 15.0