Skip to content

Commit

Permalink
proto: yield transport error for Initial packets with no CRYPTO
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Dec 19, 2023
1 parent b5d23a8 commit d200bb4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions quinn-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,10 +1812,26 @@ impl Connection {
false,
false,
);

self.process_decrypted_packet(now, remote, Some(packet_number), packet)?;
if let Some(data) = remaining {
self.handle_coalesced(now, remote, ecn, data);
}

if self.highest_space == SpaceId::Initial && self.state.is_handshake() {
// "The first packet sent by a client always includes a CRYPTO frame that contains the
// start or all of the first cryptographic handshake message. The first CRYPTO frame
// sent always begins at an offset of 0; see Section 7."
// https://www.rfc-editor.org/rfc/rfc9000.html#section-17.2.2
let space = &self.spaces[SpaceId::Initial];
if space.crypto_stream.bytes_read() == 0 {
return Err(TransportError::PROTOCOL_VIOLATION(
"received initial packet without CRYPTO frames",
)
.into());
}
}

Ok(())
}

Expand Down

0 comments on commit d200bb4

Please sign in to comment.