sodium_memcmp

Constant-time test for equality. When a comparison involves secret data (e.g. key, authentication tag), is it critical to use a constant-time comparison function in order to mitigate side-channel attacks. The sodium_memcmp() function can be used for this purpose.<br> The function returns 0 if the len bytes pointed to by b1_ match the len bytes pointed to by b2_ . Otherwise, it returns -1 .<br> WARNING: sodium_memcmp() must be used to verify if two secret keys are equal, in constant time.<br> This function is not designed for lexicographical comparisons and is not a generic replacement for memcmp().

extern (C)
int
sodium_memcmp
(
const(void*) b1_
,
const(void*) b2_
,
size_t len
)

Meta