idnits 2.17.1 draft-ietf-quic-tls-06.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (September 22, 2017) is 2401 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'QUIC-HTTP' is defined on line 1654, but no explicit reference was found in the text == Outdated reference: A later version (-28) exists of draft-ietf-tls-tls13-21 ** Downref: Normative reference to an Informational RFC: RFC 5869 == Outdated reference: A later version (-22) exists of draft-eastlake-fnv-13 -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) Summary: 1 error (**), 0 flaws (~~), 5 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 QUIC M. Thomson, Ed. 3 Internet-Draft Mozilla 4 Intended status: Standards Track S. Turner, Ed. 5 Expires: March 26, 2018 sn3rd 6 September 22, 2017 8 Using Transport Layer Security (TLS) to Secure QUIC 9 draft-ietf-quic-tls-06 11 Abstract 13 This document describes how Transport Layer Security (TLS) is used to 14 secure QUIC. 16 Note to Readers 18 Discussion of this draft takes place on the QUIC working group 19 mailing list (quic@ietf.org), which is archived at 20 https://mailarchive.ietf.org/arch/search/?email_list=quic . 22 Working Group information can be found at https://github.com/quicwg ; 23 source code and issues list for this draft can be found at 24 https://github.com/quicwg/base-drafts/labels/tls . 26 Status of This Memo 28 This Internet-Draft is submitted in full conformance with the 29 provisions of BCP 78 and BCP 79. 31 Internet-Drafts are working documents of the Internet Engineering 32 Task Force (IETF). Note that other groups may also distribute 33 working documents as Internet-Drafts. The list of current Internet- 34 Drafts is at http://datatracker.ietf.org/drafts/current/. 36 Internet-Drafts are draft documents valid for a maximum of six months 37 and may be updated, replaced, or obsoleted by other documents at any 38 time. It is inappropriate to use Internet-Drafts as reference 39 material or to cite them other than as "work in progress." 41 This Internet-Draft will expire on March 26, 2018. 43 Copyright Notice 45 Copyright (c) 2017 IETF Trust and the persons identified as the 46 document authors. All rights reserved. 48 This document is subject to BCP 78 and the IETF Trust's Legal 49 Provisions Relating to IETF Documents 50 (http://trustee.ietf.org/license-info) in effect on the date of 51 publication of this document. Please review these documents 52 carefully, as they describe your rights and restrictions with respect 53 to this document. Code Components extracted from this document must 54 include Simplified BSD License text as described in Section 4.e of 55 the Trust Legal Provisions and are provided without warranty as 56 described in the Simplified BSD License. 58 Table of Contents 60 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 61 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4 62 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 4 63 3.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 5 64 3.2. TLS Handshake . . . . . . . . . . . . . . . . . . . . . . 6 65 4. TLS Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 7 66 4.1. Handshake and Setup Sequence . . . . . . . . . . . . . . 7 67 4.2. Interface to TLS . . . . . . . . . . . . . . . . . . . . 9 68 4.2.1. Handshake Interface . . . . . . . . . . . . . . . . . 9 69 4.2.2. Source Address Validation . . . . . . . . . . . . . . 10 70 4.2.3. Key Ready Events . . . . . . . . . . . . . . . . . . 11 71 4.2.4. Secret Export . . . . . . . . . . . . . . . . . . . . 12 72 4.2.5. TLS Interface Summary . . . . . . . . . . . . . . . . 12 73 4.3. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 13 74 4.4. ClientHello Size . . . . . . . . . . . . . . . . . . . . 13 75 4.5. Peer Authentication . . . . . . . . . . . . . . . . . . . 13 76 4.6. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 14 77 5. QUIC Packet Protection . . . . . . . . . . . . . . . . . . . 14 78 5.1. Installing New Keys . . . . . . . . . . . . . . . . . . . 14 79 5.2. QUIC Key Expansion . . . . . . . . . . . . . . . . . . . 15 80 5.2.1. 0-RTT Secret . . . . . . . . . . . . . . . . . . . . 15 81 5.2.2. 1-RTT Secrets . . . . . . . . . . . . . . . . . . . . 15 82 5.2.3. Packet Protection Key and IV . . . . . . . . . . . . 17 83 5.3. QUIC AEAD Usage . . . . . . . . . . . . . . . . . . . . . 17 84 5.4. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 18 85 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 19 86 5.6. Packet Number Gaps . . . . . . . . . . . . . . . . . . . 19 87 6. Unprotected Packets . . . . . . . . . . . . . . . . . . . . . 19 88 6.1. Integrity Check Processing . . . . . . . . . . . . . . . 19 89 6.2. The 64-bit FNV-1a Algorithm . . . . . . . . . . . . . . . 20 90 7. Key Phases . . . . . . . . . . . . . . . . . . . . . . . . . 20 91 7.1. Packet Protection for the TLS Handshake . . . . . . . . . 21 92 7.1.1. Initial Key Transitions . . . . . . . . . . . . . . . 21 93 7.1.2. Retransmission and Acknowledgment of Unprotected 94 Packets . . . . . . . . . . . . . . . . . . . . . . . 22 95 7.2. Key Update . . . . . . . . . . . . . . . . . . . . . . . 23 97 8. Client Address Validation . . . . . . . . . . . . . . . . . . 24 98 8.1. HelloRetryRequest Address Validation . . . . . . . . . . 25 99 8.1.1. Stateless Address Validation . . . . . . . . . . . . 25 100 8.1.2. Sending HelloRetryRequest . . . . . . . . . . . . . . 26 101 8.2. NewSessionTicket Address Validation . . . . . . . . . . . 26 102 8.3. Address Validation Token Integrity . . . . . . . . . . . 27 103 9. Pre-handshake QUIC Messages . . . . . . . . . . . . . . . . . 27 104 9.1. Unprotected Packets Prior to Handshake Completion . . . . 28 105 9.1.1. STREAM Frames . . . . . . . . . . . . . . . . . . . . 28 106 9.1.2. ACK Frames . . . . . . . . . . . . . . . . . . . . . 28 107 9.1.3. Updates to Data and Stream Limits . . . . . . . . . . 29 108 9.1.4. Denial of Service with Unprotected Packets . . . . . 29 109 9.2. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 30 110 9.3. Receiving Out-of-Order Protected Frames . . . . . . . . . 30 111 10. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 31 112 10.1. Protocol and Version Negotiation . . . . . . . . . . . . 31 113 10.2. QUIC Transport Parameters Extension . . . . . . . . . . 32 114 10.3. Priming 0-RTT . . . . . . . . . . . . . . . . . . . . . 32 115 11. Security Considerations . . . . . . . . . . . . . . . . . . . 33 116 11.1. Packet Reflection Attack Mitigation . . . . . . . . . . 33 117 11.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 33 118 12. Error codes . . . . . . . . . . . . . . . . . . . . . . . . . 34 119 13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 34 120 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 34 121 14.1. Normative References . . . . . . . . . . . . . . . . . . 34 122 14.2. Informative References . . . . . . . . . . . . . . . . . 35 123 Appendix A. Contributors . . . . . . . . . . . . . . . . . . . . 36 124 Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 36 125 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 36 126 C.1. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 36 127 C.2. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 36 128 C.3. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 36 129 C.4. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 36 130 C.5. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 37 131 C.6. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 37 132 C.7. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 37 133 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 38 135 1. Introduction 137 This document describes how QUIC [QUIC-TRANSPORT] is secured using 138 Transport Layer Security (TLS) version 1.3 [I-D.ietf-tls-tls13]. TLS 139 1.3 provides critical latency improvements for connection 140 establishment over previous versions. Absent packet loss, most new 141 connections can be established and secured within a single round 142 trip; on subsequent connections between the same client and server, 143 the client can often send application data immediately, that is, 144 using a zero round trip setup. 146 This document describes how the standardized TLS 1.3 acts a security 147 component of QUIC. The same design could work for TLS 1.2, though 148 few of the benefits QUIC provides would be realized due to the 149 handshake latency in versions of TLS prior to 1.3. 151 2. Notational Conventions 153 The words "MUST", "MUST NOT", "SHOULD", and "MAY" are used in this 154 document. It's not shouting; when they are capitalized, they have 155 the special meaning defined in [RFC2119]. 157 This document uses the terminology established in [QUIC-TRANSPORT]. 159 For brevity, the acronym TLS is used to refer to TLS 1.3. 161 TLS terminology is used when referring to parts of TLS. Though TLS 162 assumes a continuous stream of octets, it divides that stream into 163 _records_. Most relevant to QUIC are the records that contain TLS 164 _handshake messages_, which are discrete messages that are used for 165 key agreement, authentication and parameter negotiation. Ordinarily, 166 TLS records can also contain _application data_, though in the QUIC 167 usage there is no use of TLS application data. 169 3. Protocol Overview 171 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 172 and integrity protection of packets. For this it uses keys derived 173 from a TLS 1.3 connection [I-D.ietf-tls-tls13]; QUIC also relies on 174 TLS 1.3 for authentication and negotiation of parameters that are 175 critical to security and performance. 177 Rather than a strict layering, these two protocols are co-dependent: 178 QUIC uses the TLS handshake; TLS uses the reliability and ordered 179 delivery provided by QUIC streams. 181 This document defines how QUIC interacts with TLS. This includes a 182 description of how TLS is used, how keying material is derived from 183 TLS, and the application of that keying material to protect QUIC 184 packets. Figure 1 shows the basic interactions between TLS and QUIC, 185 with the QUIC packet protection being called out specially. 187 +------------+ +------------+ 188 | |------ Handshake ------>| | 189 | |<-- Validate Address ---| | 190 | |-- OK/Error/Validate -->| | 191 | |<----- Handshake -------| | 192 | QUIC |------ Validate ------->| TLS | 193 | | | | 194 | |<------ 0-RTT OK -------| | 195 | |<------ 1-RTT OK -------| | 196 | |<--- Handshake Done ----| | 197 +------------+ +------------+ 198 | ^ ^ | 199 | Protect | Protected | | 200 v | Packet | | 201 +------------+ / / 202 | QUIC | / / 203 | Packet |-------- Get Secret -------' / 204 | Protection |<-------- Secret -----------' 205 +------------+ 207 Figure 1: QUIC and TLS Interactions 209 The initial state of a QUIC connection has packets exchanged without 210 any form of protection. In this state, QUIC is limited to using 211 stream 0 and associated packets. Stream 0 is reserved for a TLS 212 connection. This is a complete TLS connection as it would appear 213 when layered over TCP; the only difference is that QUIC provides the 214 reliability and ordering that would otherwise be provided by TCP. 216 At certain points during the TLS handshake, keying material is 217 exported from the TLS connection for use by QUIC. This keying 218 material is used to derive packet protection keys. Details on how 219 and when keys are derived and used are included in Section 5. 221 3.1. TLS Overview 223 TLS provides two endpoints with a way to establish a means of 224 communication over an untrusted medium (that is, the Internet) that 225 ensures that messages they exchange cannot be observed, modified, or 226 forged. 228 TLS features can be separated into two basic functions: an 229 authenticated key exchange and record protection. QUIC primarily 230 uses the authenticated key exchange provided by TLS but provides its 231 own packet protection. 233 The TLS authenticated key exchange occurs between two entities: 234 client and server. The client initiates the exchange and the server 235 responds. If the key exchange completes successfully, both client 236 and server will agree on a secret. TLS supports both pre-shared key 237 (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for 238 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 239 keys are destroyed. 241 After completing the TLS handshake, the client will have learned and 242 authenticated an identity for the server and the server is optionally 243 able to learn and authenticate an identity for the client. TLS 244 supports X.509 [RFC5280] certificate-based authentication for both 245 server and client. 247 The TLS key exchange is resistent to tampering by attackers and it 248 produces shared secrets that cannot be controlled by either 249 participating peer. 251 3.2. TLS Handshake 253 TLS 1.3 provides two basic handshake modes of interest to QUIC: 255 o A full 1-RTT handshake in which the client is able to send 256 application data after one round trip and the server immediately 257 responds after receiving the first handshake message from the 258 client. 260 o A 0-RTT handshake in which the client uses information it has 261 previously learned about the server to send application data 262 immediately. This application data can be replayed by an attacker 263 so it MUST NOT carry a self-contained trigger for any non- 264 idempotent action. 266 A simplified TLS 1.3 handshake with 0-RTT application data is shown 267 in Figure 2, see [I-D.ietf-tls-tls13] for more options and details. 269 Client Server 271 ClientHello 272 (0-RTT Application Data) --------> 273 ServerHello 274 {EncryptedExtensions} 275 {Finished} 276 <-------- [Application Data] 277 (EndOfEarlyData) 278 {Finished} --------> 280 [Application Data] <-------> [Application Data] 282 Figure 2: TLS Handshake with 0-RTT 284 This 0-RTT handshake is only possible if the client and server have 285 previously communicated. In the 1-RTT handshake, the client is 286 unable to send protected application data until it has received all 287 of the handshake messages sent by the server. 289 Two additional variations on this basic handshake exchange are 290 relevant to this document: 292 o The server can respond to a ClientHello with a HelloRetryRequest, 293 which adds an additional round trip prior to the basic exchange. 294 This is needed if the server wishes to request a different key 295 exchange key from the client. HelloRetryRequest is also used to 296 verify that the client is correctly able to receive packets on the 297 address it claims to have (see [QUIC-TRANSPORT]). 299 o A pre-shared key mode can be used for subsequent handshakes to 300 reduce the number of public key operations. This is the basis for 301 0-RTT data, even if the remainder of the connection is protected 302 by a new Diffie-Hellman exchange. 304 4. TLS Usage 306 QUIC reserves stream 0 for a TLS connection. Stream 0 contains a 307 complete TLS connection, which includes the TLS record layer. Other 308 than the definition of a QUIC-specific extension (see Section 10.2), 309 TLS is unmodified for this use. This means that TLS will apply 310 confidentiality and integrity protection to its records. In 311 particular, TLS record protection is what provides confidentiality 312 protection for the TLS handshake messages sent by the server. 314 QUIC permits a client to send frames on streams starting from the 315 first packet. The initial packet from a client contains a stream 316 frame for stream 0 that contains the first TLS handshake messages 317 from the client. This allows the TLS handshake to start with the 318 first packet that a client sends. 320 QUIC packets are protected using a scheme that is specific to QUIC, 321 see Section 5. Keys are exported from the TLS connection when they 322 become available using a TLS exporter (see Section 7.5 of 323 [I-D.ietf-tls-tls13] and Section 5.2). After keys are exported from 324 TLS, QUIC manages its own key schedule. 326 4.1. Handshake and Setup Sequence 328 The integration of QUIC with a TLS handshake is shown in more detail 329 in Figure 3. QUIC "STREAM" frames on stream 0 carry the TLS 330 handshake. QUIC performs loss recovery [QUIC-RECOVERY] for this 331 stream and ensures that TLS handshake messages are delivered in the 332 correct order. 334 Client Server 336 @C QUIC STREAM Frame(s) <0>: 337 ClientHello 338 + QUIC Extension 339 --------> 340 0-RTT Key => @0 342 @0 QUIC STREAM Frame(s) : 343 Replayable QUIC Frames 344 --------> 346 QUIC STREAM Frame <0>: @C 347 ServerHello 348 {TLS Handshake Messages} 349 <-------- 350 1-RTT Key => @1 352 QUIC Frames @1 353 <-------- 354 @C QUIC STREAM Frame(s) <0>: 355 (EndOfEarlyData) 356 {Finished} 357 --------> 359 @1 QUIC Frames <-------> QUIC Frames @1 361 Figure 3: QUIC over TLS Handshake 363 In Figure 3, symbols mean: 365 o "<" and ">" enclose stream numbers. 367 o "@" indicates the keys that are used for protecting the QUIC 368 packet (C = cleartext, with integrity only; 0 = 0-RTT keys; 1 = 369 1-RTT keys). 371 o "(" and ")" enclose messages that are protected with TLS 0-RTT 372 handshake or application keys. 374 o "{" and "}" enclose messages that are protected by the TLS 375 Handshake keys. 377 If 0-RTT is not attempted, then the client does not send packets 378 protected by the 0-RTT key (@0). In that case, the only key 379 transition on the client is from cleartext packets (@C) to 1-RTT 380 protection (@1), which happens after it sends its final set of TLS 381 handshake messages. 383 Note: the client uses two different types of cleartext packet during 384 the handshake. The Client Initial packet carries a TLS ClientHello 385 message; the remainder of the TLS handshake is carried in Client 386 Cleartext packets. 388 The server sends TLS handshake messages without protection (@C). The 389 server transitions from no protection (@C) to full 1-RTT protection 390 (@1) after it sends the last of its handshake messages. 392 Some TLS handshake messages are protected by the TLS handshake record 393 protection. These keys are not exported from the TLS connection for 394 use in QUIC. QUIC packets from the server are sent in the clear 395 until the final transition to 1-RTT keys. 397 The client transitions from cleartext (@C) to 0-RTT keys (@0) when 398 sending 0-RTT data, and subsequently to to 1-RTT keys (@1) after its 399 second flight of TLS handshake messages. This creates the potential 400 for unprotected packets to be received by a server in close proximity 401 to packets that are protected with 1-RTT keys. 403 More information on key transitions is included in Section 7.1. 405 4.2. Interface to TLS 407 As shown in Figure 1, the interface from QUIC to TLS consists of four 408 primary functions: Handshake, Source Address Validation, Key Ready 409 Events, and Secret Export. 411 Additional functions might be needed to configure TLS. 413 4.2.1. Handshake Interface 415 In order to drive the handshake, TLS depends on being able to send 416 and receive handshake messages on stream 0. There are two basic 417 functions on this interface: one where QUIC requests handshake 418 messages and one where QUIC provides handshake packets. 420 Before starting the handshake QUIC provides TLS with the transport 421 parameters (see Section 10.2) that it wishes to carry. 423 A QUIC client starts TLS by requesting TLS handshake octets from TLS. 424 The client acquires handshake octets before sending its first packet. 426 A QUIC server starts the process by providing TLS with stream 0 427 octets. 429 Each time that an endpoint receives data on stream 0, it delivers the 430 octets to TLS if it is able. Each time that TLS is provided with new 431 data, new handshake octets are requested from TLS. TLS might not 432 provide any octets if the handshake messages it has received are 433 incomplete or it has no data to send. 435 Once the TLS handshake is complete, this is indicated to QUIC along 436 with any final handshake octets that TLS needs to send. TLS also 437 provides QUIC with the transport parameters that the peer advertised 438 during the handshake. 440 Once the handshake is complete, TLS becomes passive. TLS can still 441 receive data from its peer and respond in kind, but it will not need 442 to send more data unless specifically requested - either by an 443 application or QUIC. One reason to send data is that the server 444 might wish to provide additional or updated session tickets to a 445 client. 447 When the handshake is complete, QUIC only needs to provide TLS with 448 any data that arrives on stream 0. In the same way that is done 449 during the handshake, new data is requested from TLS after providing 450 received data. 452 Important: Until the handshake is reported as complete, the 453 connection and key exchange are not properly authenticated at the 454 server. Even though 1-RTT keys are available to a server after 455 receiving the first handshake messages from a client, the server 456 cannot consider the client to be authenticated until it receives 457 and validates the client's Finished message. 459 The requirement for the server to wait for the client Finished 460 message creates a dependency on that message being delivered. A 461 client can avoid the potential for head-of-line blocking that this 462 implies by sending a copy of the STREAM frame that carries the 463 Finished message in multiple packets. This enables immediate 464 server processing for those packets. 466 4.2.2. Source Address Validation 468 During the processing of the TLS ClientHello, TLS requests that the 469 transport make a decision about whether to request source address 470 validation from the client. 472 An initial TLS ClientHello that resumes a session includes an address 473 validation token in the session ticket; this includes all attempts at 474 0-RTT. If the client does not attempt session resumption, no token 475 will be present. While processing the initial ClientHello, TLS 476 provides QUIC with any token that is present. In response, QUIC 477 provides one of three responses: 479 o proceed with the connection, 481 o ask for client address validation, or 483 o abort the connection. 485 If QUIC requests source address validation, it also provides a new 486 address validation token. TLS includes that along with any 487 information it requires in the cookie extension of a TLS 488 HelloRetryRequest message. In the other cases, the connection either 489 proceeds or terminates with a handshake error. 491 The client echoes the cookie extension in a second ClientHello. A 492 ClientHello that contains a valid cookie extension will always be in 493 response to a HelloRetryRequest. If address validation was requested 494 by QUIC, then this will include an address validation token. TLS 495 makes a second address validation request of QUIC, including the 496 value extracted from the cookie extension. In response to this 497 request, QUIC cannot ask for client address validation, it can only 498 abort or permit the connection attempt to proceed. 500 QUIC can provide a new address validation token for use in session 501 resumption at any time after the handshake is complete. Each time a 502 new token is provided TLS generates a NewSessionTicket message, with 503 the token included in the ticket. 505 See Section 8 for more details on client address validation. 507 4.2.3. Key Ready Events 509 TLS provides QUIC with signals when 0-RTT and 1-RTT keys are ready 510 for use. These events are not asynchronous, they always occur 511 immediately after TLS is provided with new handshake octets, or after 512 TLS produces handshake octets. 514 When TLS completed its handshake, 1-RTT keys can be provided to QUIC. 515 On both client and server, this occurs after sending the TLS Finished 516 message. 518 This ordering means that there could be frames that carry TLS 519 handshake messages ready to send at the same time that application 520 data is available. An implementation MUST ensure that TLS handshake 521 messages are always sent in cleartext packets. Separate packets are 522 required for data that needs protection from 1-RTT keys. 524 If 0-RTT is possible, it is ready after the client sends a TLS 525 ClientHello message or the server receives that message. After 526 providing a QUIC client with the first handshake octets, the TLS 527 stack might signal that 0-RTT keys are ready. On the server, after 528 receiving handshake octets that contain a ClientHello message, a TLS 529 server might signal that 0-RTT keys are available. 531 1-RTT keys are used for packets in both directions. 0-RTT keys are 532 only used to protect packets sent by the client. 534 4.2.4. Secret Export 536 Details how secrets are exported from TLS are included in 537 Section 5.2. 539 4.2.5. TLS Interface Summary 541 Figure 4 summarizes the exchange between QUIC and TLS for both client 542 and server. 544 Client Server 546 Get Handshake 547 0-RTT Key Ready 548 --- send/receive ---> 549 Handshake Received 550 0-RTT Key Ready 551 Get Handshake 552 1-RTT Keys Ready 553 <--- send/receive --- 554 Handshake Received 555 Get Handshake 556 Handshake Complete 557 1-RTT Keys Ready 558 --- send/receive ---> 559 Handshake Received 560 Get Handshake 561 Handshake Complete 562 <--- send/receive --- 563 Handshake Received 564 Get Handshake 566 Figure 4: Interaction Summary between QUIC and TLS 568 4.3. TLS Version 570 This document describes how TLS 1.3 [I-D.ietf-tls-tls13] is used with 571 QUIC. 573 In practice, the TLS handshake will negotiate a version of TLS to 574 use. This could result in a newer version of TLS than 1.3 being 575 negotiated if both endpoints support that version. This is 576 acceptable provided that the features of TLS 1.3 that are used by 577 QUIC are supported by the newer version. 579 A badly configured TLS implementation could negotiate TLS 1.2 or 580 another older version of TLS. An endpoint MUST terminate the 581 connection if a version of TLS older than 1.3 is negotiated. 583 4.4. ClientHello Size 585 QUIC requires that the initial handshake packet from a client fit 586 within the payload of a single packet. The size limits on QUIC 587 packets mean that a record containing a ClientHello needs to fit 588 within 1171 octets. 590 A TLS ClientHello can fit within this limit with ample space 591 remaining. However, there are several variables that could cause 592 this limit to be exceeded. Implementations are reminded that large 593 session tickets or HelloRetryRequest cookies, multiple or large key 594 shares, and long lists of supported ciphers, signature algorithms, 595 versions, QUIC transport parameters, and other negotiable parameters 596 and extensions could cause this message to grow. 598 For servers, the size of the session tickets and HelloRetryRequest 599 cookie extension can have an effect on a client's ability to connect. 600 Choosing a small value increases the probability that these values 601 can be successfully used by a client. 603 The TLS implementation does not need to ensure that the ClientHello 604 is sufficiently large. QUIC PADDING frames are added to increase the 605 size of the packet as necessary. 607 4.5. Peer Authentication 609 The requirements for authentication depend on the application 610 protocol that is in use. TLS provides server authentication and 611 permits the server to request client authentication. 613 A client MUST authenticate the identity of the server. This 614 typically involves verification that the identity of the server is 615 included in a certificate and that the certificate is issued by a 616 trusted entity (see for example [RFC2818]). 618 A server MAY request that the client authenticate during the 619 handshake. A server MAY refuse a connection if the client is unable 620 to authenticate when requested. The requirements for client 621 authentication vary based on application protocol and deployment. 623 A server MUST NOT use post-handshake client authentication (see 624 Section 4.6.2 of [I-D.ietf-tls-tls13]). 626 4.6. TLS Errors 628 Errors in the TLS connection SHOULD be signaled using TLS alerts on 629 stream 0. A failure in the handshake MUST be treated as a QUIC 630 connection error of type TLS_HANDSHAKE_FAILED. Once the handshake is 631 complete, an error in the TLS connection that causes a TLS alert to 632 be sent or received MUST be treated as a QUIC connection error of 633 type TLS_FATAL_ALERT_GENERATED or TLS_FATAL_ALERT_RECEIVED 634 respectively. 636 5. QUIC Packet Protection 638 QUIC packet protection provides authenticated encryption of packets. 639 This provides confidentiality and integrity protection for the 640 content of packets (see Section 5.3). Packet protection uses keys 641 that are exported from the TLS connection (see Section 5.2). 643 Different keys are used for QUIC packet protection and TLS record 644 protection. TLS handshake messages are protected solely with TLS 645 record protection, but post-handshake messages are redundantly 646 proteted with both both the QUIC packet protection and the TLS record 647 protection. These messages are limited in number, and so the 648 additional overhead is small. 650 5.1. Installing New Keys 652 As TLS reports the availability of keying material, the packet 653 protection keys and initialization vectors (IVs) are updated (see 654 Section 5.2). The selection of AEAD function is also updated to 655 match the AEAD negotiated by TLS. 657 For packets other than any unprotected handshake packets (see 658 Section 7.1), once a change of keys has been made, packets with 659 higher packet numbers MUST be sent with the new keying material. The 660 KEY_PHASE bit on these packets is inverted each time new keys are 661 installed to signal the use of the new keys to the recipient (see 662 Section 7 for details). 664 An endpoint retransmits stream data in a new packet. New packets 665 have new packet numbers and use the latest packet protection keys. 666 This simplifies key management when there are key updates (see 667 Section 7.2). 669 5.2. QUIC Key Expansion 671 QUIC uses a system of packet protection secrets, keys and IVs that 672 are modelled on the system used in TLS [I-D.ietf-tls-tls13]. The 673 secrets that QUIC uses as the basis of its key schedule are obtained 674 using TLS exporters (see Section 7.5 of [I-D.ietf-tls-tls13]). 676 QUIC uses HKDF with the same hash function negotiated by TLS for key 677 derivation. For example, if TLS is using the TLS_AES_128_GCM_SHA256, 678 the SHA-256 hash function is used. 680 5.2.1. 0-RTT Secret 682 0-RTT keys are those keys that are used in resumed connections prior 683 to the completion of the TLS handshake. Data sent using 0-RTT keys 684 might be replayed and so has some restrictions on its use, see 685 Section 9.2. 0-RTT keys are used after sending or receiving a 686 ClientHello. 688 The secret is exported from TLS using the exporter label "EXPORTER- 689 QUIC 0-RTT Secret" and an empty context. The size of the secret MUST 690 be the size of the hash output for the PRF hash function negotiated 691 by TLS. This uses the TLS early_exporter_secret. The QUIC 0-RTT 692 secret is only used for protection of packets sent by the client. 694 client_0rtt_secret 695 = TLS-Exporter("EXPORTER-QUIC 0-RTT Secret" 696 "", Hash.length) 698 5.2.2. 1-RTT Secrets 700 1-RTT keys are used by both client and server after the TLS handshake 701 completes. There are two secrets used at any time: one is used to 702 derive packet protection keys for packets sent by the client, the 703 other for packet protection keys on packets sent by the server. 705 The initial client packet protection secret is exported from TLS 706 using the exporter label "EXPORTER-QUIC client 1-RTT Secret"; the 707 initial server packet protection secret uses the exporter label 708 "EXPORTER-QUIC server 1-RTT Secret". Both exporters use an empty 709 context. The size of the secret MUST be the size of the hash output 710 for the PRF hash function negotiated by TLS. 712 client_pp_secret_0 713 = TLS-Exporter("EXPORTER-QUIC client 1-RTT Secret" 714 "", Hash.length) 715 server_pp_secret_0 716 = TLS-Exporter("EXPORTER-QUIC server 1-RTT Secret" 717 "", Hash.length) 719 These secrets are used to derive the initial client and server packet 720 protection keys. 722 After a key update (see Section 7.2), these secrets are updated using 723 the HKDF-Expand-Label function defined in Section 7.1 of 724 [I-D.ietf-tls-tls13]. HKDF-Expand-Label uses the PRF hash function 725 negotiated by TLS. The replacement secret is derived using the 726 existing Secret, a Label of "QUIC client 1-RTT Secret" for the client 727 and "QUIC server 1-RTT Secret" for the server, an empty HashValue, 728 and the same output Length as the hash function selected by TLS for 729 its PRF. 731 client_pp_secret_ 732 = HKDF-Expand-Label(client_pp_secret_, 733 "QUIC client 1-RTT Secret", 734 "", Hash.length) 735 server_pp_secret_ 736 = HKDF-Expand-Label(server_pp_secret_, 737 "QUIC server 1-RTT Secret", 738 "", Hash.length) 740 This allows for a succession of new secrets to be created as needed. 742 HKDF-Expand-Label uses HKDF-Expand [RFC5869] with a specially 743 formatted info parameter, as shown: 745 HKDF-Expand-Label(Secret, Label, HashValue, Length) = 746 HKDF-Expand(Secret, HkdfLabel, Length) 748 Where HkdfLabel is specified as: 750 struct { 751 uint16 length = Length; 752 opaque label<10..255> = "tls13 " + Label; 753 uint8 hashLength; // Always 0 754 } HkdfLabel; 756 For example, the client packet protection secret uses an info 757 parameter of: 759 info = (HashLen / 256) || (HashLen % 256) || 0x1f || 760 "tls13 QUIC client 1-RTT secret" || 0x00 762 5.2.3. Packet Protection Key and IV 764 The complete key expansion uses an identical process for key 765 expansion as defined in Section 7.3 of [I-D.ietf-tls-tls13], using 766 different values for the input secret. QUIC uses the AEAD function 767 negotiated by TLS. 769 The packet protection key and IV used to protect the 0-RTT packets 770 sent by a client are derived from the QUIC 0-RTT secret. The packet 771 protection keys and IVs for 1-RTT packets sent by the client and 772 server are derived from the current generation of client_pp_secret 773 and server_pp_secret respectively. The length of the output is 774 determined by the requirements of the AEAD function selected by TLS. 775 The key length is the AEAD key size. As defined in Section 5.3 of 776 [I-D.ietf-tls-tls13], the IV length is the larger of 8 or N_MIN (see 777 Section 4 of [RFC5116]). For any secret S, the corresponding key and 778 IV are derived as shown below: 780 key = HKDF-Expand-Label(S, "key", "", key_length) 781 iv = HKDF-Expand-Label(S, "iv", "", iv_length) 783 The QUIC record protection initially starts without keying material. 784 When the TLS state machine reports that the ClientHello has been 785 sent, the 0-RTT keys can be generated and installed for writing. 786 When the TLS state machine reports completion of the handshake, the 787 1-RTT keys can be generated and installed for writing. 789 5.3. QUIC AEAD Usage 791 The Authentication Encryption with Associated Data (AEAD) [RFC5116] 792 function used for QUIC packet protection is AEAD that is negotiated 793 for use with the TLS connection. For example, if TLS is using the 794 TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is used. 796 Regular QUIC packets are protected by an AEAD algorithm [RFC5116]. 797 Version negotiation and public reset packets are not protected. 799 Once TLS has provided a key, the contents of regular QUIC packets 800 immediately after any TLS messages have been sent are protected by 801 the AEAD selected by TLS. 803 The key, K, is either the client packet protection key 804 (client_pp_key_n) or the server packet protection key 805 (server_pp_key_n), derived as defined in Section 5.2. 807 The nonce, N, is formed by combining the packet protection IV (either 808 client_pp_iv_n or server_pp_iv_n) with the packet number. The 64 809 bits of the reconstructed QUIC packet number in network byte order is 810 left-padded with zeros to the size of the IV. The exclusive OR of 811 the padded packet number and the IV forms the AEAD nonce. 813 The associated data, A, for the AEAD is the contents of the QUIC 814 header, starting from the flags octet in either the short or long 815 header. 817 The input plaintext, P, for the AEAD is the content of the QUIC frame 818 following the header, as described in [QUIC-TRANSPORT]. 820 The output ciphertext, C, of the AEAD is transmitted in place of P. 822 Prior to TLS providing keys, no record protection is performed and 823 the plaintext, P, is transmitted unmodified. 825 5.4. Packet Numbers 827 QUIC has a single, contiguous packet number space. In comparison, 828 TLS restarts its sequence number each time that record protection 829 keys are changed. The sequence number restart in TLS ensures that a 830 compromise of the current traffic keys does not allow an attacker to 831 truncate the data that is sent after a key update by sending 832 additional packets under the old key (causing new packets to be 833 discarded). 835 QUIC does not assume a reliable transport and is required to handle 836 attacks where packets are dropped in other ways. QUIC is therefore 837 not affected by this form of truncation. 839 The QUIC packet number is not reset and it is not permitted to go 840 higher than its maximum value of 2^64-1. This establishes a hard 841 limit on the number of packets that can be sent. 843 Some AEAD functions have limits for how many packets can be encrypted 844 under the same key and IV (see for example [AEBounds]). This might 845 be lower than the packet number limit. An endpoint MUST initiate a 846 key update (Section 7.2) prior to exceeding any limit set for the 847 AEAD that is in use. 849 TLS maintains a separate sequence number that is used for record 850 protection on the connection that is hosted on stream 0. This 851 sequence number is not visible to QUIC. 853 5.5. Receiving Protected Packets 855 Once an endpoint successfully receives a packet with a given packet 856 number, it MUST discard all packets with higher packet numbers if 857 they cannot be successfully unprotected with either the same key, or 858 - if there is a key update - the next packet protection key (see 859 Section 7.2). Similarly, a packet that appears to trigger a key 860 update, but cannot be unprotected successfully MUST be discarded. 862 Failure to unprotect a packet does not necessarily indicate the 863 existence of a protocol error in a peer or an attack. The truncated 864 packet number encoding used in QUIC can cause packet numbers to be 865 decoded incorrectly if they are delayed significantly. 867 5.6. Packet Number Gaps 869 [QUIC-TRANSPORT]; Section 7.5.1.1 also requires a secret to compute 870 packet number gaps on connection ID transitions. That secret is 871 computed as: 873 packet_number_secret 874 = TLS-Exporter("EXPORTER-QUIC Packet Number Secret" 875 "", Hash.length) 877 6. Unprotected Packets 879 QUIC adds an integrity check to all cleartext packets. Cleartext 880 packets are not protected by the negotiated AEAD (see Section 5), but 881 instead include an integrity check. This check does not prevent the 882 packet from being altered, it exists for added resilience against 883 data corruption and to provide added assurance that the sender 884 intends to use QUIC. 886 Cleartext packets all use the long form of the QUIC header and so 887 will include a version number. For this version of QUIC, the 888 integrity check uses the 64-bit FNV-1a hash (see Section 6.2). The 889 output of this hash is appended to the payload of the packet. 891 The integrity check algorithm MAY change for other versions of the 892 protocol. 894 6.1. Integrity Check Processing 896 An endpoint sending a packet that has a long header and a type that 897 does not indicate that the packet will be protected (that is, 0-RTT 898 Encrypted (0x05), 1-RTT Encrypted (key phase 0) (0x06), or 1-RTT 899 Encrypted (key phase 1) (0x07)) first constructs the packet that it 900 sends without the integrity check. 902 The sender then calculates the integrity check over the entire 903 packet, starting from the type field. The output of the hash is 904 appended to the packet. 906 A receiver that receives an unprotected packet first checks that the 907 version is correct, then removes the trailing 8 octets. It 908 calculates the integrity check over the remainder of the packet. 909 Unprotected packets that do not contain a valid integrity check MUST 910 be discarded. 912 6.2. The 64-bit FNV-1a Algorithm 914 QUIC uses the 64-bit version of the alternative Fowler/Noll/Vo hash 915 (FNV-1a) [FNV]. 917 FNV-1a can be expressed in pseudocode as: 919 hash := offset basis 920 for each input octet: 921 hash := hash XOR input octet 922 hash := hash * prime 924 That is, a 64-bit unsigned integer is initialized with an offset 925 basis. Then, for each octet of the input, the exclusive binary OR of 926 the value is taken, then multiplied by a prime. Any overflow from 927 multiplication is discarded. 929 The offset basis for the 64-bit FNV-1a is the decimal value 930 14695981039346656037 (in hex, 0xcbf29ce484222325). The prime is 931 1099511628211 (in hex, 0x100000001b3; or as an expression 2^40 + 2^8 932 + 0xb3). 934 Once all octets have been processed in this fashion, the final 935 integer value is encoded as 8 octets in network byte order. 937 7. Key Phases 939 As TLS reports the availability of 0-RTT and 1-RTT keys, new keying 940 material can be exported from TLS and used for QUIC packet 941 protection. At each transition during the handshake a new secret is 942 exported from TLS and packet protection keys are derived from that 943 secret. 945 Every time that a new set of keys is used for protecting outbound 946 packets, the KEY_PHASE bit in the public flags is toggled. 0-RTT 947 protected packets use the QUIC long header, they do not use the 948 KEY_PHASE bit to select the correct keys (see Section 7.1.1). 950 Once the connection is fully enabled, the KEY_PHASE bit allows a 951 recipient to detect a change in keying material without necessarily 952 needing to receive the first packet that triggered the change. An 953 endpoint that notices a changed KEY_PHASE bit can update keys and 954 decrypt the packet that contains the changed bit, see Section 7.2. 956 The KEY_PHASE bit is included as the 0x20 bit of the QUIC short 957 header, or is determined by the packet type from the long header (a 958 type of 0x06 indicates a key phase of 0, 0x07 indicates key phase 1). 960 Transitions between keys during the handshake are complicated by the 961 need to ensure that TLS handshake messages are sent with the correct 962 packet protection. 964 7.1. Packet Protection for the TLS Handshake 966 The initial exchange of packets are sent without protection. These 967 packets use a cleartext packet type. 969 TLS handshake messages MUST NOT be protected using QUIC packet 970 protection. All TLS handshake messages up to the TLS Finished 971 message sent by either endpoint use cleartext packets. 973 Any TLS handshake messages that are sent after completing the TLS 974 handshake do not need special packet protection rules. Packets 975 containing these messages use the packet protection keys that are 976 current at the time of sending (or retransmission). 978 Like the client, a server MUST send retransmissions of its 979 unprotected handshake messages or acknowledgments for unprotected 980 handshake messages sent by the client in cleartext packets. 982 7.1.1. Initial Key Transitions 984 Once the TLS handshake is complete, keying material is exported from 985 TLS and QUIC packet protection commences. 987 Packets protected with 1-RTT keys initially have a KEY_PHASE bit set 988 to 0. This bit inverts with each subsequent key update (see 989 Section 7.2). 991 If the client sends 0-RTT data, it uses the 0-RTT packet type. The 992 packet that contains the TLS EndOfEarlyData and Finished messages are 993 sent in cleartext packets. 995 Using distinct packet types during the handshake for handshake 996 messages, 0-RTT data, and 1-RTT data ensures that the server is able 997 to distinguish between the different keys used to remove packet 998 protection. All of these packets can arrive concurrently at a 999 server. 1001 A server might choose to retain 0-RTT packets that arrive before a 1002 TLS ClientHello. The server can then use those packets once the 1003 ClientHello arrives. However, the potential for denial of service 1004 from buffering 0-RTT packets is significant. These packets cannot be 1005 authenticated and so might be employed by an attacker to exhaust 1006 server resources. Limiting the number of packets that are saved 1007 might be necessary. 1009 The server transitions to using 1-RTT keys after sending its first 1010 flight of TLS handshake messages. From this point, the server 1011 protects all packets with 1-RTT keys. Future packets are therefore 1012 protected with 1-RTT keys. Initially, these are marked with a 1013 KEY_PHASE of 0. 1015 7.1.2. Retransmission and Acknowledgment of Unprotected Packets 1017 TLS handshake messages from both client and server are critical to 1018 the key exchange. The contents of these messages determines the keys 1019 used to protect later messages. If these handshake messages are 1020 included in packets that are protected with these keys, they will be 1021 indecipherable to the recipient. 1023 Even though newer keys could be available when retransmitting, 1024 retransmissions of these handshake messages MUST be sent in cleartext 1025 packets. An endpoint MUST generate ACK frames for these messages and 1026 send them in cleartext packets. 1028 A HelloRetryRequest handshake message might be used to reject an 1029 initial ClientHello. A HelloRetryRequest handshake message is sent 1030 in a Server Stateless Retry packet; any second ClientHello that is 1031 sent in response uses a Client Initial packet type. Neither packet 1032 is protected. This is natural, because no new keying material will 1033 be available when these messages need to be sent. Upon receipt of a 1034 HelloRetryRequest, a client SHOULD cease any transmission of 0-RTT 1035 data; 0-RTT data will only be discarded by any server that sends a 1036 HelloRetryRequest. 1038 The packet type ensures that protected packets are clearly 1039 distinguished from unprotected packets. Loss or reordering might 1040 cause unprotected packets to arrive once 1-RTT keys are in use, 1041 unprotected packets are easily distinguished from 1-RTT packets using 1042 the packet type. 1044 Once 1-RTT keys are available to an endpoint, it no longer needs the 1045 TLS handshake messages that are carried in unprotected packets. 1047 However, a server might need to retransmit its TLS handshake messages 1048 in response to receiving an unprotected packet that contains ACK 1049 frames. A server MUST process ACK frames in unprotected packets 1050 until the TLS handshake is reported as complete, or it receives an 1051 ACK frame in a protected packet that acknowledges all of its 1052 handshake messages. 1054 To limit the number of key phases that could be active, an endpoint 1055 MUST NOT initiate a key update while there are any unacknowledged 1056 handshake messages, see Section 7.2. 1058 7.2. Key Update 1060 Once the TLS handshake is complete, the KEY_PHASE bit allows for 1061 refreshes of keying material by either peer. Endpoints start using 1062 updated keys immediately without additional signaling; the change in 1063 the KEY_PHASE bit indicates that a new key is in use. 1065 An endpoint MUST NOT initiate more than one key update at a time. A 1066 new key cannot be used until the endpoint has received and 1067 successfully decrypted a packet with a matching KEY_PHASE. Note that 1068 when 0-RTT is attempted the value of the KEY_PHASE bit will be 1069 different on packets sent by either peer. 1071 A receiving endpoint detects an update when the KEY_PHASE bit doesn't 1072 match what it is expecting. It creates a new secret (see 1073 Section 5.2) and the corresponding read key and IV. If the packet 1074 can be decrypted and authenticated using these values, then the keys 1075 it uses for packet protection are also updated. The next packet sent 1076 by the endpoint will then use the new keys. 1078 An endpoint doesn't need to send packets immediately when it detects 1079 that its peer has updated keys. The next packet that it sends will 1080 simply use the new keys. If an endpoint detects a second update 1081 before it has sent any packets with updated keys it indicates that 1082 its peer has updated keys twice without awaiting a reciprocal update. 1083 An endpoint MUST treat consecutive key updates as a fatal error and 1084 abort the connection. 1086 An endpoint SHOULD retain old keys for a short period to allow it to 1087 decrypt packets with smaller packet numbers than the packet that 1088 triggered the key update. This allows an endpoint to consume packets 1089 that are reordered around the transition between keys. Packets with 1090 higher packet numbers always use the updated keys and MUST NOT be 1091 decrypted with old keys. 1093 Keys and their corresponding secrets SHOULD be discarded when an 1094 endpoint has received all packets with sequence numbers lower than 1095 the lowest sequence number used for the new key. An endpoint might 1096 discard keys if it determines that the length of the delay to 1097 affected packets is excessive. 1099 This ensures that once the handshake is complete, packets with the 1100 same KEY_PHASE will have the same packet protection keys, unless 1101 there are multiple key updates in a short time frame succession and 1102 significant packet reordering. 1104 Initiating Peer Responding Peer 1106 @M QUIC Frames 1107 New Keys -> @N 1108 @N QUIC Frames 1109 --------> 1110 QUIC Frames @M 1111 New Keys -> @N 1112 QUIC Frames @N 1113 <-------- 1115 Figure 5: Key Update 1117 As shown in Figure 3 and Figure 5, there is never a situation where 1118 there are more than two different sets of keying material that might 1119 be received by a peer. Once both sending and receiving keys have 1120 been updated, 1122 A server cannot initiate a key update until it has received the 1123 client's Finished message. Otherwise, packets protected by the 1124 updated keys could be confused for retransmissions of handshake 1125 messages. A client cannot initiate a key update until all of its 1126 handshake messages have been acknowledged by the server. 1128 A packet that triggers a key update could arrive after successfully 1129 processing a packet with a higher packet number. This is only 1130 possible if there is a key compromise and an attack, or if the peer 1131 is incorrectly reverting to use of old keys. Because the latter 1132 cannot be differentiated from an attack, an endpoint MUST immediately 1133 terminate the connection if it detects this condition. 1135 8. Client Address Validation 1137 Two tools are provided by TLS to enable validation of client source 1138 addresses at a server: the cookie in the HelloRetryRequest message, 1139 and the ticket in the NewSessionTicket message. 1141 8.1. HelloRetryRequest Address Validation 1143 The cookie extension in the TLS HelloRetryRequest message allows a 1144 server to perform source address validation during the handshake. 1146 When QUIC requests address validation during the processing of the 1147 first ClientHello, the token it provides is included in the cookie 1148 extension of a HelloRetryRequest. As long as the cookie cannot be 1149 successfully guessed by a client, the server can be assured that the 1150 client received the HelloRetryRequest if it includes the value in a 1151 second ClientHello. 1153 An initial ClientHello never includes a cookie extension. Thus, if a 1154 server constructs a cookie that contains all the information 1155 necessary to reconstruct state, it can discard local state after 1156 sending a HelloRetryRequest. Presence of a valid cookie in a 1157 ClientHello indicates that the ClientHello is a second attempt from 1158 the client. 1160 An address validation token can be extracted from a second 1161 ClientHello and passed to the transport for further validation. If 1162 that validation fails, the server MUST fail the TLS handshake and 1163 send an illegal_parameter alert. 1165 Combining address validation with the other uses of HelloRetryRequest 1166 ensures that there are fewer ways in which an additional round-trip 1167 can be added to the handshake. In particular, this makes it possible 1168 to combine a request for address validation with a request for a 1169 different client key share. 1171 If TLS needs to send a HelloRetryRequest for other reasons, it needs 1172 to ensure that it can correctly identify the reason that the 1173 HelloRetryRequest was generated. During the processing of a second 1174 ClientHello, TLS does not need to consult the transport protocol 1175 regarding address validation if address validation was not requested 1176 originally. In such cases, the cookie extension could either be 1177 absent or it could indicate that an address validation token is not 1178 present. 1180 8.1.1. Stateless Address Validation 1182 A server can use the cookie extension to store all state necessary to 1183 continue the connection. This allows a server to avoid committing 1184 state for clients that have unvalidated source addresses. 1186 For instance, a server could use a statically-configured key to 1187 encrypt the information that it requires and include that information 1188 in the cookie. In addition to address validation information, a 1189 server that uses encryption also needs to be able recover the hash of 1190 the ClientHello and its length, plus any information it needs in 1191 order to reconstruct the HelloRetryRequest. 1193 8.1.2. Sending HelloRetryRequest 1195 A server does not need to maintain state for the connection when 1196 sending a HelloRetryRequest message. This might be necessary to 1197 avoid creating a denial of service exposure for the server. However, 1198 this means that information about the transport will be lost at the 1199 server. This includes the stream offset of stream 0, the packet 1200 number that the server selects, and any opportunity to measure round 1201 trip time. 1203 A server MUST send a TLS HelloRetryRequest in a Server Stateless 1204 Retry packet. Using a Server Stateless Retry packet causes the 1205 client to reset stream offsets. It also avoids the need for the 1206 server select an initial packet number, which would need to be 1207 remembered so that subsequent packets could be correctly numbered. 1209 A HelloRetryRequest message MUST NOT be split between multiple Server 1210 Stateless Retry packets. This means that HelloRetryRequest is 1211 subject to the same size constraints as a ClientHello (see 1212 Section 4.4). 1214 8.2. NewSessionTicket Address Validation 1216 The ticket in the TLS NewSessionTicket message allows a server to 1217 provide a client with a similar sort of token. When a client resumes 1218 a TLS connection - whether or not 0-RTT is attempted - it includes 1219 the ticket in the handshake message. As with the HelloRetryRequest 1220 cookie, the server includes the address validation token in the 1221 ticket. TLS provides the token it extracts from the session ticket 1222 to the transport when it asks whether source address validation is 1223 needed. 1225 If both a HelloRetryRequest cookie and a session ticket are present 1226 in the ClientHello, only the token from the cookie is passed to the 1227 transport. The presence of a cookie indicates that this is a second 1228 ClientHello - the token from the session ticket will have been 1229 provided to the transport when it appeared in the first ClientHello. 1231 A server can send a NewSessionTicket message at any time. This 1232 allows it to update the state - and the address validation token - 1233 that is included in the ticket. This might be done to refresh the 1234 ticket or token, or it might be generated in response to changes in 1235 the state of the connection. QUIC can request that a 1236 NewSessionTicket be sent by providing a new address validation token. 1238 A server that intends to support 0-RTT SHOULD provide an address 1239 validation token immediately after completing the TLS handshake. 1241 8.3. Address Validation Token Integrity 1243 TLS MUST provide integrity protection for address validation token 1244 unless the transport guarantees integrity protection by other means. 1245 For a NewSessionTicket that includes confidential information - such 1246 as the resumption secret - including the token under authenticated 1247 encryption ensures that the token gains both confidentiality and 1248 integrity protection without duplicating the overheads of that 1249 protection. 1251 9. Pre-handshake QUIC Messages 1253 Implementations MUST NOT exchange data on any stream other than 1254 stream 0 without packet protection. QUIC requires the use of several 1255 types of frame for managing loss detection and recovery during this 1256 phase. In addition, it might be useful to use the data acquired 1257 during the exchange of unauthenticated messages for congestion 1258 control. 1260 This section generally only applies to TLS handshake messages from 1261 both peers and acknowledgments of the packets carrying those 1262 messages. In many cases, the need for servers to provide 1263 acknowledgments is minimal, since the messages that clients send are 1264 small and implicitly acknowledged by the server's responses. 1266 The actions that a peer takes as a result of receiving an 1267 unauthenticated packet needs to be limited. In particular, state 1268 established by these packets cannot be retained once record 1269 protection commences. 1271 There are several approaches possible for dealing with 1272 unauthenticated packets prior to handshake completion: 1274 o discard and ignore them 1276 o use them, but reset any state that is established once the 1277 handshake completes 1279 o use them and authenticate them afterwards; failing the handshake 1280 if they can't be authenticated 1282 o save them and use them when they can be properly authenticated 1284 o treat them as a fatal error 1285 Different strategies are appropriate for different types of data. 1286 This document proposes that all strategies are possible depending on 1287 the type of message. 1289 o Transport parameters are made usable and authenticated as part of 1290 the TLS handshake (see Section 10.2). 1292 o Most unprotected messages are treated as fatal errors when 1293 received except for the small number necessary to permit the 1294 handshake to complete (see Section 9.1). 1296 o Protected packets can either be discarded or saved and later used 1297 (see Section 9.3). 1299 9.1. Unprotected Packets Prior to Handshake Completion 1301 This section describes the handling of messages that are sent and 1302 received prior to the completion of the TLS handshake. 1304 Sending and receiving unprotected messages is hazardous. Unless 1305 expressly permitted, receipt of an unprotected message of any kind 1306 MUST be treated as a fatal error. 1308 9.1.1. STREAM Frames 1310 "STREAM" frames for stream 0 are permitted. These carry the TLS 1311 handshake messages. Once 1-RTT keys are available, unprotected 1312 "STREAM" frames on stream 0 can be ignored. 1314 Receiving unprotected "STREAM" frames for other streams MUST be 1315 treated as a fatal error. 1317 9.1.2. ACK Frames 1319 "ACK" frames are permitted prior to the handshake being complete. 1320 Information learned from "ACK" frames cannot be entirely relied upon, 1321 since an attacker is able to inject these packets. Timing and packet 1322 retransmission information from "ACK" frames is critical to the 1323 functioning of the protocol, but these frames might be spoofed or 1324 altered. 1326 Endpoints MUST NOT use an "ACK" frame in an unprotected packet to 1327 acknowledge packets that were protected by 0-RTT or 1-RTT keys. An 1328 endpoint MUST treat receipt of an "ACK" frame in an unprotected 1329 packet that claims to acknowledge protected packets as a connection 1330 error of type OPTIMISTIC_ACK. An endpoint that can read protected 1331 data is always able to send protected data. 1333 Note: 0-RTT data can be acknowledged by the server as it receives 1334 it, but any packets containing acknowledgments of 0-RTT data 1335 cannot have packet protection removed by the client until the TLS 1336 handshake is complete. The 1-RTT keys necessary to remove packet 1337 protection cannot be derived until the client receives all server 1338 handshake messages. 1340 An endpoint SHOULD use data from "ACK" frames carried in unprotected 1341 packets or packets protected with 0-RTT keys only during the initial 1342 handshake. All "ACK" frames contained in unprotected packets that 1343 are received after successful receipt of a packet protected with 1344 1-RTT keys MUST be discarded. An endpoint SHOULD therefore include 1345 acknowledgments for unprotected and any packets protected with 0-RTT 1346 keys until it sees an acknowledgment for a packet that is both 1347 protected with 1-RTT keys and contains an "ACK" frame. 1349 9.1.3. Updates to Data and Stream Limits 1351 "MAX_DATA", "MAX_STREAM_DATA", "BLOCKED", "STREAM_BLOCKED", and 1352 "MAX_STREAM_ID" frames MUST NOT be sent unprotected. 1354 Though data is exchanged on stream 0, the initial flow control window 1355 on that stream is sufficiently large to allow the TLS handshake to 1356 complete. This limits the maximum size of the TLS handshake and 1357 would prevent a server or client from using an abnormally large 1358 certificate chain. 1360 Stream 0 is exempt from the connection-level flow control window. 1362 Consequently, there is no need to signal being blocked on flow 1363 control. 1365 Similarly, there is no need to increase the number of allowed streams 1366 until the handshake completes. 1368 9.1.4. Denial of Service with Unprotected Packets 1370 Accepting unprotected - specifically unauthenticated - packets 1371 presents a denial of service risk to endpoints. An attacker that is 1372 able to inject unprotected packets can cause a recipient to drop even 1373 protected packets with a matching sequence number. The spurious 1374 packet shadows the genuine packet, causing the genuine packet to be 1375 ignored as redundant. 1377 Once the TLS handshake is complete, both peers MUST ignore 1378 unprotected packets. From that point onward, unprotected messages 1379 can be safely dropped. 1381 Since only TLS handshake packets and acknowledgments are sent in the 1382 clear, an attacker is able to force implementations to rely on 1383 retransmission for packets that are lost or shadowed. Thus, an 1384 attacker that intends to deny service to an endpoint has to drop or 1385 shadow protected packets in order to ensure that their victim 1386 continues to accept unprotected packets. The ability to shadow 1387 packets means that an attacker does not need to be on path. 1389 In addition to causing valid packets to be dropped, an attacker can 1390 generate packets with an intent of causing the recipient to expend 1391 processing resources. See Section 11.2 for a discussion of these 1392 risks. 1394 To avoid receiving TLS packets that contain no useful data, a TLS 1395 implementation MUST reject empty TLS handshake records and any record 1396 that is not permitted by the TLS state machine. Any TLS application 1397 data or alerts that is received prior to the end of the handshake 1398 MUST be treated as a fatal error. 1400 9.2. Use of 0-RTT Keys 1402 If 0-RTT keys are available, the lack of replay protection means that 1403 restrictions on their use are necessary to avoid replay attacks on 1404 the protocol. 1406 A client MUST only use 0-RTT keys to protect data that is idempotent. 1407 A client MAY wish to apply additional restrictions on what data it 1408 sends prior to the completion of the TLS handshake. A client 1409 otherwise treats 0-RTT keys as equivalent to 1-RTT keys. 1411 A client that receives an indication that its 0-RTT data has been 1412 accepted by a server can send 0-RTT data until it receives all of the 1413 server's handshake messages. A client SHOULD stop sending 0-RTT data 1414 if it receives an indication that 0-RTT data has been rejected. 1416 A server MUST NOT use 0-RTT keys to protect packets. 1418 9.3. Receiving Out-of-Order Protected Frames 1420 Due to reordering and loss, protected packets might be received by an 1421 endpoint before the final TLS handshake messages are received. A 1422 client will be unable to decrypt 1-RTT packets from the server, 1423 whereas a server will be able to decrypt 1-RTT packets from the 1424 client. 1426 Packets protected with 1-RTT keys MAY be stored and later decrypted 1427 and used once the handshake is complete. A server MUST NOT use 1-RTT 1428 protected packets before verifying either the client Finished message 1429 or - in the case that the server has chosen to use a pre-shared key - 1430 the pre-shared key binder (see Section 4.2.8 of 1431 [I-D.ietf-tls-tls13]). Verifying these values provides the server 1432 with an assurance that the ClientHello has not been modified. 1434 A server could receive packets protected with 0-RTT keys prior to 1435 receiving a TLS ClientHello. The server MAY retain these packets for 1436 later decryption in anticipation of receiving a ClientHello. 1438 Receiving and verifying the TLS Finished message is critical in 1439 ensuring the integrity of the TLS handshake. A server MUST NOT use 1440 protected packets from the client prior to verifying the client 1441 Finished message if its response depends on client authentication. 1443 10. QUIC-Specific Additions to the TLS Handshake 1445 QUIC uses the TLS handshake for more than just negotiation of 1446 cryptographic parameters. The TLS handshake validates protocol 1447 version selection, provides preliminary values for QUIC transport 1448 parameters, and allows a server to perform return routeability checks 1449 on clients. 1451 10.1. Protocol and Version Negotiation 1453 The QUIC version negotiation mechanism is used to negotiate the 1454 version of QUIC that is used prior to the completion of the 1455 handshake. However, this packet is not authenticated, enabling an 1456 active attacker to force a version downgrade. 1458 To ensure that a QUIC version downgrade is not forced by an attacker, 1459 version information is copied into the TLS handshake, which provides 1460 integrity protection for the QUIC negotiation. This does not prevent 1461 version downgrade prior to the completion of the handshake, though it 1462 means that a downgrade causes a handshake failure. 1464 TLS uses Application Layer Protocol Negotiation (ALPN) [RFC7301] to 1465 select an application protocol. The application-layer protocol MAY 1466 restrict the QUIC versions that it can operate over. Servers MUST 1467 select an application protocol compatible with the QUIC version that 1468 the client has selected. 1470 If the server cannot select a compatible combination of application 1471 protocol and QUIC version, it MUST abort the connection. A client 1472 MUST abort a connection if the server picks an incompatible 1473 combination of QUIC version and ALPN identifier. 1475 10.2. QUIC Transport Parameters Extension 1477 QUIC transport parameters are carried in a TLS extension. Different 1478 versions of QUIC might define a different format for this struct. 1480 Including transport parameters in the TLS handshake provides 1481 integrity protection for these values. 1483 enum { 1484 quic_transport_parameters(26), (65535) 1485 } ExtensionType; 1487 The "extension_data" field of the quic_transport_parameters extension 1488 contains a value that is defined by the version of QUIC that is in 1489 use. The quic_transport_parameters extension carries a 1490 TransportParameters when the version of QUIC defined in 1491 [QUIC-TRANSPORT] is used. 1493 The quic_transport_parameters extension is carried in the ClientHello 1494 and the EncryptedExtensions messages during the handshake. The 1495 extension MAY be included in a NewSessionTicket message. 1497 10.3. Priming 0-RTT 1499 QUIC uses TLS without modification. Therefore, it is possible to use 1500 a pre-shared key that was established in a TLS handshake over TCP to 1501 enable 0-RTT in QUIC. Similarly, QUIC can provide a pre-shared key 1502 that can be used to enable 0-RTT in TCP. 1504 All the restrictions on the use of 0-RTT apply, with the exception of 1505 the ALPN label, which MUST only change to a label that is explicitly 1506 designated as being compatible. The client indicates which ALPN 1507 label it has chosen by placing that ALPN label first in the ALPN 1508 extension. 1510 The certificate that the server uses MUST be considered valid for 1511 both connections, which will use different protocol stacks and could 1512 use different port numbers. For instance, HTTP/1.1 and HTTP/2 1513 operate over TLS and TCP, whereas QUIC operates over UDP. 1515 Source address validation is not completely portable between 1516 different protocol stacks. Even if the source IP address remains 1517 constant, the port number is likely to be different. Packet 1518 reflection attacks are still possible in this situation, though the 1519 set of hosts that can initiate these attacks is greatly reduced. A 1520 server might choose to avoid source address validation for such a 1521 connection, or allow an increase to the amount of data that it sends 1522 toward the client without source validation. 1524 11. Security Considerations 1526 There are likely to be some real clangers here eventually, but the 1527 current set of issues is well captured in the relevant sections of 1528 the main text. 1530 Never assume that because it isn't in the security considerations 1531 section it doesn't affect security. Most of this document does. 1533 11.1. Packet Reflection Attack Mitigation 1535 A small ClientHello that results in a large block of handshake 1536 messages from a server can be used in packet reflection attacks to 1537 amplify the traffic generated by an attacker. 1539 Certificate caching [RFC7924] can reduce the size of the server's 1540 handshake messages significantly. 1542 QUIC requires that the packet containing a ClientHello be padded to a 1543 minimum size. A server is less likely to generate a packet 1544 reflection attack if the data it sends is a small multiple of this 1545 size. A server SHOULD use a HelloRetryRequest if the size of the 1546 handshake messages it sends is likely to significantly exceed the 1547 size of the packet containing the ClientHello. 1549 11.2. Peer Denial of Service 1551 QUIC, TLS and HTTP/2 all contain a messages that have legitimate uses 1552 in some contexts, but that can be abused to cause a peer to expend 1553 processing resources without having any observable impact on the 1554 state of the connection. If processing is disproportionately large 1555 in comparison to the observable effects on bandwidth or state, then 1556 this could allow a malicious peer to exhaust processing capacity 1557 without consequence. 1559 QUIC prohibits the sending of empty "STREAM" frames unless they are 1560 marked with the FIN bit. This prevents "STREAM" frames from being 1561 sent that only waste effort. 1563 TLS records SHOULD always contain at least one octet of a handshake 1564 messages or alert. Records containing only padding are permitted 1565 during the handshake, but an excessive number might be used to 1566 generate unnecessary work. Once the TLS handshake is complete, 1567 endpoints SHOULD NOT send TLS application data records unless it is 1568 to hide the length of QUIC records. QUIC packet protection does not 1569 include any allowance for padding; padded TLS application data 1570 records can be used to mask the length of QUIC frames. 1572 While there are legitimate uses for some redundant packets, 1573 implementations SHOULD track redundant packets and treat excessive 1574 volumes of any non-productive packets as indicative of an attack. 1576 12. Error codes 1578 The portion of the QUIC error code space allocated for the crypto 1579 handshake is 0xC0000000-0xFFFFFFFF. The following error codes are 1580 defined when TLS is used for the crypto handshake: 1582 TLS_HANDSHAKE_FAILED (0xC000001C): The TLS handshake failed. 1584 TLS_FATAL_ALERT_GENERATED (0xC000001D): A TLS fatal alert was sent, 1585 causing the TLS connection to end prematurely. 1587 TLS_FATAL_ALERT_RECEIVED (0xC000001E): A TLS fatal alert was 1588 received, causing the TLS connection to end prematurely. 1590 13. IANA Considerations 1592 This document does not create any new IANA registries, but it does 1593 utilize the following registries: 1595 o QUIC Transport Parameter Registry - IANA is to register the three 1596 values found in Section 12. 1598 o TLS ExtensionsType Registry - IANA is to register the 1599 quic_transport_parameters extension found in Section 10.2. 1600 Assigning 26 to the extension would be greatly appreciated. The 1601 Recommended column is to be marked Yes. 1603 o TLS Exporter Label Registry - IANA is requested to register 1604 "EXPORTER-QUIC 0-RTT Secret" from Section 5.2.1; "EXPORTER-QUIC 1605 client 1-RTT Secret" and "EXPORTER-QUIC server 1-RTT Secret" from 1606 Section 5.2.2; "EXPORTER-QUIC Packet Number Secret" Section 5.6. 1607 The DTLS column is to be marked No. The Recommended column is to 1608 be marked Yes. 1610 14. References 1612 14.1. Normative References 1614 [I-D.ietf-tls-tls13] 1615 Rescorla, E., "The Transport Layer Security (TLS) Protocol 1616 Version 1.3", draft-ietf-tls-tls13-21 (work in progress), 1617 July 2017. 1619 [QUIC-TRANSPORT] 1620 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1621 Multiplexed and Secure Transport", draft-ietf-quic- 1622 transport (work in progress), September 2017. 1624 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1625 Requirement Levels", BCP 14, RFC 2119, 1626 DOI 10.17487/RFC2119, March 1997, . 1629 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1630 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1631 . 1633 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1634 Key Derivation Function (HKDF)", RFC 5869, 1635 DOI 10.17487/RFC5869, May 2010, . 1638 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1639 "Transport Layer Security (TLS) Application-Layer Protocol 1640 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1641 July 2014, . 1643 14.2. Informative References 1645 [AEBounds] 1646 Luykx, A. and K. Paterson, "Limits on Authenticated 1647 Encryption Use in TLS", March 2016, 1648 . 1650 [FNV] Fowler, G., Noll, L., Vo, K., Eastlake, D., and T. Hansen, 1651 "The FNV Non-Cryptographic Hash Algorithm", draft- 1652 eastlake-fnv-13 (work in progress), June 2017. 1654 [QUIC-HTTP] 1655 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1656 QUIC", draft-ietf-quic-http (work in progress), September 1657 2017. 1659 [QUIC-RECOVERY] 1660 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1661 and Congestion Control", draft-ietf-quic-recovery (work in 1662 progress), September 2017. 1664 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1665 DOI 10.17487/RFC2818, May 2000, . 1668 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1669 Housley, R., and W. Polk, "Internet X.509 Public Key 1670 Infrastructure Certificate and Certificate Revocation List 1671 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1672 . 1674 [RFC7924] Santesson, S. and H. Tschofenig, "Transport Layer Security 1675 (TLS) Cached Information Extension", RFC 7924, 1676 DOI 10.17487/RFC7924, July 2016, . 1679 Appendix A. Contributors 1681 Ryan Hamilton was originally an author of this specification. 1683 Appendix B. Acknowledgments 1685 This document has benefited from input from Dragana Damjanovic, 1686 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1687 Rescorla, Ian Swett, and many others. 1689 Appendix C. Change Log 1691 *RFC Editor's Note:* Please remove this section prior to 1692 publication of a final version of this document. 1694 Issue and pull request numbers are listed with a leading octothorp. 1696 C.1. Since draft-ietf-quic-tls-05 1698 No significant changes. 1700 C.2. Since draft-ietf-quic-tls-04 1702 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 1704 C.3. Since draft-ietf-quic-tls-03 1706 No significant changes. 1708 C.4. Since draft-ietf-quic-tls-02 1710 o Updates to match changes in transport draft 1712 C.5. Since draft-ietf-quic-tls-01 1714 o Use TLS alerts to signal TLS errors (#272, #374) 1716 o Require ClientHello to fit in a single packet (#338) 1718 o The second client handshake flight is now sent in the clear (#262, 1719 #337) 1721 o The QUIC header is included as AEAD Associated Data (#226, #243, 1722 #302) 1724 o Add interface necessary for client address validation (#275) 1726 o Define peer authentication (#140) 1728 o Require at least TLS 1.3 (#138) 1730 o Define transport parameters as a TLS extension (#122) 1732 o Define handling for protected packets before the handshake 1733 completes (#39) 1735 o Decouple QUIC version and ALPN (#12) 1737 C.6. Since draft-ietf-quic-tls-00 1739 o Changed bit used to signal key phase 1741 o Updated key phase markings during the handshake 1743 o Added TLS interface requirements section 1745 o Moved to use of TLS exporters for key derivation 1747 o Moved TLS error code definitions into this document 1749 C.7. Since draft-thomson-quic-tls-01 1751 o Adopted as base for draft-ietf-quic-tls 1753 o Updated authors/editors list 1755 o Added status note 1757 Authors' Addresses 1759 Martin Thomson (editor) 1760 Mozilla 1762 Email: martin.thomson@gmail.com 1764 Sean Turner (editor) 1765 sn3rd 1767 Email: sean@sn3rd.com