00001 00006 /* 00007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 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 * This file is part of mbed TLS (https://tls.mbed.org) 00050 */ 00051 #ifndef MBEDTLS_SSL_CACHE_H 00052 #define MBEDTLS_SSL_CACHE_H 00053 00054 #if !defined(MBEDTLS_CONFIG_FILE) 00055 #include "config.h" 00056 #else 00057 #include MBEDTLS_CONFIG_FILE 00058 #endif 00059 00060 #include "ssl.h" 00061 00062 #if defined(MBEDTLS_THREADING_C) 00063 #include "threading.h" 00064 #endif 00065 00074 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT) 00075 #define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 00076 #endif 00077 00078 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES) 00079 #define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 00080 #endif 00081 00082 /* \} name SECTION: Module settings */ 00083 00084 #ifdef __cplusplus 00085 extern "C" { 00086 #endif 00087 00088 typedef struct mbedtls_ssl_cache_context mbedtls_ssl_cache_context; 00089 typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry; 00090 00094 struct mbedtls_ssl_cache_entry 00095 { 00096 #if defined(MBEDTLS_HAVE_TIME) 00097 mbedtls_time_t timestamp; 00098 #endif 00099 mbedtls_ssl_session session; 00100 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00101 mbedtls_x509_buf peer_cert; 00102 #endif 00103 mbedtls_ssl_cache_entry *next; 00104 }; 00105 00109 struct mbedtls_ssl_cache_context 00110 { 00111 mbedtls_ssl_cache_entry *chain; 00112 int timeout; 00113 int max_entries; 00114 #if defined(MBEDTLS_THREADING_C) 00115 mbedtls_threading_mutex_t mutex; 00116 #endif 00117 }; 00118 00124 void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache ); 00125 00133 int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ); 00134 00142 int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ); 00143 00144 #if defined(MBEDTLS_HAVE_TIME) 00145 00154 void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout ); 00155 #endif /* MBEDTLS_HAVE_TIME */ 00156 00164 void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max ); 00165 00171 void mbedtls_ssl_cache_free( mbedtls_ssl_cache_context *cache ); 00172 00173 #ifdef __cplusplus 00174 } 00175 #endif 00176 00177 #endif /* ssl_cache.h */