![]() |
|
|||
File indexing completed on 2025-08-27 09:37:30
0001 /** 0002 * Constant-time functions 0003 */ 0004 /* 0005 * Copyright The Mbed TLS Contributors 0006 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 0007 */ 0008 0009 #ifndef MBEDTLS_CONSTANT_TIME_H 0010 #define MBEDTLS_CONSTANT_TIME_H 0011 0012 #include <stddef.h> 0013 0014 /** Constant-time buffer comparison without branches. 0015 * 0016 * This is equivalent to the standard memcmp function, but is likely to be 0017 * compiled to code using bitwise operations rather than a branch, such that 0018 * the time taken is constant w.r.t. the data pointed to by \p a and \p b, 0019 * and w.r.t. whether \p a and \p b are equal or not. It is not constant-time 0020 * w.r.t. \p n . 0021 * 0022 * This function can be used to write constant-time code by replacing branches 0023 * with bit operations using masks. 0024 * 0025 * \param a Pointer to the first buffer, containing at least \p n bytes. May not be NULL. 0026 * \param b Pointer to the second buffer, containing at least \p n bytes. May not be NULL. 0027 * \param n The number of bytes to compare. 0028 * 0029 * \return Zero if the contents of the two buffers are the same, 0030 * otherwise non-zero. 0031 */ 0032 int mbedtls_ct_memcmp(const void *a, 0033 const void *b, 0034 size_t n); 0035 0036 #endif /* MBEDTLS_CONSTANT_TIME_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |