The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
cache.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 #ifdef WITH_TLS
18 /**
19  * $Id: 0c925ca90e434d3242d8a904a069ca64431425e8 $
20  *
21  * @file lib/tls/cache.h
22  * @brief Structures for session-resumption management.
23  *
24  * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25  */
26 RCSIDH(cache_h, "$Id: 0c925ca90e434d3242d8a904a069ca64431425e8 $")
27 
28 #include "openssl_user_macros.h"
29 
30 #include <openssl/ssl.h>
31 #include <openssl/err.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /** Current store state
38  *
39  * This tracks what session-resumption data has been provided by
40  * OpenSSL so that we can persist it asynchronously at the
41  * appropriate time.
42  */
43 typedef enum {
44  FR_TLS_CACHE_STORE_INIT = 0, //!< OpenSSL hasn't passed any cache data over.
45  FR_TLS_CACHE_STORE_REQUESTED, //!< OpenSSL passed us cache data, but we haven't
46  ///< persisted it yet.
47  FR_TLS_CACHE_STORE_PERSISTED, //!< We've persisted the cached data.
48 } fr_tls_cache_store_state_t;
49 
50 /** Current load state
51  *
52  * This tracks what session-resumption data has been requested
53  * by OpenSSL, so that was can load it asynchronously at the
54  * appropriate time.
55  */
56 typedef enum {
57  FR_TLS_CACHE_LOAD_INIT = 0, //!< Initial state.
58  FR_TLS_CACHE_LOAD_REQUESTED, //!< OpenSSL has requested session data.
59  FR_TLS_CACHE_LOAD_RETRIEVED, //!< We got the cache data from an external data store.
60  FR_TLS_CACHE_LOAD_FAILED, //!< Loading cache data failed.
61 } fr_tls_cache_load_state_t;
62 
63 /** Current delete-state
64  *
65  * This tracks whether OpenSSL has requested that session data
66  * be deleted.
67  */
68 typedef enum {
69  FR_TLS_CACHE_CLEAR_INIT = 0, //!< Initial state.
70  FR_TLS_CACHE_CLEAR_REQUESTED, //!< OpenSSL has requested we delete a cache entry.
71 } fr_tls_cache_clear_state_t;
72 
73 /** This structure holds the current cache state for the session
74  *
75  */
76 typedef struct {
77  struct {
78  fr_tls_cache_store_state_t state; //!< Tracks store state.
79  SSL_SESSION *sess; //!< Session to store.
80  } store;
81 
82  struct {
83  fr_tls_cache_load_state_t state; //!< Tracks load requests from OpenSSL.
84  uint8_t *id; //!< Session ID to load.
85  SSL_SESSION *sess; //!< Deserialized session.
86  } load;
87 
88  struct {
89  fr_tls_cache_clear_state_t state; //!< Tracks delete requests from OpenSSL.
90  uint8_t *id; //!< Session ID to be deleted.
91  } clear;
92 } fr_tls_cache_t;
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #include "conf.h"
99 #include "session.h"
100 
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104 uint8_t *fr_tls_cache_id(TALLOC_CTX *ctx, SSL_SESSION *sess);
105 
106 unlang_action_t fr_tls_cache_pending_push(request_t *request, fr_tls_session_t *tls_session);
107 
108 void fr_tls_cache_deny(request_t *request, fr_tls_session_t *tls_session);
109 
110 int fr_tls_cache_disable_cb(SSL *ssl, int is_forward_secure);
111 
112 void fr_tls_cache_session_alloc(fr_tls_session_t *tls_session);
113 
114 int fr_tls_cache_ctx_init(SSL_CTX *ctx, fr_tls_cache_conf_t const *cache_conf);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 #endif /* WITH_TLS */
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition: action.h:35
#define load(_var)
Definition: atomic_queue.h:46
#define store(_store, _var)
Definition: atomic_queue.h:48
#define RCSIDH(h, id)
Definition: build.h:482
unsigned char uint8_t
Definition: merged_model.c:30