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: d18355e9f00b59ab0ccca1bd55699008f514cce4 $
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: d18355e9f00b59ab0ccca1bd55699008f514cce4 $")
28
29#include "openssl_user_macros.h"
30
31#include <openssl/ssl.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/** The first byte of every session ID which the server generates
38 *
39 * We need to clearly separate PSK identities taken from the configuration file or database, and PSK
40 * identities which are only used for session resumption. The function session_psk_identity_is_safe() checks
41 * configured identities for validity, and rejects 0xff. We therefore use it here as a marker to distinguish
42 * the two types of identities.
43 *
44 * When an identity starts with TLS_SESSION_ID_MARKER, fr_tls_session_psk_server_cb() returns 0. OpenSSL
45 * then tries the identity as a ticket.
46 */
47#define TLS_SESSION_ID_MARKER 0xff
48
49/** State of one cache operation
50 *
51 * All policy operations are run the same way. OpenSSL asks us for
52 * something via a callback, and the callback remembers to do it.
53 * OpenSSL then returns to us, where then see that there's a policy to
54 * be run, and run it.
55 *
56 * We can't run the interpreter from an OpenSSL callback, so we have
57 * to do it via this "back and forth" bounce.
58 *
59 * Not every operation reaches every state. A clear has nothing to report
60 * back, so it only ever moves between INIT and REQUESTED.
61 */
62typedef enum : uint8_t {
63 FR_TLS_TICKET_STATEFUL_INIT = 0, //!< Nothing has been asked for.
64 FR_TLS_TICKET_STATEFUL_REQUESTED, //!< OpenSSL has asked for the operation, and the
65 ///< section which does the work has not run yet.
66 FR_TLS_TICKET_STATEFUL_SUCCESS, //!< The operation completed. For a load that means
67 ///< the session came back from the data store, and for
68 ///< a store it means the session was persisted.
69 FR_TLS_TICKET_STATEFUL_FAILED, //!< The operation did not complete.
70} fr_tls_ticket_stateful_state_t;
71
72/** This structure holds the current cache state for the session
73 *
74 */
75typedef struct {
76 struct {
77 fr_tls_ticket_stateful_state_t state; //!< Tracks store state.
78 fr_value_box_t id; //!< ID of the session being stored
79 SSL_SESSION *sess; //!< Session to store.
80 } store;
81
82 struct {
83 fr_tls_ticket_stateful_state_t state; //!< Tracks load requests from OpenSSL.
84 fr_value_box_t id; //!< Session ID that the peer asked to resume. Set when the load is
85 ///< requested, and cleared when the load fails. Stays set after a
86 ///< successful load, because a failed session is cleared by the ID in
87 ///< `load.id`. Null otherwise.
88 SSL_SESSION *sess; //!< Deserialized session.
89 bool returned; //!< We've already seen the same session
90 } load;
91
92 struct {
93 fr_tls_ticket_stateful_state_t state; //!< Tracks delete requests from OpenSSL.
94 fr_value_box_t id; //!< Session ID to clear
95 } clear;
96
97 fr_value_box_t const *session_id; //!< if set, points to tls_session->session_id
98 ///< sent by the peer in ClientHello.
99 ///< The various IDs above are _usually_ the same, but
100 ///< are not _always_ the same.
101} fr_tls_ticket_stateful_t;
102
103#ifdef __cplusplus
104}
105#endif
106#endif /* WITH_TLS */
#define load(_var)
#define store(_store, _var)
#define RCSIDH(h, id)
Definition build.h:610
unsigned char uint8_t