The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
ticket_stateful.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: 09ce9ee3f9399713aa2b4b6c16c29d1ce9f84aa6 $
20 *
21 * @file lib/tls/ticket_stateful.h
22 * @brief Types for stateful TLS session resumption, the session cache
23 *
24 * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25 * @copyright 2026 Network RADIUS SAS (legal@networkradius.com)
26 */
27RCSIDH(ticket_stateful_h, "$Id: 09ce9ee3f9399713aa2b4b6c16c29d1ce9f84aa6 $")
28
29#include "openssl_user_macros.h"
30
31#include <openssl/ssl.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/** State of one cache operation
38 *
39 * All policy operations are run the same way. OpenSSL asks us for
40 * something via a callback, and the callback remembers to do it.
41 * OpenSSL then returns to us, where then see that there's a policy to
42 * be run, and run it.
43 *
44 * We can't run the interpreter from an OpenSSL callback, so we have
45 * to do it via this "back and forth" bounce.
46 *
47 * Not every operation reaches every state. A clear has nothing to report
48 * back, so it only ever moves between INIT and REQUESTED.
49 */
50typedef enum : uint8_t {
51 FR_TLS_TICKET_STATEFUL_INIT = 0, //!< Nothing has been asked for.
52 FR_TLS_TICKET_STATEFUL_REQUESTED, //!< OpenSSL has asked for the operation, and the
53 ///< section which does the work has not run yet.
54 FR_TLS_TICKET_STATEFUL_SUCCESS, //!< The operation completed. For a load that means
55 ///< the session came back from the data store, and for
56 ///< a store it means the session was persisted.
57 FR_TLS_TICKET_STATEFUL_FAILED, //!< The operation did not complete.
58} fr_tls_ticket_stateful_state_t;
59
60/** This structure holds the current cache state for the session
61 *
62 */
63typedef struct {
64 struct {
65 fr_tls_ticket_stateful_state_t state; //!< Tracks store state.
66 fr_value_box_t id; //!< ID of the session being stored
67 SSL_SESSION *sess; //!< Session to store.
68 } store;
69
70 struct {
71 fr_tls_ticket_stateful_state_t state; //!< Tracks load requests from OpenSSL.
72 fr_value_box_t id; //!< Session ID that the peer asked to resume
73 SSL_SESSION *sess; //!< Deserialized session.
74 } load;
75
76 struct {
77 fr_tls_ticket_stateful_state_t state; //!< Tracks delete requests from OpenSSL.
78 fr_value_box_t id; //!< Session ID to clear
79 } clear;
80
81 fr_value_box_t const *session_id; //!< if set, points to tls_session->session_id
82 ///< sent by the peer in ClientHello.
83 ///< The various IDs above are _usually_ the same, but
84 ///< are not _always_ the same.
85
86 bool loaded; //!< Whether `load session` ever returned a session.
87 ///< The load state above is reset as the handshake
88 ///< moves on, so it cannot answer this later. A
89 ///< failed session is only worth clearing when a
90 ///< session was loaded, because `store session` is
91 ///< not run on failure, and `load session` does not
92 ///< remove what it read.
93} fr_tls_ticket_stateful_t;
94
95#ifdef __cplusplus
96}
97#endif
98#endif /* WITH_TLS */
#define load(_var)
#define store(_store, _var)
#define RCSIDH(h, id)
Definition build.h:604
unsigned char uint8_t