File tree Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Expand file tree Collapse file tree 3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ QuicPacketBuilderInitialize(
101
101
Builder -> Path = Path ;
102
102
Builder -> PacketBatchSent = FALSE;
103
103
Builder -> PacketBatchRetransmittable = FALSE;
104
+ Builder -> WrittenConnectionCloseFrame = FALSE;
104
105
Builder -> Metadata = & Builder -> MetadataStorage .Metadata ;
105
106
Builder -> EncryptionOverhead = CXPLAT_ENCRYPTION_OVERHEAD ;
106
107
Builder -> TotalDatagramsLength = 0 ;
@@ -493,9 +494,12 @@ QuicPacketBuilderGetPacketTypeAndKeyForControlFrames(
493
494
? QUIC_PACKET_KEY_HANDSHAKE
494
495
: QUIC_PACKET_KEY_INITIAL ;
495
496
496
- if (( Builder -> Datagram == NULL || Builder -> DatagramLength == 0 ) &&
497
+ if (! Builder -> WrittenConnectionCloseFrame &&
497
498
Connection -> Crypto .TlsState .WriteKeys [PreviousKeyType ] != NULL ) {
498
- MaxKeyType = PreviousKeyType ; // Use the lower key for the first packet in a datagram.
499
+ //
500
+ // Downgrade the key so that we send the CLOSE frame on previous protection level.
501
+ //
502
+ MaxKeyType = PreviousKeyType ;
499
503
}
500
504
}
501
505
Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ typedef struct QUIC_PACKET_BUILDER {
78
78
//
79
79
uint8_t EcnEctSet : 1 ;
80
80
81
+ //
82
+ // Indicates that a CONNECTION_CLOSE frame was written in some packet.
83
+ //
84
+ uint8_t WrittenConnectionCloseFrame : 1 ;
85
+
81
86
//
82
87
// The total number of datagrams that have been created.
83
88
//
Original file line number Diff line number Diff line change @@ -532,7 +532,7 @@ QuicSendWriteFrames(
532
532
char * CloseReasonPhrase = Connection -> CloseReasonPhrase ;
533
533
534
534
if (IsApplicationClose && ! Is1RttEncryptionLevel ) {
535
- //
535
+ //
536
536
// A CONNECTION_CLOSE of type 0x1d MUST be replaced by a CONNECTION_CLOSE of
537
537
// type 0x1c when sending the frame in Initial or Handshake packets. Otherwise,
538
538
// information about the application state might be revealed. Endpoints MUST
@@ -558,6 +558,8 @@ QuicSendWriteFrames(
558
558
AvailableBufferLength ,
559
559
Builder -> Datagram -> Buffer )) {
560
560
561
+ Builder -> WrittenConnectionCloseFrame = TRUE;
562
+
561
563
//
562
564
// We potentially send the close frame on multiple protection levels.
563
565
// We send in increasing encryption level so clear the flag only once
You can’t perform that action at this time.
0 commit comments