Skip to content

Commit

Permalink
discussion: downgrade override
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Aug 28, 2024
1 parent 0555b91 commit 28dcb9d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6816,6 +6816,7 @@ impl Connection {
.as_ref()
.map_or(false, |conn_err| !conn_err.is_app)
{
let mut force_downgrade = false;
let epoch = match self.handshake.write_level() {
crypto::Level::Initial => packet::Epoch::Initial,
crypto::Level::ZeroRTT => unreachable!(),
Expand All @@ -6831,6 +6832,7 @@ impl Connection {
// Initial later on.
//
// https://datatracker.ietf.org/doc/html/rfc9000#name-immediate-close-during-the-
force_downgrade = true;
packet::Epoch::Handshake
}
},
Expand All @@ -6845,9 +6847,17 @@ impl Connection {

// Downgrade the epoch to Initial as the remote peer might
// not be able to decrypt handshake packets yet.
//
// We don't downgrade if we forcibly downgraded an Application
// packet to a Handshake one since the
// client drops the keys for the Initial epoch upon
// sending a Handshake packet. In that scenario, we need the
// packet to remain in the Handshake
// epoch.
packet::Epoch::Handshake
if self.pkt_num_spaces[packet::Epoch::Initial]
.has_keys() =>
.has_keys() &&
!force_downgrade =>
return Ok(packet::Type::Initial),

_ => (),
Expand Down

0 comments on commit 28dcb9d

Please sign in to comment.