CRYPTO_memcmp(3ssl)

CRYPTO_memcmp3ssl

Constant time memory comparison

Usage

 #include <openssl/crypto.h>
 int CRYPTO_memcmp(const void *a, const void *b, size_t len);

Overview

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.

Notes

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.

Releases

5 releases since Debian 10 (Buster); the text changed 4 times.

  1. 10
  2. 11
  3. 12
  4. 13
  5. Arch

From openssl 3.6.5-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.