Example program to test AES-GCM functionality. Used for a workshop
Embed:
(wiki syntax)
Show/hide line numbers
ssl_cache.h
Go to the documentation of this file.
00001 /** 00002 * \file ssl_cache.h 00003 * 00004 * \brief SSL session cache implementation 00005 * 00006 * Copyright (C) 2006-2013, Brainspark B.V. 00007 * 00008 * This file is part of PolarSSL (http://www.polarssl.org) 00009 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> 00010 * 00011 * All rights reserved. 00012 * 00013 * This program is free software; you can redistribute it and/or modify 00014 * it under the terms of the GNU General Public License as published by 00015 * the Free Software Foundation; either version 2 of the License, or 00016 * (at your option) any later version. 00017 * 00018 * This program is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License along 00024 * with this program; if not, write to the Free Software Foundation, Inc., 00025 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00026 */ 00027 #ifndef POLARSSL_SSL_CACHE_H 00028 #define POLARSSL_SSL_CACHE_H 00029 00030 #include "ssl.h" 00031 00032 #if defined(POLARSSL_THREADING_C) 00033 #include "threading.h" 00034 #endif 00035 00036 /** 00037 * \name SECTION: Module settings 00038 * 00039 * The configuration options you can set for this module are in this section. 00040 * Either change them in config.h or define them on the compiler command line. 00041 * \{ 00042 */ 00043 00044 #if !defined(SSL_CACHE_DEFAULT_TIMEOUT) 00045 #define SSL_CACHE_DEFAULT_TIMEOUT 86400 /*!< 1 day */ 00046 #endif 00047 00048 #if !defined(SSL_CACHE_DEFAULT_MAX_ENTRIES) 00049 #define SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /*!< Maximum entries in cache */ 00050 #endif 00051 00052 /* \} name SECTION: Module settings */ 00053 00054 #ifdef __cplusplus 00055 extern "C" { 00056 #endif 00057 00058 typedef struct _ssl_cache_context ssl_cache_context; 00059 typedef struct _ssl_cache_entry ssl_cache_entry; 00060 00061 /** 00062 * \brief This structure is used for storing cache entries 00063 */ 00064 struct _ssl_cache_entry 00065 { 00066 #if defined(POLARSSL_HAVE_TIME) 00067 time_t timestamp ; /*!< entry timestamp */ 00068 #endif 00069 ssl_session session ; /*!< entry session */ 00070 #if defined(POLARSSL_X509_CRT_PARSE_C) 00071 x509_buf peer_cert ; /*!< entry peer_cert */ 00072 #endif 00073 ssl_cache_entry *next ; /*!< chain pointer */ 00074 }; 00075 00076 /** 00077 * \brief Cache context 00078 */ 00079 struct _ssl_cache_context 00080 { 00081 ssl_cache_entry *chain ; /*!< start of the chain */ 00082 int timeout ; /*!< cache entry timeout */ 00083 int max_entries ; /*!< maximum entries */ 00084 #if defined(POLARSSL_THREADING_C) 00085 threading_mutex_t mutex ; /*!< mutex */ 00086 #endif 00087 }; 00088 00089 /** 00090 * \brief Initialize an SSL cache context 00091 * 00092 * \param cache SSL cache context 00093 */ 00094 void ssl_cache_init( ssl_cache_context *cache ); 00095 00096 /** 00097 * \brief Cache get callback implementation 00098 * (Thread-safe if POLARSSL_THREADING_C is enabled) 00099 * 00100 * \param data SSL cache context 00101 * \param session session to retrieve entry for 00102 */ 00103 int ssl_cache_get( void *data, ssl_session *session ); 00104 00105 /** 00106 * \brief Cache set callback implementation 00107 * (Thread-safe if POLARSSL_THREADING_C is enabled) 00108 * 00109 * \param data SSL cache context 00110 * \param session session to store entry for 00111 */ 00112 int ssl_cache_set( void *data, const ssl_session *session ); 00113 00114 #if defined(POLARSSL_HAVE_TIME) 00115 /** 00116 * \brief Set the cache timeout 00117 * (Default: SSL_CACHE_DEFAULT_TIMEOUT (1 day)) 00118 * 00119 * A timeout of 0 indicates no timeout. 00120 * 00121 * \param cache SSL cache context 00122 * \param timeout cache entry timeout in seconds 00123 */ 00124 void ssl_cache_set_timeout( ssl_cache_context *cache, int timeout ); 00125 #endif /* POLARSSL_HAVE_TIME */ 00126 00127 /** 00128 * \brief Set the cache timeout 00129 * (Default: SSL_CACHE_DEFAULT_MAX_ENTRIES (50)) 00130 * 00131 * \param cache SSL cache context 00132 * \param max cache entry maximum 00133 */ 00134 void ssl_cache_set_max_entries( ssl_cache_context *cache, int max ); 00135 00136 /** 00137 * \brief Free referenced items in a cache context and clear memory 00138 * 00139 * \param cache SSL cache context 00140 */ 00141 void ssl_cache_free( ssl_cache_context *cache ); 00142 00143 #ifdef __cplusplus 00144 } 00145 #endif 00146 00147 #endif /* ssl_cache.h */ 00148 00149
Generated on Tue Jul 12 2022 19:40:20 by
1.7.2