-
Notifications
You must be signed in to change notification settings - Fork 202
/
draft-ietf-quic-tls.txt
3046 lines (2346 loc) · 130 KB
/
draft-ietf-quic-tls.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
QUIC M. Thomson, Ed.
Internet-Draft Mozilla
Intended status: Standards Track S. Turner, Ed.
Expires: 23 July 2021 sn3rd
19 January 2021
Using TLS to Secure QUIC
draft-ietf-quic-tls
Abstract
This document describes how Transport Layer Security (TLS) is used to
secure QUIC.
Note to Readers
Discussion of this draft takes place on the QUIC working group
mailing list (quic@ietf.org), which is archived at
https://mailarchive.ietf.org/arch/search/?email_list=quic.
Working Group information can be found at https://github.com/quicwg;
source code and issues list for this draft can be found at
https://github.com/quicwg/base-drafts/labels/-tls.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on 23 July 2021.
Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components
extracted from this document must include Simplified BSD License text
as described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Simplified BSD License.
Table of Contents
1. Introduction
2. Notational Conventions
2.1. TLS Overview
3. Protocol Overview
4. Carrying TLS Messages
4.1. Interface to TLS
4.1.1. Handshake Complete
4.1.2. Handshake Confirmed
4.1.3. Sending and Receiving Handshake Messages
4.1.4. Encryption Level Changes
4.1.5. TLS Interface Summary
4.2. TLS Version
4.3. ClientHello Size
4.4. Peer Authentication
4.5. Session Resumption
4.6. 0-RTT
4.6.1. Enabling 0-RTT
4.6.2. Accepting and Rejecting 0-RTT
4.6.3. Validating 0-RTT Configuration
4.7. HelloRetryRequest
4.8. TLS Errors
4.9. Discarding Unused Keys
4.9.1. Discarding Initial Keys
4.9.2. Discarding Handshake Keys
4.9.3. Discarding 0-RTT Keys
5. Packet Protection
5.1. Packet Protection Keys
5.2. Initial Secrets
5.3. AEAD Usage
5.4. Header Protection
5.4.1. Header Protection Application
5.4.2. Header Protection Sample
5.4.3. AES-Based Header Protection
5.4.4. ChaCha20-Based Header Protection
5.5. Receiving Protected Packets
5.6. Use of 0-RTT Keys
5.7. Receiving Out-of-Order Protected Packets
5.8. Retry Packet Integrity
6. Key Update
6.1. Initiating a Key Update
6.2. Responding to a Key Update
6.3. Timing of Receive Key Generation
6.4. Sending with Updated Keys
6.5. Receiving with Different Keys
6.6. Limits on AEAD Usage
6.7. Key Update Error Code
7. Security of Initial Messages
8. QUIC-Specific Adjustments to the TLS Handshake
8.1. Protocol Negotiation
8.2. QUIC Transport Parameters Extension
8.3. Removing the EndOfEarlyData Message
8.4. Prohibit TLS Middlebox Compatibility Mode
9. Security Considerations
9.1. Session Linkability
9.2. Replay Attacks with 0-RTT
9.3. Packet Reflection Attack Mitigation
9.4. Header Protection Analysis
9.5. Header Protection Timing Side-Channels
9.6. Key Diversity
9.7. Randomness
10. IANA Considerations
11. References
11.1. Normative References
11.2. Informative References
Appendix A. Sample Packet Protection
A.1. Keys
A.2. Client Initial
A.3. Server Initial
A.4. Retry
A.5. ChaCha20-Poly1305 Short Header Packet
Appendix B. AEAD Algorithm Analysis
B.1. Analysis of AEAD_AES_128_GCM and AEAD_AES_256_GCM Usage
Limits
B.1.1. Confidentiality Limit
B.1.2. Integrity Limit
B.2. Analysis of AEAD_AES_128_CCM Usage Limits
Appendix C. Change Log
C.1. Since draft-ietf-quic-tls-32
C.2. Since draft-ietf-quic-tls-31
C.3. Since draft-ietf-quic-tls-30
C.4. Since draft-ietf-quic-tls-29
C.5. Since draft-ietf-quic-tls-28
C.6. Since draft-ietf-quic-tls-27
C.7. Since draft-ietf-quic-tls-26
C.8. Since draft-ietf-quic-tls-25
C.9. Since draft-ietf-quic-tls-24
C.10. Since draft-ietf-quic-tls-23
C.11. Since draft-ietf-quic-tls-22
C.12. Since draft-ietf-quic-tls-21
C.13. Since draft-ietf-quic-tls-20
C.14. Since draft-ietf-quic-tls-18
C.15. Since draft-ietf-quic-tls-17
C.16. Since draft-ietf-quic-tls-14
C.17. Since draft-ietf-quic-tls-13
C.18. Since draft-ietf-quic-tls-12
C.19. Since draft-ietf-quic-tls-11
C.20. Since draft-ietf-quic-tls-10
C.21. Since draft-ietf-quic-tls-09
C.22. Since draft-ietf-quic-tls-08
C.23. Since draft-ietf-quic-tls-07
C.24. Since draft-ietf-quic-tls-05
C.25. Since draft-ietf-quic-tls-04
C.26. Since draft-ietf-quic-tls-03
C.27. Since draft-ietf-quic-tls-02
C.28. Since draft-ietf-quic-tls-01
C.29. Since draft-ietf-quic-tls-00
C.30. Since draft-thomson-quic-tls-01
Contributors
Authors' Addresses
1. Introduction
This document describes how QUIC [QUIC-TRANSPORT] is secured using
TLS [TLS13].
TLS 1.3 provides critical latency improvements for connection
establishment over previous versions. Absent packet loss, most new
connections can be established and secured within a single round
trip; on subsequent connections between the same client and server,
the client can often send application data immediately, that is,
using a zero round trip setup.
This document describes how TLS acts as a security component of QUIC.
2. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here.
This document uses the terminology established in [QUIC-TRANSPORT].
For brevity, the acronym TLS is used to refer to TLS 1.3, though a
newer version could be used; see Section 4.2.
2.1. TLS Overview
TLS provides two endpoints with a way to establish a means of
communication over an untrusted medium (for example, the Internet).
TLS enables authentication of peers and provides confidentiality and
integrity protection for messages that endpoints exchange.
Internally, TLS is a layered protocol, with the structure shown in
Figure 1.
+-------------+------------+--------------+---------+
Content | | | Application | |
Layer | Handshake | Alerts | Data | ... |
| | | | |
+-------------+------------+--------------+---------+
Record | |
Layer | Records |
| |
+---------------------------------------------------+
Figure 1: TLS Layers
Each Content layer message (e.g., Handshake, Alerts, and Application
Data) is carried as a series of typed TLS records by the Record
layer. Records are individually cryptographically protected and then
transmitted over a reliable transport (typically TCP), which provides
sequencing and guaranteed delivery.
The TLS authenticated key exchange occurs between two endpoints:
client and server. The client initiates the exchange and the server
responds. If the key exchange completes successfully, both client
and server will agree on a secret. TLS supports both pre-shared key
(PSK) and Diffie-Hellman over either finite fields or elliptic curves
((EC)DHE) key exchanges. PSK is the basis for Early Data (0-RTT);
the latter provides forward secrecy (FS) when the (EC)DHE keys are
destroyed. The two modes can also be combined, to provide forward
secrecy while using the PSK for authentication.
After completing the TLS handshake, the client will have learned and
authenticated an identity for the server and the server is optionally
able to learn and authenticate an identity for the client. TLS
supports X.509 [RFC5280] certificate-based authentication for both
server and client. When PSK key exchange is used (as in resumption),
knowledge of the PSK serves to authenticate the peer.
The TLS key exchange is resistant to tampering by attackers and it
produces shared secrets that cannot be controlled by either
participating peer.
TLS provides two basic handshake modes of interest to QUIC:
* A full 1-RTT handshake, in which the client is able to send
Application Data after one round trip and the server immediately
responds after receiving the first handshake message from the
client.
* A 0-RTT handshake, in which the client uses information it has
previously learned about the server to send Application Data
immediately. This Application Data can be replayed by an attacker
so 0-RTT is not suitable for carrying instructions that might
initiate any action that could cause unwanted effects if replayed.
A simplified TLS handshake with 0-RTT application data is shown in
Figure 2.
Client Server
ClientHello
(0-RTT Application Data) -------->
ServerHello
{EncryptedExtensions}
{Finished}
<-------- [Application Data]
{Finished} -------->
[Application Data] <-------> [Application Data]
() Indicates messages protected by Early Data (0-RTT) Keys
{} Indicates messages protected using Handshake Keys
[] Indicates messages protected using Application Data
(1-RTT) Keys
Figure 2: TLS Handshake with 0-RTT
Figure 2 omits the EndOfEarlyData message, which is not used in QUIC;
see Section 8.3. Likewise, neither ChangeCipherSpec nor KeyUpdate
messages are used by QUIC. ChangeCipherSpec is redundant in TLS 1.3;
see Section 8.4. QUIC has its own key update mechanism; see
Section 6.
Data is protected using a number of encryption levels:
* Initial Keys
* Early Data (0-RTT) Keys
* Handshake Keys
* Application Data (1-RTT) Keys
Application Data may appear only in the Early Data and Application
Data levels. Handshake and Alert messages may appear in any level.
The 0-RTT handshake can be used if the client and server have
previously communicated. In the 1-RTT handshake, the client is
unable to send protected Application Data until it has received all
of the Handshake messages sent by the server.
3. Protocol Overview
QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality
and integrity protection of packets. For this it uses keys derived
from a TLS handshake [TLS13], but instead of carrying TLS records
over QUIC (as with TCP), TLS Handshake and Alert messages are carried
directly over the QUIC transport, which takes over the
responsibilities of the TLS record layer, as shown in Figure 3.
+--------------+--------------+ +-------------+
| TLS | TLS | | QUIC |
| Handshake | Alerts | | Applications|
| | | | (h3, etc.) |
+--------------+--------------+-+-------------+
| |
| QUIC Transport |
| (streams, reliability, congestion, etc.) |
| |
+---------------------------------------------+
| |
| QUIC Packet Protection |
| |
+---------------------------------------------+
Figure 3: QUIC Layers
QUIC also relies on TLS for authentication and negotiation of
parameters that are critical to security and performance.
Rather than a strict layering, these two protocols cooperate: QUIC
uses the TLS handshake; TLS uses the reliability, ordered delivery,
and record layer provided by QUIC.
At a high level, there are two main interactions between the TLS and
QUIC components:
* The TLS component sends and receives messages via the QUIC
component, with QUIC providing a reliable stream abstraction to
TLS.
* The TLS component provides a series of updates to the QUIC
component, including (a) new packet protection keys to install (b)
state changes such as handshake completion, the server
certificate, etc.
Figure 4 shows these interactions in more detail, with the QUIC
packet protection being called out specially.
+------------+ +------------+
| |<---- Handshake Messages ----->| |
| |<- Validate 0-RTT parameters ->| |
| |<--------- 0-RTT Keys ---------| |
| QUIC |<------- Handshake Keys -------| TLS |
| |<--------- 1-RTT Keys ---------| |
| |<------- Handshake Done -------| |
+------------+ +------------+
| ^
| Protect | Protected
v | Packet
+------------+
| QUIC |
| Packet |
| Protection |
+------------+
Figure 4: QUIC and TLS Interactions
Unlike TLS over TCP, QUIC applications that want to send data do not
send it through TLS "application_data" records. Rather, they send it
as QUIC STREAM frames or other frame types, which are then carried in
QUIC packets.
4. Carrying TLS Messages
QUIC carries TLS handshake data in CRYPTO frames, each of which
consists of a contiguous block of handshake data identified by an
offset and length. Those frames are packaged into QUIC packets and
encrypted under the current encryption level. As with TLS over TCP,
once TLS handshake data has been delivered to QUIC, it is QUIC's
responsibility to deliver it reliably. Each chunk of data that is
produced by TLS is associated with the set of keys that TLS is
currently using. If QUIC needs to retransmit that data, it MUST use
the same keys even if TLS has already updated to newer keys.
Each encryption level corresponds to a packet number space. The
packet number space that is used determines the semantics of frames.
Some frames are prohibited in different packet number spaces; see
Section 12.5 of [QUIC-TRANSPORT].
Because packets could be reordered on the wire, QUIC uses the packet
type to indicate which keys were used to protect a given packet, as
shown in Table 1. When packets of different types need to be sent,
endpoints SHOULD use coalesced packets to send them in the same UDP
datagram.
+=====================+=================+==================+
| Packet Type | Encryption Keys | PN Space |
+=====================+=================+==================+
| Initial | Initial secrets | Initial |
+---------------------+-----------------+------------------+
| 0-RTT Protected | 0-RTT | Application data |
+---------------------+-----------------+------------------+
| Handshake | Handshake | Handshake |
+---------------------+-----------------+------------------+
| Retry | Retry | N/A |
+---------------------+-----------------+------------------+
| Version Negotiation | N/A | N/A |
+---------------------+-----------------+------------------+
| Short Header | 1-RTT | Application data |
+---------------------+-----------------+------------------+
Table 1: Encryption Keys by Packet Type
Section 17 of [QUIC-TRANSPORT] shows how packets at the various
encryption levels fit into the handshake process.
4.1. Interface to TLS
As shown in Figure 4, the interface from QUIC to TLS consists of four
primary functions:
* Sending and receiving handshake messages
* Processing stored transport and application state from a resumed
session and determining if it is valid to generate or accept early
data
* Rekeying (both transmit and receive)
* Handshake state updates
Additional functions might be needed to configure TLS. In
particular, QUIC and TLS need to agree on which is responsible for
validation of peer credentials, such as certificate validation
([RFC5280]).
4.1.1. Handshake Complete
In this document, the TLS handshake is considered complete when the
TLS stack has reported that the handshake is complete. This happens
when the TLS stack has both sent a Finished message and verified the
peer's Finished message. Verifying the peer's Finished provides the
endpoints with an assurance that previous handshake messages have not
been modified. Note that the handshake does not complete at both
endpoints simultaneously. Consequently, any requirement that is
based on the completion of the handshake depends on the perspective
of the endpoint in question.
4.1.2. Handshake Confirmed
In this document, the TLS handshake is considered confirmed at the
server when the handshake completes. The server MUST send a
HANDSHAKE_DONE frame as soon as the handshake is complete. At the
client, the handshake is considered confirmed when a HANDSHAKE_DONE
frame is received.
Additionally, a client MAY consider the handshake to be confirmed
when it receives an acknowledgment for a 1-RTT packet. This can be
implemented by recording the lowest packet number sent with 1-RTT
keys, and comparing it to the Largest Acknowledged field in any
received 1-RTT ACK frame: once the latter is greater than or equal to
the former, the handshake is confirmed.
4.1.3. Sending and Receiving Handshake Messages
In order to drive the handshake, TLS depends on being able to send
and receive handshake messages. There are two basic functions on
this interface: one where QUIC requests handshake messages and one
where QUIC provides bytes that comprise handshake messages.
Before starting the handshake QUIC provides TLS with the transport
parameters (see Section 8.2) that it wishes to carry.
A QUIC client starts TLS by requesting TLS handshake bytes from TLS.
The client acquires handshake bytes before sending its first packet.
A QUIC server starts the process by providing TLS with the client's
handshake bytes.
At any time, the TLS stack at an endpoint will have a current sending
encryption level and receiving encryption level. TLS encryption
levels determine the QUIC packet type and keys that are used for
protecting data.
Each encryption level is associated with a different sequence of
bytes, which is reliably transmitted to the peer in CRYPTO frames.
When TLS provides handshake bytes to be sent, they are appended to
the handshake bytes for the current encryption level. The encryption
level then determines the type of packet that the resulting CRYPTO
frame is carried in; see Table 1.
Four encryption levels are used, producing keys for Initial, 0-RTT,
Handshake, and 1-RTT packets. CRYPTO frames are carried in just
three of these levels, omitting the 0-RTT level. These four levels
correspond to three packet number spaces: Initial and Handshake
encrypted packets use their own separate spaces; 0-RTT and 1-RTT
packets use the application data packet number space.
QUIC takes the unprotected content of TLS handshake records as the
content of CRYPTO frames. TLS record protection is not used by QUIC.
QUIC assembles CRYPTO frames into QUIC packets, which are protected
using QUIC packet protection.
QUIC CRYPTO frames only carry TLS handshake messages. TLS alerts are
turned into QUIC CONNECTION_CLOSE error codes; see Section 4.8. TLS
application data and other content types cannot be carried by QUIC at
any encryption level; it is an error if they are received from the
TLS stack.
When an endpoint receives a QUIC packet containing a CRYPTO frame
from the network, it proceeds as follows:
* If the packet uses the current TLS receiving encryption level,
sequence the data into the input flow as usual. As with STREAM
frames, the offset is used to find the proper location in the data
sequence. If the result of this process is that new data is
available, then it is delivered to TLS in order.
* If the packet is from a previously installed encryption level, it
MUST NOT contain data that extends past the end of previously
received data in that flow. Implementations MUST treat any
violations of this requirement as a connection error of type
PROTOCOL_VIOLATION.
* If the packet is from a new encryption level, it is saved for
later processing by TLS. Once TLS moves to receiving from this
encryption level, saved data can be provided to TLS. When TLS
provides keys for a higher encryption level, if there is data from
a previous encryption level that TLS has not consumed, this MUST
be treated as a connection error of type PROTOCOL_VIOLATION.
Each time that TLS is provided with new data, new handshake bytes are
requested from TLS. TLS might not provide any bytes if the handshake
messages it has received are incomplete or it has no data to send.
The content of CRYPTO frames might either be processed incrementally
by TLS or buffered until complete messages or flights are available.
TLS is responsible for buffering handshake bytes that have arrived in
order. QUIC is responsible for buffering handshake bytes that arrive
out of order or for encryption levels that are not yet ready. QUIC
does not provide any means of flow control for CRYPTO frames; see
Section 7.5 of [QUIC-TRANSPORT].
Once the TLS handshake is complete, this is indicated to QUIC along
with any final handshake bytes that TLS needs to send. At this
stage, the transport parameters that the peer advertised during the
handshake are authenticated; see Section 8.2.
Once the handshake is complete, TLS becomes passive. TLS can still
receive data from its peer and respond in kind, but it will not need
to send more data unless specifically requested - either by an
application or QUIC. One reason to send data is that the server
might wish to provide additional or updated session tickets to a
client.
When the handshake is complete, QUIC only needs to provide TLS with
any data that arrives in CRYPTO streams. In the same manner that is
used during the handshake, new data is requested from TLS after
providing received data.
4.1.4. Encryption Level Changes
As keys at a given encryption level become available to TLS, TLS
indicates to QUIC that reading or writing keys at that encryption
level are available.
The availability of new keys is always a result of providing inputs
to TLS. TLS only provides new keys after being initialized (by a
client) or when provided with new handshake data.
However, a TLS implementation could perform some of its processing
asynchronously. In particular, the process of validating a
certificate can take some time. While waiting for TLS processing to
complete, an endpoint SHOULD buffer received packets if they might be
processed using keys that aren't yet available. These packets can be
processed once keys are provided by TLS. An endpoint SHOULD continue
to respond to packets that can be processed during this time.
After processing inputs, TLS might produce handshake bytes, keys for
new encryption levels, or both.
TLS provides QUIC with three items as a new encryption level becomes
available:
* A secret
* An Authenticated Encryption with Associated Data (AEAD) function
* A Key Derivation Function (KDF)
These values are based on the values that TLS negotiates and are used
by QUIC to generate packet and header protection keys; see Section 5
and Section 5.4.
If 0-RTT is possible, it is ready after the client sends a TLS
ClientHello message or the server receives that message. After
providing a QUIC client with the first handshake bytes, the TLS stack
might signal the change to 0-RTT keys. On the server, after
receiving handshake bytes that contain a ClientHello message, a TLS
server might signal that 0-RTT keys are available.
Although TLS only uses one encryption level at a time, QUIC may use
more than one level. For instance, after sending its Finished
message (using a CRYPTO frame at the Handshake encryption level) an
endpoint can send STREAM data (in 1-RTT encryption). If the Finished
message is lost, the endpoint uses the Handshake encryption level to
retransmit the lost message. Reordering or loss of packets can mean
that QUIC will need to handle packets at multiple encryption levels.
During the handshake, this means potentially handling packets at
higher and lower encryption levels than the current encryption level
used by TLS.
In particular, server implementations need to be able to read packets
at the Handshake encryption level at the same time as the 0-RTT
encryption level. A client could interleave ACK frames that are
protected with Handshake keys with 0-RTT data and the server needs to
process those acknowledgments in order to detect lost Handshake
packets.
QUIC also needs access to keys that might not ordinarily be available
to a TLS implementation. For instance, a client might need to
acknowledge Handshake packets before it is ready to send CRYPTO
frames at that encryption level. TLS therefore needs to provide keys
to QUIC before it might produce them for its own use.
4.1.5. TLS Interface Summary
Figure 5 summarizes the exchange between QUIC and TLS for both client
and server. Solid arrows indicate packets that carry handshake data;
dashed arrows show where application data can be sent. Each arrow is
tagged with the encryption level used for that transmission.
Client Server
====== ======
Get Handshake
Initial ------------->
Install tx 0-RTT Keys
0-RTT - - - - - - - ->
Handshake Received
Get Handshake
<------------- Initial
Install rx 0-RTT keys
Install Handshake keys
Get Handshake
<----------- Handshake
Install tx 1-RTT keys
<- - - - - - - - 1-RTT
Handshake Received (Initial)
Install Handshake keys
Handshake Received (Handshake)
Get Handshake
Handshake ----------->
Handshake Complete
Install 1-RTT keys
1-RTT - - - - - - - ->
Handshake Received
Handshake Complete
Handshake Confirmed
Install rx 1-RTT keys
<--------------- 1-RTT
(HANDSHAKE_DONE)
Handshake Confirmed
Figure 5: Interaction Summary between QUIC and TLS
Figure 5 shows the multiple packets that form a single "flight" of
messages being processed individually, to show what incoming messages
trigger different actions. This shows multiple "Get Handshake"
invocations to retrieve handshake messages at different encryption
levels. New handshake messages are requested after incoming packets
have been processed.
Figure 5 shows one possible structure for a simple handshake
exchange. The exact process varies based on the structure of
endpoint implementations and the order in which packets arrive.
Implementations could use a different number of operations or execute
them in other orders.
4.2. TLS Version
This document describes how TLS 1.3 [TLS13] is used with QUIC.
In practice, the TLS handshake will negotiate a version of TLS to
use. This could result in a newer version of TLS than 1.3 being
negotiated if both endpoints support that version. This is
acceptable provided that the features of TLS 1.3 that are used by
QUIC are supported by the newer version.
Clients MUST NOT offer TLS versions older than 1.3. A badly
configured TLS implementation could negotiate TLS 1.2 or another
older version of TLS. An endpoint MUST terminate the connection if a
version of TLS older than 1.3 is negotiated.
4.3. ClientHello Size
The first Initial packet from a client contains the start or all of
its first cryptographic handshake message, which for TLS is the
ClientHello. Servers might need to parse the entire ClientHello
(e.g., to access extensions such as Server Name Identification (SNI)
or Application Layer Protocol Negotiation (ALPN)) in order to decide
whether to accept the new incoming QUIC connection. If the
ClientHello spans multiple Initial packets, such servers would need
to buffer the first received fragments, which could consume excessive
resources if the client's address has not yet been validated. To
avoid this, servers MAY use the Retry feature (see Section 8.1 of
[QUIC-TRANSPORT]) to only buffer partial ClientHello messages from
clients with a validated address.
QUIC packet and framing add at least 36 bytes of overhead to the
ClientHello message. That overhead increases if the client chooses a
source connection ID longer than zero bytes. Overheads also do not
include the token or a destination connection ID longer than 8 bytes,
both of which might be required if a server sends a Retry packet.
A typical TLS ClientHello can easily fit into a 1200-byte packet.
However, in addition to the overheads added by QUIC, there are
several variables that could cause this limit to be exceeded. Large
session tickets, multiple or large key shares, and long lists of
supported ciphers, signature algorithms, versions, QUIC transport
parameters, and other negotiable parameters and extensions could
cause this message to grow.
For servers, in addition to connection IDs and tokens, the size of
TLS session tickets can have an effect on a client's ability to
connect efficiently. Minimizing the size of these values increases
the probability that clients can use them and still fit their entire
ClientHello message in their first Initial packet.
The TLS implementation does not need to ensure that the ClientHello
is large enough to meet the requirements for QUIC packets. QUIC
PADDING frames are added to increase the size of the packet as
necessary; see Section 14.1 of [QUIC-TRANSPORT].
4.4. Peer Authentication
The requirements for authentication depend on the application
protocol that is in use. TLS provides server authentication and
permits the server to request client authentication.
A client MUST authenticate the identity of the server. This
typically involves verification that the identity of the server is
included in a certificate and that the certificate is issued by a
trusted entity (see for example [RFC2818]).
Note: Where servers provide certificates for authentication, the
size of the certificate chain can consume a large number of bytes.
Controlling the size of certificate chains is critical to
performance in QUIC as servers are limited to sending 3 bytes for
every byte received prior to validating the client address; see
Section 8.1 of [QUIC-TRANSPORT]. The size of a certificate chain
can be managed by limiting the number of names or extensions;
using keys with small public key representations, like ECDSA; or
by using certificate compression [COMPRESS].
A server MAY request that the client authenticate during the
handshake. A server MAY refuse a connection if the client is unable
to authenticate when requested. The requirements for client
authentication vary based on application protocol and deployment.
A server MUST NOT use post-handshake client authentication (as
defined in Section 4.6.2 of [TLS13]), because the multiplexing
offered by QUIC prevents clients from correlating the certificate
request with the application-level event that triggered it (see
[HTTP2-TLS13]). More specifically, servers MUST NOT send post-
handshake TLS CertificateRequest messages and clients MUST treat
receipt of such messages as a connection error of type
PROTOCOL_VIOLATION.
4.5. Session Resumption
QUIC can use the session resumption feature of TLS 1.3. It does this
by carrying NewSessionTicket messages in CRYPTO frames after the
handshake is complete. Session resumption can be used to provide
0-RTT, and can also be used when 0-RTT is disabled.
Endpoints that use session resumption might need to remember some
information about the current connection when creating a resumed
connection. TLS requires that some information be retained; see
Section 4.6.1 of [TLS13]. QUIC itself does not depend on any state
being retained when resuming a connection, unless 0-RTT is also used;
see Section 7.4.1 of [QUIC-TRANSPORT] and Section 4.6.1. Application
protocols could depend on state that is retained between resumed
connections.
Clients can store any state required for resumption along with the
session ticket. Servers can use the session ticket to help carry
state.
Session resumption allows servers to link activity on the original
connection with the resumed connection, which might be a privacy
issue for clients. Clients can choose not to enable resumption to
avoid creating this correlation. Clients SHOULD NOT reuse tickets as
that allows entities other than the server to correlate connections;
see Section C.4 of [TLS13].
4.6. 0-RTT
The 0-RTT feature in QUIC allows a client to send application data
before the handshake is complete. This is made possible by reusing
negotiated parameters from a previous connection. To enable this,
0-RTT depends on the client remembering critical parameters and
providing the server with a TLS session ticket that allows the server
to recover the same information.
This information includes parameters that determine TLS state, as
governed by [TLS13], QUIC transport parameters, the chosen
application protocol, and any information the application protocol
might need; see Section 4.6.3. This information determines how 0-RTT
packets and their contents are formed.
To ensure that the same information is available to both endpoints,
all information used to establish 0-RTT comes from the same
connection. Endpoints cannot selectively disregard information that
might alter the sending or processing of 0-RTT.
[TLS13] sets a limit of 7 days on the time between the original
connection and any attempt to use 0-RTT. There are other constraints
on 0-RTT usage, notably those caused by the potential exposure to
replay attack; see Section 9.2.
4.6.1. Enabling 0-RTT
The TLS "early_data" extension in the NewSessionTicket message is
defined to convey (in the "max_early_data_size" parameter) the amount
of TLS 0-RTT data the server is willing to accept. QUIC does not use
TLS 0-RTT data. QUIC uses 0-RTT packets to carry early data.
Accordingly, the "max_early_data_size" parameter is repurposed to
hold a sentinel value 0xffffffff to indicate that the server is
willing to accept QUIC 0-RTT data; to indicate that the server does
not accept 0-RTT data, the "early_data" extension is omitted from the
NewSessionTicket. The amount of data that the client can send in
QUIC 0-RTT is controlled by the initial_max_data transport parameter
supplied by the server.
Servers MUST NOT send the early_data extension with a
max_early_data_size field set to any value other than 0xffffffff. A
client MUST treat receipt of a NewSessionTicket that contains an
early_data extension with any other value as a connection error of
type PROTOCOL_VIOLATION.
A client that wishes to send 0-RTT packets uses the early_data
extension in the ClientHello message of a subsequent handshake; see
Section 4.2.10 of [TLS13]. It then sends application data in 0-RTT
packets.
A client that attempts 0-RTT might also provide an address validation
token if the server has sent a NEW_TOKEN frame; see Section 8.1 of
[QUIC-TRANSPORT].
4.6.2. Accepting and Rejecting 0-RTT
A server accepts 0-RTT by sending an early_data extension in the
EncryptedExtensions; see Section 4.2.10 of [TLS13]. The server then
processes and acknowledges the 0-RTT packets that it receives.
A server rejects 0-RTT by sending the EncryptedExtensions without an
early_data extension. A server will always reject 0-RTT if it sends
a TLS HelloRetryRequest. When rejecting 0-RTT, a server MUST NOT
process any 0-RTT packets, even if it could. When 0-RTT was
rejected, a client SHOULD treat receipt of an acknowledgment for a
0-RTT packet as a connection error of type PROTOCOL_VIOLATION, if it
is able to detect the condition.
When 0-RTT is rejected, all connection characteristics that the
client assumed might be incorrect. This includes the choice of
application protocol, transport parameters, and any application
configuration. The client therefore MUST reset the state of all
streams, including application state bound to those streams.
A client MAY reattempt 0-RTT if it receives a Retry or Version
Negotiation packet. These packets do not signify rejection of 0-RTT.
4.6.3. Validating 0-RTT Configuration
When a server receives a ClientHello with the early_data extension,
it has to decide whether to accept or reject early data from the
client. Some of this decision is made by the TLS stack (e.g.,
checking that the cipher suite being resumed was included in the
ClientHello; see Section 4.2.10 of [TLS13]). Even when the TLS stack
has no reason to reject early data, the QUIC stack or the application
protocol using QUIC might reject early data because the configuration
of the transport or application associated with the resumed session
is not compatible with the server's current configuration.
QUIC requires additional transport state to be associated with a
0-RTT session ticket. One common way to implement this is using
stateless session tickets and storing this state in the session
ticket. Application protocols that use QUIC might have similar
requirements regarding associating or storing state. This associated
state is used for deciding whether early data must be rejected. For
example, HTTP/3 ([QUIC-HTTP]) settings determine how early data from
the client is interpreted. Other applications using QUIC could have
different requirements for determining whether to accept or reject
early data.
4.7. HelloRetryRequest
The HelloRetryRequest message (see Section 4.1.4 of [TLS13]) can be
used to request that a client provide new information, such as a key
share, or to validate some characteristic of the client. From the
perspective of QUIC, HelloRetryRequest is not differentiated from
other cryptographic handshake messages that are carried in Initial
packets. Although it is in principle possible to use this feature
for address verification, QUIC implementations SHOULD instead use the
Retry feature; see Section 8.1 of [QUIC-TRANSPORT].
4.8. TLS Errors
If TLS experiences an error, it generates an appropriate alert as
defined in Section 6 of [TLS13].
A TLS alert is converted into a QUIC connection error. The
AlertDescription value is added to 0x100 to produce a QUIC error code
from the range reserved for CRYPTO_ERROR. The resulting value is
sent in a QUIC CONNECTION_CLOSE frame of type 0x1c.
QUIC is only able to convey an alert level of "fatal". In TLS 1.3,
the only existing uses for the "warning" level are to signal
connection close; see Section 6.1 of [TLS13]. As QUIC provides
alternative mechanisms for connection termination and the TLS
connection is only closed if an error is encountered, a QUIC endpoint
MUST treat any alert from TLS as if it were at the "fatal" level.
QUIC permits the use of a generic code in place of a specific error
code; see Section 11 of [QUIC-TRANSPORT]. For TLS alerts, this
includes replacing any alert with a generic alert, such as
handshake_failure (0x128 in QUIC). Endpoints MAY use a generic error
code to avoid possibly exposing confidential information.
4.9. Discarding Unused Keys
After QUIC has completed a move to a new encryption level, packet
protection keys for previous encryption levels can be discarded.
This occurs several times during the handshake, as well as when keys
are updated; see Section 6.
Packet protection keys are not discarded immediately when new keys
are available. If packets from a lower encryption level contain
CRYPTO frames, frames that retransmit that data MUST be sent at the
same encryption level. Similarly, an endpoint generates
acknowledgments for packets at the same encryption level as the
packet being acknowledged. Thus, it is possible that keys for a
lower encryption level are needed for a short time after keys for a
newer encryption level are available.
An endpoint cannot discard keys for a given encryption level unless
it has received all the cryptographic handshake messages from its
peer at that encryption level and its peer has done the same.
Different methods for determining this are provided for Initial keys
(Section 4.9.1) and Handshake keys (Section 4.9.2). These methods do
not prevent packets from being received or sent at that encryption
level because a peer might not have received all the acknowledgments
necessary.
Though an endpoint might retain older keys, new data MUST be sent at
the highest currently-available encryption level. Only ACK frames
and retransmissions of data in CRYPTO frames are sent at a previous
encryption level. These packets MAY also include PADDING frames.
4.9.1. Discarding Initial Keys
Packets protected with Initial secrets (Section 5.2) are not
authenticated, meaning that an attacker could spoof packets with the
intent to disrupt a connection. To limit these attacks, Initial
packet protection keys are discarded more aggressively than other
keys.
The successful use of Handshake packets indicates that no more
Initial packets need to be exchanged, as these keys can only be
produced after receiving all CRYPTO frames from Initial packets.
Thus, a client MUST discard Initial keys when it first sends a
Handshake packet and a server MUST discard Initial keys when it first
successfully processes a Handshake packet. Endpoints MUST NOT send
Initial packets after this point.
This results in abandoning loss recovery state for the Initial
encryption level and ignoring any outstanding Initial packets.
4.9.2. Discarding Handshake Keys
An endpoint MUST discard its handshake keys when the TLS handshake is
confirmed (Section 4.1.2).
4.9.3. Discarding 0-RTT Keys
0-RTT and 1-RTT packets share the same packet number space, and
clients do not send 0-RTT packets after sending a 1-RTT packet
(Section 5.6).
Therefore, a client SHOULD discard 0-RTT keys as soon as it installs