Mbed TLS v3.6.1
ssl_cache.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  */
10 #ifndef MBEDTLS_SSL_CACHE_H
11 #define MBEDTLS_SSL_CACHE_H
12 #include "mbedtls/private_access.h"
13 
14 #include "mbedtls/build_info.h"
15 
16 #include "mbedtls/ssl.h"
17 
18 #if defined(MBEDTLS_THREADING_C)
19 #include "mbedtls/threading.h"
20 #endif
21 
30 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT)
31 #define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400
32 #endif
33 
34 #if !defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES)
35 #define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50
36 #endif
37 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
46 
51 #if defined(MBEDTLS_HAVE_TIME)
53 #endif
54 
55  unsigned char MBEDTLS_PRIVATE(session_id)[32];
56  size_t MBEDTLS_PRIVATE(session_id_len);
57 
58  unsigned char *MBEDTLS_PRIVATE(session);
59  size_t MBEDTLS_PRIVATE(session_len);
60 
62 };
63 
69  int MBEDTLS_PRIVATE(timeout);
70  int MBEDTLS_PRIVATE(max_entries);
71 #if defined(MBEDTLS_THREADING_C)
73 #endif
74 };
75 
82 
99 int mbedtls_ssl_cache_get(void *data,
100  unsigned char const *session_id,
101  size_t session_id_len,
102  mbedtls_ssl_session *session);
103 
117 int mbedtls_ssl_cache_set(void *data,
118  unsigned char const *session_id,
119  size_t session_id_len,
120  const mbedtls_ssl_session *session);
121 
137  unsigned char const *session_id,
138  size_t session_id_len);
139 
140 #if defined(MBEDTLS_HAVE_TIME)
151 
162 {
163  return cache->MBEDTLS_PRIVATE(timeout);
164 }
165 #endif /* MBEDTLS_HAVE_TIME */
166 
175 
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* ssl_cache.h */
Build-time configuration info.
time_t mbedtls_time_t
Definition: platform_time.h:27
Macro wrapper for struct's members.
#define MBEDTLS_PRIVATE(member)
SSL/TLS functions.
static int mbedtls_ssl_cache_get_timeout(mbedtls_ssl_cache_context *cache)
Get the cache timeout.
Definition: ssl_cache.h:161
int mbedtls_ssl_cache_set(void *data, unsigned char const *session_id, size_t session_id_len, const mbedtls_ssl_session *session)
Cache set callback implementation (Thread-safe if MBEDTLS_THREADING_C is enabled)
int mbedtls_ssl_cache_remove(void *data, unsigned char const *session_id, size_t session_id_len)
Remove the cache entry by the session ID (Thread-safe if MBEDTLS_THREADING_C is enabled)
void mbedtls_ssl_cache_init(mbedtls_ssl_cache_context *cache)
Initialize an SSL cache context.
void mbedtls_ssl_cache_free(mbedtls_ssl_cache_context *cache)
Free referenced items in a cache context and clear memory.
int mbedtls_ssl_cache_get(void *data, unsigned char const *session_id, size_t session_id_len, mbedtls_ssl_session *session)
Cache get callback implementation (Thread-safe if MBEDTLS_THREADING_C is enabled)
void mbedtls_ssl_cache_set_timeout(mbedtls_ssl_cache_context *cache, int timeout)
Set the cache timeout (Default: MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT (1 day))
void mbedtls_ssl_cache_set_max_entries(mbedtls_ssl_cache_context *cache, int max)
Set the maximum number of cache entries (Default: MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES (50))
Cache context.
Definition: ssl_cache.h:67
This structure is used for storing cache entries.
Definition: ssl_cache.h:50
Threading abstraction layer.