CRYPTO_memcmp.3ssl - Man Page

Constant time memory comparison


 #include <openssl/crypto.h>

 int CRYPTO_memcmp(const void *a, const void *b, size_t len);


The CRYPTO_memcmp function compares the len bytes pointed to by a and b for equality. It takes an amount of time dependent on len, but independent of the contents of the memory regions pointed to by a and b.

Return Values

CRYPTO_memcmp() returns 0 if the memory regions are equal and nonzero otherwise.


Unlike memcmp(2), this function cannot be used to order the two memory regions as the return value when they differ is undefined, other than being nonzero.


2021-03-26 1.1.1k OpenSSL