00001 00006 /* 00007 * Copyright The Mbed TLS Contributors 00008 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 00009 * 00010 * This file is provided under the Apache License 2.0, or the 00011 * GNU General Public License v2.0 or later. 00012 * 00013 * ********** 00014 * Apache License 2.0: 00015 * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00017 * not use this file except in compliance with the License. 00018 * You may obtain a copy of the License at 00019 * 00020 * http://www.apache.org/licenses/LICENSE-2.0 00021 * 00022 * Unless required by applicable law or agreed to in writing, software 00023 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00024 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00025 * See the License for the specific language governing permissions and 00026 * limitations under the License. 00027 * 00028 * ********** 00029 * 00030 * ********** 00031 * GNU General Public License v2.0 or later: 00032 * 00033 * This program is free software; you can redistribute it and/or modify 00034 * it under the terms of the GNU General Public License as published by 00035 * the Free Software Foundation; either version 2 of the License, or 00036 * (at your option) any later version. 00037 * 00038 * This program is distributed in the hope that it will be useful, 00039 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00040 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00041 * GNU General Public License for more details. 00042 * 00043 * You should have received a copy of the GNU General Public License along 00044 * with this program; if not, write to the Free Software Foundation, Inc., 00045 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00046 * 00047 * ********** 00048 */ 00049 #ifndef MBEDTLS_TIMING_H 00050 #define MBEDTLS_TIMING_H 00051 00052 #if !defined(MBEDTLS_CONFIG_FILE) 00053 #include "config.h" 00054 #else 00055 #include MBEDTLS_CONFIG_FILE 00056 #endif 00057 00058 #if !defined(MBEDTLS_TIMING_ALT) 00059 // Regular implementation 00060 // 00061 00062 #include <stdint.h> 00063 00064 #ifdef __cplusplus 00065 extern "C" { 00066 #endif 00067 00071 struct mbedtls_timing_hr_time 00072 { 00073 unsigned char opaque[32]; 00074 }; 00075 00079 typedef struct 00080 { 00081 struct mbedtls_timing_hr_time timer; 00082 uint32_t int_ms; 00083 uint32_t fin_ms; 00084 } mbedtls_timing_delay_context; 00085 00086 extern volatile int mbedtls_timing_alarmed; 00087 00098 unsigned long mbedtls_timing_hardclock( void ); 00099 00117 unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset ); 00118 00129 void mbedtls_set_alarm( int seconds ); 00130 00145 void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ); 00146 00159 int mbedtls_timing_get_delay( void *data ); 00160 00161 #ifdef __cplusplus 00162 } 00163 #endif 00164 00165 #else /* MBEDTLS_TIMING_ALT */ 00166 #include "timing_alt.h" 00167 #endif /* MBEDTLS_TIMING_ALT */ 00168 00169 #ifdef __cplusplus 00170 extern "C" { 00171 #endif 00172 00173 #if defined(MBEDTLS_SELF_TEST) 00174 00179 int mbedtls_timing_self_test( int verbose ); 00180 #endif 00181 00182 #ifdef __cplusplus 00183 } 00184 #endif 00185 00186 #endif /* timing.h */