The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
ticket.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: 272de211c2e67424d3719e4a48dcede7e4871603 $
20 *
21 * @file lib/tls/ticket.h
22 * @brief Session resumption, stateful and stateless
23 *
24 * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
25 * @copyright 2026 Network RADIUS SAS (legal@networkradius.com)
26 */
27RCSIDH(ticket_h, "$Id: 272de211c2e67424d3719e4a48dcede7e4871603 $")
28
29#include "openssl_user_macros.h"
30
31#include <openssl/ssl.h>
32#include <openssl/err.h>
33
34#include "ticket_stateful.h"
35#include "ticket_stateless.h"
36
37#ifdef _TLS_PRIVATE
38/** Is any cache operation still waiting to run?
39 *
40 * The TLS library pushes one cache operation per call, but pushing a
41 * clear will (eventually) cancel any pending load or store. Return
42 * whether there is a pending operation queued.
43 *
44 * @param[in] tls_cache to check, which may be NULL when caching is disabled.
45 * @return
46 * - true if at least one operation is queued.
47 * - false if there is nothing left to do.
48 */
49static inline bool fr_tls_ticket_stateful_pending(fr_tls_ticket_stateful_t const *tls_cache)
50{
51 if (!tls_cache) return false;
52
53 return (tls_cache->load.state == FR_TLS_TICKET_STATEFUL_REQUESTED) ||
54 (tls_cache->clear.state == FR_TLS_TICKET_STATEFUL_REQUESTED) ||
55 (tls_cache->store.state == FR_TLS_TICKET_STATEFUL_REQUESTED);
56}
57#endif
58
59/*
60 * The types above are what session.h needs. The prototypes below need
61 * the types that conf.h and session.h define.
62 */
63#include "conf.h"
64#include "session.h"
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
70/** Cache the session now that the application has decided it's OK.
71 *
72 * Just finishing the TLS handshake is not always enough. EAP runs
73 * inner methods inside of the TLS tunnel, and those methods can fail.
74 * The cache operations are marked as pending during the handshake.
75 * Calling this function tells the TLS state machine to actually store
76 * the session.
77 *
78 * All queued cache operations run before this returns. An
79 * application MUST either call this function, or
80 * fr_tls_session_fail_session(). Skipping these functions means that
81 * either a good session isn't cached, or a bad session isn't cleared.
82 * The TLS peer might then be able to resume the session.
83 *
84 * We don't allow applications to call any cache fail function. That
85 * is instead handled by fr_tls_session_fail_session(). That function
86 * both calls `fail session`, and then (if needed) `clear session`.
87 */
88unlang_action_t fr_tls_ticket_stateful_store_session(request_t *request, fr_tls_session_t *tls_session);
89
90/*
91 * The only public function is fr_tls_ticket_stateful_store_session(),
92 * which is needed for EAP. Other applications MUST instead call
93 * the various fr_session_*() functions.
94 */
95#ifdef _TLS_PRIVATE
96/*
97 * ticket.c, shared by both kinds of resumption.
98 */
99void tls_session_id_cache(fr_tls_session_t *tls_session, SSL_SESSION *sess);
100
101request_t *tls_subrequest_alloc(request_t *parent, uint32_t packet_type, fr_value_box_t const *id);
102
103int tls_ticket_id_to_box(TALLOC_CTX *ctx, fr_value_box_t *out, SSL_SESSION *sess);
104
105int tls_ticket_app_data_set(request_t *request, SSL_SESSION *sess, fr_value_box_t const *session_id);
106
107int tls_ticket_app_data_get(request_t *request, SSL_SESSION *sess, fr_value_box_t const *session_id);
108
109fr_time_delta_t tls_ticket_session_lifetime(request_t *request, fr_value_box_t const *session_id,
110 fr_tls_conf_t const *conf, SSL_SESSION *sess);
111
112bool tls_ticket_session_resumable(request_t *request, fr_value_box_t const *session_id,
113 fr_tls_conf_t const *conf, SSL_SESSION *sess);
114
115int fr_tls_ticket_disable_cb(SSL *ssl, int is_forward_secure);
116
117int fr_tls_ticket_ctx_init(SSL_CTX *ctx, fr_tls_ticket_conf_t const *cache_conf, bool client);
118
119/*
120 * ticket_stateful.c
121 */
122unlang_action_t fr_tls_ticket_stateful_clear_session(request_t *request, fr_tls_session_t *tls_session);
123
124void fr_tls_ticket_stateful_session_alloc(fr_tls_session_t *tls_session);
125
126unlang_action_t fr_tls_ticket_stateful_load_client_push(request_t *request, fr_tls_session_t *tls_session);
127
128unlang_action_t fr_tls_ticket_stateful_pending_push(request_t *request, fr_tls_session_t *tls_session);
129
130void fr_tls_ticket_stateful_disable(SSL_CTX *ctx);
131
132void fr_tls_ticket_stateful_ctx_init(SSL_CTX *ctx, fr_tls_ticket_conf_t const *cache_conf, bool client);
133
134/*
135 * ticket_stateless.c
136 */
137unlang_action_t fr_tls_ticket_stateless_pending_push(request_t *request, fr_tls_session_t *tls_session);
138
139void fr_tls_ticket_stateless_disable(SSL_CTX *ctx, bool stateful);
140
141int fr_tls_ticket_stateless_ctx_init(SSL_CTX *ctx, fr_tls_ticket_conf_t const *cache_conf);
142#endif
143
144#ifdef __cplusplus
145}
146#endif
147#endif /* WITH_TLS */
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
Definition action.h:35
static uint8_t request[4]
#define RCSIDH(h, id)
Definition build.h:604
unsigned int uint32_t
static rs_t * conf
Definition radsniff.c:52
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
static fr_slen_t parent
Definition pair.h:864
static fr_sbuff_err_t char ** out
Definition value.h:1061