00001 00006 /* 00007 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 00008 * SPDX-License-Identifier: Apache-2.0 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00011 * not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00018 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 * 00022 * This file is part of mbed TLS (https://tls.mbed.org) 00023 */ 00024 #ifndef MBEDTLS_SSL_CACHE_H 00025 #define MBEDTLS_SSL_CACHE_H 00026 00027 #if !defined(MBEDTLS_CONFIG_FILE) 00028 #include "config.h" 00029 #else 00030 #include MBEDTLS_CONFIG_FILE 00031 #endif 00032 00033 #include "ssl.h" 00034 00035 #if defined(MBEDTLS_THREADING_C) 00036 #include "threading.h" 00037 #endif 00038 00047 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT) 00048 #define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 00049 #endif 00050 00051 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES) 00052 #define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 00053 #endif 00054 00055 /* \} name SECTION: Module settings */ 00056 00057 #ifdef __cplusplus 00058 extern "C" { 00059 #endif 00060 00061 typedef struct mbedtls_ssl_cache_context mbedtls_ssl_cache_context; 00062 typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry; 00063 00067 struct mbedtls_ssl_cache_entry 00068 { 00069 #if defined(MBEDTLS_HAVE_TIME) 00070 mbedtls_time_t timestamp; 00071 #endif 00072 mbedtls_ssl_session session; 00073 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00074 mbedtls_x509_buf peer_cert; 00075 #endif 00076 mbedtls_ssl_cache_entry *next; 00077 }; 00078 00082 struct mbedtls_ssl_cache_context 00083 { 00084 mbedtls_ssl_cache_entry *chain; 00085 int timeout; 00086 int max_entries; 00087 #if defined(MBEDTLS_THREADING_C) 00088 mbedtls_threading_mutex_t mutex; 00089 #endif 00090 }; 00091 00097 void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache ); 00098 00106 int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ); 00107 00115 int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ); 00116 00117 #if defined(MBEDTLS_HAVE_TIME) 00118 00127 void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout ); 00128 #endif /* MBEDTLS_HAVE_TIME */ 00129 00137 void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max ); 00138 00144 void mbedtls_ssl_cache_free( mbedtls_ssl_cache_context *cache ); 00145 00146 #ifdef __cplusplus 00147 } 00148 #endif 00149 00150 #endif /* ssl_cache.h */