blob: 973e856d6be7672b628903ee2eabafad02be2708 [file] [log] [blame]
gabor-mezei-arm944c1072021-09-27 11:28:54 +02001/**
2 * Constant-time functions
3 *
4 * Copyright The Mbed TLS Contributors
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#include "common.h"
21
gabor-mezei-arm097d4f52021-09-27 12:55:33 +020022#if defined(MBEDTLS_BIGNUM_C)
23#include "mbedtls/bignum.h"
24#endif
25
gabor-mezei-arm944c1072021-09-27 11:28:54 +020026#include <stddef.h>
27
28int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n );
29
30int mbedtls_constant_time_memcmp( const void *v1, const void *v2, size_t len );
31
32unsigned char mbedtls_nist_kw_safer_memcmp( const void *a, const void *b, size_t n );
33
34int mbedtls_safer_memcmp( const void *a, const void *b, size_t n );
gabor-mezei-armc11cac92021-09-27 11:40:03 +020035
36
37unsigned mbedtls_cf_uint_mask( unsigned value );
gabor-mezei-armd361ccd2021-09-27 11:49:42 +020038
39size_t mbedtls_cf_size_mask( size_t bit );
gabor-mezei-arm4d6b1462021-09-27 11:53:54 +020040
41size_t mbedtls_cf_size_mask_lt( size_t x, size_t y );
gabor-mezei-arma2bcabc2021-09-27 11:58:31 +020042
43size_t mbedtls_cf_size_mask_ge( size_t x, size_t y );
gabor-mezei-arm96584dd2021-09-27 12:15:19 +020044
45size_t mbedtls_cf_size_bool_eq( size_t x, size_t y );
gabor-mezei-arm9d7bf092021-09-27 12:25:07 +020046
47unsigned mbedtls_cf_size_gt( size_t size, size_t max );
gabor-mezei-arm097d4f52021-09-27 12:55:33 +020048
49#if defined(MBEDTLS_BIGNUM_C)
50
51unsigned mbedtls_cf_mpi_uint_lt( const mbedtls_mpi_uint x,
52 const mbedtls_mpi_uint y );
53
54#endif /* MBEDTLS_BIGNUM_C */
gabor-mezei-arm75332532021-09-27 12:59:30 +020055
56unsigned mbedtls_cf_uint_if( unsigned cond, unsigned if1, unsigned if0 );
57