carta
libressl-CRYPTO_memcmp(3)

libressl-CRYPTO_memcmp3

Constant time memory comparison

Usage

Crypto Library (libcrypto, -lcrypto)

int

Overview

CRYPTO_memcmp() 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 content of the memory regions is equal or non-zero otherwise.

History

CRYPTO_memcmp() first appeared in OpenSSL 1.0.1d and has been available since OpenBSD 5.6.

Bugs

Unlike memcmp(3) and timingsafe_memcmp(3), this function cannot be used to order the two memory regions. In the current implementation, the return value is always greater than or equal to 0.

From libressl 4.4.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's mdoc source.