Loading...
Searching...
No Matches
constant_time.h File Reference
`#include <stddef.h>`
Include dependency graph for constant_time.h:

Go to the source code of this file.

## Functions

int | mbedtls_ct_memcmp (const void *a, const void *b, size_t n)

## Function Documentation

## mbedtls_ct_memcmp()

int mbedtls_ct_memcmp | ( | const void * | a,
|  | const void * | b,
|  | size_t | n
| ) |  |

Constant-time functions

Copyright The Mbed TLS Contributors SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later Constant-time buffer comparison without branches.

This is equivalent to the standard memcmp function, but is likely to be compiled to code using bitwise operation rather than a branch.

This function can be used to write constant-time code by replacing branches with bit operations using masks.

Parameters

  a | Pointer to the first buffer.
  b | Pointer to the second buffer.
  n | The number of bytes to compare in the buffer.

Returns
  Zero if the content of the two buffer is the same, otherwise non-zero.