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_SSL_COOKIE_H 00050 #define MBEDTLS_SSL_COOKIE_H 00051 00052 #if !defined(MBEDTLS_CONFIG_FILE) 00053 #include "config.h" 00054 #else 00055 #include MBEDTLS_CONFIG_FILE 00056 #endif 00057 00058 #include "ssl.h" 00059 00060 #if defined(MBEDTLS_THREADING_C) 00061 #include "threading.h" 00062 #endif 00063 00071 #ifndef MBEDTLS_SSL_COOKIE_TIMEOUT 00072 #define MBEDTLS_SSL_COOKIE_TIMEOUT 60 00073 #endif 00074 00075 /* \} name SECTION: Module settings */ 00076 00077 #ifdef __cplusplus 00078 extern "C" { 00079 #endif 00080 00084 typedef struct 00085 { 00086 mbedtls_md_context_t hmac_ctx; 00087 #if !defined(MBEDTLS_HAVE_TIME) 00088 unsigned long serial; 00089 #endif 00090 unsigned long timeout; 00093 #if defined(MBEDTLS_THREADING_C) 00094 mbedtls_threading_mutex_t mutex; 00095 #endif 00096 } mbedtls_ssl_cookie_ctx; 00097 00101 void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx ); 00102 00106 int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, 00107 int (*f_rng)(void *, unsigned char *, size_t), 00108 void *p_rng ); 00109 00119 void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay ); 00120 00124 void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ); 00125 00129 mbedtls_ssl_cookie_write_t mbedtls_ssl_cookie_write; 00130 00134 mbedtls_ssl_cookie_check_t mbedtls_ssl_cookie_check; 00135 00136 #ifdef __cplusplus 00137 } 00138 #endif 00139 00140 #endif /* ssl_cookie.h */