timingsafe_memcmp, timingsafe_bcmp - timing safe memory operations
#include <string.h> int timingsafe_memcmp(const void *s1, const void *s2, size_t n); int timingsafe_bcmp(const void *s1, const void *s2, size_t n);
The timingsafe_memcmp() and timingsafe_bcmp() functions operate on memory areas that are arrays of bytes bounded by a count. The execution times of these functions are not affected by the memory contents of their arguments. They are designed to be used in timing sensitive use cases, for example, cryptography.
The timingsafe_memcmp() function compares its arguments looking at the first n bytes where each is interpreted as an unsigned character. It returns an integer less than, equal to, or greater than 0, corresponding to whether s1 is lexicographically less than, equal to, or greater than s2 when taken to be unsigned characters. The timingsafe_memcmp() function always returns 0 when n is 0.
The timingsafe_bcmp() function compares the first n bytes of its arguments, returning 0 if they are identical and 1 otherwise. The timingsafe_bcmp() function always returns 0 when n is 0.
See attributes(7) for descriptions of the following attributes:
The timingsafe_memcmp() and timingsafe_bcmp() functions were added to Oracle Solaris in the 11.4.0 release.