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
13  *
14  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
15  *  not use this file except in compliance with the License.
16  *  You may obtain a copy of the License at
17  *
18  *  http://www.apache.org/licenses/LICENSE-2.0
19  *
20  *  Unless required by applicable law or agreed to in writing, software
21  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23  *  See the License for the specific language governing permissions and
24  *  limitations under the License.
25  */
26 
27 #ifndef MBEDTLS_CONSTANT_TIME_INVASIVE_H
28 #define MBEDTLS_CONSTANT_TIME_INVASIVE_H
29 
30 #include "common.h"
31 
32 #if defined(MBEDTLS_TEST_HOOKS)
33 
34 /** Turn a value into a mask:
35  * - if \p low <= \p c <= \p high,
36  *   return the all-bits 1 mask, aka (unsigned) -1
37  * - otherwise, return the all-bits 0 mask, aka 0
38  *
39  * \param low   The value to analyze.
40  * \param high  The value to analyze.
41  * \param c     The value to analyze.
42  *
43  * \return      All-bits-one if \p low <= \p c <= \p high, otherwise zero.
44  */
45 unsigned char mbedtls_ct_uchar_mask_of_range( unsigned char low,
46                                               unsigned char high,
47                                               unsigned char c );
48 
49 #endif /* MBEDTLS_TEST_HOOKS */
50 
51 #endif /* MBEDTLS_CONSTANT_TIME_INVASIVE_H */
52