1 /** 2 * \file constant_time_invasive.h 3 * 4 * \brief Constant-time module: interfaces for invasive testing only. 5 * 6 * The interfaces in this file are intended for testing purposes only. 7 * They SHOULD NOT be made available in library integrations except when 8 * building the library for testing. 9 */ 10 /* 11 * Copyright The Mbed TLS Contributors 12 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 13 */ 14 15 #ifndef MBEDTLS_CONSTANT_TIME_INVASIVE_H 16 #define MBEDTLS_CONSTANT_TIME_INVASIVE_H 17 18 #include "common.h" 19 20 #if defined(MBEDTLS_TEST_HOOKS) 21 22 /** Turn a value into a mask: 23 * - if \p low <= \p c <= \p high, 24 * return the all-bits 1 mask, aka (unsigned) -1 25 * - otherwise, return the all-bits 0 mask, aka 0 26 * 27 * \param low The value to analyze. 28 * \param high The value to analyze. 29 * \param c The value to analyze. 30 * 31 * \return All-bits-one if \p low <= \p c <= \p high, otherwise zero. 32 */ 33 unsigned char mbedtls_ct_uchar_mask_of_range(unsigned char low, 34 unsigned char high, 35 unsigned char c); 36 37 #endif /* MBEDTLS_TEST_HOOKS */ 38 39 #endif /* MBEDTLS_CONSTANT_TIME_INVASIVE_H */ 40