/
draft-ietf-quic-tls.txt
2912 lines (1940 loc) · 114 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: 11 September 2020 sn3rd
10 March 2020
Using TLS to Secure QUIC
draft-ietf-quic-tls-latest
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
(https://mailarchive.ietf.org/arch/search/?email_list=quic).
Working Group information can be found at https://github.com/quicwg
(https://github.com/quicwg); source code and issues list for this
draft can be found at https://github.com/quicwg/base-drafts/labels/-
tls (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 11 September 2020.
Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved.
Thomson & Turner Expires 11 September 2020 [Page 1]
Internet-Draft Using TLS to Secure QUIC March 2020
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 . . . . . . . . . . . . . . . . . . . . . . . . 4
2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4
2.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 4
3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 7
4. Carrying TLS Messages . . . . . . . . . . . . . . . . . . . . 8
4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 10
4.1.1. Handshake Complete . . . . . . . . . . . . . . . . . 10
4.1.2. Handshake Confirmed . . . . . . . . . . . . . . . . . 10
4.1.3. Sending and Receiving Handshake Messages . . . . . . 10
4.1.4. Encryption Level Changes . . . . . . . . . . . . . . 12
4.1.5. TLS Interface Summary . . . . . . . . . . . . . . . . 13
4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 14
4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 15
4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 15
4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 16
4.6. Accepting and Rejecting 0-RTT . . . . . . . . . . . . . . 16
4.7. Validating 0-RTT Configuration . . . . . . . . . . . . . 17
4.8. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 17
4.9. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 18
4.10. Discarding Unused Keys . . . . . . . . . . . . . . . . . 18
4.10.1. Discarding Initial Keys . . . . . . . . . . . . . . 19
4.10.2. Discarding Handshake Keys . . . . . . . . . . . . . 19
4.10.3. Discarding 0-RTT Keys . . . . . . . . . . . . . . . 19
5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 20
5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 20
5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 20
5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 21
5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 23
5.4.1. Header Protection Application . . . . . . . . . . . . 23
5.4.2. Header Protection Sample . . . . . . . . . . . . . . 25
5.4.3. AES-Based Header Protection . . . . . . . . . . . . . 26
5.4.4. ChaCha20-Based Header Protection . . . . . . . . . . 26
5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 27
5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 27
5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 28
5.8. Retry Packet Integrity . . . . . . . . . . . . . . . . . 29
6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 30
Thomson & Turner Expires 11 September 2020 [Page 2]
Internet-Draft Using TLS to Secure QUIC March 2020
6.1. Initiating a Key Update . . . . . . . . . . . . . . . . . 31
6.2. Responding to a Key Update . . . . . . . . . . . . . . . 32
6.3. Timing of Receive Key Generation . . . . . . . . . . . . 33
6.4. Sending with Updated Keys . . . . . . . . . . . . . . . . 33
6.5. Receiving with Different Keys . . . . . . . . . . . . . . 34
6.6. Key Update Frequency . . . . . . . . . . . . . . . . . . 35
6.7. Key Update Error Code . . . . . . . . . . . . . . . . . . 35
7. Security of Initial Messages . . . . . . . . . . . . . . . . 35
8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 35
8.1. Protocol Negotiation . . . . . . . . . . . . . . . . . . 36
8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 36
8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 37
9. Security Considerations . . . . . . . . . . . . . . . . . . . 37
9.1. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 37
9.2. Packet Reflection Attack Mitigation . . . . . . . . . . . 38
9.3. Header Protection Analysis . . . . . . . . . . . . . . . 39
9.4. Header Protection Timing Side-Channels . . . . . . . . . 39
9.5. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 40
10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 41
11. References . . . . . . . . . . . . . . . . . . . . . . . . . 41
11.1. Normative References . . . . . . . . . . . . . . . . . . 41
11.2. Informative References . . . . . . . . . . . . . . . . . 42
Appendix A. Sample Packet Protection . . . . . . . . . . . . . . 43
A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 43
A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 44
A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 46
A.4. Retry . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 47
B.1. Since draft-ietf-quic-tls-26 . . . . . . . . . . . . . . 47
B.2. Since draft-ietf-quic-tls-25 . . . . . . . . . . . . . . 47
B.3. Since draft-ietf-quic-tls-24 . . . . . . . . . . . . . . 48
B.4. Since draft-ietf-quic-tls-23 . . . . . . . . . . . . . . 48
B.5. Since draft-ietf-quic-tls-22 . . . . . . . . . . . . . . 48
B.6. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 48
B.7. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 48
B.8. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 48
B.9. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 48
B.10. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 49
B.11. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 49
B.12. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 49
B.13. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 50
B.14. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 50
B.15. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 50
B.16. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 50
B.17. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 50
B.18. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 50
B.19. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 50
B.20. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 50
Thomson & Turner Expires 11 September 2020 [Page 3]
Internet-Draft Using TLS to Secure QUIC March 2020
B.21. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 50
B.22. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 50
B.23. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 51
B.24. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 51
Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 52
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 (that is, the Internet) that
ensures that messages they exchange cannot be observed, modified, or
forged.
Internally, TLS is a layered protocol, with the structure shown in
Figure 1.
Thomson & Turner Expires 11 September 2020 [Page 4]
Internet-Draft Using TLS to Secure QUIC March 2020
+-------------+------------+--------------+---------+
Handshake | | | Application | |
Layer | Handshake | Alerts | Data | ... |
| | | | |
+-------------+------------+--------------+---------+
Record | |
Layer | Records |
| |
+---------------------------------------------------+
Figure 1: TLS Layers
Each Handshake 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 0-RTT; the latter
provides perfect forward secrecy (PFS) when the (EC)DHE keys are
destroyed.
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.
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
Thomson & Turner Expires 11 September 2020 [Page 5]
Internet-Draft Using TLS to Secure QUIC March 2020
so it MUST NOT carry a self-contained trigger for any non-
idempotent action.
A simplified TLS handshake with 0-RTT application data is shown in
Figure 2. Note that this 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 and QUIC has defined its own
key update mechanism Section 6.
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
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 is only possible 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.
Thomson & Turner Expires 11 September 2020 [Page 6]
Internet-Draft Using TLS to Secure QUIC March 2020
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.
Thomson & Turner Expires 11 September 2020 [Page 7]
Internet-Draft Using TLS to Secure QUIC March 2020
+------------+ +------------+
| |<---- 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 which 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 TLS 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.
One important difference between TLS records (used with TCP) and QUIC
CRYPTO frames is that in QUIC multiple frames may appear in the same
QUIC packet as long as they are associated with the same encryption
level. For instance, an implementation might bundle a Handshake
message and an ACK for some Handshake data into the same packet.
Some frames are prohibited in different encryption levels, others
cannot be sent. The rules here generalize those of TLS, in that
frames associated with establishing the connection can usually appear
at any encryption level, whereas those associated with transferring
data can only appear in the 0-RTT and 1-RTT encryption levels:
Thomson & Turner Expires 11 September 2020 [Page 8]
Internet-Draft Using TLS to Secure QUIC March 2020
* PADDING and PING frames MAY appear in packets of any encryption
level.
* CRYPTO frames and CONNECTION_CLOSE frames signaling errors at the
QUIC layer (type 0x1c) MAY appear in packets of any encryption
level except 0-RTT.
* CONNECTION_CLOSE frames signaling application errors (type 0x1d)
MUST only be sent in packets at the 1-RTT encryption level.
* ACK frames MAY appear in packets of any encryption level other
than 0-RTT, but can only acknowledge packets which appeared in
that packet number space.
* All other frame types MUST only be sent in the 0-RTT and 1-RTT
levels.
Note that it is not possible to send the following frames in 0-RTT
for various reasons: ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN,
PATH_RESPONSE, and RETIRE_CONNECTION_ID.
Because packets could be reordered on the wire, QUIC uses the packet
type to indicate which level a given packet was encrypted under, as
shown in Table 1. When multiple packets of different encryption
levels need to be sent, endpoints SHOULD use coalesced packets to
send them in the same UDP datagram.
+---------------------+------------------+-----------+
| Packet Type | Encryption Level | PN Space |
+=====================+==================+===========+
| Initial | Initial secrets | Initial |
+---------------------+------------------+-----------+
| 0-RTT Protected | 0-RTT | 0/1-RTT |
+---------------------+------------------+-----------+
| Handshake | Handshake | Handshake |
+---------------------+------------------+-----------+
| Retry | N/A | N/A |
+---------------------+------------------+-----------+
| Version Negotiation | N/A | N/A |
+---------------------+------------------+-----------+
| Short Header | 1-RTT | 0/1-RTT |
+---------------------+------------------+-----------+
Table 1: Encryption Levels by Packet Type
Section 17 of [QUIC-TRANSPORT] shows how packets at the various
encryption levels fit into the handshake process.
Thomson & Turner Expires 11 September 2020 [Page 9]
Internet-Draft Using TLS to Secure QUIC March 2020
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 accept early data
* Rekeying (both transmit and receive)
* Handshake state updates
Additional functions might be needed to configure TLS.
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. At the client, the handshake is
considered confirmed when a HANDSHAKE_DONE frame is received.
A client MAY consider the handshake to be confirmed when it receives
an acknowledgement 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 handshake packets.
Thomson & Turner Expires 11 September 2020 [Page 10]
Internet-Draft Using TLS to Secure QUIC March 2020
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. Each encryption
level is associated with a different flow 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 current flow and
any packet that includes the CRYPTO frame is protected using keys
from the corresponding encryption level.
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 is only capable of conveying TLS handshake records in CRYPTO
frames. TLS alerts are turned into QUIC CONNECTION_CLOSE error
codes; see Section 4.9. TLS application data and other message types
cannot be carried by QUIC at any encryption level and 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 was in the 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 which 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. When providing data
from any new encryption level to TLS, 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.
Thomson & Turner Expires 11 September 2020 [Page 11]
Internet-Draft Using TLS to Secure QUIC March 2020
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.
Once the TLS handshake is complete, this is indicated to QUIC along
with any final handshake bytes that TLS needs to send. TLS also
provides QUIC with the transport parameters that the peer advertised
during the handshake.
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 way that is
done during the handshake, new data is requested from TLS after
providing received data.
4.1.4. Encryption Level Changes
As keys for new encryption levels become available, TLS provides QUIC
with those keys. Separately, 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. These events
are not asynchronous; they always occur immediately after TLS is
provided with new handshake bytes, or after TLS produces handshake
bytes.
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
Thomson & Turner Expires 11 September 2020 [Page 12]
Internet-Draft Using TLS to Secure QUIC March 2020
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. Each arrow is tagged with the encryption level used for
that transmission.
Thomson & Turner Expires 11 September 2020 [Page 13]
Internet-Draft Using TLS to Secure QUIC March 2020
Client Server
Get Handshake
Initial ------------->
Handshake Received
Install tx 0-RTT Keys
0-RTT --------------->
Get Handshake
<------------- Initial
Handshake Received
Install Handshake keys
Install rx 0-RTT keys
Install Handshake keys
Get Handshake
<----------- Handshake
Handshake Received
Install tx 1-RTT keys
<--------------- 1-RTT
Get Handshake
Handshake Complete
Handshake ----------->
Handshake Received
Install rx 1-RTT keys
Handshake Complete
Install 1-RTT keys
1-RTT --------------->
Get Handshake
<--------------- 1-RTT
Handshake Received
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. New handshake messages are requested
after all incoming packets have been processed. This process might
vary depending on how QUIC implementations and the packets they
receive are structured.
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.
Thomson & Turner Expires 11 September 2020 [Page 14]
Internet-Draft Using TLS to Secure QUIC March 2020
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
connection ID without zero length. Overheads also do not include the
token or a 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
ClientHello message in their first Initial packet.
The TLS implementation does not need to ensure that the ClientHello
is sufficiently large. QUIC PADDING frames are added to increase the
size of the packet as necessary.
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.
Thomson & Turner Expires 11 September 2020 [Page 15]
Internet-Draft Using TLS to Secure QUIC March 2020
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]).
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. Enabling 0-RTT
To communicate their willingness to process 0-RTT data, servers send
a NewSessionTicket message that contains the "early_data" extension
with a max_early_data_size of 0xffffffff; the amount of data which
the client can send in 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 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 the application data in
0-RTT packets.
4.6. 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 acknowledgement for a
Thomson & Turner Expires 11 September 2020 [Page 16]
Internet-Draft Using TLS to Secure QUIC March 2020
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 attempt to send 0-RTT again if it receives a Retry or
Version Negotiation packet. These packets do not signify rejection
of 0-RTT.
4.7. 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.8. HelloRetryRequest
In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of
[TLS13]) can be used to correct a client's incorrect KeyShare
extension as well as for a stateless round-trip check. From the
perspective of QUIC, this just looks like additional messages carried
in the Initial encryption level. Although it is in principle
possible to use this feature for address verification in QUIC, QUIC
implementations SHOULD instead use the Retry feature (see Section 8.1
of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key
shares.
Thomson & Turner Expires 11 September 2020 [Page 17]
Internet-Draft Using TLS to Secure QUIC March 2020
4.9. TLS Errors
If TLS experiences an error, it generates an appropriate alert as
defined in Section 6 of [TLS13].
A TLS alert is turned into a QUIC connection error by converting the
one-byte alert description into a QUIC error code. The alert
description 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.
The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT
generate alerts at the "warning" level.
4.10. Discarding Unused Keys
After QUIC moves 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
acknowledgements 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 both received and acknowledged all CRYPTO frames for that
encryption level and when all CRYPTO frames for that encryption level
have been acknowledged by its peer. However, this does not guarantee
that no further packets will need to be received or sent at that
encryption level because a peer might not have received all the
acknowledgements necessary to reach the same state.
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.