haproxy/include/haproxy/quic_trace-t.h
Frederic Lecaille dc6a3c329a MINOR: quic: Allow the use of the new OpenSSL 3.5.0 QUIC TLS API (to be completed)
This patch allows the use of the new OpenSSL 3.5.0 QUIC TLS API when it is
available and detected at compilation time. The detection relies on the presence of the
OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_SEND macro from openssl-compat.h. Indeed this
macro is defined by OpenSSL since 3.5.0 version. It is not defined by quictls.
This helps in distinguishing these two TLS stacks. When the detection succeeds,
HAVE_OPENSSL_QUIC is also defined by openssl-compat.h. Then, this is this new macro
which is used to detect the availability of the new OpenSSL 3.5.0 QUIC TLS API.

Note that this detection is done only if USE_QUIC_OPENSSL_COMPAT is not asked.
So, USE_QUIC_OPENSSL_COMPAT and HAVE_OPENSSL_QUIC are exclusive.

At the same location, from openssl-compat.h, ssl_encryption_level_t enum is
defined. This enum was defined by quictls and expansively used by the haproxy
QUIC implementation. SSL_set_quic_transport_params() is replaced by
SSL_set_quic_tls_transport_params. SSL_set_quic_early_data_enabled() (quictls) is also replaced
by SSL_set_quic_tls_early_data_enabled() (OpenSSL). SSL_quic_read_level() (quictls)
is not defined by OpenSSL. It is only used by the traces to log the current
TLS stack decryption level (read). A macro makes it return -1 which is an
usused values.

The most of the differences between quictls and OpenSSL QUI APIs are in quic_ssl.c
where some callbacks must be defined for these two APIs. This is why this
patch modifies quic_ssl.c to define an array of OSSL_DISPATCH structs: <ha_quic_dispatch>.
Each element of this arry defines a callback. So, this patch implements these
six callabcks:

  - ha_quic_ossl_crypto_send()
  - ha_quic_ossl_crypto_recv_rcd()
  - ha_quic_ossl_crypto_release_rcd()
  - ha_quic_ossl_yield_secret()
  - ha_quic_ossl_got_transport_params() and
  - ha_quic_ossl_alert().

But at this time, these implementations which must return an int return 0 interpreted
as a failure by the OpenSSL QUIC API, except for ha_quic_ossl_alert() which
is implemented the same was as for quictls. The five remaining functions above
will be implemented by the next patches to come.

ha_quic_set_encryption_secrets() and ha_quic_add_handshake_data() have been moved
to be defined for both quictls and OpenSSL QUIC API.

These callbacks are attached to the SSL objects (sessions) calling qc_ssl_set_cbs()
new function. This latter callback the correct function to attached the correct
callbacks to the SSL objects (defined by <ha_quic_method> for quictls, and
<ha_quic_dispatch> for OpenSSL).

The calls to SSL_provide_quic_data() and SSL_process_quic_post_handshake()
have been also disabled. These functions are not defined by OpenSSL QUIC API.
At this time, the functions which call them are still defined when HAVE_OPENSSL_QUIC
is defined.
2025-05-20 15:00:06 +02:00

105 lines
4.0 KiB
C

/*
* include/haproxy/quic_trace-t.h
* Definitions for QUIC traces internal types, constants and flags.
*
* Copyright (C) 2023
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
*/
#ifndef _HAPROXY_QUIC_TRACE_T_H
#define _HAPROXY_QUIC_TRACE_T_H
#include <haproxy/quic_tls-t.h>
#include <haproxy/trace-t.h>
extern struct trace_source trace_quic;
/* Used only for QUIC TLS key phase traces */
struct quic_kp_trace {
const unsigned char *rx_sec;
size_t rx_seclen;
const struct quic_tls_kp *rx;
const unsigned char *tx_sec;
size_t tx_seclen;
const struct quic_tls_kp *tx;
};
/* Only for debug purpose */
struct enc_debug_info {
unsigned char *payload;
size_t payload_len;
unsigned char *aad;
size_t aad_len;
uint64_t pn;
};
/* Structure to store enough information about the RX CRYPTO frames. */
struct quic_rx_crypto_frm {
struct eb64_node offset_node;
uint64_t len;
const unsigned char *data;
struct quic_rx_packet *pkt;
};
#define QUIC_EV_CONN_NEW (1ULL << 0)
#define QUIC_EV_CONN_INIT (1ULL << 1)
#define QUIC_EV_CONN_ISEC (1ULL << 2)
#define QUIC_EV_CONN_RSEC (1ULL << 3)
#define QUIC_EV_CONN_WSEC (1ULL << 4)
#define QUIC_EV_CONN_RWSEC (1ULL << 5)
#define QUIC_EV_CONN_LPKT (1ULL << 6)
#define QUIC_EV_CONN_SPKT (1ULL << 7)
#define QUIC_EV_CONN_ENCPKT (1ULL << 8)
#define QUIC_EV_CONN_TXPKT (1ULL << 9)
#define QUIC_EV_CONN_PAPKT (1ULL << 10)
#define QUIC_EV_CONN_PAPKTS (1ULL << 11)
#define QUIC_EV_CONN_IO_CB (1ULL << 12)
#define QUIC_EV_CONN_RMHP (1ULL << 13)
#define QUIC_EV_CONN_PRSHPKT (1ULL << 14)
#define QUIC_EV_CONN_PRSAPKT (1ULL << 15)
#define QUIC_EV_CONN_PRSFRM (1ULL << 16)
#define QUIC_EV_CONN_PRSAFRM (1ULL << 17)
#define QUIC_EV_CONN_BFRM (1ULL << 18)
#define QUIC_EV_CONN_PHPKTS (1ULL << 19)
#define QUIC_EV_CONN_TRMHP (1ULL << 20)
#define QUIC_EV_CONN_ELRMHP (1ULL << 21)
#define QUIC_EV_CONN_RXPKT (1ULL << 22)
#define QUIC_EV_CONN_SSLDATA (1ULL << 23)
#define QUIC_EV_CONN_RXCDATA (1ULL << 24)
#define QUIC_EV_CONN_ADDDATA (1ULL << 25)
#define QUIC_EV_CONN_FFLIGHT (1ULL << 26)
#define QUIC_EV_CONN_SSLALERT (1ULL << 27)
#define QUIC_EV_CONN_PSTRM (1ULL << 28)
#define QUIC_EV_CONN_RTTUPDT (1ULL << 29)
#define QUIC_EV_CONN_CC (1ULL << 30)
#define QUIC_EV_CONN_SPPKTS (1ULL << 31)
#define QUIC_EV_CONN_PKTLOSS (1ULL << 32)
#define QUIC_EV_CONN_STIMER (1ULL << 33)
#define QUIC_EV_CONN_PTIMER (1ULL << 34)
#define QUIC_EV_CONN_SPTO (1ULL << 35)
#define QUIC_EV_CONN_BCFRMS (1ULL << 36)
#define QUIC_EV_CONN_XPRTSEND (1ULL << 37)
#define QUIC_EV_CONN_XPRTRECV (1ULL << 38)
#define QUIC_EV_CONN_FREED (1ULL << 39)
#define QUIC_EV_CONN_CLOSE (1ULL << 40)
#define QUIC_EV_CONN_ACKSTRM (1ULL << 41)
#define QUIC_EV_CONN_FRMLIST (1ULL << 42)
#define QUIC_EV_STATELESS_RST (1ULL << 43)
#define QUIC_EV_TRANSP_PARAMS (1ULL << 44)
#define QUIC_EV_CONN_IDLE_TIMER (1ULL << 45)
#define QUIC_EV_CONN_SUB (1ULL << 46)
#define QUIC_EV_CONN_ELEVELSEL (1ULL << 47)
#define QUIC_EV_CONN_RCV (1ULL << 48)
#define QUIC_EV_CONN_KILL (1ULL << 49)
#define QUIC_EV_CONN_KP (1ULL << 50)
#define QUIC_EV_CONN_SSL_COMPAT (1ULL << 51)
#define QUIC_EV_CONN_BIND_TID (1ULL << 52)
#define QUIC_EV_CONN_RELEASE_RCD (1ULL << 53)
#endif /* _HAPROXY_QUIC_TRACE_T_H */