Lines Matching +full:- +full:p
2 * Constant-time functions
5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
20 /* The constant-time interface provides various operations that are likely
21 * to result in constant-time code that does not branch or use conditional
27 * - boolean operations
34 * - conditional data selection
40 * - block memory operations
47 * be able to prove anything about its value at compile-time.
53 * not-larger integer types).
55 * For Arm (32-bit, 64-bit and Thumb), x86 and x86-64, assembly implementations
57 * architectures, it uses a plain C fallback designed to yield constant-time code
58 * (this has been observed to be constant-time on latest gcc, clang and MSVC
66 /* Pointer size > 64-bit */
72 /* 32-bit < pointer size <= 64-bit, or 64-bit MPI */
79 /* Pointer size <= 32-bit, and no 64-bit MPIs */
96 * \return MBEDTLS_CT_TRUE if \p x != 0, or MBEDTLS_CT_FALSE if \p x == 0
105 * \p x != \p y
110 * \return MBEDTLS_CT_TRUE if \p x != \p y, otherwise MBEDTLS_CT_FALSE.
118 * \p x == \p y
123 * \return MBEDTLS_CT_TRUE if \p x == \p y, otherwise MBEDTLS_CT_FALSE.
132 * \p x < \p y
137 * \return MBEDTLS_CT_TRUE if \p x < \p y, otherwise MBEDTLS_CT_FALSE.
145 * \p x > \p y
150 * \return MBEDTLS_CT_TRUE if \p x > \p y, otherwise MBEDTLS_CT_FALSE.
159 * \p x >= \p y
164 * \return MBEDTLS_CT_TRUE if \p x >= \p y,
174 * \p x <= \p y
179 * \return MBEDTLS_CT_TRUE if \p x <= \p y,
185 /** Boolean not-equals operation.
189 * \p x != \p y
197 * \return MBEDTLS_CT_TRUE if \p x != \p y,
207 * \p x && \p y
212 * \return MBEDTLS_CT_TRUE if \p x && \p y,
222 * \p x || \p y
227 * \return MBEDTLS_CT_TRUE if \p x || \p y,
237 * ! \p x
241 * \return MBEDTLS_CT_FALSE if \p x, otherwise MBEDTLS_CT_TRUE.
257 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
258 * \param if0 Value to use if \p condition == MBEDTLS_CT_FALSE.
260 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise \c if0.
273 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
274 * \param if0 Value to use if \p condition == MBEDTLS_CT_FALSE.
276 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise \c if0.
289 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
290 * \param if0 Value to use if \p condition == MBEDTLS_CT_FALSE.
292 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise \c if0.
307 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
308 * \param if0 Value to use if \p condition == MBEDTLS_CT_FALSE.
310 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise \c if0.
328 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
330 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise 0.
344 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
346 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise 0.
361 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
363 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise 0.
379 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
381 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise 0.
388 /** Constant-flow char selection
395 * \return \p t if \p low <= \p c <= \p high, 0 otherwise.
402 /** Choose between two error values. The values must be in the range [-32767..0].
409 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
410 * \param if0 Value to use if \p condition == MBEDTLS_CT_FALSE.
412 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise \c if0.
416 /** Choose between an error value and 0. The error value must be in the range [-32767..0].
426 * \param if1 Value to use if \p condition == MBEDTLS_CT_TRUE.
428 * \return \c if1 if \p condition == MBEDTLS_CT_TRUE, otherwise 0.
456 * memmove(start, start + offset, total - offset);
457 * memset(start + (total - offset), 0, offset);
463 * \param offset Secret. Offset from which to copy \p total - \p offset bytes.
488 * \param src1 Secret. Pointer to copy from (if \p condition == MBEDTLS_CT_TRUE).
489 * This may be equal to \p dest, but may not overlap in other ways.
490 * \param src2 Secret (contents only - may branch to determine if this parameter is NULL).
491 …* Pointer to copy from (if \p condition == MBEDTLS_CT_FALSE and \p src2 is not NU…
492 …* This may be equal to \p dest, but may not overlap it in other ways. It may over…
508 * This function copies \p len bytes from \p src + \p offset to
509 * \p dst, with a code flow and memory access pattern that does not depend on
510 * \p offset, but only on \p offset_min, \p offset_max and \p len.
512 * \note This function reads from \p dest, but the value that
514 * function's behavior is well-defined regardless of the
517 * if \p dest is not initialized.
520 * buffer of at least \p len bytes.
522 * readable buffer of at least \p offset_max + \p len
523 * bytes. Shouldn't overlap with \p dest
525 * This must be no less than \p offset_min and no greater
526 * than \p offset_max.
527 * \param offset_min The minimal value of \p offset.
528 * \param offset_max The maximal value of \p offset.
547 /** Constant-time buffer comparison without branches.
550 * the input data - differences in the head or tail are ignored. Functionally equivalent to:
552 * memcmp(a + skip_head, b + skip_head, size - skip_head - skip_tail)
554 * Time taken depends on \p n, but not on \p skip_head or \p skip_tail .
556 * Behaviour is undefined if ( \p skip_head + \p skip_tail) > \p n.
558 …* \param a Secret. Pointer to the first buffer, containing at least \p n bytes. May not be…
559 …* \param b Secret. Pointer to the second buffer, containing at least \p n bytes. May not b…
561 …* \param skip_head Secret. The number of bytes to treat as non-significant at the start of the buf…
563 …* \param skip_tail Secret. The number of bytes to treat as non-significant at the end of the buffe…
566 * \return Zero if the contents of the two buffers are the same, otherwise non-zero.