idnits 2.17.1 draft-ietf-quic-tls-04.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 (June 13, 2017) is 2508 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 1644, but no explicit reference was found in the text == Outdated reference: A later version (-28) exists of draft-ietf-tls-tls13-20 ** 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: December 15, 2017 sn3rd 6 June 13, 2017 8 Using Transport Layer Security (TLS) to Secure QUIC 9 draft-ietf-quic-tls-04 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 December 15, 2017. 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 . . . . . . . . . . 24 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 . . . . . . . . . . 31 114 10.3. Priming 0-RTT . . . . . . . . . . . . . . . . . . . . . 32 115 11. Security Considerations . . . . . . . . . . . . . . . . . . . 32 116 11.1. Packet Reflection Attack Mitigation . . . . . . . . . . 33 117 11.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 33 118 12. Error codes . . . . . . . . . . . . . . . . . . . . . . . . . 33 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-02 . . . . . . . . . . . . . . 36 127 C.2. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 36 128 C.3. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 37 129 C.4. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 37 130 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 37 132 1. Introduction 134 This document describes how QUIC [QUIC-TRANSPORT] is secured using 135 Transport Layer Security (TLS) version 1.3 [I-D.ietf-tls-tls13]. TLS 136 1.3 provides critical latency improvements for connection 137 establishment over previous versions. Absent packet loss, most new 138 connections can be established and secured within a single round 139 trip; on subsequent connections between the same client and server, 140 the client can often send application data immediately, that is, 141 using a zero round trip setup. 143 This document describes how the standardized TLS 1.3 acts a security 144 component of QUIC. The same design could work for TLS 1.2, though 145 few of the benefits QUIC provides would be realized due to the 146 handshake latency in versions of TLS prior to 1.3. 148 2. Notational Conventions 150 The words "MUST", "MUST NOT", "SHOULD", and "MAY" are used in this 151 document. It's not shouting; when they are capitalized, they have 152 the special meaning defined in [RFC2119]. 154 This document uses the terminology established in [QUIC-TRANSPORT]. 156 For brevity, the acronym TLS is used to refer to TLS 1.3. 158 TLS terminology is used when referring to parts of TLS. Though TLS 159 assumes a continuous stream of octets, it divides that stream into 160 _records_. Most relevant to QUIC are the records that contain TLS 161 _handshake messages_, which are discrete messages that are used for 162 key agreement, authentication and parameter negotiation. Ordinarily, 163 TLS records can also contain _application data_, though in the QUIC 164 usage there is no use of TLS application data. 166 3. Protocol Overview 168 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 169 and integrity protection of packets. For this it uses keys derived 170 from a TLS 1.3 connection [I-D.ietf-tls-tls13]; QUIC also relies on 171 TLS 1.3 for authentication and negotiation of parameters that are 172 critical to security and performance. 174 Rather than a strict layering, these two protocols are co-dependent: 175 QUIC uses the TLS handshake; TLS uses the reliability and ordered 176 delivery provided by QUIC streams. 178 This document defines how QUIC interacts with TLS. This includes a 179 description of how TLS is used, how keying material is derived from 180 TLS, and the application of that keying material to protect QUIC 181 packets. Figure 1 shows the basic interactions between TLS and QUIC, 182 with the QUIC packet protection being called out specially. 184 +------------+ +------------+ 185 | |------ Handshake ------>| | 186 | |<-- Validate Address ---| | 187 | |-- OK/Error/Validate -->| | 188 | |<----- Handshake -------| | 189 | QUIC |------ Validate ------->| TLS | 190 | | | | 191 | |<------ 0-RTT OK -------| | 192 | |<------ 1-RTT OK -------| | 193 | |<--- Handshake Done ----| | 194 +------------+ +------------+ 195 | ^ ^ | 196 | Protect | Protected | | 197 v | Packet | | 198 +------------+ / / 199 | QUIC | / / 200 | Packet |-------- Get Secret -------' / 201 | Protection |<-------- Secret -----------' 202 +------------+ 204 Figure 1: QUIC and TLS Interactions 206 The initial state of a QUIC connection has packets exchanged without 207 any form of protection. In this state, QUIC is limited to using 208 stream 0 and associated packets. Stream 0 is reserved for a TLS 209 connection. This is a complete TLS connection as it would appear 210 when layered over TCP; the only difference is that QUIC provides the 211 reliability and ordering that would otherwise be provided by TCP. 213 At certain points during the TLS handshake, keying material is 214 exported from the TLS connection for use by QUIC. This keying 215 material is used to derive packet protection keys. Details on how 216 and when keys are derived and used are included in Section 5. 218 3.1. TLS Overview 220 TLS provides two endpoints with a way to establish a means of 221 communication over an untrusted medium (that is, the Internet) that 222 ensures that messages they exchange cannot be observed, modified, or 223 forged. 225 TLS features can be separated into two basic functions: an 226 authenticated key exchange and record protection. QUIC primarily 227 uses the authenticated key exchange provided by TLS but provides its 228 own packet protection. 230 The TLS authenticated key exchange occurs between two entities: 231 client and server. The client initiates the exchange and the server 232 responds. If the key exchange completes successfully, both client 233 and server will agree on a secret. TLS supports both pre-shared key 234 (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for 235 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 236 keys are destroyed. 238 After completing the TLS handshake, the client will have learned and 239 authenticated an identity for the server and the server is optionally 240 able to learn and authenticate an identity for the client. TLS 241 supports X.509 [RFC5280] certificate-based authentication for both 242 server and client. 244 The TLS key exchange is resistent to tampering by attackers and it 245 produces shared secrets that cannot be controlled by either 246 participating peer. 248 3.2. TLS Handshake 250 TLS 1.3 provides two basic handshake modes of interest to QUIC: 252 o A full 1-RTT handshake in which the client is able to send 253 application data after one round trip and the server immediately 254 after receiving the first handshake message from the client. 256 o A 0-RTT handshake in which the client uses information it has 257 previously learned about the server to send application data 258 immediately. This application data can be replayed by an attacker 259 so it MUST NOT carry a self-contained trigger for any non- 260 idempotent action. 262 A simplified TLS 1.3 handshake with 0-RTT application data is shown 263 in Figure 2, see [I-D.ietf-tls-tls13] for more options and details. 265 Client Server 267 ClientHello 268 (0-RTT Application Data) --------> 269 ServerHello 270 {EncryptedExtensions} 271 {Finished} 272 <-------- [Application Data] 273 (EndOfEarlyData) 274 {Finished} --------> 276 [Application Data] <-------> [Application Data] 278 Figure 2: TLS Handshake with 0-RTT 280 This 0-RTT handshake is only possible if the client and server have 281 previously communicated. In the 1-RTT handshake, the client is 282 unable to send protected application data until it has received all 283 of the handshake messages sent by the server. 285 Two additional variations on this basic handshake exchange are 286 relevant to this document: 288 o The server can respond to a ClientHello with a HelloRetryRequest, 289 which adds an additional round trip prior to the basic exchange. 290 This is needed if the server wishes to request a different key 291 exchange key from the client. HelloRetryRequest is also used to 292 verify that the client is correctly able to receive packets on the 293 address it claims to have (see [QUIC-TRANSPORT]). 295 o A pre-shared key mode can be used for subsequent handshakes to 296 reduce the number of public key operations. This is the basis for 297 0-RTT data, even if the remainder of the connection is protected 298 by a new Diffie-Hellman exchange. 300 4. TLS Usage 302 QUIC reserves stream 0 for a TLS connection. Stream 0 contains a 303 complete TLS connection, which includes the TLS record layer. Other 304 than the definition of a QUIC-specific extension (see Section 10.2), 305 TLS is unmodified for this use. This means that TLS will apply 306 confidentiality and integrity protection to its records. In 307 particular, TLS record protection is what provides confidentiality 308 protection for the TLS handshake messages sent by the server. 310 QUIC permits a client to send frames on streams starting from the 311 first packet. The initial packet from a client contains a stream 312 frame for stream 0 that contains the first TLS handshake messages 313 from the client. This allows the TLS handshake to start with the 314 first packet that a client sends. 316 QUIC packets are protected using a scheme that is specific to QUIC, 317 see Section 5. Keys are exported from the TLS connection when they 318 become available using a TLS exporter (see Section 7.5 of 319 [I-D.ietf-tls-tls13] and Section 5.2). After keys are exported from 320 TLS, QUIC manages its own key schedule. 322 4.1. Handshake and Setup Sequence 324 The integration of QUIC with a TLS handshake is shown in more detail 325 in Figure 3. QUIC "STREAM" frames on stream 0 carry the TLS 326 handshake. QUIC performs loss recovery [QUIC-RECOVERY] for this 327 stream and ensures that TLS handshake messages are delivered in the 328 correct order. 330 Client Server 332 @C QUIC STREAM Frame(s) <0>: 333 ClientHello 334 + QUIC Extension 335 --------> 336 0-RTT Key => @0 338 @0 QUIC STREAM Frame(s) : 339 Replayable QUIC Frames 340 --------> 342 QUIC STREAM Frame <0>: @C 343 ServerHello 344 {TLS Handshake Messages} 345 <-------- 346 1-RTT Key => @1 348 QUIC Frames @1 349 <-------- 350 @C QUIC STREAM Frame(s) <0>: 351 (EndOfEarlyData) 352 {Finished} 353 --------> 355 @1 QUIC Frames <-------> QUIC Frames @1 357 Figure 3: QUIC over TLS Handshake 359 In Figure 3, symbols mean: 361 o "<" and ">" enclose stream numbers. 363 o "@" indicates the keys that are used for protecting the QUIC 364 packet (C = cleartext, with integrity only; 0 = 0-RTT keys; 1 = 365 1-RTT keys). 367 o "(" and ")" enclose messages that are protected with TLS 0-RTT 368 handshake or application keys. 370 o "{" and "}" enclose messages that are protected by the TLS 371 Handshake keys. 373 If 0-RTT is not attempted, then the client does not send packets 374 protected by the 0-RTT key (@0). In that case, the only key 375 transition on the client is from cleartext packets (@C) to 1-RTT 376 protection (@1), which happens after it sends its final set of TLS 377 handshake messages. 379 Note: the client uses two different types of cleartext packet during 380 the handshake. The Client Initial packet carries a TLS ClientHello 381 message; the remainder of the TLS handshake is carried in Client 382 Cleartext packets. 384 The server sends TLS handshake messages without protection (@C). The 385 server transitions from no protection (@C) to full 1-RTT protection 386 (@1) after it sends the last of its handshake messages. 388 Some TLS handshake messages are protected by the TLS handshake record 389 protection. These keys are not exported from the TLS connection for 390 use in QUIC. QUIC packets from the server are sent in the clear 391 until the final transition to 1-RTT keys. 393 The client transitions from cleartext (@C) to 0-RTT keys (@0) when 394 sending 0-RTT data, and subsequently to to 1-RTT keys (@1) after its 395 second flight of TLS handshake messages. This creates the potential 396 for unprotected packets to be received by a server in close proximity 397 to packets that are protected with 1-RTT keys. 399 More information on key transitions is included in Section 7.1. 401 4.2. Interface to TLS 403 As shown in Figure 1, the interface from QUIC to TLS consists of four 404 primary functions: Handshake, Source Address Validation, Key Ready 405 Events, and Secret Export. 407 Additional functions might be needed to configure TLS. 409 4.2.1. Handshake Interface 411 In order to drive the handshake, TLS depends on being able to send 412 and receive handshake messages on stream 0. There are two basic 413 functions on this interface: one where QUIC requests handshake 414 messages and one where QUIC provides handshake packets. 416 Before starting the handshake QUIC provides TLS with the transport 417 parameters (see Section 10.2) that it wishes to carry. 419 A QUIC client starts TLS by requesting TLS handshake octets from TLS. 420 The client acquires handshake octets before sending its first packet. 422 A QUIC server starts the process by providing TLS with stream 0 423 octets. 425 Each time that an endpoint receives data on stream 0, it delivers the 426 octets to TLS if it is able. Each time that TLS is provided with new 427 data, new handshake octets are requested from TLS. TLS might not 428 provide any octets if the handshake messages it has received are 429 incomplete or it has no data to send. 431 Once the TLS handshake is complete, this is indicated to QUIC along 432 with any final handshake octets that TLS needs to send. TLS also 433 provides QUIC with the transport parameters that the peer advertised 434 during the handshake. 436 Once the handshake is complete, TLS becomes passive. TLS can still 437 receive data from its peer and respond in kind, but it will not need 438 to send more data unless specifically requested - either by an 439 application or QUIC. One reason to send data is that the server 440 might wish to provide additional or updated session tickets to a 441 client. 443 When the handshake is complete, QUIC only needs to provide TLS with 444 any data that arrives on stream 0. In the same way that is done 445 during the handshake, new data is requested from TLS after providing 446 received data. 448 Important: Until the handshake is reported as complete, the 449 connection and key exchange are not properly authenticated at the 450 server. Even though 1-RTT keys are available to a server after 451 receiving the first handshake messages from a client, the server 452 cannot consider the client to be authenticated until it receives 453 and validates the client's Finished message. 455 The requirement for the server to wait for the client Finished 456 message creates a dependency on that message being delivered. A 457 client can avoid the potential for head-of-line blocking that this 458 implies by sending a copy of the STREAM frame that carries the 459 Finished message in multiple packets. This enables immediate 460 server processing for those packets. 462 4.2.2. Source Address Validation 464 During the processing of the TLS ClientHello, TLS requests that the 465 transport make a decision about whether to request source address 466 validation from the client. 468 An initial TLS ClientHello that resumes a session includes an address 469 validation token in the session ticket; this includes all attempts at 470 0-RTT. If the client does not attempt session resumption, no token 471 will be present. While processing the initial ClientHello, TLS 472 provides QUIC with any token that is present. In response, QUIC 473 provides one of three responses: 475 o proceed with the connection, 477 o ask for client address validation, or 479 o abort the connection. 481 If QUIC requests source address validation, it also provides a new 482 address validation token. TLS includes that along with any 483 information it requires in the cookie extension of a TLS 484 HelloRetryRequest message. In the other cases, the connection either 485 proceeds or terminates with a handshake error. 487 The client echoes the cookie extension in a second ClientHello. A 488 ClientHello that contains a valid cookie extension will always be in 489 response to a HelloRetryRequest. If address validation was requested 490 by QUIC, then this will include an address validation token. TLS 491 makes a second address validation request of QUIC, including the 492 value extracted from the cookie extension. In response to this 493 request, QUIC cannot ask for client address validation, it can only 494 abort or permit the connection attempt to proceed. 496 QUIC can provide a new address validation token for use in session 497 resumption at any time after the handshake is complete. Each time a 498 new token is provided TLS generates a NewSessionTicket message, with 499 the token included in the ticket. 501 See Section 8 for more details on client address validation. 503 4.2.3. Key Ready Events 505 TLS provides QUIC with signals when 0-RTT and 1-RTT keys are ready 506 for use. These events are not asynchronous, they always occur 507 immediately after TLS is provided with new handshake octets, or after 508 TLS produces handshake octets. 510 When TLS completed its handshake, 1-RTT keys can be provided to QUIC. 511 On both client and server, this occurs after sending the TLS Finished 512 message. 514 This ordering means that there could be frames that carry TLS 515 handshake messages ready to send at the same time that application 516 data is available. An implementation MUST ensure that TLS handshake 517 messages are always sent in cleartext packets. Separate packets are 518 required for data that needs protection from 1-RTT keys. 520 If 0-RTT is possible, it is ready after the client sends a TLS 521 ClientHello message or the server receives that message. After 522 providing a QUIC client with the first handshake octets, the TLS 523 stack might signal that 0-RTT keys are ready. On the server, after 524 receiving handshake octets that contain a ClientHello message, a TLS 525 server might signal that 0-RTT keys are available. 527 1-RTT keys are used for packets in both directions. 0-RTT keys are 528 only used to protect packets sent by the client. 530 4.2.4. Secret Export 532 Details how secrets are exported from TLS are included in 533 Section 5.2. 535 4.2.5. TLS Interface Summary 537 Figure 4 summarizes the exchange between QUIC and TLS for both client 538 and server. 540 Client Server 542 Get Handshake 543 0-RTT Key Ready 544 --- send/receive ---> 545 Handshake Received 546 0-RTT Key Ready 547 Get Handshake 548 1-RTT Keys Ready 549 <--- send/receive --- 550 Handshake Received 551 Get Handshake 552 Handshake Complete 553 1-RTT Keys Ready 554 --- send/receive ---> 555 Handshake Received 556 Get Handshake 557 Handshake Complete 558 <--- send/receive --- 559 Handshake Received 560 Get Handshake 562 Figure 4: Interaction Summary between QUIC and TLS 564 4.3. TLS Version 566 This document describes how TLS 1.3 [I-D.ietf-tls-tls13] is used with 567 QUIC. 569 In practice, the TLS handshake will negotiate a version of TLS to 570 use. This could result in a newer version of TLS than 1.3 being 571 negotiated if both endpoints support that version. This is 572 acceptable provided that the features of TLS 1.3 that are used by 573 QUIC are supported by the newer version. 575 A badly configured TLS implementation could negotiate TLS 1.2 or 576 another older version of TLS. An endpoint MUST terminate the 577 connection if a version of TLS older than 1.3 is negotiated. 579 4.4. ClientHello Size 581 QUIC requires that the initial handshake packet from a client fit 582 within the payload of a single packet. The size limits on QUIC 583 packets mean that a record containing a ClientHello needs to fit 584 within 1197 octets. 586 A TLS ClientHello can fit within this limit with ample space 587 remaining. However, there are several variables that could cause 588 this limit to be exceeded. Implementations are reminded that large 589 session tickets or HelloRetryRequest cookies, multiple or large key 590 shares, and long lists of supported ciphers, signature algorithms, 591 versions, QUIC transport parameters, and other negotiable parameters 592 and extensions could cause this message to grow. 594 For servers, the size of the session tickets and HelloRetryRequest 595 cookie extension can have an effect on a client's ability to connect. 596 Choosing a small value increases the probability that these values 597 can be successfully used by a client. 599 The TLS implementation does not need to ensure that the ClientHello 600 is sufficiently large. QUIC PADDING frames are added to increase the 601 size of the packet as necessary. 603 4.5. Peer Authentication 605 The requirements for authentication depend on the application 606 protocol that is in use. TLS provides server authentication and 607 permits the server to request client authentication. 609 A client MUST authenticate the identity of the server. This 610 typically involves verification that the identity of the server is 611 included in a certificate and that the certificate is issued by a 612 trusted entity (see for example [RFC2818]). 614 A server MAY request that the client authenticate during the 615 handshake. A server MAY refuse a connection if the client is unable 616 to authenticate when requested. The requirements for client 617 authentication vary based on application protocol and deployment. 619 A server MUST NOT use post-handshake client authentication (see 620 Section 4.6.2 of [I-D.ietf-tls-tls13]). 622 4.6. TLS Errors 624 Errors in the TLS connection SHOULD be signaled using TLS alerts on 625 stream 0. A failure in the handshake MUST be treated as a QUIC 626 connection error of type TLS_HANDSHAKE_FAILED. Once the handshake is 627 complete, an error in the TLS connection that causes a TLS alert to 628 be sent or received MUST be treated as a QUIC connection error of 629 type TLS_FATAL_ALERT_GENERATED or TLS_FATAL_ALERT_RECEIVED 630 respectively. 632 5. QUIC Packet Protection 634 QUIC packet protection provides authenticated encryption of packets. 635 This provides confidentiality and integrity protection for the 636 content of packets (see Section 5.3). Packet protection uses keys 637 that are exported from the TLS connection (see Section 5.2). 639 Different keys are used for QUIC packet protection and TLS record 640 protection. TLS handshake messages are protected solely with TLS 641 record protection, but post-handshake messages are redundantly 642 proteted with both both the QUIC packet protection and the TLS record 643 protection. These messages are limited in number, and so the 644 additional overhead is small. 646 5.1. Installing New Keys 648 As TLS reports the availability of keying material, the packet 649 protection keys and initialization vectors (IVs) are updated (see 650 Section 5.2). The selection of AEAD function is also updated to 651 match the AEAD negotiated by TLS. 653 For packets other than any unprotected handshake packets (see 654 Section 7.1), once a change of keys has been made, packets with 655 higher packet numbers MUST be sent with the new keying material. The 656 KEY_PHASE bit on these packets is inverted each time new keys are 657 installed to signal the use of the new keys to the recipient (see 658 Section 7 for details). 660 An endpoint retransmits stream data in a new packet. New packets 661 have new packet numbers and use the latest packet protection keys. 662 This simplifies key management when there are key updates (see 663 Section 7.2). 665 5.2. QUIC Key Expansion 667 QUIC uses a system of packet protection secrets, keys and IVs that 668 are modelled on the system used in TLS [I-D.ietf-tls-tls13]. The 669 secrets that QUIC uses as the basis of its key schedule are obtained 670 using TLS exporters (see Section 7.5 of [I-D.ietf-tls-tls13]). 672 QUIC uses HKDF with the same hash function negotiated by TLS for key 673 derivation. For example, if TLS is using the TLS_AES_128_GCM_SHA256, 674 the SHA-256 hash function is used. 676 5.2.1. 0-RTT Secret 678 0-RTT keys are those keys that are used in resumed connections prior 679 to the completion of the TLS handshake. Data sent using 0-RTT keys 680 might be replayed and so has some restrictions on its use, see 681 Section 9.2. 0-RTT keys are used after sending or receiving a 682 ClientHello. 684 The secret is exported from TLS using the exporter label "EXPORTER- 685 QUIC 0-RTT Secret" and an empty context. The size of the secret MUST 686 be the size of the hash output for the PRF hash function negotiated 687 by TLS. This uses the TLS early_exporter_secret. The QUIC 0-RTT 688 secret is only used for protection of packets sent by the client. 690 client_0rtt_secret 691 = TLS-Exporter("EXPORTER-QUIC 0-RTT Secret" 692 "", Hash.length) 694 5.2.2. 1-RTT Secrets 696 1-RTT keys are used by both client and server after the TLS handshake 697 completes. There are two secrets used at any time: one is used to 698 derive packet protection keys for packets sent by the client, the 699 other for packet protection keys on packets sent by the server. 701 The initial client packet protection secret is exported from TLS 702 using the exporter label "EXPORTER-QUIC client 1-RTT Secret"; the 703 initial server packet protection secret uses the exporter label 704 "EXPORTER-QUIC server 1-RTT Secret". Both exporters use an empty 705 context. The size of the secret MUST be the size of the hash output 706 for the PRF hash function negotiated by TLS. 708 client_pp_secret_0 709 = TLS-Exporter("EXPORTER-QUIC client 1-RTT Secret" 710 "", Hash.length) 711 server_pp_secret_0 712 = TLS-Exporter("EXPORTER-QUIC server 1-RTT Secret" 713 "", Hash.length) 715 These secrets are used to derive the initial client and server packet 716 protection keys. 718 After a key update (see Section 7.2), these secrets are updated using 719 the HKDF-Expand-Label function defined in Section 7.1 of 720 [I-D.ietf-tls-tls13]. HKDF-Expand-Label uses the PRF hash function 721 negotiated by TLS. The replacement secret is derived using the 722 existing Secret, a Label of "QUIC client 1-RTT Secret" for the client 723 and "QUIC server 1-RTT Secret" for the server, an empty HashValue, 724 and the same output Length as the hash function selected by TLS for 725 its PRF. 727 client_pp_secret_ 728 = HKDF-Expand-Label(client_pp_secret_, 729 "QUIC client 1-RTT Secret", 730 "", Hash.length) 731 server_pp_secret_ 732 = HKDF-Expand-Label(server_pp_secret_, 733 "QUIC server 1-RTT Secret", 734 "", Hash.length) 736 This allows for a succession of new secrets to be created as needed. 738 HKDF-Expand-Label uses HKDF-Expand [RFC5869] with a specially 739 formatted info parameter, as shown: 741 HKDF-Expand-Label(Secret, Label, HashValue, Length) = 742 HKDF-Expand(Secret, HkdfLabel, Length) 744 Where HkdfLabel is specified as: 746 struct { 747 uint16 length = Length; 748 opaque label<10..255> = "TLS 1.3, " + Label; 749 uint8 hashLength; // Always 0 750 } HkdfLabel; 752 For example, the client packet protection secret uses an info 753 parameter of: 755 info = (HashLen / 256) || (HashLen % 256) || 0x21 || 756 "TLS 1.3, QUIC client 1-RTT secret" || 0x00 758 5.2.3. Packet Protection Key and IV 760 The complete key expansion uses an identical process for key 761 expansion as defined in Section 7.3 of [I-D.ietf-tls-tls13], using 762 different values for the input secret. QUIC uses the AEAD function 763 negotiated by TLS. 765 The packet protection key and IV used to protect the 0-RTT packets 766 sent by a client are derived from the QUIC 0-RTT secret. The packet 767 protection keys and IVs for 1-RTT packets sent by the client and 768 server are derived from the current generation of client_pp_secret 769 and server_pp_secret respectively. The length of the output is 770 determined by the requirements of the AEAD function selected by TLS. 771 The key length is the AEAD key size. As defined in Section 5.3 of 772 [I-D.ietf-tls-tls13], the IV length is the larger of 8 or N_MIN (see 773 Section 4 of [RFC5116]). For any secret S, the corresponding key and 774 IV are derived as shown below: 776 key = HKDF-Expand-Label(S, "key", "", key_length) 777 iv = HKDF-Expand-Label(S, "iv", "", iv_length) 779 The QUIC record protection initially starts without keying material. 780 When the TLS state machine reports that the ClientHello has been 781 sent, the 0-RTT keys can be generated and installed for writing. 782 When the TLS state machine reports completion of the handshake, the 783 1-RTT keys can be generated and installed for writing. 785 5.3. QUIC AEAD Usage 787 The Authentication Encryption with Associated Data (AEAD) [RFC5116] 788 function used for QUIC packet protection is AEAD that is negotiated 789 for use with the TLS connection. For example, if TLS is using the 790 TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is used. 792 Regular QUIC packets are protected by an AEAD algorithm [RFC5116]. 793 Version negotiation and public reset packets are not protected. 795 Once TLS has provided a key, the contents of regular QUIC packets 796 immediately after any TLS messages have been sent are protected by 797 the AEAD selected by TLS. 799 The key, K, is either the client packet protection key 800 (client_pp_key_n) or the server packet protection key 801 (server_pp_key_n), derived as defined in Section 5.2. 803 The nonce, N, is formed by combining the packet protection IV (either 804 client_pp_iv_n or server_pp_iv_n) with the packet number. The 64 805 bits of the reconstructed QUIC packet number in network byte order is 806 left-padded with zeros to the size of the IV. The exclusive OR of 807 the padded packet number and the IV forms the AEAD nonce. 809 The associated data, A, for the AEAD is the contents of the QUIC 810 header, starting from the flags octet in the common header. 812 The input plaintext, P, for the AEAD is the contents of the QUIC 813 frame following the packet number, as described in [QUIC-TRANSPORT]. 815 The output ciphertext, C, of the AEAD is transmitted in place of P. 817 Prior to TLS providing keys, no record protection is performed and 818 the plaintext, P, is transmitted unmodified. 820 5.4. Packet Numbers 822 QUIC has a single, contiguous packet number space. In comparison, 823 TLS restarts its sequence number each time that record protection 824 keys are changed. The sequence number restart in TLS ensures that a 825 compromise of the current traffic keys does not allow an attacker to 826 truncate the data that is sent after a key update by sending 827 additional packets under the old key (causing new packets to be 828 discarded). 830 QUIC does not assume a reliable transport and is required to handle 831 attacks where packets are dropped in other ways. QUIC is therefore 832 not affected by this form of truncation. 834 The QUIC packet number is not reset and it is not permitted to go 835 higher than its maximum value of 2^64-1. This establishes a hard 836 limit on the number of packets that can be sent. 838 Some AEAD functions have limits for how many packets can be encrypted 839 under the same key and IV (see for example [AEBounds]). This might 840 be lower than the packet number limit. An endpoint MUST initiate a 841 key update (Section 7.2) prior to exceeding any limit set for the 842 AEAD that is in use. 844 TLS maintains a separate sequence number that is used for record 845 protection on the connection that is hosted on stream 0. This 846 sequence number is not visible to QUIC. 848 5.5. Receiving Protected Packets 850 Once an endpoint successfully receives a packet with a given packet 851 number, it MUST discard all packets with higher packet numbers if 852 they cannot be successfully unprotected with either the same key, or 853 - if there is a key update - the next packet protection key (see 854 Section 7.2). Similarly, a packet that appears to trigger a key 855 update, but cannot be unprotected successfully MUST be discarded. 857 Failure to unprotect a packet does not necessarily indicate the 858 existence of a protocol error in a peer or an attack. The truncated 859 packet number encoding used in QUIC can cause packet numbers to be 860 decoded incorrectly if they are delayed significantly. 862 5.6. Packet Number Gaps 864 [QUIC-TRANSPORT]; Section 7.5.1.1 also requires a secret to compute 865 packet number gaps on connection ID transitions. That secret is 866 computed as: 868 packet_number_secret 869 = TLS-Exporter("EXPORTER-QUIC Packet Number Secret" 870 "", Hash.length) 872 6. Unprotected Packets 874 QUIC adds an integrity check to all unprotected packets. Any packet 875 that is not protected by the negotiated AEAD (see Section 5), 876 includes an integrity check. This check does not prevent the packet 877 from being altered, it exists for added resilience against data 878 corruption and to provided added assurance that the sender intends to 879 use QUIC. 881 Unprotected packets all use the long form of the QUIC header and so 882 will include a version number. For this version of QUIC, the 883 integrity check uses the 64-bit FNV-1a hash (see Section 6.2). The 884 output of this hash is appended to the payload of the packet. 886 The integrity check algorithm MAY change for other versions of the 887 protocol. 889 6.1. Integrity Check Processing 891 An endpoint sending a packet that has a long header and a type that 892 does not indicate that the packet will be protected (that is, 0-RTT 893 Encrypted (0x05), 1-RTT Encrypted (key phase 0) (0x06), or 1-RTT 894 Encrypted (key phase 1) (0x07)) first constructs the packet that it 895 sends without the integrity check. 897 The sender then calculates the integrity check over the entire 898 packet, starting from the type field. The output of the hash is 899 appended to the packet. 901 A receiver that receives an unprotected packet first checks that the 902 version is correct, then removes the trailing 8 octets. It 903 calculates the integrity check over the remainder of the packet. 904 Unprotected packets that do not contain a valid integrity check MUST 905 be discarded. 907 6.2. The 64-bit FNV-1a Algorithm 909 QUIC uses the 64-bit version of the alternative Fowler/Noll/Vo hash 910 (FNV-1a) [FNV]. 912 FNV-1a can be expressed in pseudocode as: 914 "hash := offset basis for each input octet: hash := hash XOR input 915 octet hash := hash * prime " 917 That is, a 64-bit unsigned integer is initialized with an offset 918 basis. Then, for each octet of the input, the exclusive binary OR of 919 the value is taken, then multiplied by a prime. Any overflow from 920 multiplication is discarded. 922 The offset basis for the 64-bit FNV-1a is the decimal value 923 14695981039346656037 (in hex, 0xcbf29ce484222325). The prime is 924 1099511628211 (in hex, 0x100000001b3; or as an expression 2^40 + 2^8 925 + 0xb3). 927 Once all octets have been processed in this fashion, the final 928 integer value is encoded as 8 octets in network byte order. 930 7. Key Phases 932 As TLS reports the availability of 0-RTT and 1-RTT keys, new keying 933 material can be exported from TLS and used for QUIC packet 934 protection. At each transition during the handshake a new secret is 935 exported from TLS and packet protection keys are derived from that 936 secret. 938 Every time that a new set of keys is used for protecting outbound 939 packets, the KEY_PHASE bit in the public flags is toggled. 0-RTT 940 protected packets use the QUIC long header, they do not use the 941 KEY_PHASE bit to select the correct keys (see Section 7.1.1). 943 Once the connection is fully enabled, the KEY_PHASE bit allows a 944 recipient to detect a change in keying material without necessarily 945 needing to receive the first packet that triggered the change. An 946 endpoint that notices a changed KEY_PHASE bit can update keys and 947 decrypt the packet that contains the changed bit, see Section 7.2. 949 The KEY_PHASE bit is included as the 0x20 bit of the QUIC short 950 header, or is determined by the packet type from the long header (a 951 type of 0x06 indicates a key phase of 0, 0x07 indicates key phase 1). 953 Transitions between keys during the handshake are complicated by the 954 need to ensure that TLS handshake messages are sent with the correct 955 packet protection. 957 7.1. Packet Protection for the TLS Handshake 959 The initial exchange of packets are sent without protection. These 960 packets use a cleartext packet type. 962 TLS handshake messages MUST NOT be protected using QUIC packet 963 protection. All TLS handshake messages up to the TLS Finished 964 message sent by either endpoint use cleartext packets. 966 Any TLS handshake messages that are sent after completing the TLS 967 handshake do not need special packet protection rules. Packets 968 containing these messages use the packet protection keys that are 969 current at the time of sending (or retransmission). 971 Like the client, a server MUST send retransmissions of its 972 unprotected handshake messages or acknowledgments for unprotected 973 handshake messages sent by the client in cleartext packets. 975 7.1.1. Initial Key Transitions 977 Once the TLS handshake is complete, keying material is exported from 978 TLS and QUIC packet protection commences. 980 Packets protected with 1-RTT keys initially have a KEY_PHASE bit set 981 to 0. This bit inverts with each subsequent key update (see 982 Section 7.2). 984 If the client sends 0-RTT data, it uses the 0-RTT packet type. The 985 packet that contains the TLS EndOfEarlyData and Finished messages are 986 sent in cleartext packets. 988 Using distinct packet types during the handshake for handshake 989 messages, 0-RTT data, and 1-RTT data ensures that the server is able 990 to distinguish between the different keys used to remove packet 991 protection. All of these packets can arrive concurrently at a 992 server. 994 A server might choose to retain 0-RTT packets that arrive before a 995 TLS ClientHello. The server can then use those packets once the 996 ClientHello arrives. However, the potential for denial of service 997 from buffering 0-RTT packets is significant. These packets cannot be 998 authenticated and so might be employed by an attacker to exhaust 999 server resources. Limiting the number of packets that are saved 1000 might be necessary. 1002 The server transitions to using 1-RTT keys after sending its first 1003 flight of TLS handshake messages. From this point, the server 1004 protects all packets with 1-RTT keys. Future packets are therefore 1005 protected with 1-RTT keys. Initially, these are marked with a 1006 KEY_PHASE of 0. 1008 7.1.2. Retransmission and Acknowledgment of Unprotected Packets 1010 TLS handshake messages from both client and server are critical to 1011 the key exchange. The contents of these messages determines the keys 1012 used to protect later messages. If these handshake messages are 1013 included in packets that are protected with these keys, they will be 1014 indecipherable to the recipient. 1016 Even though newer keys could be available when retransmitting, 1017 retransmissions of these handshake messages MUST be sent in cleartext 1018 packets. An endpoint MUST generate ACK frames for these messages and 1019 send them in cleartext packets. 1021 A HelloRetryRequest handshake message might be used to reject an 1022 initial ClientHello. A HelloRetryRequest handshake message is sent 1023 in a Server Stateless Retry packet; any second ClientHello that is 1024 sent in response uses a Client Initial packet type. Neither packet 1025 is protected. This is natural, because no new keying material will 1026 be available when these messages need to be sent. Upon receipt of a 1027 HelloRetryRequest, a client SHOULD cease any transmission of 0-RTT 1028 data; 0-RTT data will only be discarded by any server that sends a 1029 HelloRetryRequest. 1031 The packet type ensures that protected packets are clearly 1032 distinguished from unprotected packets. Loss or reordering might 1033 cause unprotected packets to arrive once 1-RTT keys are in use, 1034 unprotected packets are easily distinguished from 1-RTT packets using 1035 the packet type. 1037 Once 1-RTT keys are available to an endpoint, it no longer needs the 1038 TLS handshake messages that are carried in unprotected packets. 1039 However, a server might need to retransmit its TLS handshake messages 1040 in response to receiving an unprotected packet that contains ACK 1041 frames. A server MUST process ACK frames in unprotected packets 1042 until the TLS handshake is reported as complete, or it receives an 1043 ACK frame in a protected packet that acknowledges all of its 1044 handshake messages. 1046 To limit the number of key phases that could be active, an endpoint 1047 MUST NOT initiate a key update while there are any unacknowledged 1048 handshake messages, see Section 7.2. 1050 7.2. Key Update 1052 Once the TLS handshake is complete, the KEY_PHASE bit allows for 1053 refreshes of keying material by either peer. Endpoints start using 1054 updated keys immediately without additional signaling; the change in 1055 the KEY_PHASE bit indicates that a new key is in use. 1057 An endpoint MUST NOT initiate more than one key update at a time. A 1058 new key cannot be used until the endpoint has received and 1059 successfully decrypted a packet with a matching KEY_PHASE. Note that 1060 when 0-RTT is attempted the value of the KEY_PHASE bit will be 1061 different on packets sent by either peer. 1063 A receiving endpoint detects an update when the KEY_PHASE bit doesn't 1064 match what it is expecting. It creates a new secret (see 1065 Section 5.2) and the corresponding read key and IV. If the packet 1066 can be decrypted and authenticated using these values, then the keys 1067 it uses for packet protection are also updated. The next packet sent 1068 by the endpoint will then use the new keys. 1070 An endpoint doesn't need to send packets immediately when it detects 1071 that its peer has updated keys. The next packet that it sends will 1072 simply use the new keys. If an endpoint detects a second update 1073 before it has sent any packets with updated keys it indicates that 1074 its peer has updated keys twice without awaiting a reciprocal update. 1075 An endpoint MUST treat consecutive key updates as a fatal error and 1076 abort the connection. 1078 An endpoint SHOULD retain old keys for a short period to allow it to 1079 decrypt packets with smaller packet numbers than the packet that 1080 triggered the key update. This allows an endpoint to consume packets 1081 that are reordered around the transition between keys. Packets with 1082 higher packet numbers always use the updated keys and MUST NOT be 1083 decrypted with old keys. 1085 Keys and their corresponding secrets SHOULD be discarded when an 1086 endpoint has received all packets with sequence numbers lower than 1087 the lowest sequence number used for the new key. An endpoint might 1088 discard keys if it determines that the length of the delay to 1089 affected packets is excessive. 1091 This ensures that once the handshake is complete, packets with the 1092 same KEY_PHASE will have the same packet protection keys, unless 1093 there are multiple key updates in a short time frame succession and 1094 significant packet reordering. 1096 Initiating Peer Responding Peer 1098 @M QUIC Frames 1099 New Keys -> @N 1100 @N QUIC Frames 1101 --------> 1102 QUIC Frames @M 1103 New Keys -> @N 1104 QUIC Frames @N 1105 <-------- 1107 Figure 5: Key Update 1109 As shown in Figure 3 and Figure 5, there is never a situation where 1110 there are more than two different sets of keying material that might 1111 be received by a peer. Once both sending and receiving keys have 1112 been updated, 1114 A server cannot initiate a key update until it has received the 1115 client's Finished message. Otherwise, packets protected by the 1116 updated keys could be confused for retransmissions of handshake 1117 messages. A client cannot initiate a key update until all of its 1118 handshake messages have been acknowledged by the server. 1120 A packet that triggers a key update could arrive after successfully 1121 processing a packet with a higher packet number. This is only 1122 possible if there is a key compromise and an attack, or if the peer 1123 is incorrectly reverting to use of old keys. Because the latter 1124 cannot be differentiated from an attack, an endpoint MUST immediately 1125 terminate the connection if it detects this condition. 1127 8. Client Address Validation 1129 Two tools are provided by TLS to enable validation of client source 1130 addresses at a server: the cookie in the HelloRetryRequest message, 1131 and the ticket in the NewSessionTicket message. 1133 8.1. HelloRetryRequest Address Validation 1135 The cookie extension in the TLS HelloRetryRequest message allows a 1136 server to perform source address validation during the handshake. 1138 When QUIC requests address validation during the processing of the 1139 first ClientHello, the token it provides is included in the cookie 1140 extension of a HelloRetryRequest. As long as the cookie cannot be 1141 successfully guessed by a client, the server can be assured that the 1142 client received the HelloRetryRequest if it includes the value in a 1143 second ClientHello. 1145 An initial ClientHello never includes a cookie extension. Thus, if a 1146 server constructs a cookie that contains all the information 1147 necessary to reconstruct state, it can discard local state after 1148 sending a HelloRetryRequest. Presence of a valid cookie in a 1149 ClientHello indicates that the ClientHello is a second attempt from 1150 the client. 1152 An address validation token can be extracted from a second 1153 ClientHello and passed to the transport for further validation. If 1154 that validation fails, the server MUST fail the TLS handshake and 1155 send an illegal_parameter alert. 1157 Combining address validation with the other uses of HelloRetryRequest 1158 ensures that there are fewer ways in which an additional round-trip 1159 can be added to the handshake. In particular, this makes it possible 1160 to combine a request for address validation with a request for a 1161 different client key share. 1163 If TLS needs to send a HelloRetryRequest for other reasons, it needs 1164 to ensure that it can correctly identify the reason that the 1165 HelloRetryRequest was generated. During the processing of a second 1166 ClientHello, TLS does not need to consult the transport protocol 1167 regarding address validation if address validation was not requested 1168 originally. In such cases, the cookie extension could either be 1169 absent or it could indicate that an address validation token is not 1170 present. 1172 8.1.1. Stateless Address Validation 1174 A server can use the cookie extension to store all state necessary to 1175 continue the connection. This allows a server to avoid committing 1176 state for clients that have unvalidated source addresses. 1178 For instance, a server could use a statically-configured key to 1179 encrypt the information that it requires and include that information 1180 in the cookie. In addition to address validation information, a 1181 server that uses encryption also needs to be able recover the hash of 1182 the ClientHello and its length, plus any information it needs in 1183 order to reconstruct the HelloRetryRequest. 1185 8.1.2. Sending HelloRetryRequest 1187 A server does not need to maintain state for the connection when 1188 sending a HelloRetryRequest message. This might be necessary to 1189 avoid creating a denial of service exposure for the server. However, 1190 this means that information about the transport will be lost at the 1191 server. This includes the stream offset of stream 0, the packet 1192 number that the server selects, and any opportunity to measure round 1193 trip time. 1195 A server MUST send a TLS HelloRetryRequest in a Server Stateless 1196 Retry packet. Using a Server Stateless Retry packet causes the 1197 client to reset stream offsets. It also avoids the need for the 1198 server select an initial packet number, which would need to be 1199 remembered so that subsequent packets could be correctly numbered. 1201 A HelloRetryRequest message MUST NOT be split between multiple Server 1202 Stateless Retry packets. This means that HelloRetryRequest is 1203 subject to the same size constraints as a ClientHello (see 1204 Section 4.4). 1206 8.2. NewSessionTicket Address Validation 1208 The ticket in the TLS NewSessionTicket message allows a server to 1209 provide a client with a similar sort of token. When a client resumes 1210 a TLS connection - whether or not 0-RTT is attempted - it includes 1211 the ticket in the handshake message. As with the HelloRetryRequest 1212 cookie, the server includes the address validation token in the 1213 ticket. TLS provides the token it extracts from the session ticket 1214 to the transport when it asks whether source address validation is 1215 needed. 1217 If both a HelloRetryRequest cookie and a session ticket are present 1218 in the ClientHello, only the token from the cookie is passed to the 1219 transport. The presence of a cookie indicates that this is a second 1220 ClientHello - the token from the session ticket will have been 1221 provided to the transport when it appeared in the first ClientHello. 1223 A server can send a NewSessionTicket message at any time. This 1224 allows it to update the state - and the address validation token - 1225 that is included in the ticket. This might be done to refresh the 1226 ticket or token, or it might be generated in response to changes in 1227 the state of the connection. QUIC can request that a 1228 NewSessionTicket be sent by providing a new address validation token. 1230 A server that intends to support 0-RTT SHOULD provide an address 1231 validation token immediately after completing the TLS handshake. 1233 8.3. Address Validation Token Integrity 1235 TLS MUST provide integrity protection for address validation token 1236 unless the transport guarantees integrity protection by other means. 1237 For a NewSessionTicket that includes confidential information - such 1238 as the resumption secret - including the token under authenticated 1239 encryption ensures that the token gains both confidentiality and 1240 integrity protection without duplicating the overheads of that 1241 protection. 1243 9. Pre-handshake QUIC Messages 1245 Implementations MUST NOT exchange data on any stream other than 1246 stream 0 without packet protection. QUIC requires the use of several 1247 types of frame for managing loss detection and recovery during this 1248 phase. In addition, it might be useful to use the data acquired 1249 during the exchange of unauthenticated messages for congestion 1250 control. 1252 This section generally only applies to TLS handshake messages from 1253 both peers and acknowledgments of the packets carrying those 1254 messages. In many cases, the need for servers to provide 1255 acknowledgments is minimal, since the messages that clients send are 1256 small and implicitly acknowledged by the server's responses. 1258 The actions that a peer takes as a result of receiving an 1259 unauthenticated packet needs to be limited. In particular, state 1260 established by these packets cannot be retained once record 1261 protection commences. 1263 There are several approaches possible for dealing with 1264 unauthenticated packets prior to handshake completion: 1266 o discard and ignore them 1268 o use them, but reset any state that is established once the 1269 handshake completes 1271 o use them and authenticate them afterwards; failing the handshake 1272 if they can't be authenticated 1274 o save them and use them when they can be properly authenticated 1276 o treat them as a fatal error 1278 Different strategies are appropriate for different types of data. 1279 This document proposes that all strategies are possible depending on 1280 the type of message. 1282 o Transport parameters are made usable and authenticated as part of 1283 the TLS handshake (see Section 10.2). 1285 o Most unprotected messages are treated as fatal errors when 1286 received except for the small number necessary to permit the 1287 handshake to complete (see Section 9.1). 1289 o Protected packets can either be discarded or saved and later used 1290 (see Section 9.3). 1292 9.1. Unprotected Packets Prior to Handshake Completion 1294 This section describes the handling of messages that are sent and 1295 received prior to the completion of the TLS handshake. 1297 Sending and receiving unprotected messages is hazardous. Unless 1298 expressly permitted, receipt of an unprotected message of any kind 1299 MUST be treated as a fatal error. 1301 9.1.1. STREAM Frames 1303 "STREAM" frames for stream 0 are permitted. These carry the TLS 1304 handshake messages. Once 1-RTT keys are available, unprotected 1305 "STREAM" frames on stream 0 can be ignored. 1307 Receiving unprotected "STREAM" frames for other streams MUST be 1308 treated as a fatal error. 1310 9.1.2. ACK Frames 1312 "ACK" frames are permitted prior to the handshake being complete. 1313 Information learned from "ACK" frames cannot be entirely relied upon, 1314 since an attacker is able to inject these packets. Timing and packet 1315 retransmission information from "ACK" frames is critical to the 1316 functioning of the protocol, but these frames might be spoofed or 1317 altered. 1319 Endpoints MUST NOT use an unprotected "ACK" frame to acknowledge data 1320 that was protected by 0-RTT or 1-RTT keys. An endpoint MUST ignore 1321 an unprotected "ACK" frame if it claims to acknowledge data that was 1322 sent in a protected packet. Such an acknowledgement can only serve 1323 as a denial of service, since an endpoint that can read protected 1324 data is always able to send protected data. 1326 ISSUE: What about 0-RTT data? Should we allow acknowledgment of 1327 0-RTT with unprotected frames? If we don't, then 0-RTT data will 1328 be unacknowledged until the handshake completes. This isn't a 1329 problem if the handshake completes without loss, but it could mean 1330 that 0-RTT stalls when a handshake packet disappears for any 1331 reason. 1333 An endpoint SHOULD use data from unprotected or 0-RTT-protected "ACK" 1334 frames only during the initial handshake and while they have 1335 insufficient information from 1-RTT-protected "ACK" frames. Once 1336 sufficient information has been obtained from protected messages, 1337 information obtained from less reliable sources can be discarded. 1339 9.1.3. Updates to Data and Stream Limits 1341 "MAX_DATA", "MAX_STREAM_DATA", "BLOCKED", "STREAM_BLOCKED", and 1342 "MAX_STREAM_ID" frames MUST NOT be sent unprotected. 1344 Though data is exchanged on stream 0, the initial flow control window 1345 on that stream is sufficiently large to allow the TLS handshake to 1346 complete. This limits the maximum size of the TLS handshake and 1347 would prevent a server or client from using an abnormally large 1348 certificate chain. 1350 Stream 0 is exempt from the connection-level flow control window. 1352 Consequently, there is no need to signal being blocked on flow 1353 control. 1355 Similarly, there is no need to increase the number of allowed streams 1356 until the handshake completes. 1358 9.1.4. Denial of Service with Unprotected Packets 1360 Accepting unprotected - specifically unauthenticated - packets 1361 presents a denial of service risk to endpoints. An attacker that is 1362 able to inject unprotected packets can cause a recipient to drop even 1363 protected packets with a matching sequence number. The spurious 1364 packet shadows the genuine packet, causing the genuine packet to be 1365 ignored as redundant. 1367 Once the TLS handshake is complete, both peers MUST ignore 1368 unprotected packets. From that point onward, unprotected messages 1369 can be safely dropped. 1371 Since only TLS handshake packets and acknowledgments are sent in the 1372 clear, an attacker is able to force implementations to rely on 1373 retransmission for packets that are lost or shadowed. Thus, an 1374 attacker that intends to deny service to an endpoint has to drop or 1375 shadow protected packets in order to ensure that their victim 1376 continues to accept unprotected packets. The ability to shadow 1377 packets means that an attacker does not need to be on path. 1379 In addition to causing valid packets to be dropped, an attacker can 1380 generate packets with an intent of causing the recipient to expend 1381 processing resources. See Section 11.2 for a discussion of these 1382 risks. 1384 To avoid receiving TLS packets that contain no useful data, a TLS 1385 implementation MUST reject empty TLS handshake records and any record 1386 that is not permitted by the TLS state machine. Any TLS application 1387 data or alerts that is received prior to the end of the handshake 1388 MUST be treated as a fatal error. 1390 9.2. Use of 0-RTT Keys 1392 If 0-RTT keys are available, the lack of replay protection means that 1393 restrictions on their use are necessary to avoid replay attacks on 1394 the protocol. 1396 A client MUST only use 0-RTT keys to protect data that is idempotent. 1397 A client MAY wish to apply additional restrictions on what data it 1398 sends prior to the completion of the TLS handshake. A client 1399 otherwise treats 0-RTT keys as equivalent to 1-RTT keys. 1401 A client that receives an indication that its 0-RTT data has been 1402 accepted by a server can send 0-RTT data until it receives all of the 1403 server's handshake messages. A client SHOULD stop sending 0-RTT data 1404 if it receives an indication that 0-RTT data has been rejected. 1406 A server MUST NOT use 0-RTT keys to protect packets. 1408 9.3. Receiving Out-of-Order Protected Frames 1410 Due to reordering and loss, protected packets might be received by an 1411 endpoint before the final TLS handshake messages are received. A 1412 client will be unable to decrypt 1-RTT packets from the server, 1413 whereas a server will be able to decrypt 1-RTT packets from the 1414 client. 1416 Packets protected with 1-RTT keys MAY be stored and later decrypted 1417 and used once the handshake is complete. A server MUST NOT use 1-RTT 1418 protected packets before verifying either the client Finished message 1419 or - in the case that the server has chosen to use a pre-shared key - 1420 the pre-shared key binder (see Section 4.2.8 of 1421 [I-D.ietf-tls-tls13]). Verifying these values provides the server 1422 with an assurance that the ClientHello has not been modified. 1424 A server could receive packets protected with 0-RTT keys prior to 1425 receiving a TLS ClientHello. The server MAY retain these packets for 1426 later decryption in anticipation of receiving a ClientHello. 1428 Receiving and verifying the TLS Finished message is critical in 1429 ensuring the integrity of the TLS handshake. A server MUST NOT use 1430 protected packets from the client prior to verifying the client 1431 Finished message if its response depends on client authentication. 1433 10. QUIC-Specific Additions to the TLS Handshake 1435 QUIC uses the TLS handshake for more than just negotiation of 1436 cryptographic parameters. The TLS handshake validates protocol 1437 version selection, provides preliminary values for QUIC transport 1438 parameters, and allows a server to perform return routeability checks 1439 on clients. 1441 10.1. Protocol and Version Negotiation 1443 The QUIC version negotiation mechanism is used to negotiate the 1444 version of QUIC that is used prior to the completion of the 1445 handshake. However, this packet is not authenticated, enabling an 1446 active attacker to force a version downgrade. 1448 To ensure that a QUIC version downgrade is not forced by an attacker, 1449 version information is copied into the TLS handshake, which provides 1450 integrity protection for the QUIC negotiation. This does not prevent 1451 version downgrade prior to the completion of the handshake, though it 1452 means that a downgrade causes a handshake failure. 1454 TLS uses Application Layer Protocol Negotiation (ALPN) [RFC7301] to 1455 select an application protocol. The application-layer protocol MAY 1456 restrict the QUIC versions that it can operate over. Servers MUST 1457 select an application protocol compatible with the QUIC version that 1458 the client has selected. 1460 If the server cannot select a compatible combination of application 1461 protocol and QUIC version, it MUST abort the connection. A client 1462 MUST abort a connection if the server picks an incompatible 1463 combination of QUIC version and ALPN identifier. 1465 10.2. QUIC Transport Parameters Extension 1467 QUIC transport parameters are carried in a TLS extension. Different 1468 versions of QUIC might define a different format for this struct. 1470 Including transport parameters in the TLS handshake provides 1471 integrity protection for these values. 1473 enum { 1474 quic_transport_parameters(26), (65535) 1475 } ExtensionType; 1477 The "extension_data" field of the quic_transport_parameters extension 1478 contains a value that is defined by the version of QUIC that is in 1479 use. The quic_transport_parameters extension carries a 1480 TransportParameters when the version of QUIC defined in 1481 [QUIC-TRANSPORT] is used. 1483 The quic_transport_parameters extension is carried in the ClientHello 1484 and the EncryptedExtensions messages during the handshake. The 1485 extension MAY be included in a NewSessionTicket message. 1487 10.3. Priming 0-RTT 1489 QUIC uses TLS without modification. Therefore, it is possible to use 1490 a pre-shared key that was established in a TLS handshake over TCP to 1491 enable 0-RTT in QUIC. Similarly, QUIC can provide a pre-shared key 1492 that can be used to enable 0-RTT in TCP. 1494 All the restrictions on the use of 0-RTT apply, with the exception of 1495 the ALPN label, which MUST only change to a label that is explicitly 1496 designated as being compatible. The client indicates which ALPN 1497 label it has chosen by placing that ALPN label first in the ALPN 1498 extension. 1500 The certificate that the server uses MUST be considered valid for 1501 both connections, which will use different protocol stacks and could 1502 use different port numbers. For instance, HTTP/1.1 and HTTP/2 1503 operate over TLS and TCP, whereas QUIC operates over UDP. 1505 Source address validation is not completely portable between 1506 different protocol stacks. Even if the source IP address remains 1507 constant, the port number is likely to be different. Packet 1508 reflection attacks are still possible in this situation, though the 1509 set of hosts that can initiate these attacks is greatly reduced. A 1510 server might choose to avoid source address validation for such a 1511 connection, or allow an increase to the amount of data that it sends 1512 toward the client without source validation. 1514 11. Security Considerations 1516 There are likely to be some real clangers here eventually, but the 1517 current set of issues is well captured in the relevant sections of 1518 the main text. 1520 Never assume that because it isn't in the security considerations 1521 section it doesn't affect security. Most of this document does. 1523 11.1. Packet Reflection Attack Mitigation 1525 A small ClientHello that results in a large block of handshake 1526 messages from a server can be used in packet reflection attacks to 1527 amplify the traffic generated by an attacker. 1529 Certificate caching [RFC7924] can reduce the size of the server's 1530 handshake messages significantly. 1532 QUIC requires that the packet containing a ClientHello be padded to a 1533 minimum size. A server is less likely to generate a packet 1534 reflection attack if the data it sends is a small multiple of this 1535 size. A server SHOULD use a HelloRetryRequest if the size of the 1536 handshake messages it sends is likely to significantly exceed the 1537 size of the packet containing the ClientHello. 1539 11.2. Peer Denial of Service 1541 QUIC, TLS and HTTP/2 all contain a messages that have legitimate uses 1542 in some contexts, but that can be abused to cause a peer to expend 1543 processing resources without having any observable impact on the 1544 state of the connection. If processing is disproportionately large 1545 in comparison to the observable effects on bandwidth or state, then 1546 this could allow a malicious peer to exhaust processing capacity 1547 without consequence. 1549 QUIC prohibits the sending of empty "STREAM" frames unless they are 1550 marked with the FIN bit. This prevents "STREAM" frames from being 1551 sent that only waste effort. 1553 TLS records SHOULD always contain at least one octet of a handshake 1554 messages or alert. Records containing only padding are permitted 1555 during the handshake, but an excessive number might be used to 1556 generate unnecessary work. Once the TLS handshake is complete, 1557 endpoints SHOULD NOT send TLS application data records unless it is 1558 to hide the length of QUIC records. QUIC packet protection does not 1559 include any allowance for padding; padded TLS application data 1560 records can be used to mask the length of QUIC frames. 1562 While there are legitimate uses for some redundant packets, 1563 implementations SHOULD track redundant packets and treat excessive 1564 volumes of any non-productive packets as indicative of an attack. 1566 12. Error codes 1568 The portion of the QUIC error code space allocated for the crypto 1569 handshake is 0xC0000000-0xFFFFFFFF. The following error codes are 1570 defined when TLS is used for the crypto handshake: 1572 TLS_HANDSHAKE_FAILED (0xC000001C): The TLS handshake failed. 1574 TLS_FATAL_ALERT_GENERATED (0xC000001D): A TLS fatal alert was sent, 1575 causing the TLS connection to end prematurely. 1577 TLS_FATAL_ALERT_RECEIVED (0xC000001E): A TLS fatal alert was 1578 received, causing the TLS connection to end prematurely. 1580 13. IANA Considerations 1582 This document does not create any new IANA registries, but it does 1583 utilize the following registries: 1585 o QUIC Transport Parameter Registry - IANA is to register the three 1586 values found in Section 12. 1588 o TLS ExtensionsType Registry - IANA is to register the 1589 quic_transport_parameters extension found in Section 10.2. 1590 Assigning 26 to the extension would be greatly appreciated. The 1591 Recommended column is to be marked Yes. 1593 o TLS Exporter Label Registry - IANA is requested to register 1594 "EXPORTER-QUIC 0-RTT Secret" from Section 5.2.1; "EXPORTER-QUIC 1595 client 1-RTT Secret" and "EXPORTER-QUIC server 1-RTT Secret" from 1596 Section 5.2.2; "EXPORTER-QUIC Packet Number Secret" Section 5.6. 1597 The DTLS column is to be marked No. The Recommended column is to 1598 be marked Yes. 1600 14. References 1602 14.1. Normative References 1604 [I-D.ietf-tls-tls13] 1605 Rescorla, E., "The Transport Layer Security (TLS) Protocol 1606 Version 1.3", draft-ietf-tls-tls13-20 (work in progress), 1607 April 2017. 1609 [QUIC-TRANSPORT] 1610 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1611 Multiplexed and Secure Transport", draft-ietf-quic- 1612 transport (work in progress), June 2017. 1614 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1615 Requirement Levels", BCP 14, RFC 2119, 1616 DOI 10.17487/RFC2119, March 1997, 1617 . 1619 [RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated 1620 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1621 . 1623 [RFC5869] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand 1624 Key Derivation Function (HKDF)", RFC 5869, 1625 DOI 10.17487/RFC5869, May 2010, 1626 . 1628 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1629 "Transport Layer Security (TLS) Application-Layer Protocol 1630 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1631 July 2014, . 1633 14.2. Informative References 1635 [AEBounds] 1636 Luykx, A. and K. Paterson, "Limits on Authenticated 1637 Encryption Use in TLS", March 2016, 1638 . 1640 [FNV] Fowler, G., Noll, L., Vo, K., Eastlake, D., and T. Hansen, 1641 "The FNV Non-Cryptographic Hash Algorithm", draft- 1642 eastlake-fnv-13 (work in progress), June 2017. 1644 [QUIC-HTTP] 1645 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1646 QUIC", draft-ietf-quic-http (work in progress), June 2017. 1648 [QUIC-RECOVERY] 1649 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1650 and Congestion Control", draft-ietf-quic-recovery (work in 1651 progress), June 2017. 1653 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1654 DOI 10.17487/RFC2818, May 2000, 1655 . 1657 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1658 Housley, R., and W. Polk, "Internet X.509 Public Key 1659 Infrastructure Certificate and Certificate Revocation List 1660 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1661 . 1663 [RFC7924] Santesson, S. and H. Tschofenig, "Transport Layer Security 1664 (TLS) Cached Information Extension", RFC 7924, 1665 DOI 10.17487/RFC7924, July 2016, 1666 . 1668 Appendix A. Contributors 1670 Ryan Hamilton was originally an author of this specification. 1672 Appendix B. Acknowledgments 1674 This document has benefited from input from Dragana Damjanovic, 1675 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1676 Rescorla, Ian Swett, and many others. 1678 Appendix C. Change Log 1680 *RFC Editor's Note:* Please remove this section prior to 1681 publication of a final version of this document. 1683 Issue and pull request numbers are listed with a leading octothorp. 1685 C.1. Since draft-ietf-quic-tls-02 1687 o Updates to match changes in transport draft 1689 C.2. Since draft-ietf-quic-tls-01 1691 o Use TLS alerts to signal TLS errors (#272, #374) 1693 o Require ClientHello to fit in a single packet (#338) 1695 o The second client handshake flight is now sent in the clear (#262, 1696 #337) 1698 o The QUIC header is included as AEAD Associated Data (#226, #243, 1699 #302) 1701 o Add interface necessary for client address validation (#275) 1703 o Define peer authentication (#140) 1705 o Require at least TLS 1.3 (#138) 1707 o Define transport parameters as a TLS extension (#122) 1709 o Define handling for protected packets before the handshake 1710 completes (#39) 1712 o Decouple QUIC version and ALPN (#12) 1714 C.3. Since draft-ietf-quic-tls-00 1716 o Changed bit used to signal key phase 1718 o Updated key phase markings during the handshake 1720 o Added TLS interface requirements section 1722 o Moved to use of TLS exporters for key derivation 1724 o Moved TLS error code definitions into this document 1726 C.4. Since draft-thomson-quic-tls-01 1728 o Adopted as base for draft-ietf-quic-tls 1730 o Updated authors/editors list 1732 o Added status note 1734 Authors' Addresses 1736 Martin Thomson (editor) 1737 Mozilla 1739 Email: martin.thomson@gmail.com 1741 Sean Turner (editor) 1742 sn3rd 1744 Email: sean@sn3rd.com