idnits 2.17.1 draft-ietf-quic-tls-16.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 : ---------------------------------------------------------------------------- ** The abstract seems to contain references ([2], [3], [1]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: o If the packet is from a previously installed encryption level, it MUST not contain data which extends past the end of previously received data in that flow. Implementations MUST treat any violations of this requirement as a connection error of type PROTOCOL_VIOLATION. -- The document date (October 23, 2018) is 2010 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) -- Looks like a reference, but probably isn't: '1' on line 1376 -- Looks like a reference, but probably isn't: '2' on line 1378 -- Looks like a reference, but probably isn't: '3' on line 1380 == Unused Reference: 'QUIC-HTTP' is defined on line 1359, but no explicit reference was found in the text -- Possible downref: Non-RFC (?) normative reference: ref. 'AES' ** Downref: Normative reference to an Informational RFC: RFC 8439 (ref. 'CHACHA') == Outdated reference: A later version (-34) exists of draft-ietf-quic-recovery-16 == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-16 -- Possible downref: Non-RFC (?) normative reference: ref. 'SHA' == Outdated reference: A later version (-34) exists of draft-ietf-quic-http-16 -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) Summary: 2 errors (**), 0 flaws (~~), 6 warnings (==), 8 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: April 26, 2019 sn3rd 6 October 23, 2018 8 Using Transport Layer Security (TLS) to Secure QUIC 9 draft-ietf-quic-tls-16 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 [1]. 22 Working Group information can be found at https://github.com/quicwg 23 [2]; source code and issues list for this draft can be found at 24 https://github.com/quicwg/base-drafts/labels/-tls [3]. 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 https://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 April 26, 2019. 43 Copyright Notice 45 Copyright (c) 2018 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 (https://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 . . . . . . . . . . . . . . . . . . . 3 62 2.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 4 63 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 6 64 4. Carrying TLS Messages . . . . . . . . . . . . . . . . . . . . 7 65 4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 9 66 4.1.1. Sending and Receiving Handshake Messages . . . . . . 9 67 4.1.2. Encryption Level Changes . . . . . . . . . . . . . . 11 68 4.1.3. TLS Interface Summary . . . . . . . . . . . . . . . . 11 69 4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 12 70 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 13 71 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 13 72 4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 14 73 4.6. Rejecting 0-RTT . . . . . . . . . . . . . . . . . . . . . 14 74 4.7. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 14 75 4.8. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 15 76 4.9. Discarding Unused Keys . . . . . . . . . . . . . . . . . 15 77 5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 16 78 5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 16 79 5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 17 80 5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 18 81 5.4. Packet Number Protection . . . . . . . . . . . . . . . . 19 82 5.4.1. AES-Based Packet Number Protection . . . . . . . . . 20 83 5.4.2. ChaCha20-Based Packet Number Protection . . . . . . . 20 84 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 20 85 5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 21 86 5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 21 87 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 22 88 7. Security of Initial Messages . . . . . . . . . . . . . . . . 23 89 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 24 90 8.1. Protocol and Version Negotiation . . . . . . . . . . . . 24 91 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 25 92 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 25 93 9. Security Considerations . . . . . . . . . . . . . . . . . . . 26 94 9.1. Packet Reflection Attack Mitigation . . . . . . . . . . . 26 95 9.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 26 96 9.3. Packet Number Protection Analysis . . . . . . . . . . . . 26 97 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 27 98 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 28 99 11.1. Normative References . . . . . . . . . . . . . . . . . . 28 100 11.2. Informative References . . . . . . . . . . . . . . . . . 29 101 11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 29 102 Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 30 103 A.1. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 30 104 A.2. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 30 105 A.3. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 30 106 A.4. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 30 107 A.5. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 30 108 A.6. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 30 109 A.7. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 31 110 A.8. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 31 111 A.9. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 31 112 A.10. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 31 113 A.11. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 31 114 A.12. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 31 115 A.13. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 32 116 A.14. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 32 117 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 32 118 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 32 119 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 32 121 1. Introduction 123 This document describes how QUIC [QUIC-TRANSPORT] is secured using 124 Transport Layer Security (TLS) version 1.3 [TLS13]. TLS 1.3 provides 125 critical latency improvements for connection establishment over 126 previous versions. Absent packet loss, most new connections can be 127 established and secured within a single round trip; on subsequent 128 connections between the same client and server, the client can often 129 send application data immediately, that is, using a zero round trip 130 setup. 132 This document describes how the standardized TLS 1.3 acts as a 133 security component of QUIC. 135 2. Notational Conventions 137 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 138 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 139 "OPTIONAL" in this document are to be interpreted as described in BCP 140 14 [RFC2119] [RFC8174] when, and only when, they appear in all 141 capitals, as shown here. 143 This document uses the terminology established in [QUIC-TRANSPORT]. 145 For brevity, the acronym TLS is used to refer to TLS 1.3. 147 2.1. TLS Overview 149 TLS provides two endpoints with a way to establish a means of 150 communication over an untrusted medium (that is, the Internet) that 151 ensures that messages they exchange cannot be observed, modified, or 152 forged. 154 Internally, TLS is a layered protocol, with the structure shown 155 below: 157 +--------------+--------------+--------------+ 158 | Handshake | Alerts | Application | 159 | Layer | | Data | 160 | | | | 161 +--------------+--------------+--------------+ 162 | | 163 | Record Layer | 164 | | 165 +--------------------------------------------+ 167 Each upper layer (handshake, alerts, and application data) is carried 168 as a series of typed TLS records. Records are individually 169 cryptographically protected and then transmitted over a reliable 170 transport (typically TCP) which provides sequencing and guaranteed 171 delivery. 173 Change Cipher Spec records cannot be sent in QUIC. 175 The TLS authenticated key exchange occurs between two entities: 176 client and server. The client initiates the exchange and the server 177 responds. If the key exchange completes successfully, both client 178 and server will agree on a secret. TLS supports both pre-shared key 179 (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for 180 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 181 keys are destroyed. 183 After completing the TLS handshake, the client will have learned and 184 authenticated an identity for the server and the server is optionally 185 able to learn and authenticate an identity for the client. TLS 186 supports X.509 [RFC5280] certificate-based authentication for both 187 server and client. 189 The TLS key exchange is resistant to tampering by attackers and it 190 produces shared secrets that cannot be controlled by either 191 participating peer. 193 TLS 1.3 provides two basic handshake modes of interest to QUIC: 195 o A full 1-RTT handshake in which the client is able to send 196 application data after one round trip and the server immediately 197 responds after receiving the first handshake message from the 198 client. 200 o A 0-RTT handshake in which the client uses information it has 201 previously learned about the server to send application data 202 immediately. This application data can be replayed by an attacker 203 so it MUST NOT carry a self-contained trigger for any non- 204 idempotent action. 206 A simplified TLS 1.3 handshake with 0-RTT application data is shown 207 in Figure 1. Note that this omits the EndOfEarlyData message, which 208 is not used in QUIC (see Section 8.3). 210 Client Server 212 ClientHello 213 (0-RTT Application Data) --------> 214 ServerHello 215 {EncryptedExtensions} 216 {Finished} 217 <-------- [Application Data] 218 {Finished} --------> 220 [Application Data] <-------> [Application Data] 222 () Indicates messages protected by early data (0-RTT) keys 223 {} Indicates messages protected using handshake keys 224 [] Indicates messages protected using application data 225 (1-RTT) keys 227 Figure 1: TLS Handshake with 0-RTT 229 Data is protected using a number of encryption levels: 231 o Plaintext 233 o Early Data (0-RTT) Keys 235 o Handshake Keys 237 o Application Data (1-RTT) Keys 239 Application data may appear only in the early data and application 240 data levels. Handshake and Alert messages may appear in any level. 242 The 0-RTT handshake is only possible if the client and server have 243 previously communicated. In the 1-RTT handshake, the client is 244 unable to send protected application data until it has received all 245 of the handshake messages sent by the server. 247 3. Protocol Overview 249 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 250 and integrity protection of packets. For this it uses keys derived 251 from a TLS 1.3 handshake [TLS13], but instead of carrying TLS records 252 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 253 directly over the QUIC transport, which takes over the 254 responsibilities of the TLS record layer, as shown below. 256 +--------------+--------------+ +-------------+ 257 | TLS | TLS | | QUIC | 258 | Handshake | Alerts | | Applications| 259 | | | | (h2q, etc.) | 260 +--------------+--------------+-+-------------+ 261 | | 262 | QUIC Transport | 263 | (streams, reliability, congestion, etc.) | 264 | | 265 +---------------------------------------------+ 266 | | 267 | QUIC Packet Protection | 268 | | 269 +---------------------------------------------+ 271 QUIC also relies on TLS 1.3 for authentication and negotiation of 272 parameters that are critical to security and performance. 274 Rather than a strict layering, these two protocols are co-dependent: 275 QUIC uses the TLS handshake; TLS uses the reliability, ordered 276 delivery, and record layer provided by QUIC. 278 At a high level, there are two main interactions between the TLS and 279 QUIC components: 281 o The TLS component sends and receives messages via the QUIC 282 component, with QUIC providing a reliable stream abstraction to 283 TLS. 285 o The TLS component provides a series of updates to the QUIC 286 component, including (a) new packet protection keys to install (b) 287 state changes such as handshake completion, the server 288 certificate, etc. 290 Figure 2 shows these interactions in more detail, with the QUIC 291 packet protection being called out specially. 293 +------------+ +------------+ 294 | |<- Handshake Messages ->| | 295 | |<---- 0-RTT Keys -------| | 296 | |<--- Handshake Keys-----| | 297 | QUIC |<---- 1-RTT Keys -------| TLS | 298 | |<--- Handshake Done ----| | 299 +------------+ +------------+ 300 | ^ 301 | Protect | Protected 302 v | Packet 303 +------------+ 304 | QUIC | 305 | Packet | 306 | Protection | 307 +------------+ 309 Figure 2: QUIC and TLS Interactions 311 Unlike TLS over TCP, QUIC applications which want to send data do not 312 send it through TLS "application_data" records. Rather, they send it 313 as QUIC STREAM frames which are then carried in QUIC packets. 315 4. Carrying TLS Messages 317 QUIC carries TLS handshake data in CRYPTO frames, each of which 318 consists of a contiguous block of handshake data identified by an 319 offset and length. Those frames are packaged into QUIC packets and 320 encrypted under the current TLS encryption level. As with TLS over 321 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 322 responsibility to deliver it reliably. Each chunk of data that is 323 produced by TLS is associated with the set of keys that TLS is 324 currently using. If QUIC needs to retransmit that data, it MUST use 325 the same keys even if TLS has already updated to newer keys. 327 One important difference between TLS 1.3 records (used with TCP) and 328 QUIC CRYPTO frames is that in QUIC multiple frames may appear in the 329 same QUIC packet as long as they are associated with the same 330 encryption level. For instance, an implementation might bundle a 331 Handshake message and an ACK for some Handshake data into the same 332 packet. 334 Each encryption level has a specific list of frames which may appear 335 in it. The rules here generalize those of TLS, in that frames 336 associated with establishing the connection can usually appear at any 337 encryption level, whereas those associated with transferring data can 338 only appear in the 0-RTT and 1-RTT encryption levels: 340 o CRYPTO frames MAY appear in packets of any encryption level except 341 0-RTT. 343 o CONNECTION_CLOSE MAY appear in packets of any encryption level 344 other than 0-RTT. 346 o APPLICATION_CLOSE MAY appear in packets of any encryption level 347 other than Initial and 0-RTT. 349 o PADDING frames MAY appear in packets of any encryption level. 351 o ACK frames MAY appear in packets of any encryption level other 352 than 0-RTT, but can only acknowledge packets which appeared in 353 that packet number space. 355 o STREAM frames MUST ONLY appear in the 0-RTT and 1-RTT levels. 357 o All other frame types MUST only appear at the 1-RTT levels. 359 Because packets could be reordered on the wire, QUIC uses the packet 360 type to indicate which level a given packet was encrypted under, as 361 shown in Table 1. When multiple packets of different encryption 362 levels need to be sent, endpoints SHOULD use coalesced packets to 363 send them in the same UDP datagram. 365 +-----------------+------------------+-----------+ 366 | Packet Type | Encryption Level | PN Space | 367 +-----------------+------------------+-----------+ 368 | Initial | Initial secrets | Initial | 369 | | | | 370 | 0-RTT Protected | 0-RTT | 0/1-RTT | 371 | | | | 372 | Handshake | Handshake | Handshake | 373 | | | | 374 | Retry | N/A | N/A | 375 | | | | 376 | Short Header | 1-RTT | 0/1-RTT | 377 +-----------------+------------------+-----------+ 379 Table 1: Encryption Levels by Packet Type 381 Section 6.5 of [QUIC-TRANSPORT] shows how packets at the various 382 encryption levels fit into the handshake process. 384 4.1. Interface to TLS 386 As shown in Figure 2, the interface from QUIC to TLS consists of 387 three primary functions: 389 o Sending and receiving handshake messages 391 o Rekeying (both transmit and receive) 393 o Handshake state updates 395 Additional functions might be needed to configure TLS. 397 4.1.1. Sending and Receiving Handshake Messages 399 In order to drive the handshake, TLS depends on being able to send 400 and receive handshake messages. There are two basic functions on 401 this interface: one where QUIC requests handshake messages and one 402 where QUIC provides handshake packets. 404 Before starting the handshake QUIC provides TLS with the transport 405 parameters (see Section 8.2) that it wishes to carry. 407 A QUIC client starts TLS by requesting TLS handshake octets from TLS. 408 The client acquires handshake octets before sending its first packet. 409 A QUIC server starts the process by providing TLS with the client's 410 handshake octets. 412 At any given time, the TLS stack at an endpoint will have a current 413 sending encryption level and receiving encryption level. Each 414 encryption level is associated with a different flow of bytes, which 415 is reliably transmitted to the peer in CRYPTO frames. When TLS 416 provides handshake octets to be sent, they are appended to the 417 current flow and any packet that includes the CRYPTO frame is 418 protected using keys from the corresponding encryption level. 420 QUIC takes the unprotected content of TLS handshake records as the 421 content of CRYPTO frames. TLS record protection is not used by QUIC. 422 QUIC assembles CRYPTO frames into QUIC packets, which are protected 423 using QUIC packet protection. 425 When an endpoint receives a QUIC packet containing a CRYPTO frame 426 from the network, it proceeds as follows: 428 o If the packet was in the TLS receiving encryption level, sequence 429 the data into the input flow as usual. As with STREAM frames, the 430 offset is used to find the proper location in the data sequence. 432 If the result of this process is that new data is available, then 433 it is delivered to TLS in order. 435 o If the packet is from a previously installed encryption level, it 436 MUST not contain data which extends past the end of previously 437 received data in that flow. Implementations MUST treat any 438 violations of this requirement as a connection error of type 439 PROTOCOL_VIOLATION. 441 o If the packet is from a new encryption level, it is saved for 442 later processing by TLS. Once TLS moves to receiving from this 443 encryption level, saved data can be provided. When providing data 444 from any new encryption level to TLS, if there is data from a 445 previous encryption level that TLS has not consumed, this MUST be 446 treated as a connection error of type PROTOCOL_VIOLATION. 448 Each time that TLS is provided with new data, new handshake octets 449 are requested from TLS. TLS might not provide any octets if the 450 handshake messages it has received are incomplete or it has no data 451 to send. 453 Once the TLS handshake is complete, this is indicated to QUIC along 454 with any final handshake octets that TLS needs to send. TLS also 455 provides QUIC with the transport parameters that the peer advertised 456 during the handshake. 458 Once the handshake is complete, TLS becomes passive. TLS can still 459 receive data from its peer and respond in kind, but it will not need 460 to send more data unless specifically requested - either by an 461 application or QUIC. One reason to send data is that the server 462 might wish to provide additional or updated session tickets to a 463 client. 465 When the handshake is complete, QUIC only needs to provide TLS with 466 any data that arrives in CRYPTO streams. In the same way that is 467 done during the handshake, new data is requested from TLS after 468 providing received data. 470 Important: Until the handshake is reported as complete, the 471 connection and key exchange are not properly authenticated at the 472 server. Even though 1-RTT keys are available to a server after 473 receiving the first handshake messages from a client, the server 474 cannot consider the client to be authenticated until it receives 475 and validates the client's Finished message. 477 The requirement for the server to wait for the client Finished 478 message creates a dependency on that message being delivered. A 479 client can avoid the potential for head-of-line blocking that this 480 implies by sending a copy of the CRYPTO frame that carries the 481 Finished message in multiple packets. This enables immediate 482 server processing for those packets. 484 4.1.2. Encryption Level Changes 486 As keys for new encryption levels become available, TLS provides QUIC 487 with those keys. Separately, as TLS starts using keys at a given 488 encryption level, TLS indicates to QUIC that it is now reading or 489 writing with keys at that encryption level. These events are not 490 asynchronous; they always occur immediately after TLS is provided 491 with new handshake octets, or after TLS produces handshake octets. 493 If 0-RTT is possible, it is ready after the client sends a TLS 494 ClientHello message or the server receives that message. After 495 providing a QUIC client with the first handshake octets, the TLS 496 stack might signal the change to 0-RTT keys. On the server, after 497 receiving handshake octets that contain a ClientHello message, a TLS 498 server might signal that 0-RTT keys are available. 500 Although TLS only uses one encryption level at a time, QUIC may use 501 more than one level. For instance, after sending its Finished 502 message (using a CRYPTO frame at the Handshake encryption level) an 503 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 504 message is lost, the endpoint uses the Handshake encryption level to 505 retransmit the lost message. Reordering or loss of packets can mean 506 that QUIC will need to handle packets at multiple encryption levels. 507 During the handshake, this means potentially handling packets at 508 higher and lower encryption levels than the current encryption level 509 used by TLS. 511 In particular, server implementations need to be able to read packets 512 at the Handshake encryption level at the same time as the 0-RTT 513 encryption level. A client could interleave ACK frames that are 514 protected with Handshake keys with 0-RTT data and the server needs to 515 process those acknowledgments in order to detect lost Handshake 516 packets. 518 4.1.3. TLS Interface Summary 520 Figure 3 summarizes the exchange between QUIC and TLS for both client 521 and server. Each arrow is tagged with the encryption level used for 522 that transmission. 524 Client Server 526 Get Handshake 527 Initial -------------> 528 Rekey tx to 0-RTT Keys 529 0-RTT ---------------> 530 Handshake Received 531 Get Handshake 532 <------------- Initial 533 Rekey rx to 0-RTT keys 534 Handshake Received 535 Rekey rx to Handshake keys 536 Get Handshake 537 <----------- Handshake 538 Rekey tx to 1-RTT keys 539 <--------------- 1-RTT 540 Handshake Received 541 Rekey rx to Handshake keys 542 Handshake Received 543 Get Handshake 544 Handshake Complete 545 Handshake -----------> 546 Rekey tx to 1-RTT keys 547 1-RTT ---------------> 548 Handshake Received 549 Rekey rx to 1-RTT keys 550 Get Handshake 551 Handshake Complete 552 <--------------- 1-RTT 553 Handshake Received 555 Figure 3: Interaction Summary between QUIC and TLS 557 4.2. TLS Version 559 This document describes how TLS 1.3 [TLS13] is used with QUIC. 561 In practice, the TLS handshake will negotiate a version of TLS to 562 use. This could result in a newer version of TLS than 1.3 being 563 negotiated if both endpoints support that version. This is 564 acceptable provided that the features of TLS 1.3 that are used by 565 QUIC are supported by the newer version. 567 A badly configured TLS implementation could negotiate TLS 1.2 or 568 another older version of TLS. An endpoint MUST terminate the 569 connection if a version of TLS older than 1.3 is negotiated. 571 4.3. ClientHello Size 573 QUIC requires that the first Initial packet from a client contain an 574 entire cryptographic handshake message, which for TLS is the 575 ClientHello. Though a packet larger than 1200 octets might be 576 supported by the path, a client improves the likelihood that a packet 577 is accepted if it ensures that the first ClientHello message is small 578 enough to stay within this limit. 580 QUIC packet and framing add at least 36 octets of overhead to the 581 ClientHello message. That overhead increases if the client chooses a 582 connection ID without zero length. Overheads also do not include the 583 token or a connection ID longer than 8 octets, both of which might be 584 required if a server sends a Retry packet. 586 A typical TLS ClientHello can easily fit into a 1200 octet packet. 587 However, in addition to the overheads added by QUIC, there are 588 several variables that could cause this limit to be exceeded. Large 589 session tickets, multiple or large key shares, and long lists of 590 supported ciphers, signature algorithms, versions, QUIC transport 591 parameters, and other negotiable parameters and extensions could 592 cause this message to grow. 594 For servers, in addition to connection IDs and tokens, the size of 595 TLS session tickets can have an effect on a client's ability to 596 connect. Minimizing the size of these values increases the 597 probability that they can be successfully used by a client. 599 A client is not required to fit the ClientHello that it sends in 600 response to a HelloRetryRequest message into a single UDP datagram. 602 The TLS implementation does not need to ensure that the ClientHello 603 is sufficiently large. QUIC PADDING frames are added to increase the 604 size of the packet as necessary. 606 4.4. Peer Authentication 608 The requirements for authentication depend on the application 609 protocol that is in use. TLS provides server authentication and 610 permits the server to request client authentication. 612 A client MUST authenticate the identity of the server. This 613 typically involves verification that the identity of the server is 614 included in a certificate and that the certificate is issued by a 615 trusted entity (see for example [RFC2818]). 617 A server MAY request that the client authenticate during the 618 handshake. A server MAY refuse a connection if the client is unable 619 to authenticate when requested. The requirements for client 620 authentication vary based on application protocol and deployment. 622 A server MUST NOT use post-handshake client authentication (see 623 Section 4.6.2 of [TLS13]). 625 4.5. Enabling 0-RTT 627 In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket 628 message that contains the "max_early_data" extension with the value 629 0xffffffff; the amount of data which the client can send in 0-RTT is 630 controlled by the "initial_max_data" transport parameter supplied by 631 the server. A client MUST treat receipt of a NewSessionTicket that 632 contains a "max_early_data" extension with any other value as a 633 connection error of type PROTOCOL_VIOLATION. 635 Early data within the TLS connection MUST NOT be used. As it is for 636 other TLS application data, a server MUST treat receiving early data 637 on the TLS connection as a connection error of type 638 PROTOCOL_VIOLATION. 640 4.6. Rejecting 0-RTT 642 A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This 643 also prevents QUIC from sending 0-RTT data. A server will always 644 reject 0-RTT if it sends a TLS HelloRetryRequest. 646 When 0-RTT is rejected, all connection characteristics that the 647 client assumed might be incorrect. This includes the choice of 648 application protocol, transport parameters, and any application 649 configuration. The client therefore MUST reset the state of all 650 streams, including application state bound to those streams. 652 A client MAY attempt to send 0-RTT again if it receives a Retry or 653 Version Negotiation packet. These packets do not signify rejection 654 of 0-RTT. 656 4.7. HelloRetryRequest 658 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 659 [TLS13]) can be used to correct a client's incorrect KeyShare 660 extension as well as for a stateless round-trip check. From the 661 perspective of QUIC, this just looks like additional messages carried 662 in the Initial encryption level. Although it is in principle 663 possible to use this feature for address verification in QUIC, QUIC 664 implementations SHOULD instead use the Retry feature (see Section 4.4 665 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 666 shares. 668 4.8. TLS Errors 670 If TLS experiences an error, it generates an appropriate alert as 671 defined in Section 6 of [TLS13]. 673 A TLS alert is turned into a QUIC connection error by converting the 674 one-octet alert description into a QUIC error code. The alert 675 description is added to 0x100 to produce a QUIC error code from the 676 range reserved for CRYPTO_ERROR. The resulting value is sent in a 677 QUIC CONNECTION_CLOSE frame. 679 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 680 generate alerts at the "warning" level. 682 4.9. Discarding Unused Keys 684 After QUIC moves to a new encryption level, packet protection keys 685 for previous encryption levels can be discarded. This occurs several 686 times during the handshake, as well as when keys are updated (see 687 Section 6). 689 Packet protection keys are not discarded immediately when new keys 690 are available. If packets from a lower encryption level contain 691 CRYPTO frames, frames that retransmit that data MUST be sent at the 692 same encryption level. Similarly, an endpoint generates 693 acknowledgements for packets at the same encryption level as the 694 packet being acknowledged. Thus, it is possible that keys for a 695 lower encryption level are needed for a short time after keys for a 696 newer encryption level are available. 698 An endpoint cannot discard keys for a given encryption level unless 699 it has both received and acknowledged all CRYPTO frames for that 700 encryption level and when all CRYPTO frames for that encryption level 701 have been acknowledged by its peer. However, this does not guarantee 702 that no further packets will need to be received or sent at that 703 encryption level because a peer might not have received all the 704 acknowledgements necessary to reach the same state. 706 After all CRYPTO frames for a given encryption level have been sent 707 and all expected CRYPTO frames received, and all the corresponding 708 acknowledgments have been received or sent, an endpoint starts a 709 timer. For 0-RTT keys, which do not carry CRYPTO frames, this timer 710 starts when the first packets protected with 1-RTT are sent or 711 received. To limit the effect of packet loss around a change in 712 keys, endpoints MUST retain packet protection keys for that 713 encryption level for at least three times the current Retransmission 714 Timeout (RTO) interval as defined in [QUIC-RECOVERY]. Retaining keys 715 for this interval allows packets containing CRYPTO or ACK frames at 716 that encryption level to be sent if packets are determined to be lost 717 or new packets require acknowledgment. 719 Though an endpoint might retain older keys, new data MUST be sent at 720 the highest currently-available encryption level. Only ACK frames 721 and retransmissions of data in CRYPTO frames are sent at a previous 722 encryption level. These packets MAY also include PADDING frames. 724 Once this timer expires, an endpoint MUST NOT either accept or 725 generate new packets using those packet protection keys. An endpoint 726 can discard packet protection keys for that encryption level. 728 Key updates (see Section 6) can be used to update 1-RTT keys before 729 keys from other encryption levels are discarded. In that case, 730 packets protected with the newest packet protection keys and packets 731 sent two updates prior will appear to use the same keys. After the 732 handshake is complete, endpoints only need to maintain the two latest 733 sets of packet protection keys and MAY discard older keys. Updating 734 keys multiple times rapidly can cause packets to be effectively lost 735 if packets are significantly delayed. Because key updates can only 736 be performed once per round trip time, only packets that are delayed 737 by more than a round trip will be lost as a result of changing keys; 738 such packets will be marked as lost before this, as they leave a gap 739 in the sequence of packet numbers. 741 5. Packet Protection 743 As with TLS over TCP, QUIC protects packets with keys derived from 744 the TLS handshake, using the AEAD algorithm negotiated by TLS. 746 5.1. Packet Protection Keys 748 QUIC derives packet protection keys in the same way that TLS derives 749 record protection keys. 751 Each encryption level has separate secret values for protection of 752 packets sent in each direction. These traffic secrets are derived by 753 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 754 encryption levels except the Initial encryption level. The secrets 755 for the Initial encryption level are computed based on the client's 756 initial Destination Connection ID, as described in Section 5.2. 758 The keys used for packet protection are computed from the TLS secrets 759 using the method described in Section 7.3 of [TLS13]), except that 760 the label for HKDF-Expand-Label uses the prefix "quic " rather than 761 "tls13 ". A different label provides key separation between TLS and 762 QUIC. 764 For example, where TLS might use a label of 765 0x002009746c733133206b657900 to derive a key, QUIC uses 766 0x00200871756963206b657900. 768 The HKDF-Expand-Label function with a "quic " label is also used to 769 derive the initial secrets (see Section 5.2) and to derive a packet 770 number protection key (the "pn" label, see Section 5.4). 772 5.2. Initial Secrets 774 Initial packets are protected with a secret derived from the 775 Destination Connection ID field from the client's first Initial 776 packet of the connection. Specifically: 778 initial_salt = 0x9c108f98520a5c5c32968e950e8a2c5fe06d6c38 779 initial_secret = HKDF-Extract(initial_salt, 780 client_dst_connection_id) 782 client_initial_secret = HKDF-Expand-Label(initial_secret, 783 "client in", "", 784 Hash.length) 785 server_initial_secret = HKDF-Expand-Label(initial_secret, 786 "server in", "", 787 Hash.length) 789 The hash function for HKDF when deriving initial secrets and keys is 790 SHA-256 [SHA]. 792 The connection ID used with HKDF-Expand-Label is the Destination 793 Connection ID in the Initial packet sent by the client. This will be 794 a randomly-selected value unless the client creates the Initial 795 packet after receiving a Retry packet, where the Destination 796 Connection ID is selected by the server. 798 The value of initial_salt is a 20 octet sequence shown in the figure 799 in hexadecimal notation. Future versions of QUIC SHOULD generate a 800 new salt value, thus ensuring that the keys are different for each 801 version of QUIC. This prevents a middlebox that only recognizes one 802 version of QUIC from seeing or modifying the contents of handshake 803 packets from future versions. 805 Note: The Destination Connection ID is of arbitrary length, and it 806 could be zero length if the server sends a Retry packet with a 807 zero-length Source Connection ID field. In this case, the Initial 808 keys provide no assurance to the client that the server received 809 its packet; the client has to rely on the exchange that included 810 the Retry packet for that property. 812 5.3. AEAD Usage 814 The Authentication Encryption with Associated Data (AEAD) [AEAD] 815 function used for QUIC packet protection is the AEAD that is 816 negotiated for use with the TLS connection. For example, if TLS is 817 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 818 used. 820 QUIC packets are protected prior to applying packet number protection 821 (Section 5.4). The unprotected packet number is part of the 822 associated data (A). When removing packet protection, an endpoint 823 first removes the protection from the packet number. 825 All QUIC packets other than Version Negotiation and Retry packets are 826 protected with an AEAD algorithm [AEAD]. Prior to establishing a 827 shared secret, packets are protected with AEAD_AES_128_GCM and a key 828 derived from the destination connection ID in the client's first 829 Initial packet (see Section 5.2). This provides protection against 830 off-path attackers and robustness against QUIC version unaware 831 middleboxes, but not against on-path attackers. 833 All ciphersuites currently defined for TLS 1.3 - and therefore QUIC - 834 have a 16-byte authentication tag and produce an output 16 bytes 835 larger than their input. 837 The key and IV for the packet are computed as described in 838 Section 5.1. The nonce, N, is formed by combining the packet 839 protection IV with the packet number. The 64 bits of the 840 reconstructed QUIC packet number in network byte order are left- 841 padded with zeros to the size of the IV. The exclusive OR of the 842 padded packet number and the IV forms the AEAD nonce. 844 The associated data, A, for the AEAD is the contents of the QUIC 845 header, starting from the flags octet in either the short or long 846 header, up to and including the unprotected packet number. 848 The input plaintext, P, for the AEAD is the content of the QUIC frame 849 following the header, as described in [QUIC-TRANSPORT]. 851 The output ciphertext, C, of the AEAD is transmitted in place of P. 853 Some AEAD functions have limits for how many packets can be encrypted 854 under the same key and IV (see for example [AEBounds]). This might 855 be lower than the packet number limit. An endpoint MUST initiate a 856 key update (Section 6) prior to exceeding any limit set for the AEAD 857 that is in use. 859 5.4. Packet Number Protection 861 QUIC packet numbers are protected using a key that is derived from 862 the current set of secrets. The key derived using the "pn" label is 863 used to protect the packet number from casual observation. The 864 packet number protection algorithm depends on the negotiated AEAD. 866 Packet number protection is applied after packet protection is 867 applied (see Section 5.3). The ciphertext of the packet is sampled 868 and used as input to an encryption algorithm. 870 In sampling the packet ciphertext, the packet number length is 871 assumed to be 4 octets (its maximum possible encoded length), unless 872 there is insufficient space in the packet for sampling. The sampled 873 ciphertext starts after allowing for a 4 octet packet number unless 874 this would cause the sample to extend past the end of the packet. If 875 the sample would extend past the end of the packet, the end of the 876 packet is sampled. 878 For example, the sampled ciphertext for a packet with a short header 879 can be determined by: 881 sample_offset = 1 + len(connection_id) + 4 883 if sample_offset + sample_length > packet_length then 884 sample_offset = packet_length - sample_length 885 sample = packet[sample_offset..sample_offset+sample_length] 887 A packet with a long header is sampled in the same way, noting that 888 multiple QUIC packets might be included in the same UDP datagram and 889 that each one is handled separately. 891 sample_offset = 6 + len(destination_connection_id) + 892 len(source_connection_id) + 893 len(payload_length) + 4 894 if packet_type == Initial: 895 sample_offset += len(token_length) + 896 len(token) 898 To ensure that this process does not sample the packet number, packet 899 number protection algorithms MUST NOT sample more ciphertext than the 900 minimum expansion of the corresponding AEAD. 902 Packet number protection is applied to the packet number encoded as 903 described in Section 4.11 of [QUIC-TRANSPORT]. Since the length of 904 the packet number is stored in the first octet of the encoded packet 905 number, it may be necessary to progressively decrypt the packet 906 number. 908 Before a TLS ciphersuite can be used with QUIC, a packet protection 909 algorithm MUST be specifed for the AEAD used with that ciphersuite. 910 This document defines algorithms for AEAD_AES_128_GCM, 911 AEAD_AES_128_CCM, AEAD_AES_256_GCM, AEAD_AES_256_CCM (all AES AEADs 912 are defined in [AEAD]), and AEAD_CHACHA20_POLY1305 ([CHACHA]). 914 5.4.1. AES-Based Packet Number Protection 916 This section defines the packet protection algorithm for 917 AEAD_AES_128_GCM, AEAD_AES_128_CCM, AEAD_AES_256_GCM, and 918 AEAD_AES_256_CCM. AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit 919 AES [AES] in counter (CTR) mode. AEAD_AES_256_GCM, and 920 AEAD_AES_256_CCM use 256-bit AES in CTR mode. 922 This algorithm samples 16 octets from the packet ciphertext. This 923 value is used as the counter input to AES-CTR. 925 encrypted_pn = AES-CTR(pn_key, sample, packet_number) 927 5.4.2. ChaCha20-Based Packet Number Protection 929 When AEAD_CHACHA20_POLY1305 is in use, packet number protection uses 930 the raw ChaCha20 function as defined in Section 2.4 of [CHACHA]. 931 This uses a 256-bit key and 16 octets sampled from the packet 932 protection output. 934 The first 4 octets of the sampled ciphertext are interpreted as a 935 32-bit number in little-endian order and are used as the block count. 936 The remaining 12 octets are interpreted as three concatenated 32-bit 937 numbers in little-endian order and used as the nonce. 939 The encoded packet number is then encrypted with ChaCha20 directly. 940 In pseudocode: 942 counter = DecodeLE(sample[0..3]) 943 nonce = DecodeLE(sample[4..7], sample[8..11], sample[12..15]) 944 encrypted_pn = ChaCha20(pn_key, counter, nonce, packet_number) 946 5.5. Receiving Protected Packets 948 Once an endpoint successfully receives a packet with a given packet 949 number, it MUST discard all packets in the same packet number space 950 with higher packet numbers if they cannot be successfully unprotected 951 with either the same key, or - if there is a key update - the next 952 packet protection key (see Section 6). Similarly, a packet that 953 appears to trigger a key update, but cannot be unprotected 954 successfully MUST be discarded. 956 Failure to unprotect a packet does not necessarily indicate the 957 existence of a protocol error in a peer or an attack. The truncated 958 packet number encoding used in QUIC can cause packet numbers to be 959 decoded incorrectly if they are delayed significantly. 961 5.6. Use of 0-RTT Keys 963 If 0-RTT keys are available (see Section 4.5), the lack of replay 964 protection means that restrictions on their use are necessary to 965 avoid replay attacks on the protocol. 967 A client MUST only use 0-RTT keys to protect data that is idempotent. 968 A client MAY wish to apply additional restrictions on what data it 969 sends prior to the completion of the TLS handshake. A client 970 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 971 it MUST NOT send ACKs with 0-RTT keys. 973 A client that receives an indication that its 0-RTT data has been 974 accepted by a server can send 0-RTT data until it receives all of the 975 server's handshake messages. A client SHOULD stop sending 0-RTT data 976 if it receives an indication that 0-RTT data has been rejected. 978 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 979 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 980 attempt to decrypt 0-RTT packets it receives and instead MUST discard 981 them. 983 Note: 0-RTT data can be acknowledged by the server as it receives 984 it, but any packets containing acknowledgments of 0-RTT data 985 cannot have packet protection removed by the client until the TLS 986 handshake is complete. The 1-RTT keys necessary to remove packet 987 protection cannot be derived until the client receives all server 988 handshake messages. 990 5.7. Receiving Out-of-Order Protected Frames 992 Due to reordering and loss, protected packets might be received by an 993 endpoint before the final TLS handshake messages are received. A 994 client will be unable to decrypt 1-RTT packets from the server, 995 whereas a server will be able to decrypt 1-RTT packets from the 996 client. 998 However, a server MUST NOT process data from incoming 1-RTT protected 999 packets before verifying either the client Finished message or - in 1000 the case that the server has chosen to use a pre-shared key - the 1001 pre-shared key binder (see Section 4.2.11 of [TLS13]). Verifying 1002 these values provides the server with an assurance that the 1003 ClientHello has not been modified. Packets protected with 1-RTT keys 1004 MAY be stored and later decrypted and used once the handshake is 1005 complete. 1007 A server could receive packets protected with 0-RTT keys prior to 1008 receiving a TLS ClientHello. The server MAY retain these packets for 1009 later decryption in anticipation of receiving a ClientHello. 1011 6. Key Update 1013 Once the 1-RTT keys are established and the short header is in use, 1014 it is possible to update the keys. The KEY_PHASE bit in the short 1015 header is used to indicate whether key updates have occurred. The 1016 KEY_PHASE bit is initially set to 0 and then inverted with each key 1017 update. 1019 The KEY_PHASE bit allows a recipient to detect a change in keying 1020 material without necessarily needing to receive the first packet that 1021 triggered the change. An endpoint that notices a changed KEY_PHASE 1022 bit can update keys and decrypt the packet that contains the changed 1023 bit. 1025 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1026 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1027 of a TLS KeyUpdate message as a connection error of type 0x10a, 1028 equivalent to a fatal TLS alert of unexpected_message (see 1029 Section 4.8). 1031 An endpoint MUST NOT initiate more than one key update at a time. A 1032 new key cannot be used until the endpoint has received and 1033 successfully decrypted a packet with a matching KEY_PHASE. 1035 A receiving endpoint detects an update when the KEY_PHASE bit does 1036 not match what it is expecting. It creates a new secret (see 1037 Section 7.2 of [TLS13]) and the corresponding read key and IV using 1038 the same variation on HKDF as defined in Section 5.1; that is, the 1039 prefix "quic " is used in place of "tls13 ". 1041 If the packet can be decrypted and authenticated using the updated 1042 key and IV, then the keys the endpoint uses for packet protection are 1043 also updated. The next packet sent by the endpoint will then use the 1044 new keys. 1046 An endpoint does not always need to send packets when it detects that 1047 its peer has updated keys. The next packet that it sends will simply 1048 use the new keys. If an endpoint detects a second update before it 1049 has sent any packets with updated keys, it indicates that its peer 1050 has updated keys twice without awaiting a reciprocal update. An 1051 endpoint MUST treat consecutive key updates as a fatal error and 1052 abort the connection. 1054 An endpoint SHOULD retain old keys for a short period to allow it to 1055 decrypt packets with smaller packet numbers than the packet that 1056 triggered the key update. This allows an endpoint to consume packets 1057 that are reordered around the transition between keys. Packets with 1058 higher packet numbers always use the updated keys and MUST NOT be 1059 decrypted with old keys. 1061 Keys and their corresponding secrets SHOULD be discarded when an 1062 endpoint has received all packets with packet numbers lower than the 1063 lowest packet number used for the new key. An endpoint might discard 1064 keys if it determines that the length of the delay to affected 1065 packets is excessive. 1067 This ensures that once the handshake is complete, packets with the 1068 same KEY_PHASE will have the same packet protection keys, unless 1069 there are multiple key updates in a short time frame succession and 1070 significant packet reordering. 1072 Initiating Peer Responding Peer 1074 @M QUIC Frames 1075 New Keys -> @N 1076 @N QUIC Frames 1077 --------> 1078 QUIC Frames @M 1079 New Keys -> @N 1080 QUIC Frames @N 1081 <-------- 1083 Figure 4: Key Update 1085 A packet that triggers a key update could arrive after successfully 1086 processing a packet with a higher packet number. This is only 1087 possible if there is a key compromise and an attack, or if the peer 1088 is incorrectly reverting to use of old keys. Because the latter 1089 cannot be differentiated from an attack, an endpoint MUST immediately 1090 terminate the connection if it detects this condition. 1092 7. Security of Initial Messages 1094 Initial packets are not protected with a secret key, so they are 1095 subject to potential tampering by an attacker. QUIC provides 1096 protection against attackers that cannot read packets, but does not 1097 attempt to provide additional protection against attacks where the 1098 attacker can observe and inject packets. Some forms of tampering - 1099 such as modifying the TLS messages themselves - are detectable, but 1100 some - such as modifying ACKs - are not. 1102 For example, an attacker could inject a packet containing an ACK 1103 frame that makes it appear that a packet had not been received or to 1104 create a false impression of the state of the connection (e.g., by 1105 modifying the ACK Delay). Note that such a packet could cause a 1106 legitimate packet to be dropped as a duplicate. Implementations 1107 SHOULD use caution in relying on any data which is contained in 1108 Initial packets that is not otherwise authenticated. 1110 It is also possible for the attacker to tamper with data that is 1111 carried in Handshake packets, but because that tampering requires 1112 modifying TLS handshake messages, that tampering will cause the TLS 1113 handshake to fail. 1115 8. QUIC-Specific Additions to the TLS Handshake 1117 QUIC uses the TLS handshake for more than just negotiation of 1118 cryptographic parameters. The TLS handshake validates protocol 1119 version selection, provides preliminary values for QUIC transport 1120 parameters, and allows a server to perform return routeability checks 1121 on clients. 1123 8.1. Protocol and Version Negotiation 1125 The QUIC version negotiation mechanism is used to negotiate the 1126 version of QUIC that is used prior to the completion of the 1127 handshake. However, this packet is not authenticated, enabling an 1128 active attacker to force a version downgrade. 1130 To ensure that a QUIC version downgrade is not forced by an attacker, 1131 version information is copied into the TLS handshake, which provides 1132 integrity protection for the QUIC negotiation. This does not prevent 1133 version downgrade prior to the completion of the handshake, though it 1134 means that a downgrade causes a handshake failure. 1136 TLS uses Application Layer Protocol Negotiation (ALPN) [RFC7301] to 1137 select an application protocol. The application-layer protocol MAY 1138 restrict the QUIC versions that it can operate over. Servers MUST 1139 select an application protocol compatible with the QUIC version that 1140 the client has selected. 1142 If the server cannot select a compatible combination of application 1143 protocol and QUIC version, it MUST abort the connection. A client 1144 MUST abort a connection if the server picks an incompatible 1145 combination of QUIC version and ALPN identifier. 1147 8.2. QUIC Transport Parameters Extension 1149 QUIC transport parameters are carried in a TLS extension. Different 1150 versions of QUIC might define a different format for this struct. 1152 Including transport parameters in the TLS handshake provides 1153 integrity protection for these values. 1155 enum { 1156 quic_transport_parameters(0xffa5), (65535) 1157 } ExtensionType; 1159 The "extension_data" field of the quic_transport_parameters extension 1160 contains a value that is defined by the version of QUIC that is in 1161 use. The quic_transport_parameters extension carries a 1162 TransportParameters when the version of QUIC defined in 1163 [QUIC-TRANSPORT] is used. 1165 The quic_transport_parameters extension is carried in the ClientHello 1166 and the EncryptedExtensions messages during the handshake. 1168 While the transport parameters are technically available prior to the 1169 completion of the handshake, they cannot be fully trusted until the 1170 handshake completes, and reliance on them should be minimized. 1171 However, any tampering with the parameters will cause the handshake 1172 to fail. 1174 Endpoints MUST NOT send this extension in a TLS connection that does 1175 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1176 fatal unsupported_extension alert MUST be sent if this extension is 1177 received when the transport is not QUIC. 1179 8.3. Removing the EndOfEarlyData Message 1181 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1182 rely on this message to mark the end of 0-RTT data or to signal the 1183 change to Handshake keys. 1185 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1186 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1187 error of type PROTOCOL_VIOLATION. 1189 As a result, EndOfEarlyData does not appear in the TLS handshake 1190 transcript. 1192 9. Security Considerations 1194 There are likely to be some real clangers here eventually, but the 1195 current set of issues is well captured in the relevant sections of 1196 the main text. 1198 Never assume that because it isn't in the security considerations 1199 section it doesn't affect security. Most of this document does. 1201 9.1. Packet Reflection Attack Mitigation 1203 A small ClientHello that results in a large block of handshake 1204 messages from a server can be used in packet reflection attacks to 1205 amplify the traffic generated by an attacker. 1207 QUIC includes three defenses against this attack. First, the packet 1208 containing a ClientHello MUST be padded to a minimum size. Second, 1209 if responding to an unverified source address, the server is 1210 forbidden to send more than three UDP datagrams in its first flight 1211 (see Section 4.7 of [QUIC-TRANSPORT]). Finally, because 1212 acknowledgements of Handshake packets are authenticated, a blind 1213 attacker cannot forge them. Put together, these defenses limit the 1214 level of amplification. 1216 9.2. Peer Denial of Service 1218 QUIC, TLS, and HTTP/2 all contain messages that have legitimate uses 1219 in some contexts, but that can be abused to cause a peer to expend 1220 processing resources without having any observable impact on the 1221 state of the connection. If processing is disproportionately large 1222 in comparison to the observable effects on bandwidth or state, then 1223 this could allow a malicious peer to exhaust processing capacity 1224 without consequence. 1226 QUIC prohibits the sending of empty "STREAM" frames unless they are 1227 marked with the FIN bit. This prevents "STREAM" frames from being 1228 sent that only waste effort. 1230 While there are legitimate uses for some redundant packets, 1231 implementations SHOULD track redundant packets and treat excessive 1232 volumes of any non-productive packets as indicative of an attack. 1234 9.3. Packet Number Protection Analysis 1236 Packet number protection relies on the packet protection AEAD being a 1237 pseudorandom function (PRF), which is not a property that AEAD 1238 algorithms guarantee. Therefore, no strong assurances about the 1239 general security of this mechanism can be shown in the general case. 1241 The AEAD algorithms described in this document are assumed to be 1242 PRFs. 1244 The packet number protection algorithms defined in this document take 1245 the form: 1247 encrypted_pn = packet_number XOR PRF(pn_key, sample) 1249 This construction is secure against chosen plaintext attacks (IND- 1250 CPA) [IMC]. 1252 Use of the same key and ciphertext sample more than once risks 1253 compromising packet number protection. Protecting two different 1254 packet numbers with the same key and ciphertext sample reveals the 1255 exclusive OR of those packet numbers. Assuming that the AEAD acts as 1256 a PRF, if L bits are sampled, the odds of two ciphertext samples 1257 being identical approach 2^(-L/2), that is, the birthday bound. For 1258 the algorithms described in this document, that probability is one in 1259 2^64. 1261 Note: In some cases, inputs shorter than the full size required by 1262 the packet protection algorithm might be used. 1264 To prevent an attacker from modifying packet numbers, values of 1265 packet numbers are transitively authenticated using packet 1266 protection; packet numbers are part of the authenticated additional 1267 data. A falsified or modified packet number can only be detected 1268 once the packet protection is removed. 1270 An attacker can guess values for packet numbers and have an endpoint 1271 confirm guesses through timing side channels. If the recipient of a 1272 packet discards packets with duplicate packet numbers without 1273 attempting to remove packet protection they could reveal through 1274 timing side-channels that the packet number matches a received 1275 packet. For authentication to be free from side-channels, the entire 1276 process of packet number protection removal, packet number recovery, 1277 and packet protection removal MUST be applied together without timing 1278 and other side-channels. 1280 For the sending of packets, construction and protection of packet 1281 payloads and packet numbers MUST be free from side-channels that 1282 would reveal the packet number or its encoded size. 1284 10. IANA Considerations 1286 This document does not create any new IANA registries, but it 1287 registers the values in the following registries: 1289 o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register 1290 the quic_transport_parameters extension found in Section 8.2. The 1291 Recommended column is to be marked Yes. The TLS 1.3 Column is to 1292 include CH and EE. 1294 11. References 1296 11.1. Normative References 1298 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1299 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1300 . 1302 [AES] "Advanced encryption standard (AES)", National Institute 1303 of Standards and Technology report, 1304 DOI 10.6028/nist.fips.197, November 2001. 1306 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1307 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1308 . 1310 [QUIC-RECOVERY] 1311 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1312 and Congestion Control", draft-ietf-quic-recovery-16 (work 1313 in progress), October 2018. 1315 [QUIC-TRANSPORT] 1316 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1317 Multiplexed and Secure Transport", draft-ietf-quic- 1318 transport-16 (work in progress), October 2018. 1320 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1321 Requirement Levels", BCP 14, RFC 2119, 1322 DOI 10.17487/RFC2119, March 1997, 1323 . 1325 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1326 "Transport Layer Security (TLS) Application-Layer Protocol 1327 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1328 July 2014, . 1330 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1331 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1332 May 2017, . 1334 [SHA] Dang, Q., "Secure Hash Standard", National Institute of 1335 Standards and Technology report, 1336 DOI 10.6028/nist.fips.180-4, July 2015. 1338 [TLS-REGISTRIES] 1339 Salowey, J. and S. Turner, "IANA Registry Updates for 1340 Transport Layer Security (TLS) and Datagram Transport 1341 Layer Security (DTLS)", draft-ietf-tls-iana-registry- 1342 updates-05 (work in progress), May 2018. 1344 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1345 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1346 . 1348 11.2. Informative References 1350 [AEBounds] 1351 Luykx, A. and K. Paterson, "Limits on Authenticated 1352 Encryption Use in TLS", March 2016, 1353 . 1355 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1356 Cryptography, Second Edition", ISBN 978-1466570269, 1357 November 2014. 1359 [QUIC-HTTP] 1360 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1361 QUIC", draft-ietf-quic-http-16 (work in progress), October 1362 2018. 1364 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1365 DOI 10.17487/RFC2818, May 2000, 1366 . 1368 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1369 Housley, R., and W. Polk, "Internet X.509 Public Key 1370 Infrastructure Certificate and Certificate Revocation List 1371 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1372 . 1374 11.3. URIs 1376 [1] https://mailarchive.ietf.org/arch/search/?email_list=quic 1378 [2] https://github.com/quicwg 1380 [3] https://github.com/quicwg/base-drafts/labels/-tls 1382 Appendix A. Change Log 1384 *RFC Editor's Note:* Please remove this section prior to 1385 publication of a final version of this document. 1387 Issue and pull request numbers are listed with a leading octothorp. 1389 A.1. Since draft-ietf-quic-tls-13 1391 o Updated to TLS 1.3 final (#1660) 1393 A.2. Since draft-ietf-quic-tls-12 1395 o Changes to integration of the TLS handshake (#829, #1018, #1094, 1396 #1165, #1190, #1233, #1242, #1252, #1450) 1398 * The cryptographic handshake uses CRYPTO frames, not stream 0 1400 * QUIC packet protection is used in place of TLS record 1401 protection 1403 * Separate QUIC packet number spaces are used for the handshake 1405 * Changed Retry to be independent of the cryptographic handshake 1407 * Limit the use of HelloRetryRequest to address TLS needs (like 1408 key shares) 1410 o Changed codepoint of TLS extension (#1395, #1402) 1412 A.3. Since draft-ietf-quic-tls-11 1414 o Encrypted packet numbers. 1416 A.4. Since draft-ietf-quic-tls-10 1418 o No significant changes. 1420 A.5. Since draft-ietf-quic-tls-09 1422 o Cleaned up key schedule and updated the salt used for handshake 1423 packet protection (#1077) 1425 A.6. Since draft-ietf-quic-tls-08 1427 o Specify value for max_early_data_size to enable 0-RTT (#942) 1429 o Update key derivation function (#1003, #1004) 1431 A.7. Since draft-ietf-quic-tls-07 1433 o Handshake errors can be reported with CONNECTION_CLOSE (#608, 1434 #891) 1436 A.8. Since draft-ietf-quic-tls-05 1438 No significant changes. 1440 A.9. Since draft-ietf-quic-tls-04 1442 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 1444 A.10. Since draft-ietf-quic-tls-03 1446 No significant changes. 1448 A.11. Since draft-ietf-quic-tls-02 1450 o Updates to match changes in transport draft 1452 A.12. Since draft-ietf-quic-tls-01 1454 o Use TLS alerts to signal TLS errors (#272, #374) 1456 o Require ClientHello to fit in a single packet (#338) 1458 o The second client handshake flight is now sent in the clear (#262, 1459 #337) 1461 o The QUIC header is included as AEAD Associated Data (#226, #243, 1462 #302) 1464 o Add interface necessary for client address validation (#275) 1466 o Define peer authentication (#140) 1468 o Require at least TLS 1.3 (#138) 1470 o Define transport parameters as a TLS extension (#122) 1472 o Define handling for protected packets before the handshake 1473 completes (#39) 1475 o Decouple QUIC version and ALPN (#12) 1477 A.13. Since draft-ietf-quic-tls-00 1479 o Changed bit used to signal key phase 1481 o Updated key phase markings during the handshake 1483 o Added TLS interface requirements section 1485 o Moved to use of TLS exporters for key derivation 1487 o Moved TLS error code definitions into this document 1489 A.14. Since draft-thomson-quic-tls-01 1491 o Adopted as base for draft-ietf-quic-tls 1493 o Updated authors/editors list 1495 o Added status note 1497 Acknowledgments 1499 This document has benefited from input from Dragana Damjanovic, 1500 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1501 Rescorla, Ian Swett, and many others. 1503 Contributors 1505 Ryan Hamilton was originally an author of this specification. 1507 Authors' Addresses 1509 Martin Thomson (editor) 1510 Mozilla 1512 Email: martin.thomson@gmail.com 1514 Sean Turner (editor) 1515 sn3rd 1517 Email: sean@sn3rd.com