idnits 2.17.1 draft-ietf-quic-tls-19.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 (March 11, 2019) is 1866 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 1591 -- Looks like a reference, but probably isn't: '2' on line 1593 -- Looks like a reference, but probably isn't: '3' on line 1595 -- Looks like a reference, but probably isn't: '0' on line 1685 == Unused Reference: 'QUIC-HTTP' is defined on line 1574, 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-19 == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-19 -- Possible downref: Non-RFC (?) normative reference: ref. 'SHA' == Outdated reference: A later version (-34) exists of draft-ietf-quic-http-19 -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) Summary: 2 errors (**), 0 flaws (~~), 6 warnings (==), 9 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: September 12, 2019 sn3rd 6 March 11, 2019 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-19 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 September 12, 2019. 43 Copyright Notice 45 Copyright (c) 2019 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 . . . . . . . . . . . . . . . . . . . 4 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 . . . . . . . . . . . . . . . . 12 69 4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 13 70 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 14 71 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 14 72 4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 15 73 4.6. Rejecting 0-RTT . . . . . . . . . . . . . . . . . . . . . 15 74 4.7. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 15 75 4.8. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 16 76 4.9. Discarding Unused Keys . . . . . . . . . . . . . . . . . 16 77 4.10. Discarding Initial Keys . . . . . . . . . . . . . . . . . 17 78 5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 18 79 5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 18 80 5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 18 81 5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 19 82 5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 20 83 5.4.1. Header Protection Application . . . . . . . . . . . . 21 84 5.4.2. Header Protection Sample . . . . . . . . . . . . . . 22 85 5.4.3. AES-Based Header Protection . . . . . . . . . . . . . 23 86 5.4.4. ChaCha20-Based Header Protection . . . . . . . . . . 24 87 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 24 88 5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 24 89 5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 25 90 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 25 91 7. Security of Initial Messages . . . . . . . . . . . . . . . . 27 92 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 28 93 8.1. Protocol and Version Negotiation . . . . . . . . . . . . 28 94 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 28 95 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 29 97 9. Security Considerations . . . . . . . . . . . . . . . . . . . 29 98 9.1. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 29 99 9.2. Packet Reflection Attack Mitigation . . . . . . . . . . . 30 100 9.3. Peer Denial of Service . . . . . . . . . . . . . . . . . 31 101 9.4. Header Protection Analysis . . . . . . . . . . . . . . . 31 102 9.5. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 32 103 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 33 104 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 33 105 11.1. Normative References . . . . . . . . . . . . . . . . . . 33 106 11.2. Informative References . . . . . . . . . . . . . . . . . 34 107 11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 35 108 Appendix A. Sample Initial Packet Protection . . . . . . . . . . 35 109 A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 35 110 A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 36 111 A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 38 112 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 39 113 B.1. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 39 114 B.2. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 39 115 B.3. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 39 116 B.4. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 40 117 B.5. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 40 118 B.6. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 40 119 B.7. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 40 120 B.8. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 41 121 B.9. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 41 122 B.10. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 41 123 B.11. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 41 124 B.12. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 41 125 B.13. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 41 126 B.14. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 41 127 B.15. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 41 128 B.16. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 42 129 B.17. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 42 130 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 42 131 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 42 132 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 42 134 1. Introduction 136 This document describes how QUIC [QUIC-TRANSPORT] is secured using 137 TLS [TLS13]. 139 TLS 1.3 provides critical latency improvements for connection 140 establishment over previous versions. Absent packet loss, most new 141 connections can be established and secured within a single round 142 trip; on subsequent connections between the same client and server, 143 the client can often send application data immediately, that is, 144 using a zero round trip setup. 146 This document describes how TLS acts as a security component of QUIC. 148 2. Notational Conventions 150 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 151 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 152 "OPTIONAL" in this document are to be interpreted as described in BCP 153 14 [RFC2119] [RFC8174] when, and only when, they appear in all 154 capitals, as shown here. 156 This document uses the terminology established in [QUIC-TRANSPORT]. 158 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 159 newer version could be used (see Section 4.2). 161 2.1. TLS Overview 163 TLS provides two endpoints with a way to establish a means of 164 communication over an untrusted medium (that is, the Internet) that 165 ensures that messages they exchange cannot be observed, modified, or 166 forged. 168 Internally, TLS is a layered protocol, with the structure shown 169 below: 171 +--------------+--------------+--------------+ 172 | Handshake | Alerts | Application | 173 | Layer | | Data | 174 | | | | 175 +--------------+--------------+--------------+ 176 | | 177 | Record Layer | 178 | | 179 +--------------------------------------------+ 181 Each upper layer (handshake, alerts, and application data) is carried 182 as a series of typed TLS records. Records are individually 183 cryptographically protected and then transmitted over a reliable 184 transport (typically TCP) which provides sequencing and guaranteed 185 delivery. 187 Change Cipher Spec records cannot be sent in QUIC. 189 The TLS authenticated key exchange occurs between two entities: 190 client and server. The client initiates the exchange and the server 191 responds. If the key exchange completes successfully, both client 192 and server will agree on a secret. TLS supports both pre-shared key 193 (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for 194 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 195 keys are destroyed. 197 After completing the TLS handshake, the client will have learned and 198 authenticated an identity for the server and the server is optionally 199 able to learn and authenticate an identity for the client. TLS 200 supports X.509 [RFC5280] certificate-based authentication for both 201 server and client. 203 The TLS key exchange is resistant to tampering by attackers and it 204 produces shared secrets that cannot be controlled by either 205 participating peer. 207 TLS provides two basic handshake modes of interest to QUIC: 209 o A full 1-RTT handshake in which the client is able to send 210 application data after one round trip and the server immediately 211 responds after receiving the first handshake message from the 212 client. 214 o A 0-RTT handshake in which the client uses information it has 215 previously learned about the server to send application data 216 immediately. This application data can be replayed by an attacker 217 so it MUST NOT carry a self-contained trigger for any non- 218 idempotent action. 220 A simplified TLS handshake with 0-RTT application data is shown in 221 Figure 1. Note that this omits the EndOfEarlyData message, which is 222 not used in QUIC (see Section 8.3). 224 Client Server 226 ClientHello 227 (0-RTT Application Data) --------> 228 ServerHello 229 {EncryptedExtensions} 230 {Finished} 231 <-------- [Application Data] 232 {Finished} --------> 234 [Application Data] <-------> [Application Data] 236 () Indicates messages protected by early data (0-RTT) keys 237 {} Indicates messages protected using handshake keys 238 [] Indicates messages protected using application data 239 (1-RTT) keys 241 Figure 1: TLS Handshake with 0-RTT 243 Data is protected using a number of encryption levels: 245 o Initial Keys 247 o Early Data (0-RTT) Keys 249 o Handshake Keys 251 o Application Data (1-RTT) Keys 253 Application data may appear only in the early data and application 254 data levels. Handshake and Alert messages may appear in any level. 256 The 0-RTT handshake is only possible if the client and server have 257 previously communicated. In the 1-RTT handshake, the client is 258 unable to send protected application data until it has received all 259 of the handshake messages sent by the server. 261 3. Protocol Overview 263 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 264 and integrity protection of packets. For this it uses keys derived 265 from a TLS handshake [TLS13], but instead of carrying TLS records 266 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 267 directly over the QUIC transport, which takes over the 268 responsibilities of the TLS record layer, as shown below. 270 +--------------+--------------+ +-------------+ 271 | TLS | TLS | | QUIC | 272 | Handshake | Alerts | | Applications| 273 | | | | (h3, etc.) | 274 +--------------+--------------+-+-------------+ 275 | | 276 | QUIC Transport | 277 | (streams, reliability, congestion, etc.) | 278 | | 279 +---------------------------------------------+ 280 | | 281 | QUIC Packet Protection | 282 | | 283 +---------------------------------------------+ 285 QUIC also relies on TLS for authentication and negotiation of 286 parameters that are critical to security and performance. 288 Rather than a strict layering, these two protocols are co-dependent: 289 QUIC uses the TLS handshake; TLS uses the reliability, ordered 290 delivery, and record layer provided by QUIC. 292 At a high level, there are two main interactions between the TLS and 293 QUIC components: 295 o The TLS component sends and receives messages via the QUIC 296 component, with QUIC providing a reliable stream abstraction to 297 TLS. 299 o The TLS component provides a series of updates to the QUIC 300 component, including (a) new packet protection keys to install (b) 301 state changes such as handshake completion, the server 302 certificate, etc. 304 Figure 2 shows these interactions in more detail, with the QUIC 305 packet protection being called out specially. 307 +------------+ +------------+ 308 | |<- Handshake Messages ->| | 309 | |<---- 0-RTT Keys -------| | 310 | |<--- Handshake Keys-----| | 311 | QUIC |<---- 1-RTT Keys -------| TLS | 312 | |<--- Handshake Done ----| | 313 +------------+ +------------+ 314 | ^ 315 | Protect | Protected 316 v | Packet 317 +------------+ 318 | QUIC | 319 | Packet | 320 | Protection | 321 +------------+ 323 Figure 2: QUIC and TLS Interactions 325 Unlike TLS over TCP, QUIC applications which want to send data do not 326 send it through TLS "application_data" records. Rather, they send it 327 as QUIC STREAM frames which are then carried in QUIC packets. 329 4. Carrying TLS Messages 331 QUIC carries TLS handshake data in CRYPTO frames, each of which 332 consists of a contiguous block of handshake data identified by an 333 offset and length. Those frames are packaged into QUIC packets and 334 encrypted under the current TLS encryption level. As with TLS over 335 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 336 responsibility to deliver it reliably. Each chunk of data that is 337 produced by TLS is associated with the set of keys that TLS is 338 currently using. If QUIC needs to retransmit that data, it MUST use 339 the same keys even if TLS has already updated to newer keys. 341 One important difference between TLS records (used with TCP) and QUIC 342 CRYPTO frames is that in QUIC multiple frames may appear in the same 343 QUIC packet as long as they are associated with the same encryption 344 level. For instance, an implementation might bundle a Handshake 345 message and an ACK for some Handshake data into the same packet. 347 Some frames are prohibited in different encryption levels, others 348 cannot be sent. The rules here generalize those of TLS, in that 349 frames associated with establishing the connection can usually appear 350 at any encryption level, whereas those associated with transferring 351 data can only appear in the 0-RTT and 1-RTT encryption levels: 353 o PADDING frames MAY appear in packets of any encryption level. 355 o CRYPTO and CONNECTION_CLOSE frames MAY appear in packets of any 356 encryption level except 0-RTT. 358 o ACK frames MAY appear in packets of any encryption level other 359 than 0-RTT, but can only acknowledge packets which appeared in 360 that packet number space. 362 o All other frame types MUST only be sent in the 0-RTT and 1-RTT 363 levels. 365 Note that it is not possible to send the following frames in 0-RTT 366 for various reasons: ACK, CRYPTO, NEW_TOKEN, PATH_RESPONSE, and 367 RETIRE_CONNECTION_ID. 369 Because packets could be reordered on the wire, QUIC uses the packet 370 type to indicate which level a given packet was encrypted under, as 371 shown in Table 1. When multiple packets of different encryption 372 levels need to be sent, endpoints SHOULD use coalesced packets to 373 send them in the same UDP datagram. 375 +-----------------+------------------+-----------+ 376 | Packet Type | Encryption Level | PN Space | 377 +-----------------+------------------+-----------+ 378 | Initial | Initial secrets | Initial | 379 | | | | 380 | 0-RTT Protected | 0-RTT | 0/1-RTT | 381 | | | | 382 | Handshake | Handshake | Handshake | 383 | | | | 384 | Retry | N/A | N/A | 385 | | | | 386 | Short Header | 1-RTT | 0/1-RTT | 387 +-----------------+------------------+-----------+ 389 Table 1: Encryption Levels by Packet Type 391 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 392 encryption levels fit into the handshake process. 394 4.1. Interface to TLS 396 As shown in Figure 2, the interface from QUIC to TLS consists of 397 three primary functions: 399 o Sending and receiving handshake messages 401 o Rekeying (both transmit and receive) 403 o Handshake state updates 405 Additional functions might be needed to configure TLS. 407 4.1.1. Sending and Receiving Handshake Messages 409 In order to drive the handshake, TLS depends on being able to send 410 and receive handshake messages. There are two basic functions on 411 this interface: one where QUIC requests handshake messages and one 412 where QUIC provides handshake packets. 414 Before starting the handshake QUIC provides TLS with the transport 415 parameters (see Section 8.2) that it wishes to carry. 417 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 418 The client acquires handshake bytes before sending its first packet. 419 A QUIC server starts the process by providing TLS with the client's 420 handshake bytes. 422 At any given time, the TLS stack at an endpoint will have a current 423 sending encryption level and receiving encryption level. Each 424 encryption level is associated with a different flow of bytes, which 425 is reliably transmitted to the peer in CRYPTO frames. When TLS 426 provides handshake bytes to be sent, they are appended to the current 427 flow and any packet that includes the CRYPTO frame is protected using 428 keys from the corresponding encryption level. 430 QUIC takes the unprotected content of TLS handshake records as the 431 content of CRYPTO frames. TLS record protection is not used by QUIC. 432 QUIC assembles CRYPTO frames into QUIC packets, which are protected 433 using QUIC packet protection. 435 When an endpoint receives a QUIC packet containing a CRYPTO frame 436 from the network, it proceeds as follows: 438 o If the packet was in the TLS receiving encryption level, sequence 439 the data into the input flow as usual. As with STREAM frames, the 440 offset is used to find the proper location in the data sequence. 441 If the result of this process is that new data is available, then 442 it is delivered to TLS in order. 444 o If the packet is from a previously installed encryption level, it 445 MUST not contain data which extends past the end of previously 446 received data in that flow. Implementations MUST treat any 447 violations of this requirement as a connection error of type 448 PROTOCOL_VIOLATION. 450 o If the packet is from a new encryption level, it is saved for 451 later processing by TLS. Once TLS moves to receiving from this 452 encryption level, saved data can be provided. When providing data 453 from any new encryption level to TLS, if there is data from a 454 previous encryption level that TLS has not consumed, this MUST be 455 treated as a connection error of type PROTOCOL_VIOLATION. 457 Each time that TLS is provided with new data, new handshake bytes are 458 requested from TLS. TLS might not provide any bytes if the handshake 459 messages it has received are incomplete or it has no data to send. 461 Once the TLS handshake is complete, this is indicated to QUIC along 462 with any final handshake bytes that TLS needs to send. TLS also 463 provides QUIC with the transport parameters that the peer advertised 464 during the handshake. 466 Once the handshake is complete, TLS becomes passive. TLS can still 467 receive data from its peer and respond in kind, but it will not need 468 to send more data unless specifically requested - either by an 469 application or QUIC. One reason to send data is that the server 470 might wish to provide additional or updated session tickets to a 471 client. 473 When the handshake is complete, QUIC only needs to provide TLS with 474 any data that arrives in CRYPTO streams. In the same way that is 475 done during the handshake, new data is requested from TLS after 476 providing received data. 478 Important: Until the handshake is reported as complete, the 479 connection and key exchange are not properly authenticated at the 480 server. Even though 1-RTT keys are available to a server after 481 receiving the first handshake messages from a client, the server 482 cannot consider the client to be authenticated until it receives 483 and validates the client's Finished message. 485 The requirement for the server to wait for the client Finished 486 message creates a dependency on that message being delivered. A 487 client can avoid the potential for head-of-line blocking that this 488 implies by sending a copy of the CRYPTO frame that carries the 489 Finished message in multiple packets. This enables immediate 490 server processing for those packets. 492 4.1.2. Encryption Level Changes 494 As keys for new encryption levels become available, TLS provides QUIC 495 with those keys. Separately, as TLS starts using keys at a given 496 encryption level, TLS indicates to QUIC that it is now reading or 497 writing with keys at that encryption level. These events are not 498 asynchronous; they always occur immediately after TLS is provided 499 with new handshake bytes, or after TLS produces handshake bytes. 501 TLS provides QUIC with three items as a new encryption level becomes 502 available: 504 o A secret 506 o An Authenticated Encryption with Associated Data (AEAD) function 508 o A Key Derivation Function (KDF) 510 These values are based on the values that TLS negotiates and are used 511 by QUIC to generate packet and header protection keys (see Section 5 512 and Section 5.4). 514 If 0-RTT is possible, it is ready after the client sends a TLS 515 ClientHello message or the server receives that message. After 516 providing a QUIC client with the first handshake bytes, the TLS stack 517 might signal the change to 0-RTT keys. On the server, after 518 receiving handshake bytes that contain a ClientHello message, a TLS 519 server might signal that 0-RTT keys are available. 521 Although TLS only uses one encryption level at a time, QUIC may use 522 more than one level. For instance, after sending its Finished 523 message (using a CRYPTO frame at the Handshake encryption level) an 524 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 525 message is lost, the endpoint uses the Handshake encryption level to 526 retransmit the lost message. Reordering or loss of packets can mean 527 that QUIC will need to handle packets at multiple encryption levels. 528 During the handshake, this means potentially handling packets at 529 higher and lower encryption levels than the current encryption level 530 used by TLS. 532 In particular, server implementations need to be able to read packets 533 at the Handshake encryption level at the same time as the 0-RTT 534 encryption level. A client could interleave ACK frames that are 535 protected with Handshake keys with 0-RTT data and the server needs to 536 process those acknowledgments in order to detect lost Handshake 537 packets. 539 4.1.3. TLS Interface Summary 541 Figure 3 summarizes the exchange between QUIC and TLS for both client 542 and server. Each arrow is tagged with the encryption level used for 543 that transmission. 545 Client Server 547 Get Handshake 548 Initial -------------> 549 Rekey tx to 0-RTT Keys 550 0-RTT ---------------> 551 Handshake Received 552 Get Handshake 553 <------------- Initial 554 Rekey rx to 0-RTT keys 555 Handshake Received 556 Rekey rx to Handshake keys 557 Get Handshake 558 <----------- Handshake 559 Rekey tx to 1-RTT keys 560 <--------------- 1-RTT 561 Handshake Received 562 Rekey rx to Handshake keys 563 Handshake Received 564 Get Handshake 565 Handshake Complete 566 Handshake -----------> 567 Rekey tx to 1-RTT keys 568 1-RTT ---------------> 569 Handshake Received 570 Rekey rx to 1-RTT keys 571 Get Handshake 572 Handshake Complete 573 <--------------- 1-RTT 574 Handshake Received 576 Figure 3: Interaction Summary between QUIC and TLS 578 4.2. TLS Version 580 This document describes how TLS 1.3 [TLS13] is used with QUIC. 582 In practice, the TLS handshake will negotiate a version of TLS to 583 use. This could result in a newer version of TLS than 1.3 being 584 negotiated if both endpoints support that version. This is 585 acceptable provided that the features of TLS 1.3 that are used by 586 QUIC are supported by the newer version. 588 A badly configured TLS implementation could negotiate TLS 1.2 or 589 another older version of TLS. An endpoint MUST terminate the 590 connection if a version of TLS older than 1.3 is negotiated. 592 4.3. ClientHello Size 594 QUIC requires that the first Initial packet from a client contain an 595 entire cryptographic handshake message, which for TLS is the 596 ClientHello. Though a packet larger than 1200 bytes might be 597 supported by the path, a client improves the likelihood that a packet 598 is accepted if it ensures that the first ClientHello message is small 599 enough to stay within this limit. 601 QUIC packet and framing add at least 36 bytes of overhead to the 602 ClientHello message. That overhead increases if the client chooses a 603 connection ID without zero length. Overheads also do not include the 604 token or a connection ID longer than 8 bytes, both of which might be 605 required if a server sends a Retry packet. 607 A typical TLS ClientHello can easily fit into a 1200 byte packet. 608 However, in addition to the overheads added by QUIC, there are 609 several variables that could cause this limit to be exceeded. Large 610 session tickets, multiple or large key shares, and long lists of 611 supported ciphers, signature algorithms, versions, QUIC transport 612 parameters, and other negotiable parameters and extensions could 613 cause this message to grow. 615 For servers, in addition to connection IDs and tokens, the size of 616 TLS session tickets can have an effect on a client's ability to 617 connect. Minimizing the size of these values increases the 618 probability that they can be successfully used by a client. 620 A client is not required to fit the ClientHello that it sends in 621 response to a HelloRetryRequest message into a single UDP datagram. 623 The TLS implementation does not need to ensure that the ClientHello 624 is sufficiently large. QUIC PADDING frames are added to increase the 625 size of the packet as necessary. 627 4.4. Peer Authentication 629 The requirements for authentication depend on the application 630 protocol that is in use. TLS provides server authentication and 631 permits the server to request client authentication. 633 A client MUST authenticate the identity of the server. This 634 typically involves verification that the identity of the server is 635 included in a certificate and that the certificate is issued by a 636 trusted entity (see for example [RFC2818]). 638 A server MAY request that the client authenticate during the 639 handshake. A server MAY refuse a connection if the client is unable 640 to authenticate when requested. The requirements for client 641 authentication vary based on application protocol and deployment. 643 A server MUST NOT use post-handshake client authentication (see 644 Section 4.6.2 of [TLS13]). 646 4.5. Enabling 0-RTT 648 In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket 649 message that contains the "early_data" extension with a 650 max_early_data_size of 0xffffffff; the amount of data which the 651 client can send in 0-RTT is controlled by the "initial_max_data" 652 transport parameter supplied by the server. A client MUST treat 653 receipt of a NewSessionTicket that contains an "early_data" extension 654 with any other value as a connection error of type 655 PROTOCOL_VIOLATION. 657 Early data within the TLS connection MUST NOT be used. As it is for 658 other TLS application data, a server MUST treat receiving early data 659 on the TLS connection as a connection error of type 660 PROTOCOL_VIOLATION. 662 4.6. Rejecting 0-RTT 664 A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This 665 also prevents QUIC from sending 0-RTT data. A server will always 666 reject 0-RTT if it sends a TLS HelloRetryRequest. 668 When 0-RTT is rejected, all connection characteristics that the 669 client assumed might be incorrect. This includes the choice of 670 application protocol, transport parameters, and any application 671 configuration. The client therefore MUST reset the state of all 672 streams, including application state bound to those streams. 674 A client MAY attempt to send 0-RTT again if it receives a Retry or 675 Version Negotiation packet. These packets do not signify rejection 676 of 0-RTT. 678 4.7. HelloRetryRequest 680 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 681 [TLS13]) can be used to correct a client's incorrect KeyShare 682 extension as well as for a stateless round-trip check. From the 683 perspective of QUIC, this just looks like additional messages carried 684 in the Initial encryption level. Although it is in principle 685 possible to use this feature for address verification in QUIC, QUIC 686 implementations SHOULD instead use the Retry feature (see Section 8.1 687 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 688 shares. 690 4.8. TLS Errors 692 If TLS experiences an error, it generates an appropriate alert as 693 defined in Section 6 of [TLS13]. 695 A TLS alert is turned into a QUIC connection error by converting the 696 one-byte alert description into a QUIC error code. The alert 697 description is added to 0x100 to produce a QUIC error code from the 698 range reserved for CRYPTO_ERROR. The resulting value is sent in a 699 QUIC CONNECTION_CLOSE frame. 701 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 702 generate alerts at the "warning" level. 704 4.9. Discarding Unused Keys 706 After QUIC moves to a new encryption level, packet protection keys 707 for previous encryption levels can be discarded. This occurs several 708 times during the handshake, as well as when keys are updated (see 709 Section 6). Initial packet protection keys are treated specially, 710 see Section 4.10. 712 Packet protection keys are not discarded immediately when new keys 713 are available. If packets from a lower encryption level contain 714 CRYPTO frames, frames that retransmit that data MUST be sent at the 715 same encryption level. Similarly, an endpoint generates 716 acknowledgements for packets at the same encryption level as the 717 packet being acknowledged. Thus, it is possible that keys for a 718 lower encryption level are needed for a short time after keys for a 719 newer encryption level are available. 721 An endpoint cannot discard keys for a given encryption level unless 722 it has both received and acknowledged all CRYPTO frames for that 723 encryption level and when all CRYPTO frames for that encryption level 724 have been acknowledged by its peer. However, this does not guarantee 725 that no further packets will need to be received or sent at that 726 encryption level because a peer might not have received all the 727 acknowledgements necessary to reach the same state. 729 After all CRYPTO frames for a given encryption level have been sent 730 and all expected CRYPTO frames received, and all the corresponding 731 acknowledgments have been received or sent, an endpoint starts a 732 timer. For 0-RTT keys, which do not carry CRYPTO frames, this timer 733 starts when the first packets protected with 1-RTT are sent or 734 received. To limit the effect of packet loss around a change in 735 keys, endpoints MUST retain packet protection keys for that 736 encryption level for at least three times the current Probe Timeout 737 (PTO) interval as defined in [QUIC-RECOVERY]. Retaining keys for 738 this interval allows packets containing CRYPTO or ACK frames at that 739 encryption level to be sent if packets are determined to be lost or 740 new packets require acknowledgment. 742 Though an endpoint might retain older keys, new data MUST be sent at 743 the highest currently-available encryption level. Only ACK frames 744 and retransmissions of data in CRYPTO frames are sent at a previous 745 encryption level. These packets MAY also include PADDING frames. 747 Once this timer expires, an endpoint MUST NOT either accept or 748 generate new packets using those packet protection keys. An endpoint 749 can discard packet protection keys for that encryption level. 751 Key updates (see Section 6) can be used to update 1-RTT keys before 752 keys from other encryption levels are discarded. In that case, 753 packets protected with the newest packet protection keys and packets 754 sent two updates prior will appear to use the same keys. After the 755 handshake is complete, endpoints only need to maintain the two latest 756 sets of packet protection keys and MAY discard older keys. Updating 757 keys multiple times rapidly can cause packets to be effectively lost 758 if packets are significantly delayed. Because key updates can only 759 be performed once per round trip time, only packets that are delayed 760 by more than a round trip will be lost as a result of changing keys; 761 such packets will be marked as lost before this, as they leave a gap 762 in the sequence of packet numbers. 764 4.10. Discarding Initial Keys 766 Packets protected with Initial secrets (Section 5.2) are not 767 authenticated, meaning that an attacker could spoof packets with the 768 intent to disrupt a connection. To limit these attacks, Initial 769 packet protection keys can be discarded more aggressively than other 770 keys. 772 The successful use of Handshake packets indicates that no more 773 Initial packets need to be exchanged, as these keys can only be 774 produced after receiving all CRYPTO frames from Initial packets. 775 Thus, a client MUST discard Initial keys when it first sends a 776 Handshake packet and a server MUST discard Initial keys when it first 777 successfully processes a Handshake packet. Endpoints MUST NOT send 778 Initial packets after this point. 780 This results in abandoning loss recovery state for the Initial 781 encryption level and ignoring any outstanding Initial packets. 783 5. Packet Protection 785 As with TLS over TCP, QUIC protects packets with keys derived from 786 the TLS handshake, using the AEAD algorithm negotiated by TLS. 788 5.1. Packet Protection Keys 790 QUIC derives packet protection keys in the same way that TLS derives 791 record protection keys. 793 Each encryption level has separate secret values for protection of 794 packets sent in each direction. These traffic secrets are derived by 795 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 796 encryption levels except the Initial encryption level. The secrets 797 for the Initial encryption level are computed based on the client's 798 initial Destination Connection ID, as described in Section 5.2. 800 The keys used for packet protection are computed from the TLS secrets 801 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 802 function described in Section 7.1 of [TLS13] is used, using the hash 803 function from the negotiated cipher suite. Other versions of TLS 804 MUST provide a similar function in order to be used with QUIC. 806 The current encryption level secret and the label "quic key" are 807 input to the KDF to produce the AEAD key; the label "quic iv" is used 808 to derive the IV, see Section 5.3. The header protection key uses 809 the "quic hp" label, see Section 5.4. Using these labels provides 810 key separation between QUIC and TLS, see Section 9.5. 812 The KDF used for initial secrets is always the HKDF-Expand-Label 813 function from TLS 1.3 (see Section 5.2). 815 5.2. Initial Secrets 817 Initial packets are protected with a secret derived from the 818 Destination Connection ID field from the client's first Initial 819 packet of the connection. Specifically: 821 initial_salt = 0xef4fb0abb47470c41befcf8031334fae485e09a0 822 initial_secret = HKDF-Extract(initial_salt, 823 client_dst_connection_id) 825 client_initial_secret = HKDF-Expand-Label(initial_secret, 826 "client in", "", 827 Hash.length) 828 server_initial_secret = HKDF-Expand-Label(initial_secret, 829 "server in", "", 830 Hash.length) 832 The hash function for HKDF when deriving initial secrets and keys is 833 SHA-256 [SHA]. 835 The connection ID used with HKDF-Expand-Label is the Destination 836 Connection ID in the Initial packet sent by the client. This will be 837 a randomly-selected value unless the client creates the Initial 838 packet after receiving a Retry packet, where the Destination 839 Connection ID is selected by the server. 841 The value of initial_salt is a 20 byte sequence shown in the figure 842 in hexadecimal notation. Future versions of QUIC SHOULD generate a 843 new salt value, thus ensuring that the keys are different for each 844 version of QUIC. This prevents a middlebox that only recognizes one 845 version of QUIC from seeing or modifying the contents of packets from 846 future versions. 848 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 849 Initial packets even where the TLS versions offered do not include 850 TLS 1.3. 852 Appendix A contains test vectors for the initial packet encryption. 854 Note: The Destination Connection ID is of arbitrary length, and it 855 could be zero length if the server sends a Retry packet with a 856 zero-length Source Connection ID field. In this case, the Initial 857 keys provide no assurance to the client that the server received 858 its packet; the client has to rely on the exchange that included 859 the Retry packet for that property. 861 5.3. AEAD Usage 863 The Authentication Encryption with Associated Data (AEAD) [AEAD] 864 function used for QUIC packet protection is the AEAD that is 865 negotiated for use with the TLS connection. For example, if TLS is 866 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 867 used. 869 Packets are protected prior to applying header protection 870 (Section 5.4). The unprotected packet header is part of the 871 associated data (A). When removing packet protection, an endpoint 872 first removes the header protection. 874 All QUIC packets other than Version Negotiation and Retry packets are 875 protected with an AEAD algorithm [AEAD]. Prior to establishing a 876 shared secret, packets are protected with AEAD_AES_128_GCM and a key 877 derived from the Destination Connection ID in the client's first 878 Initial packet (see Section 5.2). This provides protection against 879 off-path attackers and robustness against QUIC version unaware 880 middleboxes, but not against on-path attackers. 882 QUIC can use any of the ciphersuites defined in [TLS13] with the 883 exception of TLS_AES_128_CCM_8_SHA256. The AEAD for that 884 ciphersuite, AEAD_AES_128_CCM_8 [CCM], does not produce a large 885 enough authentication tag for use with the header protection designs 886 provided (see Section 5.4). All other ciphersuites defined in 887 [TLS13] have a 16-byte authentication tag and produce an output 16 888 bytes larger than their input. 890 The key and IV for the packet are computed as described in 891 Section 5.1. The nonce, N, is formed by combining the packet 892 protection IV with the packet number. The 62 bits of the 893 reconstructed QUIC packet number in network byte order are left- 894 padded with zeros to the size of the IV. The exclusive OR of the 895 padded packet number and the IV forms the AEAD nonce. 897 The associated data, A, for the AEAD is the contents of the QUIC 898 header, starting from the flags byte in either the short or long 899 header, up to and including the unprotected packet number. 901 The input plaintext, P, for the AEAD is the payload of the QUIC 902 packet, as described in [QUIC-TRANSPORT]. 904 The output ciphertext, C, of the AEAD is transmitted in place of P. 906 Some AEAD functions have limits for how many packets can be encrypted 907 under the same key and IV (see for example [AEBounds]). This might 908 be lower than the packet number limit. An endpoint MUST initiate a 909 key update (Section 6) prior to exceeding any limit set for the AEAD 910 that is in use. 912 5.4. Header Protection 914 Parts of QUIC packet headers, in particular the Packet Number field, 915 are protected using a key that is derived separate to the packet 916 protection key and IV. The key derived using the "quic hp" label is 917 used to provide confidentiality protection for those fields that are 918 not exposed to on-path elements. 920 This protection applies to the least-significant bits of the first 921 byte, plus the Packet Number field. The four least-significant bits 922 of the first byte are protected for packets with long headers; the 923 five least significant bits of the first byte are protected for 924 packets with short headers. For both header forms, this covers the 925 reserved bits and the Packet Number Length field; the Key Phase bit 926 is also protected for packets with a short header. 928 The same header protection key is used for the duration of the 929 connection, with the value not changing after a key update (see 930 Section 6). This allows header protection to be used to protect the 931 key phase. 933 This process does not apply to Retry or Version Negotiation packets, 934 which do not contain a protected payload or any of the fields that 935 are protected by this process. 937 5.4.1. Header Protection Application 939 Header protection is applied after packet protection is applied (see 940 Section 5.3). The ciphertext of the packet is sampled and used as 941 input to an encryption algorithm. The algorithm used depends on the 942 negotiated AEAD. 944 The output of this algorithm is a 5 byte mask which is applied to the 945 protected header fields using exclusive OR. The least significant 946 bits of the first byte of the packet are masked by the least 947 significant bits of the first mask byte, and the packet number is 948 masked with the remaining bytes. Any unused bytes of mask that might 949 result from a shorter packet number encoding are unused. 951 Figure 4 shows a sample algorithm for applying header protection. 952 Removing header protection only differs in the order in which the 953 packet number length (pn_length) is determined. 955 mask = header_protection(hp_key, sample) 957 pn_length = (packet[0] & 0x03) + 1 958 if (packet[0] & 0x80) == 0x80: 959 # Long header: 4 bits masked 960 packet[0] ^= mask[0] & 0x0f 961 else: 962 # Short header: 5 bits masked 963 packet[0] ^= mask[0] & 0x1f 965 # pn_offset is the start of the Packet Number field. 966 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 968 Figure 4: Header Protection Pseudocode 970 Figure 5 shows the protected fields of long and short headers marked 971 with an E. Figure 5 also shows the sampled fields. 973 Long Header: 974 +-+-+-+-+-+-+-+-+ 975 |1|1|T T|E E E E| 976 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 977 | Version -> Length Fields ... 978 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 980 Short Header: 981 +-+-+-+-+-+-+-+-+ 982 |0|1|S|E E E E E| 983 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 984 | Destination Connection ID (0/32..144) ... 985 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 987 Common Fields: 988 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 989 |E E E E E E E E E Packet Number (8/16/24/32) E E E E E E E E... 990 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 991 | [Protected Payload (8/16/24)] ... 992 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 993 | Sampled part of Protected Payload (128) ... 994 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 995 | Protected Payload Remainder (*) ... 996 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 998 Figure 5: Header Protection and Ciphertext Sample 1000 Before a TLS ciphersuite can be used with QUIC, a header protection 1001 algorithm MUST be specified for the AEAD used with that ciphersuite. 1002 This document defines algorithms for AEAD_AES_128_GCM, 1003 AEAD_AES_128_CCM, AEAD_AES_256_GCM, AEAD_AES_256_CCM (all AES AEADs 1004 are defined in [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior 1005 to TLS selecting a ciphersuite, AES header protection is used 1006 (Section 5.4.3), matching the AEAD_AES_128_GCM packet protection. 1008 5.4.2. Header Protection Sample 1010 The header protection algorithm uses both the header protection key 1011 and a sample of the ciphertext from the packet Payload field. 1013 The same number of bytes are always sampled, but an allowance needs 1014 to be made for the endpoint removing protection, which will not know 1015 the length of the Packet Number field. In sampling the packet 1016 ciphertext, the Packet Number field is assumed to be 4 bytes long 1017 (its maximum possible encoded length). 1019 An endpoint MUST discard packets that are not long enough to contain 1020 a complete sample. 1022 To ensure that sufficient data is available for sampling, packets are 1023 padded so that the combined lengths of the encoded packet number and 1024 protected payload is at least 4 bytes longer than the sample required 1025 for header protection. For the AEAD functions defined in [TLS13], 1026 which have 16-byte expansions and 16-byte header protection samples, 1027 this results in needing at least 3 bytes of frames in the unprotected 1028 payload if the packet number is encoded on a single byte, or 2 bytes 1029 of frames for a 2-byte packet number encoding. 1031 The sampled ciphertext for a packet with a short header can be 1032 determined by the following pseudocode: 1034 sample_offset = 1 + len(connection_id) + 4 1036 sample = packet[sample_offset..sample_offset+sample_length] 1038 For example, for a packet with a short header, an 8 byte connection 1039 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1040 28 inclusive (using zero-based indexing). 1042 A packet with a long header is sampled in the same way, noting that 1043 multiple QUIC packets might be included in the same UDP datagram and 1044 that each one is handled separately. 1046 sample_offset = 6 + len(destination_connection_id) + 1047 len(source_connection_id) + 1048 len(payload_length) + 4 1049 if packet_type == Initial: 1050 sample_offset += len(token_length) + 1051 len(token) 1053 sample = packet[sample_offset..sample_offset+sample_length] 1055 5.4.3. AES-Based Header Protection 1057 This section defines the packet protection algorithm for 1058 AEAD_AES_128_GCM, AEAD_AES_128_CCM, AEAD_AES_256_GCM, and 1059 AEAD_AES_256_CCM. AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit 1060 AES [AES] in electronic code-book (ECB) mode. AEAD_AES_256_GCM, and 1061 AEAD_AES_256_CCM use 256-bit AES in ECB mode. 1063 This algorithm samples 16 bytes from the packet ciphertext. This 1064 value is used as the input to AES-ECB. In pseudocode: 1066 mask = AES-ECB(hp_key, sample) 1068 5.4.4. ChaCha20-Based Header Protection 1070 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1071 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1072 256-bit key and 16 bytes sampled from the packet protection output. 1074 The first 4 bytes of the sampled ciphertext are interpreted as a 1075 32-bit number in little-endian order and are used as the block count. 1076 The remaining 12 bytes are interpreted as three concatenated 32-bit 1077 numbers in little-endian order and used as the nonce. 1079 The encryption mask is produced by invoking ChaCha20 to protect 5 1080 zero bytes. In pseudocode: 1082 counter = DecodeLE(sample[0..3]) 1083 nonce = DecodeLE(sample[4..7], sample[8..11], sample[12..15]) 1084 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1086 5.5. Receiving Protected Packets 1088 Once an endpoint successfully receives a packet with a given packet 1089 number, it MUST discard all packets in the same packet number space 1090 with higher packet numbers if they cannot be successfully unprotected 1091 with either the same key, or - if there is a key update - the next 1092 packet protection key (see Section 6). Similarly, a packet that 1093 appears to trigger a key update, but cannot be unprotected 1094 successfully MUST be discarded. 1096 Failure to unprotect a packet does not necessarily indicate the 1097 existence of a protocol error in a peer or an attack. The truncated 1098 packet number encoding used in QUIC can cause packet numbers to be 1099 decoded incorrectly if they are delayed significantly. 1101 5.6. Use of 0-RTT Keys 1103 If 0-RTT keys are available (see Section 4.5), the lack of replay 1104 protection means that restrictions on their use are necessary to 1105 avoid replay attacks on the protocol. 1107 A client MUST only use 0-RTT keys to protect data that is idempotent. 1108 A client MAY wish to apply additional restrictions on what data it 1109 sends prior to the completion of the TLS handshake. A client 1110 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1111 it MUST NOT send ACKs with 0-RTT keys. 1113 A client that receives an indication that its 0-RTT data has been 1114 accepted by a server can send 0-RTT data until it receives all of the 1115 server's handshake messages. A client SHOULD stop sending 0-RTT data 1116 if it receives an indication that 0-RTT data has been rejected. 1118 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1119 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1120 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1121 them. 1123 Note: 0-RTT data can be acknowledged by the server as it receives 1124 it, but any packets containing acknowledgments of 0-RTT data 1125 cannot have packet protection removed by the client until the TLS 1126 handshake is complete. The 1-RTT keys necessary to remove packet 1127 protection cannot be derived until the client receives all server 1128 handshake messages. 1130 5.7. Receiving Out-of-Order Protected Frames 1132 Due to reordering and loss, protected packets might be received by an 1133 endpoint before the final TLS handshake messages are received. A 1134 client will be unable to decrypt 1-RTT packets from the server, 1135 whereas a server will be able to decrypt 1-RTT packets from the 1136 client. 1138 However, a server MUST NOT process data from incoming 1-RTT protected 1139 packets before verifying either the client Finished message or - in 1140 the case that the server has chosen to use a pre-shared key - the 1141 pre-shared key binder (see Section 4.2.11 of [TLS13]). Verifying 1142 these values provides the server with an assurance that the 1143 ClientHello has not been modified. Packets protected with 1-RTT keys 1144 MAY be stored and later decrypted and used once the handshake is 1145 complete. 1147 A server could receive packets protected with 0-RTT keys prior to 1148 receiving a TLS ClientHello. The server MAY retain these packets for 1149 later decryption in anticipation of receiving a ClientHello. 1151 6. Key Update 1153 Once the 1-RTT keys are established and the short header is in use, 1154 it is possible to update the keys. The KEY_PHASE bit in the short 1155 header is used to indicate whether key updates have occurred. The 1156 KEY_PHASE bit is initially set to 0 and then inverted with each key 1157 update. 1159 The KEY_PHASE bit allows a recipient to detect a change in keying 1160 material without necessarily needing to receive the first packet that 1161 triggered the change. An endpoint that notices a changed KEY_PHASE 1162 bit can update keys and decrypt the packet that contains the changed 1163 bit. 1165 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1166 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1167 of a TLS KeyUpdate message as a connection error of type 0x10a, 1168 equivalent to a fatal TLS alert of unexpected_message (see 1169 Section 4.8). 1171 An endpoint MUST NOT initiate more than one key update at a time. A 1172 new key cannot be used until the endpoint has received and 1173 successfully decrypted a packet with a matching KEY_PHASE. 1175 A receiving endpoint detects an update when the KEY_PHASE bit does 1176 not match what it is expecting. It creates a new secret (see 1177 Section 7.2 of [TLS13]) and the corresponding read key and IV using 1178 the KDF function provided by TLS. The header protection key is not 1179 updated. 1181 If the packet can be decrypted and authenticated using the updated 1182 key and IV, then the keys the endpoint uses for packet protection are 1183 also updated. The next packet sent by the endpoint will then use the 1184 new keys. 1186 An endpoint does not always need to send packets when it detects that 1187 its peer has updated keys. The next packet that it sends will simply 1188 use the new keys. If an endpoint detects a second update before it 1189 has sent any packets with updated keys, it indicates that its peer 1190 has updated keys twice without awaiting a reciprocal update. An 1191 endpoint MUST treat consecutive key updates as a fatal error and 1192 abort the connection. 1194 An endpoint SHOULD retain old keys for a period of no more than three 1195 times the Probe Timeout (PTO, see [QUIC-RECOVERY]). After this 1196 period, old keys and their corresponding secrets SHOULD be discarded. 1197 Retaining keys allow endpoints to process packets that were sent with 1198 old keys and delayed in the network. Packets with higher packet 1199 numbers always use the updated keys and MUST NOT be decrypted with 1200 old keys. 1202 This ensures that once the handshake is complete, packets with the 1203 same KEY_PHASE will have the same packet protection keys, unless 1204 there are multiple key updates in a short time frame succession and 1205 significant packet reordering. 1207 Initiating Peer Responding Peer 1209 @M QUIC Frames 1210 New Keys -> @N 1211 @N QUIC Frames 1212 --------> 1213 QUIC Frames @M 1214 New Keys -> @N 1215 QUIC Frames @N 1216 <-------- 1218 Figure 6: Key Update 1220 A packet that triggers a key update could arrive after successfully 1221 processing a packet with a higher packet number. This is only 1222 possible if there is a key compromise and an attack, or if the peer 1223 is incorrectly reverting to use of old keys. Because the latter 1224 cannot be differentiated from an attack, an endpoint MUST immediately 1225 terminate the connection if it detects this condition. 1227 In deciding when to update keys, endpoints MUST NOT exceed the limits 1228 for use of specific keys, as described in Section 5.5 of [TLS13]. 1230 7. Security of Initial Messages 1232 Initial packets are not protected with a secret key, so they are 1233 subject to potential tampering by an attacker. QUIC provides 1234 protection against attackers that cannot read packets, but does not 1235 attempt to provide additional protection against attacks where the 1236 attacker can observe and inject packets. Some forms of tampering - 1237 such as modifying the TLS messages themselves - are detectable, but 1238 some - such as modifying ACKs - are not. 1240 For example, an attacker could inject a packet containing an ACK 1241 frame that makes it appear that a packet had not been received or to 1242 create a false impression of the state of the connection (e.g., by 1243 modifying the ACK Delay). Note that such a packet could cause a 1244 legitimate packet to be dropped as a duplicate. Implementations 1245 SHOULD use caution in relying on any data which is contained in 1246 Initial packets that is not otherwise authenticated. 1248 It is also possible for the attacker to tamper with data that is 1249 carried in Handshake packets, but because that tampering requires 1250 modifying TLS handshake messages, that tampering will cause the TLS 1251 handshake to fail. 1253 8. QUIC-Specific Additions to the TLS Handshake 1255 QUIC uses the TLS handshake for more than just negotiation of 1256 cryptographic parameters. The TLS handshake validates protocol 1257 version selection, provides preliminary values for QUIC transport 1258 parameters, and allows a server to perform return routeability checks 1259 on clients. 1261 8.1. Protocol and Version Negotiation 1263 The QUIC version negotiation mechanism is used to negotiate the 1264 version of QUIC that is used prior to the completion of the 1265 handshake. However, this packet is not authenticated, enabling an 1266 active attacker to force a version downgrade. 1268 To ensure that a QUIC version downgrade is not forced by an attacker, 1269 version information is copied into the TLS handshake, which provides 1270 integrity protection for the QUIC negotiation. This does not prevent 1271 version downgrade prior to the completion of the handshake, though it 1272 means that a downgrade causes a handshake failure. 1274 QUIC requires that the cryptographic handshake provide authenticated 1275 protocol negotiation. TLS uses Application Layer Protocol 1276 Negotiation (ALPN) [RFC7301] to select an application protocol. 1277 Unless another mechanism is used for agreeing on an application 1278 protocol, endpoints MUST use ALPN for this purpose. When using ALPN, 1279 endpoints MUST abort a connection if an application protocol is not 1280 negotiated. 1282 An application-layer protocol MAY restrict the QUIC versions that it 1283 can operate over. Servers MUST select an application protocol 1284 compatible with the QUIC version that the client has selected. If 1285 the server cannot select a compatible combination of application 1286 protocol and QUIC version, it MUST abort the connection. A client 1287 MUST abort a connection if the server picks an incompatible 1288 combination of QUIC version and ALPN identifier. 1290 8.2. QUIC Transport Parameters Extension 1292 QUIC transport parameters are carried in a TLS extension. Different 1293 versions of QUIC might define a different format for this struct. 1295 Including transport parameters in the TLS handshake provides 1296 integrity protection for these values. 1298 enum { 1299 quic_transport_parameters(0xffa5), (65535) 1300 } ExtensionType; 1302 The "extension_data" field of the quic_transport_parameters extension 1303 contains a value that is defined by the version of QUIC that is in 1304 use. The quic_transport_parameters extension carries a 1305 TransportParameters struct when the version of QUIC defined in 1306 [QUIC-TRANSPORT] is used. 1308 The quic_transport_parameters extension is carried in the ClientHello 1309 and the EncryptedExtensions messages during the handshake. 1311 While the transport parameters are technically available prior to the 1312 completion of the handshake, they cannot be fully trusted until the 1313 handshake completes, and reliance on them should be minimized. 1314 However, any tampering with the parameters will cause the handshake 1315 to fail. 1317 Endpoints MUST NOT send this extension in a TLS connection that does 1318 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1319 fatal unsupported_extension alert MUST be sent if this extension is 1320 received when the transport is not QUIC. 1322 8.3. Removing the EndOfEarlyData Message 1324 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1325 rely on this message to mark the end of 0-RTT data or to signal the 1326 change to Handshake keys. 1328 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1329 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1330 error of type PROTOCOL_VIOLATION. 1332 As a result, EndOfEarlyData does not appear in the TLS handshake 1333 transcript. 1335 9. Security Considerations 1337 There are likely to be some real clangers here eventually, but the 1338 current set of issues is well captured in the relevant sections of 1339 the main text. 1341 Never assume that because it isn't in the security considerations 1342 section it doesn't affect security. Most of this document does. 1344 9.1. Replay Attacks with 0-RTT 1346 As described in Section 8 of [TLS13], use of TLS early data comes 1347 with an exposure to replay attack. The use of 0-RTT in QUIC is 1348 similarly vulnerable to replay attack. 1350 Endpoints MUST implement and use the replay protections described in 1351 [TLS13], however it is recognized that these protections are 1352 imperfect. Therefore, additional consideration of the risk of replay 1353 is needed. 1355 QUIC is not vulnerable to replay attack, except via the application 1356 protocol information it might carry. The management of QUIC protocol 1357 state based on the frame types defined in [QUIC-TRANSPORT] is not 1358 vulnerable to replay. Processing of QUIC frames is idempotent and 1359 cannot result in invalid connection states if frames are replayed, 1360 reordered or lost. QUIC connections do not produce effects that last 1361 beyond the lifetime of the connection, except for those produced by 1362 the application protocol that QUIC serves. 1364 Note: TLS session tickets and address validation tokens are used to 1365 carry QUIC configuration information between connections. These 1366 MUST NOT be used to carry application semantics. The potential 1367 for reuse of these tokens means that they require stronger 1368 protections against replay. 1370 A server that accepts 0-RTT on a connection incurs a higher cost than 1371 accepting a connection without 0-RTT. This includes higher 1372 processing and computation costs. Servers need to consider the 1373 probability of replay and all associated costs when accepting 0-RTT. 1375 Ultimately, the responsibility for managing the risks of replay 1376 attacks with 0-RTT lies with an application protocol. An application 1377 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1378 the measures that are employed to protect against replay attack. An 1379 analysis of replay risk needs to consider all QUIC protocol features 1380 that carry application semantics. 1382 Disabling 0-RTT entirely is the most effective defense against replay 1383 attack. 1385 QUIC extensions MUST describe how replay attacks affects their 1386 operation, or prohibit their use in 0-RTT. Application protocols 1387 MUST either prohibit the use of extensions that carry application 1388 semantics in 0-RTT or provide replay mitigation strategies. 1390 9.2. Packet Reflection Attack Mitigation 1392 A small ClientHello that results in a large block of handshake 1393 messages from a server can be used in packet reflection attacks to 1394 amplify the traffic generated by an attacker. 1396 QUIC includes three defenses against this attack. First, the packet 1397 containing a ClientHello MUST be padded to a minimum size. Second, 1398 if responding to an unverified source address, the server is 1399 forbidden to send more than three UDP datagrams in its first flight 1400 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1401 acknowledgements of Handshake packets are authenticated, a blind 1402 attacker cannot forge them. Put together, these defenses limit the 1403 level of amplification. 1405 9.3. Peer Denial of Service 1407 QUIC, TLS, and HTTP/2 all contain messages that have legitimate uses 1408 in some contexts, but that can be abused to cause a peer to expend 1409 processing resources without having any observable impact on the 1410 state of the connection. If processing is disproportionately large 1411 in comparison to the observable effects on bandwidth or state, then 1412 this could allow a malicious peer to exhaust processing capacity 1413 without consequence. 1415 QUIC prohibits the sending of empty "STREAM" frames unless they are 1416 marked with the FIN bit. This prevents "STREAM" frames from being 1417 sent that only waste effort. 1419 While there are legitimate uses for some redundant packets, 1420 implementations SHOULD track redundant packets and treat excessive 1421 volumes of any non-productive packets as indicative of an attack. 1423 9.4. Header Protection Analysis 1425 Header protection relies on the packet protection AEAD being a 1426 pseudorandom function (PRF), which is not a property that AEAD 1427 algorithms guarantee. Therefore, no strong assurances about the 1428 general security of this mechanism can be shown in the general case. 1429 The AEAD algorithms described in this document are assumed to be 1430 PRFs. 1432 The header protection algorithms defined in this document take the 1433 form: 1435 protected_field = field XOR PRF(hp_key, sample) 1437 This construction is secure against chosen plaintext attacks (IND- 1438 CPA) [IMC]. 1440 Use of the same key and ciphertext sample more than once risks 1441 compromising header protection. Protecting two different headers 1442 with the same key and ciphertext sample reveals the exclusive OR of 1443 the protected fields. Assuming that the AEAD acts as a PRF, if L 1444 bits are sampled, the odds of two ciphertext samples being identical 1445 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1446 described in this document, that probability is one in 2^64. 1448 Note: In some cases, inputs shorter than the full size required by 1449 the packet protection algorithm might be used. 1451 To prevent an attacker from modifying packet headers, the header is 1452 transitively authenticated using packet protection; the entire packet 1453 header is part of the authenticated additional data. Protected 1454 fields that are falsified or modified can only be detected once the 1455 packet protection is removed. 1457 An attacker could guess values for packet numbers and have an 1458 endpoint confirm guesses through timing side channels. Similarly, 1459 guesses for the packet number length can be trialed and exposed. If 1460 the recipient of a packet discards packets with duplicate packet 1461 numbers without attempting to remove packet protection they could 1462 reveal through timing side-channels that the packet number matches a 1463 received packet. For authentication to be free from side-channels, 1464 the entire process of header protection removal, packet number 1465 recovery, and packet protection removal MUST be applied together 1466 without timing and other side-channels. 1468 For the sending of packets, construction and protection of packet 1469 payloads and packet numbers MUST be free from side-channels that 1470 would reveal the packet number or its encoded size. 1472 9.5. Key Diversity 1474 In using TLS, the central key schedule of TLS is used. As a result 1475 of the TLS handshake messages being integrated into the calculation 1476 of secrets, the inclusion of the QUIC transport parameters extension 1477 ensures that handshake and 1-RTT keys are not the same as those that 1478 might be produced by a server running TLS over TCP. To avoid the 1479 possibility of cross-protocol key synchronization, additional 1480 measures are provided to improve key separation. 1482 The QUIC packet protection keys and IVs are derived using a different 1483 label than the equivalent keys in TLS. 1485 To preserve this separation, a new version of QUIC SHOULD define new 1486 labels for key derivation for packet protection key and IV, plus the 1487 header protection keys. This version of QUIC uses the string "quic". 1488 Other versions can use a version-specific label in place of that 1489 string. 1491 The initial secrets use a key that is specific to the negotiated QUIC 1492 version. New QUIC versions SHOULD define a new salt value used in 1493 calculating initial secrets. 1495 10. IANA Considerations 1497 This document does not create any new IANA registries, but it 1498 registers the values in the following registries: 1500 o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register 1501 the quic_transport_parameters extension found in Section 8.2. The 1502 Recommended column is to be marked Yes. The TLS 1.3 Column is to 1503 include CH and EE. 1505 11. References 1507 11.1. Normative References 1509 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1510 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1511 . 1513 [AES] "Advanced encryption standard (AES)", National Institute 1514 of Standards and Technology report, 1515 DOI 10.6028/nist.fips.197, November 2001. 1517 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1518 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1519 . 1521 [QUIC-RECOVERY] 1522 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1523 and Congestion Control", draft-ietf-quic-recovery-19 (work 1524 in progress), March 2019. 1526 [QUIC-TRANSPORT] 1527 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1528 Multiplexed and Secure Transport", draft-ietf-quic- 1529 transport-19 (work in progress), March 2019. 1531 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1532 Requirement Levels", BCP 14, RFC 2119, 1533 DOI 10.17487/RFC2119, March 1997, 1534 . 1536 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1537 "Transport Layer Security (TLS) Application-Layer Protocol 1538 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1539 July 2014, . 1541 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1542 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1543 May 2017, . 1545 [SHA] Dang, Q., "Secure Hash Standard", National Institute of 1546 Standards and Technology report, 1547 DOI 10.6028/nist.fips.180-4, July 2015. 1549 [TLS-REGISTRIES] 1550 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 1551 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 1552 . 1554 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1555 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1556 . 1558 11.2. Informative References 1560 [AEBounds] 1561 Luykx, A. and K. Paterson, "Limits on Authenticated 1562 Encryption Use in TLS", March 2016, 1563 . 1565 [CCM] McGrew, D. and D. Bailey, "AES-CCM Cipher Suites for 1566 Transport Layer Security (TLS)", RFC 6655, 1567 DOI 10.17487/RFC6655, July 2012, 1568 . 1570 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1571 Cryptography, Second Edition", ISBN 978-1466570269, 1572 November 2014. 1574 [QUIC-HTTP] 1575 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1576 QUIC", draft-ietf-quic-http-19 (work in progress), March 1577 2019. 1579 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1580 DOI 10.17487/RFC2818, May 2000, 1581 . 1583 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1584 Housley, R., and W. Polk, "Internet X.509 Public Key 1585 Infrastructure Certificate and Certificate Revocation List 1586 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1587 . 1589 11.3. URIs 1591 [1] https://mailarchive.ietf.org/arch/search/?email_list=quic 1593 [2] https://github.com/quicwg 1595 [3] https://github.com/quicwg/base-drafts/labels/-tls 1597 Appendix A. Sample Initial Packet Protection 1599 This section shows examples of packet protection for Initial packets 1600 so that implementations can be verified incrementally. These packets 1601 use an 8-byte client-chosen Destination Connection ID of 1602 0x8394c8f03e515708. Values for both server and client packet 1603 protection are shown together with values in hexadecimal. 1605 A.1. Keys 1607 The labels generated by the HKDF-Expand-Label function are: 1609 client in: 00200f746c73313320636c69656e7420696e00 1611 server in: 00200f746c7331332073657276657220696e00 1613 quic key: 00100e746c7331332071756963206b657900 1615 quic iv: 000c0d746c733133207175696320697600 1617 quic hp: 00100d746c733133207175696320687000 1619 The initial secret is common: 1621 initial_secret = HKDF-Extract(initial_salt, cid) 1622 = 4496d3903d3f97cc5e45ac5790ddc686 1623 683c7c0067012bb09d900cc21832d596 1625 The secrets for protecting client packets are: 1627 client_initial_secret 1628 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 1629 = 8a3515a14ae3c31b9c2d6d5bc58538ca 1630 5cd2baa119087143e60887428dcb52f6 1632 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 1633 = 98b0d7e5e7a402c67c33f350fa65ea54 1635 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 1636 = 19e94387805eb0b46c03a788 1638 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 1639 = 0edd982a6ac527f2eddcbb7348dea5d7 1641 The secrets for protecting server packets are: 1643 server_initial_secret 1644 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 1645 = 47b2eaea6c266e32c0697a9e2a898bdf 1646 5c4fb3e5ac34f0e549bf2c58581a3811 1648 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 1649 = 9a8be902a9bdd91d16064ca118045fb4 1651 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 1652 = 0a82086d32205ba22241d8dc 1654 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 1655 = 94b9452d2b3c7c7f6da7fdd8593537fd 1657 A.2. Client Initial 1659 The client sends an Initial packet. The unprotected payload of this 1660 packet contains the following CRYPTO frame, plus enough PADDING 1661 frames to make an 1163 byte payload: 1663 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 1664 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 1665 736572766572ff01000100000a001400 12001d00170018001901000101010201 1666 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 1667 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 1668 05030603020308040805080604010501 060102010402050206020202002d0002 1669 0101001c00024001 1671 The unprotected header includes the connection ID and a 4 byte packet 1672 number encoding for a packet number of 2: 1674 c3ff000012508394c8f03e51570800449f00000002 1675 Protecting the payload produces output that is sampled for header 1676 protection. Because the header uses a 4 byte packet number encoding, 1677 the first 16 bytes of the protected payload is sampled, then applied 1678 to the header: 1680 sample = 0000f3a694c75775b4e546172ce9e047 1682 mask = AES-ECB(hp, sample)[0..4] 1683 = 020dbc1958 1685 header[0] ^= mask[0] & 0x0f 1686 = c1 1687 header[17..20] ^= mask[1..4] 1688 = 0dbc195a 1689 header = c1ff000012508394c8f03e51570800449f0dbc195a 1691 The resulting protected packet is: 1693 c1ff000012508394c8f03e5157080044 9f0dbc195a0000f3a694c75775b4e546 1694 172ce9e047cd0b5bee5181648c727adc 87f7eae54473ec6cba6bdad4f5982317 1695 4b769f12358abd292d4f3286934484fb 8b239c38732e1f3bbbc6a003056487eb 1696 8b5c88b9fd9279ffff3b0f4ecf95c462 4db6d65d4113329ee9b0bf8cdd7c8a8d 1697 72806d55df25ecb66488bc119d7c9a29 abaf99bb33c56b08ad8c26995f838bb3 1698 b7a3d5c1858b8ec06b839db2dcf918d5 ea9317f1acd6b663cc8925868e2f6a1b 1699 da546695f3c3f33175944db4a11a346a fb07e78489e509b02add51b7b203eda5 1700 c330b03641179a31fbba9b56ce00f3d5 b5e3d7d9c5429aebb9576f2f7eacbe27 1701 bc1b8082aaf68fb69c921aa5d33ec0c8 510410865a178d86d7e54122d55ef2c2 1702 bbc040be46d7fece73fe8a1b24495ec1 60df2da9b20a7ba2f26dfa2a44366dbc 1703 63de5cd7d7c94c57172fe6d79c901f02 5c0010b02c89b395402c009f62dc053b 1704 8067a1e0ed0a1e0cf5087d7f78cbd94a fe0c3dd55d2d4b1a5cfe2b68b86264e3 1705 51d1dcd858783a240f893f008ceed743 d969b8f735a1677ead960b1fb1ecc5ac 1706 83c273b49288d02d7286207e663c45e1 a7baf50640c91e762941cf380ce8d79f 1707 3e86767fbbcd25b42ef70ec334835a3a 6d792e170a432ce0cb7bde9aaa1e7563 1708 7c1c34ae5fef4338f53db8b13a4d2df5 94efbfa08784543815c9c0d487bddfa1 1709 539bc252cf43ec3686e9802d651cfd2a 829a06a9f332a733a4a8aed80efe3478 1710 093fbc69c8608146b3f16f1a5c4eac93 20da49f1afa5f538ddecbbe7888f4355 1711 12d0dd74fd9b8c99e3145ba84410d8ca 9a36dd884109e76e5fb8222a52e1473d 1712 a168519ce7a8a3c32e9149671b16724c 6c5c51bb5cd64fb591e567fb78b10f9f 1713 6fee62c276f282a7df6bcf7c17747bc9 a81e6c9c3b032fdd0e1c3ac9eaa5077d 1714 e3ded18b2ed4faf328f49875af2e36ad 5ce5f6cc99ef4b60e57b3b5b9c9fcbcd 1715 4cfb3975e70ce4c2506bcd71fef0e535 92461504e3d42c885caab21b782e2629 1716 4c6a9d61118cc40a26f378441ceb48f3 1a362bf8502a723a36c63502229a462c 1717 c2a3796279a5e3a7f81a68c7f81312c3 81cc16a4ab03513a51ad5b54306ec1d7 1718 8a5e47e2b15e5b7a1438e5b8b2882dbd ad13d6a4a8c3558cae043501b68eb3b0 1719 40067152337c051c40b5af809aca2856 986fd1c86a4ade17d254b6262ac1bc07 1720 7343b52bf89fa27d73e3c6f3118c9961 f0bebe68a5c323c2d84b8c29a2807df6 1721 63635223242a2ce9828d4429ac270aab 5f1841e8e49cf433b1547989f419caa3 1722 c758fff96ded40cf3427f0761b678daa 1a9e5554465d46b7a917493fc70f9ec5 1723 e4e5d786ca501730898aaa1151dcd318 29641e29428d90e6065511c24d3109f7 1724 cba32225d4accfc54fec42b733f95852 52ee36fa5ea0c656934385b468eee245 1725 315146b8c047ed27c519b2c0a52d33ef e72c186ffe0a230f505676c5324baa6a 1726 e006a73e13aa8c39ab173ad2b2778eea 0b34c46f2b3beae2c62a2c8db238bf58 1727 fc7c27bdceb96c56d29deec87c12351b fd5962497418716a4b915d334ffb5b92 1728 ca94ffe1e4f78967042638639a9de325 357f5f08f6435061e5a274703936c06f 1729 c56af92c420797499ca431a7abaa4618 63bca656facfad564e6274d4a741033a 1730 ca1e31bf63200df41cdf41c10b912bec 1732 A.3. Server Initial 1734 The server sends the following payload in response, including an ACK 1735 frame, a CRYPTO frame, and no PADDING frames: 1737 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 1738 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 1739 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 1740 0304 1741 The header from the server includes a new connection ID and a 2-byte 1742 packet number encoding for a packet number of 1: 1744 c1ff00001205f067a5502a4262b50040740001 1746 As a result, after protection, the header protection sample is taken 1747 starting from the third protected octet: 1749 sample = c4c2a2303d297e3c519bf6b22386e3d0 1750 mask = 75f7ec8b62 1751 header = c4ff00001205f067a5502a4262b5004074f7ed 1753 The final protected packet is then: 1755 c4ff00001205f067a5502a4262b50040 74f7ed5f01c4c2a2303d297e3c519bf6 1756 b22386e3d0bd6dfc6612167729803104 1bb9a79c9f0f9d4c5877270a660f5da3 1757 6207d98b73839b2fdf2ef8e7df5a51b1 7b8c68d864fd3e708c6c1b71a98a3318 1758 15599ef5014ea38c44bdfd387c03b527 5c35e009b6238f831420047c7271281c 1759 cb54df7884 1761 Appendix B. Change Log 1763 *RFC Editor's Note:* Please remove this section prior to 1764 publication of a final version of this document. 1766 Issue and pull request numbers are listed with a leading octothorp. 1768 B.1. Since draft-ietf-quic-tls-18 1770 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 1772 B.2. Since draft-ietf-quic-tls-17 1774 o Endpoints discard initial keys as soon as handshake keys are 1775 available (#1951, #2045) 1777 o Use of ALPN or equivalent is mandatory (#2263, #2284) 1779 B.3. Since draft-ietf-quic-tls-14 1781 o Update the salt used for Initial secrets (#1970) 1783 o Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 1785 o Change header protection 1787 * Sample from a fixed offset (#1575, #2030) 1788 * Cover part of the first byte, including the key phase (#1322, 1789 #2006) 1791 o TLS provides an AEAD and KDF function (#2046) 1793 * Clarify that the TLS KDF is used with TLS (#1997) 1795 * Change the labels for calculation of QUIC keys (#1845, #1971, 1796 #1991) 1798 o Initial keys are discarded once Handshake are avaialble (#1951, 1799 #2045) 1801 B.4. Since draft-ietf-quic-tls-13 1803 o Updated to TLS 1.3 final (#1660) 1805 B.5. Since draft-ietf-quic-tls-12 1807 o Changes to integration of the TLS handshake (#829, #1018, #1094, 1808 #1165, #1190, #1233, #1242, #1252, #1450) 1810 * The cryptographic handshake uses CRYPTO frames, not stream 0 1812 * QUIC packet protection is used in place of TLS record 1813 protection 1815 * Separate QUIC packet number spaces are used for the handshake 1817 * Changed Retry to be independent of the cryptographic handshake 1819 * Limit the use of HelloRetryRequest to address TLS needs (like 1820 key shares) 1822 o Changed codepoint of TLS extension (#1395, #1402) 1824 B.6. Since draft-ietf-quic-tls-11 1826 o Encrypted packet numbers. 1828 B.7. Since draft-ietf-quic-tls-10 1830 o No significant changes. 1832 B.8. Since draft-ietf-quic-tls-09 1834 o Cleaned up key schedule and updated the salt used for handshake 1835 packet protection (#1077) 1837 B.9. Since draft-ietf-quic-tls-08 1839 o Specify value for max_early_data_size to enable 0-RTT (#942) 1841 o Update key derivation function (#1003, #1004) 1843 B.10. Since draft-ietf-quic-tls-07 1845 o Handshake errors can be reported with CONNECTION_CLOSE (#608, 1846 #891) 1848 B.11. Since draft-ietf-quic-tls-05 1850 No significant changes. 1852 B.12. Since draft-ietf-quic-tls-04 1854 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 1856 B.13. Since draft-ietf-quic-tls-03 1858 No significant changes. 1860 B.14. Since draft-ietf-quic-tls-02 1862 o Updates to match changes in transport draft 1864 B.15. Since draft-ietf-quic-tls-01 1866 o Use TLS alerts to signal TLS errors (#272, #374) 1868 o Require ClientHello to fit in a single packet (#338) 1870 o The second client handshake flight is now sent in the clear (#262, 1871 #337) 1873 o The QUIC header is included as AEAD Associated Data (#226, #243, 1874 #302) 1876 o Add interface necessary for client address validation (#275) 1878 o Define peer authentication (#140) 1879 o Require at least TLS 1.3 (#138) 1881 o Define transport parameters as a TLS extension (#122) 1883 o Define handling for protected packets before the handshake 1884 completes (#39) 1886 o Decouple QUIC version and ALPN (#12) 1888 B.16. Since draft-ietf-quic-tls-00 1890 o Changed bit used to signal key phase 1892 o Updated key phase markings during the handshake 1894 o Added TLS interface requirements section 1896 o Moved to use of TLS exporters for key derivation 1898 o Moved TLS error code definitions into this document 1900 B.17. Since draft-thomson-quic-tls-01 1902 o Adopted as base for draft-ietf-quic-tls 1904 o Updated authors/editors list 1906 o Added status note 1908 Acknowledgments 1910 This document has benefited from input from Dragana Damjanovic, 1911 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1912 Rescorla, Ian Swett, and many others. 1914 Contributors 1916 Ryan Hamilton was originally an author of this specification. 1918 Authors' Addresses 1920 Martin Thomson (editor) 1921 Mozilla 1923 Email: mt@lowentropy.net 1924 Sean Turner (editor) 1925 sn3rd 1927 Email: sean@sn3rd.com