Compare two memory regions in constant time with respect to their contents.

Synopsis

Declared in <openssl/crypto.h>

int
CRYPTO_memcmp(
    void const* in_a,
    void const* in_b,
    size_t len);

Description

Runtime depends on len but not on the data at in_a / in_b. Unlike memcmp, the non‐zero return value must not be used to sort elements.

Return Value

0 if the len bytes are equal; non‐zero otherwise (ordering is undefined).

Parameters

Name

Description

in_a

First buffer.

in_b

Second buffer.

len

Number of bytes to compare.

Created with MrDocs