From 9a22770ac580781f4cc8c46e643fb70521beffe0 Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Thu, 21 Aug 2025 08:27:44 +0200 Subject: [PATCH] BUG/MINOR: quic-be: missing Initial packet number space discarding A QUIC client must discard the Initial packet number space as soon as it first sends a Handshake packet. This patch implements this packet number space which was missing. --- src/quic_tx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/quic_tx.c b/src/quic_tx.c index 160341695..bbeefe1cd 100644 --- a/src/quic_tx.c +++ b/src/quic_tx.c @@ -443,6 +443,24 @@ static int qc_send_ppkts(struct buffer *buf, struct ssl_sock_ctx *ctx) if (pkt->in_flight_len) qc_set_timer(qc); TRACE_PROTO("TX pkt", QUIC_EV_CONN_SPPKTS, qc, pkt); + if (pkt->type == QUIC_PACKET_TYPE_HANDSHAKE && qc_is_back(qc) && + qc->ipktns && !quic_tls_pktns_is_dcd(qc, qc->ipktns)) { + /* RFC 9000 + * 4.9.1. Discarding Initial Keys + * The successful use of Handshake packets indicates that no more + * Initial packets need to be exchanged, as these keys can only + * be produced after receiving all CRYPTO frames from Initial packets. + * Thus, a client MUST discard Initial keys when it first sends a + * Handshake packet... + * + * Discard the Initial packet number space. + */ + TRACE_PROTO("discarding Initial pktns", QUIC_EV_CONN_PRSHPKT, qc); + quic_pktns_discard(qc->ipktns, qc, 0); + qc_set_timer(qc); + qc_el_rx_pkts_del(qc->iel); + qc_release_pktns_frms(qc, qc->ipktns); + } next_pkt = pkt->next; quic_tx_packet_refinc(pkt); eb64_insert(&pkt->pktns->tx.pkts, &pkt->pn_node);