/
draft-ietf-quic-tls.txt
2016 lines (1336 loc) · 77.9 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: June 10, 2019 sn3rd
December 07, 2018
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 [1].
Working Group information can be found at https://github.com/quicwg
[2]; source code and issues list for this draft can be found at
https://github.com/quicwg/base-drafts/labels/-tls [3].
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 June 10, 2019.
Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the
document authors. All rights reserved.
Thomson & Turner Expires June 10, 2019 [Page 1]
Internet-Draft QUIC over TLS December 2018
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 . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Notational Conventions . . . . . . . . . . . . . . . . . . . 3
2.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 4
3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 6
4. Carrying TLS Messages . . . . . . . . . . . . . . . . . . . . 7
4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 9
4.1.1. Sending and Receiving Handshake Messages . . . . . . 9
4.1.2. Encryption Level Changes . . . . . . . . . . . . . . 11
4.1.3. TLS Interface Summary . . . . . . . . . . . . . . . . 12
4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 13
4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 13
4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 14
4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 14
4.6. Rejecting 0-RTT . . . . . . . . . . . . . . . . . . . . . 14
4.7. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 15
4.8. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 15
4.9. Discarding Unused Keys . . . . . . . . . . . . . . . . . 15
5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 16
5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 17
5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 17
5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 18
5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 19
5.4.1. Header Protection Application . . . . . . . . . . . . 20
5.4.2. Header Protection Sample . . . . . . . . . . . . . . 21
5.4.3. AES-Based Header Protection . . . . . . . . . . . . . 22
5.4.4. ChaCha20-Based Header Protection . . . . . . . . . . 23
5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 23
5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 23
5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 24
6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 24
7. Security of Initial Messages . . . . . . . . . . . . . . . . 26
8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 27
8.1. Protocol and Version Negotiation . . . . . . . . . . . . 27
8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 27
8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 28
9. Security Considerations . . . . . . . . . . . . . . . . . . . 28
Thomson & Turner Expires June 10, 2019 [Page 2]
Internet-Draft QUIC over TLS December 2018
9.1. Packet Reflection Attack Mitigation . . . . . . . . . . . 28
9.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 29
9.3. Header Protection Analysis . . . . . . . . . . . . . . . 29
9.4. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 30
10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 31
11. References . . . . . . . . . . . . . . . . . . . . . . . . . 31
11.1. Normative References . . . . . . . . . . . . . . . . . . 31
11.2. Informative References . . . . . . . . . . . . . . . . . 32
11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 33
A.1. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 33
A.2. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 33
A.3. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 33
A.4. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 33
A.5. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 34
A.6. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 34
A.7. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 34
A.8. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 34
A.9. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 34
A.10. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 34
A.11. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 34
A.12. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 34
A.13. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 35
A.14. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 35
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 35
Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 35
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
Thomson & Turner Expires June 10, 2019 [Page 3]
Internet-Draft QUIC over TLS December 2018
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
below:
+--------------+--------------+--------------+
| Handshake | Alerts | Application |
| Layer | | Data |
| | | |
+--------------+--------------+--------------+
| |
| Record Layer |
| |
+--------------------------------------------+
Each upper layer (handshake, alerts, and application data) is carried
as a series of typed TLS records. Records are individually
cryptographically protected and then transmitted over a reliable
transport (typically TCP) which provides sequencing and guaranteed
delivery.
Change Cipher Spec records cannot be sent in QUIC.
The TLS authenticated key exchange occurs between two entities:
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 (DH) key exchanges. PSK is the basis for
0-RTT; the latter provides perfect forward secrecy (PFS) when the DH
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
Thomson & Turner Expires June 10, 2019 [Page 4]
Internet-Draft QUIC over TLS December 2018
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:
o 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.
o 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 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 1. Note that this omits the EndOfEarlyData message, which is
not used in QUIC (see Section 8.3).
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 1: TLS Handshake with 0-RTT
Data is protected using a number of encryption levels:
o Plaintext
o Early Data (0-RTT) Keys
Thomson & Turner Expires June 10, 2019 [Page 5]
Internet-Draft QUIC over TLS December 2018
o Handshake Keys
o 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.
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 below.
+--------------+--------------+ +-------------+
| TLS | TLS | | QUIC |
| Handshake | Alerts | | Applications|
| | | | (h2q, etc.) |
+--------------+--------------+-+-------------+
| |
| QUIC Transport |
| (streams, reliability, congestion, etc.) |
| |
+---------------------------------------------+
| |
| QUIC Packet Protection |
| |
+---------------------------------------------+
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 are co-dependent:
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:
Thomson & Turner Expires June 10, 2019 [Page 6]
Internet-Draft QUIC over TLS December 2018
o The TLS component sends and receives messages via the QUIC
component, with QUIC providing a reliable stream abstraction to
TLS.
o 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 2 shows these interactions in more detail, with the QUIC
packet protection being called out specially.
+------------+ +------------+
| |<- Handshake Messages ->| |
| |<---- 0-RTT Keys -------| |
| |<--- Handshake Keys-----| |
| QUIC |<---- 1-RTT Keys -------| TLS |
| |<--- Handshake Done ----| |
+------------+ +------------+
| ^
| Protect | Protected
v | Packet
+------------+
| QUIC |
| Packet |
| Protection |
+------------+
Figure 2: 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 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
Thomson & Turner Expires June 10, 2019 [Page 7]
Internet-Draft QUIC over TLS December 2018
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.
Each encryption level has a specific list of frames which may appear
in it. 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:
o CRYPTO frames MAY appear in packets of any encryption level except
0-RTT.
o CONNECTION_CLOSE MAY appear in packets of any encryption level
other than 0-RTT.
o PADDING frames MAY appear in packets of any encryption level.
o 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.
o STREAM frames MUST ONLY appear in the 0-RTT and 1-RTT levels.
o All other frame types MUST only appear at the 1-RTT levels.
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 |
| | | |
| Short Header | 1-RTT | 0/1-RTT |
+-----------------+------------------+-----------+
Table 1: Encryption Levels by Packet Type
Thomson & Turner Expires June 10, 2019 [Page 8]
Internet-Draft QUIC over TLS December 2018
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 2, the interface from QUIC to TLS consists of
three primary functions:
o Sending and receiving handshake messages
o Rekeying (both transmit and receive)
o Handshake state updates
Additional functions might be needed to configure TLS.
4.1.1. 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.
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 given 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.
When an endpoint receives a QUIC packet containing a CRYPTO frame
from the network, it proceeds as follows:
Thomson & Turner Expires June 10, 2019 [Page 9]
Internet-Draft QUIC over TLS December 2018
o 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.
o 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.
o 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.
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.
Important: Until the handshake is reported as complete, the
connection and key exchange are not properly authenticated at the
server. Even though 1-RTT keys are available to a server after
receiving the first handshake messages from a client, the server
cannot consider the client to be authenticated until it receives
and validates the client's Finished message.
Thomson & Turner Expires June 10, 2019 [Page 10]
Internet-Draft QUIC over TLS December 2018
The requirement for the server to wait for the client Finished
message creates a dependency on that message being delivered. A
client can avoid the potential for head-of-line blocking that this
implies by sending a copy of the CRYPTO frame that carries the
Finished message in multiple packets. This enables immediate
server processing for those packets.
4.1.2. Encryption Level Changes
As keys for new encryption levels become available, TLS provides QUIC
with those keys. Separately, as TLS starts using keys at a given
encryption level, TLS indicates to QUIC that it is now reading or
writing with keys at that encryption level. 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:
o A secret
o An Authenticated Encryption with Associated Data (AEAD) function
o 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.
Thomson & Turner Expires June 10, 2019 [Page 11]
Internet-Draft QUIC over TLS December 2018
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.
4.1.3. TLS Interface Summary
Figure 3 summarizes the exchange between QUIC and TLS for both client
and server. Each arrow is tagged with the encryption level used for
that transmission.
Client Server
Get Handshake
Initial ------------->
Rekey tx to 0-RTT Keys
0-RTT --------------->
Handshake Received
Get Handshake
<------------- Initial
Rekey rx to 0-RTT keys
Handshake Received
Rekey rx to Handshake keys
Get Handshake
<----------- Handshake
Rekey tx to 1-RTT keys
<--------------- 1-RTT
Handshake Received
Rekey rx to Handshake keys
Handshake Received
Get Handshake
Handshake Complete
Handshake ----------->
Rekey tx to 1-RTT keys
1-RTT --------------->
Handshake Received
Rekey rx to 1-RTT keys
Get Handshake
Handshake Complete
<--------------- 1-RTT
Handshake Received
Figure 3: Interaction Summary between QUIC and TLS
Thomson & Turner Expires June 10, 2019 [Page 12]
Internet-Draft QUIC over TLS December 2018
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.
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
QUIC requires that the first Initial packet from a client contain an
entire cryptographic handshake message, which for TLS is the
ClientHello. Though a packet larger than 1200 bytes might be
supported by the path, a client improves the likelihood that a packet
is accepted if it ensures that the first ClientHello message is small
enough to stay within this limit.
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. Minimizing the size of these values increases the
probability that they can be successfully used by a client.
A client is not required to fit the ClientHello that it sends in
response to a HelloRetryRequest message into a single UDP datagram.
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.
Thomson & Turner Expires June 10, 2019 [Page 13]
Internet-Draft QUIC over TLS December 2018
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]).
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 (see
Section 4.6.2 of [TLS13]).
4.5. Enabling 0-RTT
In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket
message that contains the "max_early_data" extension with the value
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. A client MUST treat receipt of a NewSessionTicket that
contains a "max_early_data" extension with any other value as a
connection error of type PROTOCOL_VIOLATION.
Early data within the TLS connection MUST NOT be used. As it is for
other TLS application data, a server MUST treat receiving early data
on the TLS connection as a connection error of type
PROTOCOL_VIOLATION.
4.6. Rejecting 0-RTT
A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This
also prevents QUIC from sending 0-RTT data. A server will always
reject 0-RTT if it sends a TLS HelloRetryRequest.
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.
Thomson & Turner Expires June 10, 2019 [Page 14]
Internet-Draft QUIC over TLS December 2018
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. 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.
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 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.9. 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
Thomson & Turner Expires June 10, 2019 [Page 15]
Internet-Draft QUIC over TLS December 2018
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.
After all CRYPTO frames for a given encryption level have been sent
and all expected CRYPTO frames received, and all the corresponding
acknowledgments have been received or sent, an endpoint starts a
timer. For 0-RTT keys, which do not carry CRYPTO frames, this timer
starts when the first packets protected with 1-RTT are sent or
received. To limit the effect of packet loss around a change in
keys, endpoints MUST retain packet protection keys for that
encryption level for at least three times the current Retransmission
Timeout (RTO) interval as defined in [QUIC-RECOVERY]. Retaining keys
for this interval allows packets containing CRYPTO or ACK frames at
that encryption level to be sent if packets are determined to be lost
or new packets require acknowledgment.
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.
Once this timer expires, an endpoint MUST NOT either accept or
generate new packets using those packet protection keys. An endpoint
can discard packet protection keys for that encryption level.
Key updates (see Section 6) can be used to update 1-RTT keys before
keys from other encryption levels are discarded. In that case,
packets protected with the newest packet protection keys and packets
sent two updates prior will appear to use the same keys. After the
handshake is complete, endpoints only need to maintain the two latest
sets of packet protection keys and MAY discard older keys. Updating
keys multiple times rapidly can cause packets to be effectively lost
if packets are significantly delayed. Because key updates can only
be performed once per round trip time, only packets that are delayed
by more than a round trip will be lost as a result of changing keys;
such packets will be marked as lost before this, as they leave a gap
in the sequence of packet numbers.
5. Packet Protection
As with TLS over TCP, QUIC protects packets with keys derived from
the TLS handshake, using the AEAD algorithm negotiated by TLS.
Thomson & Turner Expires June 10, 2019 [Page 16]
Internet-Draft QUIC over TLS December 2018
5.1. Packet Protection Keys
QUIC derives packet protection keys in the same way that TLS derives
record protection keys.
Each encryption level has separate secret values for protection of
packets sent in each direction. These traffic secrets are derived by
TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all
encryption levels except the Initial encryption level. The secrets
for the Initial encryption level are computed based on the client's
initial Destination Connection ID, as described in Section 5.2.
The keys used for packet protection are computed from the TLS secrets
using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label
function described in Section 7.1 of [TLS13]) is used, using the hash
function from the negotiated cipher suite. Other versions of TLS
MUST provide a similar function in order to be used QUIC.
The current encryption level secret and the label "quic key" are
input to the KDF to produce the AEAD key; the label "quic iv" is used
to derive the IV, see Section 5.3. The packet number protection key
uses the "quic hp" label, see Section 5.4). Using these labels
provides key separation between QUIC and TLS, see Section 9.4.
The KDF used for initial secrets is always the HKDF-Expand-Label
function from TLS 1.3 (see Section 5.2).
5.2. Initial Secrets
Initial packets are protected with a secret derived from the
Destination Connection ID field from the client's first Initial
packet of the connection. Specifically:
initial_salt = 0xef4fb0abb47470c41befcf8031334fae485e09a0
initial_secret = HKDF-Extract(initial_salt,
client_dst_connection_id)
client_initial_secret = HKDF-Expand-Label(initial_secret,
"client in", "",
Hash.length)
server_initial_secret = HKDF-Expand-Label(initial_secret,
"server in", "",
Hash.length)
The hash function for HKDF when deriving initial secrets and keys is
SHA-256 [SHA].
Thomson & Turner Expires June 10, 2019 [Page 17]
Internet-Draft QUIC over TLS December 2018
The connection ID used with HKDF-Expand-Label is the Destination
Connection ID in the Initial packet sent by the client. This will be
a randomly-selected value unless the client creates the Initial
packet after receiving a Retry packet, where the Destination
Connection ID is selected by the server.
The value of initial_salt is a 20 byte sequence shown in the figure
in hexadecimal notation. Future versions of QUIC SHOULD generate a
new salt value, thus ensuring that the keys are different for each
version of QUIC. This prevents a middlebox that only recognizes one
version of QUIC from seeing or modifying the contents of handshake
packets from future versions.
The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for
Initial packets even where the TLS versions offered do not include
TLS 1.3.
Note: The Destination Connection ID is of arbitrary length, and it
could be zero length if the server sends a Retry packet with a
zero-length Source Connection ID field. In this case, the Initial
keys provide no assurance to the client that the server received
its packet; the client has to rely on the exchange that included
the Retry packet for that property.
5.3. AEAD Usage
The Authentication Encryption with Associated Data (AEAD) [AEAD]
function used for QUIC packet protection is the AEAD that is
negotiated for use with the TLS connection. For example, if TLS is
using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is
used.
Packets are protected prior to applying header protection
(Section 5.4). The unprotected packet header is part of the
associated data (A). When removing packet protection, an endpoint
first removes the header protection.
All QUIC packets other than Version Negotiation and Retry packets are
protected with an AEAD algorithm [AEAD]. Prior to establishing a
shared secret, packets are protected with AEAD_AES_128_GCM and a key
derived from the destination connection ID in the client's first
Initial packet (see Section 5.2). This provides protection against
off-path attackers and robustness against QUIC version unaware
middleboxes, but not against on-path attackers.