Skip to content

Commit

Permalink
QUIC CHANNEL, TXP: Discard INITIAL EL correctly
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #21547)
  • Loading branch information
hlandau authored and mattcaswell committed Aug 8, 2023
1 parent 457678d commit 3eb0f9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/internal/quic_txp.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void ossl_quic_tx_packetiser_record_received_closing_bytes(

typedef struct quic_txp_status_st {
int sent_ack_eliciting; /* Was an ACK-eliciting packet sent? */
int sent_handshake; /* Was a Handshake packet sent? */
} QUIC_TXP_STATUS;

int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp,
Expand Down
7 changes: 7 additions & 0 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,13 @@ static int ch_tx(QUIC_CHANNEL *ch)
ch->have_sent_ack_eliciting_since_rx = 1;
}

if (!ch->is_server && status.sent_handshake)
/*
* RFC 9001 s. 4.9.1: A client MUST discard Initial keys when it
* first sends a Handshake packet.
*/
ch_discard_el(ch, QUIC_ENC_LEVEL_INITIAL);

if (ch->rxku_pending_confirm_done)
ch->rxku_pending_confirm = 0;

Expand Down
4 changes: 4 additions & 0 deletions ssl/quic/quic_txp.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,10 @@ int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp,
++pkts_done;
}

status->sent_handshake
= (pkt[QUIC_ENC_LEVEL_HANDSHAKE].h_valid
&& pkt[QUIC_ENC_LEVEL_HANDSHAKE].h.bytes_appended > 0);

/* Flush & Cleanup */
res = TX_PACKETISER_RES_NO_PKT;
out:
Expand Down

0 comments on commit 3eb0f9a

Please sign in to comment.