Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/core/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,16 +941,6 @@ QuicCryptoWriteFrames(
return TRUE;
}

if (QuicConnIsClient(Connection) &&
Builder->Key == Crypto->TlsState.WriteKeys[QUIC_PACKET_KEY_HANDSHAKE]) {
CXPLAT_DBG_ASSERT(Builder->Key);
//
// Per spec, client MUST discard Initial keys when it starts
// encrypting packets with handshake keys.
//
QuicCryptoDiscardKeys(Crypto, QUIC_PACKET_KEY_INITIAL);
}

uint8_t PrevFrameCount = Builder->Metadata->FrameCount;

uint16_t AvailableBufferLength =
Expand Down
11 changes: 11 additions & 0 deletions src/core/packet_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,17 @@ QuicPacketBuilderFinalize(
Builder->Path,
Builder->Metadata);

//
// Per RFC 9001 s4.9.1, a client MUST discard Initial keys when it first
// sends a Handshake packet. This must happen on ANY Handshake packet
// (not just those carrying CRYPTO frames) so that Initial bytes in flight
// are released from congestion control and the TLS Finished can be sent.
//
if (QuicConnIsClient(Connection) &&
Builder->Key->Type == QUIC_PACKET_KEY_HANDSHAKE) {
QuicCryptoDiscardKeys(&Connection->Crypto, QUIC_PACKET_KEY_INITIAL);
}

Builder->Metadata->FrameCount = 0;

if (Builder->Metadata->Flags.IsAckEliciting) {
Expand Down
36 changes: 17 additions & 19 deletions src/platform/tls_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3321,25 +3321,23 @@ CxPlatTlsProcessData(

Exit:

if (!(TlsContext->ResultFlags & CXPLAT_TLS_RESULT_ERROR)) {
if (State->WriteKeys[QUIC_PACKET_KEY_HANDSHAKE] != NULL &&
State->BufferOffsetHandshake == 0) {
State->BufferOffsetHandshake = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSslHandshakeDataStart,
TlsContext->Connection,
"Writing Handshake data starts at %u",
State->BufferOffsetHandshake);
}
if (State->WriteKeys[QUIC_PACKET_KEY_1_RTT] != NULL &&
State->BufferOffset1Rtt == 0) {
State->BufferOffset1Rtt = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSsl1RttDataStart,
TlsContext->Connection,
"Writing 1-RTT data starts at %u",
State->BufferOffset1Rtt);
}
if (State->WriteKeys[QUIC_PACKET_KEY_HANDSHAKE] != NULL &&
State->BufferOffsetHandshake == 0) {
State->BufferOffsetHandshake = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSslHandshakeDataStart,
TlsContext->Connection,
"Writing Handshake data starts at %u",
State->BufferOffsetHandshake);
}
if (State->WriteKeys[QUIC_PACKET_KEY_1_RTT] != NULL &&
State->BufferOffset1Rtt == 0) {
State->BufferOffset1Rtt = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSsl1RttDataStart,
TlsContext->Connection,
"Writing 1-RTT data starts at %u",
State->BufferOffset1Rtt);
}

return TlsContext->ResultFlags;
Expand Down
36 changes: 17 additions & 19 deletions src/platform/tls_quictls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2145,25 +2145,23 @@ CxPlatTlsProcessData(

Exit:

if (!(TlsContext->ResultFlags & CXPLAT_TLS_RESULT_ERROR)) {
if (State->WriteKeys[QUIC_PACKET_KEY_HANDSHAKE] != NULL &&
State->BufferOffsetHandshake == 0) {
State->BufferOffsetHandshake = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSslHandshakeDataStart,
TlsContext->Connection,
"Writing Handshake data starts at %u",
State->BufferOffsetHandshake);
}
if (State->WriteKeys[QUIC_PACKET_KEY_1_RTT] != NULL &&
State->BufferOffset1Rtt == 0) {
State->BufferOffset1Rtt = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSsl1RttDataStart,
TlsContext->Connection,
"Writing 1-RTT data starts at %u",
State->BufferOffset1Rtt);
}
if (State->WriteKeys[QUIC_PACKET_KEY_HANDSHAKE] != NULL &&
State->BufferOffsetHandshake == 0) {
State->BufferOffsetHandshake = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSslHandshakeDataStart,
TlsContext->Connection,
"Writing Handshake data starts at %u",
State->BufferOffsetHandshake);
}
if (State->WriteKeys[QUIC_PACKET_KEY_1_RTT] != NULL &&
State->BufferOffset1Rtt == 0) {
State->BufferOffset1Rtt = State->BufferTotalLength;
QuicTraceLogConnInfo(
OpenSsl1RttDataStart,
TlsContext->Connection,
"Writing 1-RTT data starts at %u",
State->BufferOffset1Rtt);
}

return TlsContext->ResultFlags;
Expand Down
Loading