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 #include "ssl.h" 00028 00029 #if defined(MBEDTLS_THREADING_C) 00030 #include "threading.h" 00031 #endif 00032 00041 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT) 00042 #define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 00043 #endif 00044 00045 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES) 00046 #define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 00047 #endif 00048 00049 /* \} name SECTION: Module settings */ 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 00055 typedef struct mbedtls_ssl_cache_context mbedtls_ssl_cache_context; 00056 typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry; 00057 00061 struct mbedtls_ssl_cache_entry 00062 { 00063 #if defined(MBEDTLS_HAVE_TIME) 00064 mbedtls_time_t timestamp; 00065 #endif 00066 mbedtls_ssl_session session; 00067 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00068 mbedtls_x509_buf peer_cert; 00069 #endif 00070 mbedtls_ssl_cache_entry *next; 00071 }; 00072 00076 struct mbedtls_ssl_cache_context 00077 { 00078 mbedtls_ssl_cache_entry *chain; 00079 int timeout; 00080 int max_entries; 00081 #if defined(MBEDTLS_THREADING_C) 00082 mbedtls_threading_mutex_t mutex; 00083 #endif 00084 }; 00085 00091 void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache ); 00092 00100 int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ); 00101 00109 int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ); 00110 00111 #if defined(MBEDTLS_HAVE_TIME) 00112 00121 void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout ); 00122 #endif /* MBEDTLS_HAVE_TIME */ 00123 00131 void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max ); 00132 00138 void mbedtls_ssl_cache_free( mbedtls_ssl_cache_context *cache ); 00139 00140 #ifdef __cplusplus 00141 } 00142 #endif 00143 00144 #endif /* ssl_cache.h */