Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
ssl_cache.h
00001 /** 00002 * \file ssl_cache.h 00003 * 00004 * \brief SSL session cache implementation 00005 */ 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 00033 /** 00034 * \name SECTION: Module settings 00035 * 00036 * The configuration options you can set for this module are in this section. 00037 * Either change them in config.h or define them on the compiler command line. 00038 * \{ 00039 */ 00040 00041 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT) 00042 #define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /*!< 1 day */ 00043 #endif 00044 00045 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES) 00046 #define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /*!< Maximum entries in cache */ 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 00058 /** 00059 * \brief This structure is used for storing cache entries 00060 */ 00061 struct mbedtls_ssl_cache_entry 00062 { 00063 #if defined(MBEDTLS_HAVE_TIME) 00064 mbedtls_time_t timestamp ; /*!< entry timestamp */ 00065 #endif 00066 mbedtls_ssl_session session ; /*!< entry session */ 00067 #if defined(MBEDTLS_X509_CRT_PARSE_C) 00068 mbedtls_x509_buf peer_cert ; /*!< entry peer_cert */ 00069 #endif 00070 mbedtls_ssl_cache_entry *next ; /*!< chain pointer */ 00071 }; 00072 00073 /** 00074 * \brief Cache context 00075 */ 00076 struct mbedtls_ssl_cache_context 00077 { 00078 mbedtls_ssl_cache_entry *chain ; /*!< start of the chain */ 00079 int timeout ; /*!< cache entry timeout */ 00080 int max_entries ; /*!< maximum entries */ 00081 #if defined(MBEDTLS_THREADING_C) 00082 mbedtls_threading_mutex_t mutex ; /*!< mutex */ 00083 #endif 00084 }; 00085 00086 /** 00087 * \brief Initialize an SSL cache context 00088 * 00089 * \param cache SSL cache context 00090 */ 00091 void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache ); 00092 00093 /** 00094 * \brief Cache get callback implementation 00095 * (Thread-safe if MBEDTLS_THREADING_C is enabled) 00096 * 00097 * \param data SSL cache context 00098 * \param session session to retrieve entry for 00099 */ 00100 int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session ); 00101 00102 /** 00103 * \brief Cache set callback implementation 00104 * (Thread-safe if MBEDTLS_THREADING_C is enabled) 00105 * 00106 * \param data SSL cache context 00107 * \param session session to store entry for 00108 */ 00109 int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session ); 00110 00111 #if defined(MBEDTLS_HAVE_TIME) 00112 /** 00113 * \brief Set the cache timeout 00114 * (Default: MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT (1 day)) 00115 * 00116 * A timeout of 0 indicates no timeout. 00117 * 00118 * \param cache SSL cache context 00119 * \param timeout cache entry timeout in seconds 00120 */ 00121 void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout ); 00122 #endif /* MBEDTLS_HAVE_TIME */ 00123 00124 /** 00125 * \brief Set the maximum number of cache entries 00126 * (Default: MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES (50)) 00127 * 00128 * \param cache SSL cache context 00129 * \param max cache entry maximum 00130 */ 00131 void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max ); 00132 00133 /** 00134 * \brief Free referenced items in a cache context and clear memory 00135 * 00136 * \param cache SSL cache context 00137 */ 00138 void mbedtls_ssl_cache_free( mbedtls_ssl_cache_context *cache ); 00139 00140 #ifdef __cplusplus 00141 } 00142 #endif 00143 00144 #endif /* ssl_cache.h */
Generated on Fri Jul 22 2022 04:54:01 by
