-
Notifications
You must be signed in to change notification settings - Fork 10
/
rfc8446.xml
7840 lines (6746 loc) · 333 KB
/
rfc8446.xml
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
<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>
<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc strict="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc text-list-symbols="-o*+"?>
<rfc ipr="pre5378Trust200902" number="8446" category="std"
obsoletes="5077, 5246, 6961" updates="5705, 6066"
submissionType="IETF" consensus="yes">
<front>
<title abbrev="TLS">The Transport Layer Security (TLS) Protocol Version 1.3</title>
<author initials="E." surname="Rescorla" fullname="Eric Rescorla">
<organization>Mozilla</organization>
<address>
<email>[email protected]</email>
</address>
</author>
<date year="2018" month="August"/>
<abstract>
<t>This document specifies version 1.3 of the Transport Layer Security
(TLS) protocol. TLS allows client/server applications to communicate
over the Internet in a way that is designed to prevent eavesdropping,
tampering, and message forgery.</t>
<t>This document updates RFCs 5705 and 6066, and obsoletes
RFCs 5077, 5246, and 6961. This document also specifies new
requirements for TLS 1.2 implementations.</t>
</abstract>
</front>
<middle>
<section anchor="introduction" title="Introduction">
<t>The primary goal of TLS is to provide a secure channel between two
communicating peers; the only requirement from the underlying
transport is a reliable, in-order data stream. Specifically, the
secure channel should provide the following properties:</t>
<t><list style="symbols">
<t>Authentication: The server side of the channel is always
authenticated; the client side is optionally
authenticated. Authentication can happen via asymmetric cryptography
(e.g., RSA <xref target="RSA"/>, the Elliptic Curve Digital Signature
Algorithm (ECDSA) <xref target="ECDSA"/>, or the Edwards-Curve Digital
Signature Algorithm (EdDSA) <xref target="RFC8032"/>)
or a symmetric pre-shared key (PSK).</t>
<t>Confidentiality: Data sent over the channel after establishment
is only visible to the
endpoints. TLS does not hide the length of the data it transmits,
though endpoints are able to pad TLS records in order to obscure lengths
and improve protection against traffic analysis techniques.</t>
<t>Integrity: Data sent over the channel after establishment cannot be
modified by attackers without detection.</t>
</list></t>
<t>These properties should be true even in the face of an attacker who has complete
control of the network, as described in <xref target="RFC3552"/>.
See <xref target="security-analysis"/> for a more complete statement of the relevant security
properties.</t>
<t>TLS consists of two primary components:</t>
<t><list style="symbols">
<t>A handshake protocol (<xref target="handshake-protocol"/>) that authenticates the communicating parties,
negotiates cryptographic modes and parameters, and establishes
shared keying material. The handshake protocol is designed to
resist tampering; an active attacker should not be able to force
the peers to negotiate different parameters than they would
if the connection were not under attack.</t>
<t>A record protocol (<xref target="record-protocol"/>) that uses the parameters established by the
handshake protocol to protect traffic between the communicating
peers. The record protocol divides traffic up into a series of
records, each of which is independently protected using the
traffic keys.</t>
</list></t>
<t>TLS is application protocol independent; higher-level protocols can
layer on top of TLS transparently. The TLS standard, however, does not
specify how protocols add security with TLS; how to
initiate TLS handshaking and how to interpret the authentication
certificates exchanged are left to the judgment of the designers and
implementors of protocols that run on top of TLS.</t>
<t>This document defines TLS version 1.3. While TLS 1.3 is not directly
compatible with previous versions, all versions of TLS incorporate a
versioning mechanism which allows clients and servers to interoperably
negotiate a common version if one is supported by both peers.</t>
<t>This document supersedes and obsoletes previous versions of TLS,
including version 1.2 <xref target="RFC5246"/>. It also obsoletes the TLS
ticket mechanism defined in <xref target="RFC5077"/> and replaces it with the
mechanism defined in <xref target="resumption-and-psk"/>.
Because TLS 1.3
changes the way keys are derived, it updates <xref target="RFC5705"/> as
described in <xref target="exporters"/>. It also changes how Online
Certificate Status Protocol (OCSP) messages are carried and therefore updates
<xref target="RFC6066"/> and obsoletes <xref target="RFC6961"/> as described
in <xref target="ocsp-and-sct"/>.</t>
<section anchor="conventions-and-terminology" title="Conventions and Terminology">
<t>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
<xref format="default" pageno="false" target="RFC2119"/>
<xref format="default" pageno="false" target="RFC8174"/> when,
and only when, they appear in all capitals, as shown here.</t>
<t>The following terms are used:</t>
<t><list style="hanging">
<t hangText="client:">The endpoint initiating the TLS connection.</t>
<t hangText="connection:">A transport-layer connection between two endpoints.</t>
<t hangText="endpoint:">Either the client or server of the connection.</t>
<t hangText="handshake:">An initial negotiation between client and server that establishes the parameters of their subsequent interactions within TLS.</t>
<t hangText="peer:">An endpoint. When discussing a particular endpoint, "peer" refers to the endpoint that is not the primary subject of discussion.</t>
<t hangText="receiver:">An endpoint that is receiving records.</t>
<t hangText="sender:">An endpoint that is transmitting records.</t>
<t hangText="server:">The endpoint that did not initiate the TLS connection.</t>
</list></t>
</section>
<section anchor="major-differences-from-tls-12" title="Major Differences from TLS 1.2">
<t>The following is a list of the major functional differences between
TLS 1.2 and TLS 1.3. It is not intended to be exhaustive, and there
are many minor differences.</t>
<t><list style="symbols">
<t>The list of supported symmetric encryption algorithms has been pruned of all algorithms that
are considered legacy. Those that remain are all Authenticated Encryption
with Associated Data (AEAD) algorithms. The cipher suite concept has been
changed to separate the authentication and key exchange mechanisms from
the record protection algorithm (including secret key length) and a hash
to be used with both the key derivation function and handshake
message authentication code (MAC).</t>
<t>A zero round-trip time (0-RTT) mode was added, saving a round trip at connection setup for
some application data, at the cost of certain security properties.</t>
<t>Static RSA and Diffie-Hellman cipher suites have been removed;
all public-key based key exchange mechanisms now provide forward secrecy.</t>
<t>All handshake messages after the ServerHello are now encrypted. The
newly introduced EncryptedExtensions message allows various extensions
previously sent in the clear in the ServerHello to also enjoy
confidentiality protection.</t>
<t>The key derivation functions have been redesigned. The new design allows
easier analysis by cryptographers due to their improved key separation
properties. The HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
is used as an underlying primitive.</t>
<t>The handshake state machine has been significantly restructured to
be more consistent and to remove superfluous messages such as
ChangeCipherSpec (except when needed for middlebox compatibility).</t>
<t>Elliptic curve algorithms are now in the base spec, and new signature
algorithms, such as EdDSA, are included. TLS 1.3 removed point format
negotiation in favor of a single point format for each curve.</t>
<t>Other cryptographic improvements were made, including changing the RSA
padding to use the RSA Probabilistic Signature Scheme (RSASSA-PSS),
and the removal of compression, the Digital Signature Algorithm (DSA),
and custom Ephemeral Diffie-Hellman (DHE) groups.</t>
<t>The TLS 1.2 version negotiation mechanism has been deprecated in favor
of a version list in an extension. This increases compatibility with
existing servers that incorrectly implemented version negotiation.</t>
<t>Session resumption with and without server-side state as well as the
PSK-based cipher suites of earlier TLS versions have been replaced by a
single new PSK exchange.</t>
<t>References have been updated to point to the updated versions of RFCs, as
appropriate (e.g., RFC 5280 rather than RFC 3280).</t>
</list></t>
</section>
<section anchor="updates-affecting-tls-12" title="Updates Affecting TLS 1.2">
<t>This document defines several changes that optionally affect
implementations of TLS 1.2, including those which do not also
support TLS 1.3:</t>
<t><list style="symbols">
<t>A version downgrade protection mechanism is described in <xref target="server-hello"/>.</t>
<t>RSASSA-PSS signature schemes are defined in <xref target="signature-algorithms"/>.</t>
<t>The "supported_versions" ClientHello extension can be used to negotiate
the version of TLS to use, in preference to the legacy_version field of
the ClientHello.</t>
<t>The "signature_algorithms_cert" extension allows a client to indicate
which signature algorithms it can validate in X.509 certificates.</t>
</list></t>
<t>Additionally, this document clarifies some compliance requirements for earlier
versions of TLS; see <xref target="protocol-invariants"/>.</t>
</section>
</section>
<section anchor="protocol-overview" title="Protocol Overview">
<t>The cryptographic parameters used by the secure channel are produced by the
TLS handshake protocol. This sub-protocol of TLS is used by the client
and server when first communicating with each other.
The handshake protocol allows peers to negotiate a protocol version,
select cryptographic algorithms, optionally authenticate each other,
and establish shared secret keying material.
Once the handshake is complete, the peers use the established keys
to protect the application-layer traffic.</t>
<t>A failure of the handshake or other protocol error triggers the
termination of the connection, optionally preceded by an alert message
(<xref target="alert-protocol"/>).</t>
<t>TLS supports three basic key exchange modes:</t>
<t><list style="symbols">
<t>(EC)DHE (Diffie-Hellman over either finite fields or elliptic curves)</t>
<t>PSK-only</t>
<t>PSK with (EC)DHE</t>
</list></t>
<t><xref target="tls-full"/> below shows the basic full TLS handshake:</t>
<figure title="Message Flow for Full TLS Handshake" anchor="tls-full"><artwork><![CDATA[
Client Server
Key ^ ClientHello
Exch | + key_share*
| + signature_algorithms*
| + psk_key_exchange_modes*
v + pre_shared_key* -------->
ServerHello ^ Key
+ key_share* | Exch
+ pre_shared_key* v
{EncryptedExtensions} ^ Server
{CertificateRequest*} v Params
{Certificate*} ^
{CertificateVerify*} | Auth
{Finished} v
<-------- [Application Data*]
^ {Certificate*}
Auth | {CertificateVerify*}
v {Finished} -------->
[Application Data] <-------> [Application Data]
+ Indicates noteworthy extensions sent in the
previously noted message.
* Indicates optional or situation-dependent
messages/extensions that are not always sent.
{} Indicates messages protected using keys
derived from a [sender]_handshake_traffic_secret.
[] Indicates messages protected using keys
derived from [sender]_application_traffic_secret_N.
]]></artwork></figure>
<t>The handshake can be thought of as having three phases (indicated
in the diagram above):</t>
<t><list style="symbols">
<t>Key Exchange: Establish shared keying material and select the
cryptographic parameters. Everything after this phase is
encrypted.</t>
<t>Server Parameters: Establish other handshake parameters
(whether the client is authenticated, application-layer protocol
support, etc.).</t>
<t>Authentication: Authenticate the server (and, optionally, the client)
and provide key confirmation and handshake integrity.</t>
</list></t>
<t>In the Key Exchange phase, the client sends the ClientHello
(<xref target="client-hello"/>) message, which contains a random nonce
(ClientHello.random); its offered protocol versions; a list of
symmetric cipher/HKDF hash pairs; either a set of Diffie-Hellman key shares
(in the "key_share" (<xref target="key-share"/>) extension),
a set of pre&nbhy;shared key labels (in the "pre_shared_key"
(<xref target="pre-shared-key-extension"/>) extension), or both; and
potentially additional extensions. Additional fields and/or messages
may also be present for middlebox compatibility.</t>
<t>The server processes the ClientHello and determines the appropriate
cryptographic parameters for the connection. It then responds with its
own ServerHello (<xref target="server-hello"/>), which indicates the negotiated connection
parameters. The combination of the ClientHello
and the ServerHello determines the shared keys. If (EC)DHE
key establishment is in use, then the ServerHello
contains a "key_share" extension with the server's ephemeral
Diffie-Hellman share; the server's share MUST be in the same group as one of the
client's shares. If PSK key establishment is
in use, then the ServerHello contains a "pre_shared_key"
extension indicating which of the client's offered PSKs was selected.
Note that implementations can use (EC)DHE and PSK together, in which
case both extensions will be supplied.</t>
<t>The server then sends two messages to establish the Server Parameters:</t>
<t><list style="hanging">
<t hangText='EncryptedExtensions:'>
responses to ClientHello extensions that are not required to
determine the cryptographic parameters, other than those
that are specific to individual certificates.
[<xref target="encrypted-extensions"/>]</t>
<t hangText='CertificateRequest:'>
if certificate-based client authentication is desired, the
desired parameters for that certificate. This message is
omitted if client authentication is not desired.
[<xref target="certificate-request"/>]</t>
</list></t>
<t>Finally, the client and server exchange Authentication messages. TLS
uses the same set of messages every time that certificate-based
authentication is needed. (PSK-based authentication happens as a side
effect of key exchange.)
Specifically:</t>
<t><list style="hanging">
<t hangText='Certificate:'>
The certificate of the endpoint and any per-certificate extensions.
This message is omitted by the server if not authenticating with a
certificate and by the client if the server did not send
CertificateRequest (thus indicating that the client should not
authenticate with a certificate). Note that if raw
public keys <xref target="RFC7250"/> or the cached information extension
<xref target="RFC7924"/> are in use, then this message will not
contain a certificate but rather some other value corresponding to
the server's long-term key. [<xref target="certificate"/>]</t>
<t hangText='CertificateVerify:'>
A signature over the entire handshake using the private key
corresponding to the public key in the Certificate message. This
message is omitted if the endpoint is not authenticating via a
certificate. [<xref target="certificate-verify"/>]</t>
<t hangText='Finished:'>
A MAC (Message Authentication Code) over the entire handshake.
This message provides key confirmation, binds the endpoint's identity
to the exchanged keys, and in PSK mode
also authenticates the handshake. [<xref target="finished"/>]</t>
</list></t>
<t>Upon receiving the server's messages, the client responds with its
Authentication messages, namely Certificate and CertificateVerify (if
requested), and Finished.</t>
<t>At this point, the handshake is complete, and the client and server
derive the keying material required by the record layer to exchange
application-layer data protected through authenticated encryption.
Application Data MUST NOT be sent prior to sending the Finished message,
except as specified in <xref target="zero-rtt-data"/>.
Note that while the server may send Application Data prior to receiving
the client's Authentication messages, any data sent at that point is,
of course, being sent to an unauthenticated peer.</t>
<section anchor="incorrect-dhe-share" title="Incorrect DHE Share">
<t>If the client has not provided a sufficient "key_share" extension (e.g., it
includes only DHE or ECDHE groups unacceptable to or unsupported by the
server), the server corrects the mismatch with a HelloRetryRequest and
the client needs to restart the handshake with an appropriate
"key_share" extension, as shown in <xref target="tls-restart"/>.
If no common cryptographic parameters can be negotiated,
the server MUST abort the handshake with an appropriate alert.</t>
<figure title="Message Flow for a Full Handshake with Mismatched Parameters" anchor="tls-restart"><artwork><![CDATA[
Client Server
ClientHello
+ key_share -------->
HelloRetryRequest
<-------- + key_share
ClientHello
+ key_share -------->
ServerHello
+ key_share
{EncryptedExtensions}
{CertificateRequest*}
{Certificate*}
{CertificateVerify*}
{Finished}
<-------- [Application Data*]
{Certificate*}
{CertificateVerify*}
{Finished} -------->
[Application Data] <-------> [Application Data]
]]></artwork></figure>
<t>Note: The handshake transcript incorporates the initial
ClientHello&wj;/HelloRetryRequest exchange; it is not reset with the
new ClientHello.</t>
<t>TLS also allows several optimized variants of the basic handshake, as
described in the following sections.</t>
</section>
<section anchor="resumption-and-psk" title="Resumption and Pre-Shared Key (PSK)">
<t>Although TLS PSKs can be established out of band,
PSKs can also be established in a previous connection and
then used to establish a new connection ("session resumption" or "resuming"
with a PSK). Once a handshake has completed, the server can
send the client a PSK identity that corresponds to a unique key derived from
the initial handshake (see <xref target="NSTMessage"/>). The client
can then use that PSK identity in future handshakes to negotiate the use
of the associated PSK. If the server accepts the PSK, then the security context of the
new connection is cryptographically tied to the original connection and the key derived
from the initial handshake is used to bootstrap the cryptographic state
instead of a full handshake.
In TLS 1.2 and below, this functionality was provided by "session IDs" and
"session tickets" <xref target="RFC5077"/>. Both mechanisms are obsoleted in TLS 1.3.</t>
<t>PSKs can be used with (EC)DHE key exchange in order to provide forward
secrecy in combination with shared keys, or can be used alone, at the
cost of losing forward secrecy for the application data.</t>
<t><xref target="tls-resumption-psk"/> shows a pair of handshakes in which the
first handshake establishes a PSK and the second handshake uses it:</t>
<figure title="Message Flow for Resumption and PSK" anchor="tls-resumption-psk"><artwork><![CDATA[
Client Server
Initial Handshake:
ClientHello
+ key_share -------->
ServerHello
+ key_share
{EncryptedExtensions}
{CertificateRequest*}
{Certificate*}
{CertificateVerify*}
{Finished}
<-------- [Application Data*]
{Certificate*}
{CertificateVerify*}
{Finished} -------->
<-------- [NewSessionTicket]
[Application Data] <-------> [Application Data]
Subsequent Handshake:
ClientHello
+ key_share*
+ pre_shared_key -------->
ServerHello
+ pre_shared_key
+ key_share*
{EncryptedExtensions}
{Finished}
<-------- [Application Data*]
{Finished} -------->
[Application Data] <-------> [Application Data]
]]></artwork></figure>
<t>As the server is authenticating via a PSK, it does not send a
Certificate or a CertificateVerify message. When a client offers resumption
via a PSK, it SHOULD also supply a "key_share" extension to the server to
allow the server to decline resumption and fall back
to a full handshake, if needed. The server responds with a "pre_shared_key"
extension to negotiate the use of PSK key establishment and can (as shown here)
respond with a "key_share" extension to do (EC)DHE key establishment, thus
providing forward secrecy.</t>
<t>When PSKs are provisioned out of band, the PSK identity and the KDF hash
algorithm to be used with the PSK MUST also be provisioned.</t>
<t><list style="hanging">
<t hangText='Note:'>
When using an out-of-band provisioned pre-shared secret, a critical
consideration is using sufficient entropy during the key generation, as
discussed in <xref target="RFC4086"></xref>. Deriving a shared secret from a
password or other low-entropy sources is not secure. A low-entropy secret, or
password, is subject to dictionary attacks based on the PSK binder. The
specified PSK authentication is not a strong password-based authenticated key
exchange even when used with Diffie-Hellman key establishment. Specifically,
it does not prevent an attacker that can observe the handshake from performing
a brute-force attack on the password/pre-shared key.</t>
</list></t>
</section>
<section anchor="zero-rtt-data" title="0-RTT Data">
<t>When clients and servers share a PSK (either obtained externally or
via a previous handshake), TLS 1.3 allows clients to send data on the
first flight ("early data"). The client uses the PSK to authenticate
the server and to encrypt the early data.</t>
<t>As shown in <xref target="tls-0-rtt"/>, the 0-RTT data is just added to the
1-RTT handshake in the first flight. The rest of the handshake uses the same
messages as for a 1-RTT handshake with PSK resumption.</t>
<figure title="Message Flow for a 0-RTT Handshake" anchor="tls-0-rtt"><artwork><![CDATA[
Client Server
ClientHello
+ early_data
+ key_share*
+ psk_key_exchange_modes
+ pre_shared_key
(Application Data*) -------->
ServerHello
+ pre_shared_key
+ key_share*
{EncryptedExtensions}
+ early_data*
{Finished}
<-------- [Application Data*]
(EndOfEarlyData)
{Finished} -------->
[Application Data] <-------> [Application Data]
+ Indicates noteworthy extensions sent in the
previously noted message.
* Indicates optional or situation-dependent
messages/extensions that are not always sent.
() Indicates messages protected using keys
derived from a client_early_traffic_secret.
{} Indicates messages protected using keys
derived from a [sender]_handshake_traffic_secret.
[] Indicates messages protected using keys
derived from [sender]_application_traffic_secret_N.
]]></artwork></figure>
<t>IMPORTANT NOTE: The security properties for 0-RTT data are weaker than
those for other kinds of TLS data. Specifically:</t>
<t><list style="numbers">
<t>This data is not forward secret, as it is encrypted solely under
keys derived using the offered PSK.</t>
<t>There are no guarantees of non-replay between connections.
Protection against replay for ordinary TLS 1.3 1-RTT data is
provided via the server's Random value, but 0-RTT data does not depend
on the ServerHello and therefore has weaker guarantees. This is especially
relevant if the data is authenticated either with TLS client
authentication or inside the application protocol. The same warnings
apply to any use of the early_exporter_master_secret.</t>
</list></t>
<t>0-RTT data cannot be duplicated within a connection (i.e., the server will
not process the same data twice for the same connection), and an
attacker will not be able to make 0-RTT data appear to be 1-RTT data
(because it is protected with different keys). <xref target="replay-0rtt"/>
contains a description of potential attacks, and <xref target="anti-replay"/>
describes mechanisms which the server can use to limit the impact of
replay.</t>
</section>
</section>
<section anchor="presentation-language" title="Presentation Language">
<t>This document deals with the formatting of data in an external
representation. The following very basic and somewhat casually defined
presentation syntax will be used.</t>
<section anchor="basic-block-size" title="Basic Block Size">
<t>The representation of all data items is explicitly specified. The basic data
block size is one byte (i.e., 8 bits). Multiple-byte data items are
concatenations of bytes, from left to right, from top to bottom. From the byte
stream, a multi-byte item (a numeric in the following example) is formed
(using C notation) by:</t>
<figure><artwork><![CDATA[
value = (byte[0] << 8*(n-1)) | (byte[1] << 8*(n-2)) |
... | byte[n-1];
]]></artwork></figure>
<t>This byte ordering for multi-byte values is the commonplace network byte order
or big-endian format.</t>
</section>
<section anchor="miscellaneous" title="Miscellaneous">
<t>Comments begin with "/*" and end with "*/".</t>
<t>Optional components are denoted by enclosing them in "[[ ]]"
(double brackets).</t>
<t>Single-byte entities containing uninterpreted data are of
type opaque.</t>
<t>A type alias T' for an existing type T is defined by:</t>
<figure><artwork><![CDATA[
T T';
]]></artwork></figure>
</section>
<section anchor="numbers" title="Numbers">
<t>The basic numeric data type is an unsigned byte (uint8). All larger numeric
data types are constructed from a fixed-length series of bytes concatenated as
described in <xref target="basic-block-size"/> and are also unsigned. The
following numeric types are predefined.</t>
<figure><artwork><![CDATA[
uint8 uint16[2];
uint8 uint24[3];
uint8 uint32[4];
uint8 uint64[8];
]]></artwork></figure>
<t>All values, here and elsewhere in the specification, are transmitted in
network byte (big-endian) order; the uint32 represented by the hex bytes 01 02
03 04 is equivalent to the decimal value 16909060.</t>
</section>
<section anchor="vectors" title="Vectors">
<t>A vector (single-dimensioned array) is a stream of homogeneous data
elements. The size of the vector may be specified at documentation time or left
unspecified until runtime. In either case, the length declares the number of
bytes, not the number of elements, in the vector. The syntax for specifying a
new type, T', that is a fixed-length vector of type T is</t>
<figure><artwork><![CDATA[
T T'[n];
]]></artwork></figure>
<t>Here, T' occupies n bytes in the data stream, where n is a multiple of the
size of T. The length of the vector is not included in the encoded stream.</t>
<t>In the following example, Datum is defined to be three consecutive bytes
that the protocol does not interpret, while Data is three consecutive Datum,
consuming a total of nine bytes.</t>
<figure><artwork><![CDATA[
opaque Datum[3]; /* three uninterpreted bytes */
Datum Data[9]; /* three consecutive 3-byte vectors */
]]></artwork></figure>
<t>Variable-length vectors are defined by specifying a subrange of legal
lengths, inclusively, using the notation <floor..ceiling>. When these
are encoded, the actual length precedes the vector's contents in the byte
stream. The length will be in the form of a number consuming as many bytes as
required to hold the vector's specified maximum (ceiling) length. A
variable-length vector with an actual length field of zero is referred to as
an empty vector.</t>
<figure><artwork><![CDATA[
T T'<floor..ceiling>;
]]></artwork></figure>
<t>In the following example, "mandatory" is a vector that must contain between
300 and 400 bytes of type opaque. It can never be empty. The actual length
field consumes two bytes, a uint16, which is sufficient to represent the value
400 (see <xref target="numbers"/>). Similarly, "longer" can represent up to
800 bytes of data, or 400 uint16 elements, and it may be empty. Its encoding
will include a two-byte actual length field prepended to the vector. The
length of an encoded vector must be an exact multiple of the length of a
single element (e.g., a 17-byte vector of uint16 would be illegal).</t>
<figure><artwork><![CDATA[
opaque mandatory<300..400>;
/* length field is two bytes, cannot be empty */
uint16 longer<0..800>;
/* zero to 400 16-bit unsigned integers */
]]></artwork></figure>
</section>
<section anchor="enumerateds" title="Enumerateds">
<t>An additional sparse data type, called "enum" or "enumerated",
is available. Each definition is a different type. Only enumerateds of
the same type may be assigned or compared. Every element of an
enumerated must be assigned a value, as demonstrated in the following
example. Since the elements of the enumerated are not ordered, they
can be assigned any unique value, in any order.</t>
<figure><artwork><![CDATA[
enum { e1(v1), e2(v2), ... , en(vn) [[, (n)]] } Te;
]]></artwork></figure>
<t>Future extensions or additions to the protocol may define new values.
Implementations need to be able to parse and ignore unknown values unless the
definition of the field states otherwise.</t>
<t>An enumerated occupies as much space in the byte stream as would its maximal
defined ordinal value. The following definition would cause one byte to be used
to carry fields of type Color.</t>
<figure><artwork><![CDATA[
enum { red(3), blue(5), white(7) } Color;
]]></artwork></figure>
<t>One may optionally specify a value without its associated tag to force the
width definition without defining a superfluous element.</t>
<t>In the following example, Taste will consume two bytes in the data stream but
can only assume the values 1, 2, or 4 in the current version of the protocol.</t>
<figure><artwork><![CDATA[
enum { sweet(1), sour(2), bitter(4), (32000) } Taste;
]]></artwork></figure>
<t>The names of the elements of an enumeration are scoped within the defined type.
In the first example, a fully qualified reference to the second element of the
enumeration would be Color.blue. Such qualification is not required if the
target of the assignment is well specified.</t>
<figure><artwork><![CDATA[
Color color = Color.blue; /* overspecified, legal */
Color color = blue; /* correct, type implicit */
]]></artwork></figure>
<t>The names assigned to enumerateds do not need to be unique. The numerical value
can describe a range over which the same name applies. The value includes the
minimum and maximum inclusive values in that range, separated by two period
characters. This is principally useful for reserving regions of the space.</t>
<figure><artwork><![CDATA[
enum { sad(0), meh(1..254), happy(255) } Mood;
]]></artwork></figure>
</section>
<section anchor="constructed-types" title="Constructed Types">
<t>Structure types may be constructed from primitive types for
convenience. Each specification declares a new, unique type. The syntax used for
definitions is much like that of C.
</t>
<figure><artwork><![CDATA[
struct {
T1 f1;
T2 f2;
...
Tn fn;
} T;
]]></artwork></figure>
<t>Fixed- and variable-length vector fields are allowed using the standard
vector syntax. Structures V1 and V2 in the variants example
(<xref target="variants"/>) demonstrate this.</t>
<t>The fields within a structure may be qualified using the type's name, with a
syntax much like that available for enumerateds. For example, T.f2 refers to
the second field of the previous declaration.</t>
</section>
<section anchor="constants" title="Constants">
<t>Fields and variables may be assigned a fixed value using "=", as in:</t>
<figure><artwork><![CDATA[
struct {
T1 f1 = 8; /* T.f1 must always be 8 */
T2 f2;
} T;
]]></artwork></figure>
</section>
<section anchor="variants" title="Variants">
<t>Defined structures may have variants based on some knowledge that is
available within the environment. The selector must be an enumerated
type that defines the possible variants the structure defines. Each
arm of the select (below) specifies the type of that variant's field
and an optional field label. The mechanism by which the variant is selected
at runtime is not prescribed by the presentation language.</t>
<figure><artwork><![CDATA[
struct {
T1 f1;
T2 f2;
....
Tn fn;
select (E) {
case e1: Te1 [[fe1]];
case e2: Te2 [[fe2]];
....
case en: Ten [[fen]];
};
} Tv;
]]></artwork></figure>
<t>For example:</t>
<figure><artwork><![CDATA[
enum { apple(0), orange(1) } VariantTag;
struct {
uint16 number;
opaque string<0..10>; /* variable length */
} V1;
struct {
uint32 number;
opaque string[10]; /* fixed length */
} V2;
struct {
VariantTag type;
select (VariantRecord.type) {
case apple: V1;
case orange: V2;
};
} VariantRecord;
]]></artwork></figure>
</section>
</section>
<section anchor="handshake-protocol" title="Handshake Protocol">
<t>The handshake protocol is used to negotiate the security parameters
of a connection. Handshake messages are supplied to the TLS record layer, where
they are encapsulated within one or more TLSPlaintext or TLSCiphertext structures which are
processed and transmitted as specified by the current active connection state.</t>
<figure><artwork><![CDATA[
enum {
client_hello(1),
server_hello(2),
new_session_ticket(4),
end_of_early_data(5),
encrypted_extensions(8),
certificate(11),
certificate_request(13),
certificate_verify(15),
finished(20),
key_update(24),
message_hash(254),
(255)
} HandshakeType;
struct {
HandshakeType msg_type; /* handshake type */
uint24 length; /* remaining bytes in message */
select (Handshake.msg_type) {
case client_hello: ClientHello;
case server_hello: ServerHello;
case end_of_early_data: EndOfEarlyData;
case encrypted_extensions: EncryptedExtensions;
case certificate_request: CertificateRequest;
case certificate: Certificate;
case certificate_verify: CertificateVerify;
case finished: Finished;
case new_session_ticket: NewSessionTicket;
case key_update: KeyUpdate;
};
} Handshake;
]]></artwork></figure>
<t>Protocol messages MUST be sent in the order defined in
<xref target="the-transcript-hash"/> and shown in the diagrams in <xref target="protocol-overview"/>.
A peer which receives a handshake message in an unexpected order
MUST abort the handshake with an "unexpected_message" alert.</t>
<t>New handshake message types are assigned by IANA as described in
<xref target="iana-considerations"/>.</t>
<section anchor="key-exchange-messages" title="Key Exchange Messages">
<t>The key exchange messages are used to determine the security capabilities
of the client and the server and to establish shared secrets, including
the traffic keys used to protect the rest of the handshake and the data.</t>
<section anchor="cryptographic-negotiation" title="Cryptographic Negotiation">
<t>In TLS, the cryptographic negotiation proceeds by the client offering the
following four sets of options in its ClientHello:</t>
<t><list style="symbols">
<t>A list of cipher suites which indicates the AEAD algorithm/HKDF hash
pairs which the client supports.</t>
<t>A "supported_groups" (<xref target="negotiated-groups"/>) extension which indicates the (EC)DHE groups
which the client supports and a "key_share" (<xref target="key-share"/>) extension which contains
(EC)DHE shares for some or all of these groups.</t>
<t>A "signature_algorithms" (<xref target="signature-algorithms"/>) extension which indicates the signature
algorithms which the client can accept. A "signature_algorithms_cert" extension
(<xref target="signature-algorithms"/>) may also be added to indicate
certificate-specific signature algorithms.</t>
<t>A "pre_shared_key" (<xref target="pre-shared-key-extension"/>) extension which
contains a list of symmetric key identities known to the client and a
"psk_key_exchange_modes" (<xref target="pre-shared-key-exchange-modes"/>)
extension which indicates the key exchange modes that may be used
with PSKs.</t>
</list></t>
<t>If the server does not select a PSK, then the first three of these
options are entirely orthogonal: the server independently selects a
cipher suite, an (EC)DHE group and key share for key establishment,
and a signature algorithm/certificate pair to authenticate itself to
the client. If there is no overlap between the received "supported_groups"
and the groups supported by the server, then the server MUST abort the
handshake with a "handshake_failure" or an "insufficient_security" alert.</t>
<t>If the server selects a PSK, then it MUST also select a key
establishment mode from the set indicated by the client's
"psk_key_exchange_modes" extension (at present, PSK alone or with
(EC)DHE). Note that if the PSK can be used without (EC)DHE, then
non&nbhy;overlap in the "supported_groups" parameters need not be fatal, as it
is in the non-PSK case discussed in the previous paragraph.</t>
<t>If the server selects an (EC)DHE group and the client did not offer a
compatible "key_share" extension in the initial ClientHello, the server MUST
respond with a HelloRetryRequest (<xref target="hello-retry-request"/>)
message.</t>
<t>If the server successfully selects parameters and does not require a
HelloRetryRequest, it indicates the selected parameters in the ServerHello as
follows:</t>
<t><list style="symbols">
<t>If PSK is being used, then the server will send a
"pre_shared_key" extension indicating the selected key.</t>
<t>When (EC)DHE is in use, the server will also provide a
"key_share" extension. If PSK is not being used, then (EC)DHE and
certificate-based authentication are always used.</t>
<t>When authenticating via a certificate, the server will send
the Certificate (<xref target="certificate"/>) and CertificateVerify
(<xref target="certificate-verify"/>) messages. In TLS 1.3
as defined by this document, either a PSK or a certificate
is always used, but not both. Future documents may define how
to use them together.</t>
</list></t>
<t>If the server is unable to negotiate a supported set of parameters
(i.e., there is no overlap between the client and server parameters),
it MUST abort the handshake with either a "handshake_failure" or
"insufficient_security" fatal alert (see <xref
target="alert-protocol"/>).</t>
</section>
<section anchor="client-hello" title="Client Hello">
<t>When a client first connects to a server, it is REQUIRED to send the
ClientHello as its first TLS message. The client will also send a
ClientHello when the server has responded to its ClientHello with a
HelloRetryRequest. In that case, the client MUST send the same
ClientHello without modification, except as follows:</t>
<t><list style="symbols">
<t>If a "key_share" extension was supplied in the HelloRetryRequest,
replacing the list of shares with a list containing a single
KeyShareEntry from the indicated group.</t>
<t>Removing the "early_data" extension (<xref
target="early-data-indication"/>) if one was present. Early data is not
permitted after a HelloRetryRequest.</t>
<t>Including a "cookie" extension if one was provided in the
HelloRetryRequest.</t>
<t>Updating the "pre_shared_key" extension if present by
recomputing the "obfuscated_ticket_age" and binder values
and (optionally) removing
any PSKs which are incompatible with the server's indicated
cipher suite.</t>
<t>Optionally adding, removing, or changing the length of the "padding"
extension <xref target="RFC7685"/>.</t>
<t>Other modifications that may be allowed by an extension defined in the
future and present in the HelloRetryRequest.</t>
</list></t>
<t>Because TLS 1.3 forbids renegotiation, if a server has negotiated
TLS 1.3 and receives a ClientHello at any other time, it MUST terminate
the connection with an "unexpected_message" alert.</t>
<t>If a server established a TLS connection with a previous version of TLS
and receives a TLS 1.3 ClientHello in a renegotiation, it MUST retain the
previous protocol version. In particular, it MUST NOT negotiate TLS 1.3.</t>
<t>Structure of this message:</t>
<figure><artwork><![CDATA[
uint16 ProtocolVersion;
opaque Random[32];
uint8 CipherSuite[2]; /* Cryptographic suite selector */
struct {
ProtocolVersion legacy_version = 0x0303; /* TLS v1.2 */
Random random;
opaque legacy_session_id<0..32>;
CipherSuite cipher_suites<2..2^16-2>;
opaque legacy_compression_methods<1..2^8-1>;
Extension extensions<8..2^16-1>;
} ClientHello;
]]></artwork></figure>