00001 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 #if !defined(POLARSSL_CONFIG_OPTIONS) 00037 #define SSL_CACHE_DEFAULT_TIMEOUT 86400 00038 #define SSL_CACHE_DEFAULT_MAX_ENTRIES 50 00039 #endif /* !POLARSSL_CONFIG_OPTIONS */ 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 typedef struct _ssl_cache_context ssl_cache_context; 00046 typedef struct _ssl_cache_entry ssl_cache_entry; 00047 00051 struct _ssl_cache_entry 00052 { 00053 #if defined(POLARSSL_HAVE_TIME) 00054 time_t timestamp; 00055 #endif 00056 ssl_session session; 00057 #if defined(POLARSSL_X509_CRT_PARSE_C) 00058 x509_buf peer_cert; 00059 #endif 00060 ssl_cache_entry *next; 00061 }; 00062 00066 struct _ssl_cache_context 00067 { 00068 ssl_cache_entry *chain; 00069 int timeout; 00070 int max_entries; 00071 #if defined(POLARSSL_THREADING_C) 00072 threading_mutex_t mutex; 00073 #endif 00074 }; 00075 00081 void ssl_cache_init( ssl_cache_context *cache ); 00082 00090 int ssl_cache_get( void *data, ssl_session *session ); 00091 00099 int ssl_cache_set( void *data, const ssl_session *session ); 00100 00101 #if defined(POLARSSL_HAVE_TIME) 00102 00111 void ssl_cache_set_timeout( ssl_cache_context *cache, int timeout ); 00112 #endif /* POLARSSL_HAVE_TIME */ 00113 00121 void ssl_cache_set_max_entries( ssl_cache_context *cache, int max ); 00122 00128 void ssl_cache_free( ssl_cache_context *cache ); 00129 00130 #ifdef __cplusplus 00131 } 00132 #endif 00133 00134 #endif /* ssl_cache.h */