idnits 2.17.1 draft-ietf-quic-tls-28.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: ---------------------------------------------------------------------------- == There are 2 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (20 May 2020) is 1429 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: '0' on line 2136 -- Looks like a reference, but probably isn't: '1' on line 1458 -- 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-28 == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-28 -- Possible downref: Non-RFC (?) normative reference: ref. 'SHA' -- Obsolete informational reference (is this intentional?): RFC 8740 (ref. 'HTTP2-TLS13') (Obsoleted by RFC 9113) == Outdated reference: A later version (-34) exists of draft-ietf-quic-http-28 -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) Summary: 1 error (**), 0 flaws (~~), 5 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: 21 November 2020 sn3rd 6 20 May 2020 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-28 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 (mailto:quic@ietf.org)), which is 20 archived at https://mailarchive.ietf.org/arch/ 21 search/?email_list=quic. 23 Working Group information can be found at https://github.com/quicwg; 24 source code and issues list for this draft can be found at 25 https://github.com/quicwg/base-drafts/labels/-tls. 27 Status of This Memo 29 This Internet-Draft is submitted in full conformance with the 30 provisions of BCP 78 and BCP 79. 32 Internet-Drafts are working documents of the Internet Engineering 33 Task Force (IETF). Note that other groups may also distribute 34 working documents as Internet-Drafts. The list of current Internet- 35 Drafts is at https://datatracker.ietf.org/drafts/current/. 37 Internet-Drafts are draft documents valid for a maximum of six months 38 and may be updated, replaced, or obsoleted by other documents at any 39 time. It is inappropriate to use Internet-Drafts as reference 40 material or to cite them other than as "work in progress." 42 This Internet-Draft will expire on 21 November 2020. 44 Copyright Notice 46 Copyright (c) 2020 IETF Trust and the persons identified as the 47 document authors. All rights reserved. 49 This document is subject to BCP 78 and the IETF Trust's Legal 50 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 51 license-info) in effect on the date of publication of this document. 52 Please review these documents carefully, as they describe your rights 53 and restrictions with respect to this document. Code Components 54 extracted from this document must include Simplified BSD License text 55 as described in Section 4.e of the Trust Legal Provisions and are 56 provided without warranty as described in the Simplified BSD License. 58 Table of Contents 60 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 61 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4 62 2.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 4 63 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 7 64 4. Carrying TLS Messages . . . . . . . . . . . . . . . . . . . . 8 65 4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 10 66 4.1.1. Handshake Complete . . . . . . . . . . . . . . . . . 10 67 4.1.2. Handshake Confirmed . . . . . . . . . . . . . . . . . 11 68 4.1.3. Sending and Receiving Handshake Messages . . . . . . 11 69 4.1.4. Encryption Level Changes . . . . . . . . . . . . . . 13 70 4.1.5. TLS Interface Summary . . . . . . . . . . . . . . . . 14 71 4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 15 72 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 15 73 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 16 74 4.5. Session Resumption . . . . . . . . . . . . . . . . . . . 17 75 4.6. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 17 76 4.7. Accepting and Rejecting 0-RTT . . . . . . . . . . . . . . 18 77 4.8. Validating 0-RTT Configuration . . . . . . . . . . . . . 18 78 4.9. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 19 79 4.10. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 19 80 4.11. Discarding Unused Keys . . . . . . . . . . . . . . . . . 19 81 4.11.1. Discarding Initial Keys . . . . . . . . . . . . . . 20 82 4.11.2. Discarding Handshake Keys . . . . . . . . . . . . . 20 83 4.11.3. Discarding 0-RTT Keys . . . . . . . . . . . . . . . 20 84 5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 21 85 5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 21 86 5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 21 87 5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 23 88 5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 24 89 5.4.1. Header Protection Application . . . . . . . . . . . . 24 90 5.4.2. Header Protection Sample . . . . . . . . . . . . . . 26 91 5.4.3. AES-Based Header Protection . . . . . . . . . . . . . 28 92 5.4.4. ChaCha20-Based Header Protection . . . . . . . . . . 28 93 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 28 94 5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 29 95 5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 29 96 5.8. Retry Packet Integrity . . . . . . . . . . . . . . . . . 30 98 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 32 99 6.1. Initiating a Key Update . . . . . . . . . . . . . . . . . 33 100 6.2. Responding to a Key Update . . . . . . . . . . . . . . . 34 101 6.3. Timing of Receive Key Generation . . . . . . . . . . . . 34 102 6.4. Sending with Updated Keys . . . . . . . . . . . . . . . . 35 103 6.5. Receiving with Different Keys . . . . . . . . . . . . . . 35 104 6.6. Key Update Frequency . . . . . . . . . . . . . . . . . . 36 105 6.7. Key Update Error Code . . . . . . . . . . . . . . . . . . 36 106 7. Security of Initial Messages . . . . . . . . . . . . . . . . 37 107 8. QUIC-Specific Adjustments to the TLS Handshake . . . . . . . 37 108 8.1. Protocol Negotiation . . . . . . . . . . . . . . . . . . 37 109 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 38 110 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 38 111 8.4. Prohibit TLS Middlebox Compatibility Mode . . . . . . . . 39 112 9. Security Considerations . . . . . . . . . . . . . . . . . . . 39 113 9.1. Session Linkability . . . . . . . . . . . . . . . . . . . 39 114 9.2. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 39 115 9.3. Packet Reflection Attack Mitigation . . . . . . . . . . . 40 116 9.4. Header Protection Analysis . . . . . . . . . . . . . . . 41 117 9.5. Header Protection Timing Side-Channels . . . . . . . . . 42 118 9.6. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 42 119 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 43 120 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 43 121 11.1. Normative References . . . . . . . . . . . . . . . . . . 43 122 11.2. Informative References . . . . . . . . . . . . . . . . . 44 123 Appendix A. Sample Packet Protection . . . . . . . . . . . . . . 45 124 A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 45 125 A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 46 126 A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 48 127 A.4. Retry . . . . . . . . . . . . . . . . . . . . . . . . . . 49 128 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 49 129 B.1. Since draft-ietf-quic-tls-27 . . . . . . . . . . . . . . 49 130 B.2. Since draft-ietf-quic-tls-26 . . . . . . . . . . . . . . 49 131 B.3. Since draft-ietf-quic-tls-25 . . . . . . . . . . . . . . 50 132 B.4. Since draft-ietf-quic-tls-24 . . . . . . . . . . . . . . 50 133 B.5. Since draft-ietf-quic-tls-23 . . . . . . . . . . . . . . 50 134 B.6. Since draft-ietf-quic-tls-22 . . . . . . . . . . . . . . 50 135 B.7. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 50 136 B.8. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 50 137 B.9. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 51 138 B.10. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 51 139 B.11. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 51 140 B.12. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 51 141 B.13. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 51 142 B.14. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 52 143 B.15. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 52 144 B.16. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 52 145 B.17. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 52 146 B.18. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 52 147 B.19. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 52 148 B.20. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 52 149 B.21. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 52 150 B.22. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 53 151 B.23. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 53 152 B.24. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 53 153 B.25. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 53 154 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 54 155 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 54 157 1. Introduction 159 This document describes how QUIC [QUIC-TRANSPORT] is secured using 160 TLS [TLS13]. 162 TLS 1.3 provides critical latency improvements for connection 163 establishment over previous versions. Absent packet loss, most new 164 connections can be established and secured within a single round 165 trip; on subsequent connections between the same client and server, 166 the client can often send application data immediately, that is, 167 using a zero round trip setup. 169 This document describes how TLS acts as a security component of QUIC. 171 2. Notational Conventions 173 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 174 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 175 "OPTIONAL" in this document are to be interpreted as described in 176 BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all 177 capitals, as shown here. 179 This document uses the terminology established in [QUIC-TRANSPORT]. 181 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 182 newer version could be used (see Section 4.2). 184 2.1. TLS Overview 186 TLS provides two endpoints with a way to establish a means of 187 communication over an untrusted medium (that is, the Internet) that 188 ensures that messages they exchange cannot be observed, modified, or 189 forged. 191 Internally, TLS is a layered protocol, with the structure shown in 192 Figure 1. 194 +-------------+------------+--------------+---------+ 195 Handshake | | | Application | | 196 Layer | Handshake | Alerts | Data | ... | 197 | | | | | 198 +-------------+------------+--------------+---------+ 199 Record | | 200 Layer | Records | 201 | | 202 +---------------------------------------------------+ 204 Figure 1: TLS Layers 206 Each Handshake layer message (e.g., Handshake, Alerts, and 207 Application Data) is carried as a series of typed TLS records by the 208 Record layer. Records are individually cryptographically protected 209 and then transmitted over a reliable transport (typically TCP) which 210 provides sequencing and guaranteed delivery. 212 The TLS authenticated key exchange occurs between two endpoints: 213 client and server. The client initiates the exchange and the server 214 responds. If the key exchange completes successfully, both client 215 and server will agree on a secret. TLS supports both pre-shared key 216 (PSK) and Diffie-Hellman over either finite fields or elliptic curves 217 ((EC)DHE) key exchanges. PSK is the basis for 0-RTT; the latter 218 provides perfect forward secrecy (PFS) when the (EC)DHE keys are 219 destroyed. 221 After completing the TLS handshake, the client will have learned and 222 authenticated an identity for the server and the server is optionally 223 able to learn and authenticate an identity for the client. TLS 224 supports X.509 [RFC5280] certificate-based authentication for both 225 server and client. 227 The TLS key exchange is resistant to tampering by attackers and it 228 produces shared secrets that cannot be controlled by either 229 participating peer. 231 TLS provides two basic handshake modes of interest to QUIC: 233 * A full 1-RTT handshake in which the client is able to send 234 Application Data after one round trip and the server immediately 235 responds after receiving the first handshake message from the 236 client. 238 * A 0-RTT handshake in which the client uses information it has 239 previously learned about the server to send Application Data 240 immediately. This Application Data can be replayed by an attacker 241 so it MUST NOT carry a self-contained trigger for any non- 242 idempotent action. 244 A simplified TLS handshake with 0-RTT application data is shown in 245 Figure 2. 247 Client Server 249 ClientHello 250 (0-RTT Application Data) --------> 251 ServerHello 252 {EncryptedExtensions} 253 {Finished} 254 <-------- [Application Data] 255 {Finished} --------> 257 [Application Data] <-------> [Application Data] 259 () Indicates messages protected by Early Data (0-RTT) Keys 260 {} Indicates messages protected using Handshake Keys 261 [] Indicates messages protected using Application Data 262 (1-RTT) Keys 264 Figure 2: TLS Handshake with 0-RTT 266 Figure 2 omits the EndOfEarlyData message, which is not used in QUIC; 267 see Section 8.3. Likewise, neither ChangeCipherSpec nor KeyUpdate 268 messages are used by QUIC. ChangeCipherSpec is redundant in TLS 1.3; 269 see Section 8.4. QUIC has its own key update mechanism; see 270 Section 6. 272 Data is protected using a number of encryption levels: 274 * Initial Keys 276 * Early Data (0-RTT) Keys 278 * Handshake Keys 280 * Application Data (1-RTT) Keys 282 Application Data may appear only in the Early Data and Application 283 Data levels. Handshake and Alert messages may appear in any level. 285 The 0-RTT handshake is only possible if the client and server have 286 previously communicated. In the 1-RTT handshake, the client is 287 unable to send protected Application Data until it has received all 288 of the Handshake messages sent by the server. 290 3. Protocol Overview 292 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 293 and integrity protection of packets. For this it uses keys derived 294 from a TLS handshake [TLS13], but instead of carrying TLS records 295 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 296 directly over the QUIC transport, which takes over the 297 responsibilities of the TLS record layer, as shown in Figure 3. 299 +--------------+--------------+ +-------------+ 300 | TLS | TLS | | QUIC | 301 | Handshake | Alerts | | Applications| 302 | | | | (h3, etc.) | 303 +--------------+--------------+-+-------------+ 304 | | 305 | QUIC Transport | 306 | (streams, reliability, congestion, etc.) | 307 | | 308 +---------------------------------------------+ 309 | | 310 | QUIC Packet Protection | 311 | | 312 +---------------------------------------------+ 314 Figure 3: QUIC Layers 316 QUIC also relies on TLS for authentication and negotiation of 317 parameters that are critical to security and performance. 319 Rather than a strict layering, these two protocols cooperate: QUIC 320 uses the TLS handshake; TLS uses the reliability, ordered delivery, 321 and record layer provided by QUIC. 323 At a high level, there are two main interactions between the TLS and 324 QUIC components: 326 * The TLS component sends and receives messages via the QUIC 327 component, with QUIC providing a reliable stream abstraction to 328 TLS. 330 * The TLS component provides a series of updates to the QUIC 331 component, including (a) new packet protection keys to install (b) 332 state changes such as handshake completion, the server 333 certificate, etc. 335 Figure 4 shows these interactions in more detail, with the QUIC 336 packet protection being called out specially. 338 +------------+ +------------+ 339 | |<---- Handshake Messages ----->| | 340 | |<- Validate 0-RTT parameters ->| | 341 | |<--------- 0-RTT Keys ---------| | 342 | QUIC |<------- Handshake Keys -------| TLS | 343 | |<--------- 1-RTT Keys ---------| | 344 | |<------- Handshake Done -------| | 345 +------------+ +------------+ 346 | ^ 347 | Protect | Protected 348 v | Packet 349 +------------+ 350 | QUIC | 351 | Packet | 352 | Protection | 353 +------------+ 355 Figure 4: QUIC and TLS Interactions 357 Unlike TLS over TCP, QUIC applications which want to send data do not 358 send it through TLS "application_data" records. Rather, they send it 359 as QUIC STREAM frames or other frame types which are then carried in 360 QUIC packets. 362 4. Carrying TLS Messages 364 QUIC carries TLS handshake data in CRYPTO frames, each of which 365 consists of a contiguous block of handshake data identified by an 366 offset and length. Those frames are packaged into QUIC packets and 367 encrypted under the current TLS encryption level. As with TLS over 368 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 369 responsibility to deliver it reliably. Each chunk of data that is 370 produced by TLS is associated with the set of keys that TLS is 371 currently using. If QUIC needs to retransmit that data, it MUST use 372 the same keys even if TLS has already updated to newer keys. 374 One important difference between TLS records (used with TCP) and QUIC 375 CRYPTO frames is that in QUIC multiple frames may appear in the same 376 QUIC packet as long as they are associated with the same packet 377 number space. For instance, an endpoint can bundle a Handshake 378 message and an ACK for some Handshake data into the same packet. 380 Some frames are prohibited in different packet number spaces. The 381 rules here generalize those of TLS, in that frames associated with 382 establishing the connection can usually appear in packets in any 383 packet number space, whereas those associated with transferring data 384 can only appear in the application data packet number space: 386 * PADDING, PING, and CRYPTO frames MAY appear in any packet number 387 space. 389 * CONNECTION_CLOSE frames signaling errors at the QUIC layer (type 390 0x1c) MAY appear in any packet number space. CONNECTION_CLOSE 391 frames signaling application errors (type 0x1d) MUST only appear 392 in the application data packet number space. 394 * ACK frames MAY appear in any packet number space, but can only 395 acknowledge packets which appeared in that packet number space. 396 However, as noted below, 0-RTT packets cannot contain ACK frames. 398 * All other frame types MUST only be sent in the application data 399 packet number space. 401 Note that it is not possible to send the following frames in 0-RTT 402 packets for various reasons: ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN, 403 PATH_RESPONSE, and RETIRE_CONNECTION_ID. A server MAY treat receipt 404 of these frames in 0-RTT packets as a connection error of type 405 PROTOCOL_VIOLATION. 407 Because packets could be reordered on the wire, QUIC uses the packet 408 type to indicate which keys were used to protect a given packet, as 409 shown in Table 1. When packets of different types need to be sent, 410 endpoints SHOULD use coalesced packets to send them in the same UDP 411 datagram. 413 +---------------------+-----------------+------------------+ 414 | Packet Type | Encryption Keys | PN Space | 415 +=====================+=================+==================+ 416 | Initial | Initial secrets | Initial | 417 +---------------------+-----------------+------------------+ 418 | 0-RTT Protected | 0-RTT | Application data | 419 +---------------------+-----------------+------------------+ 420 | Handshake | Handshake | Handshake | 421 +---------------------+-----------------+------------------+ 422 | Retry | Retry | N/A | 423 +---------------------+-----------------+------------------+ 424 | Version Negotiation | N/A | N/A | 425 +---------------------+-----------------+------------------+ 426 | Short Header | 1-RTT | Application data | 427 +---------------------+-----------------+------------------+ 429 Table 1: Encryption Keys by Packet Type 431 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 432 encryption levels fit into the handshake process. 434 4.1. Interface to TLS 436 As shown in Figure 4, the interface from QUIC to TLS consists of four 437 primary functions: 439 * Sending and receiving handshake messages 441 * Processing stored transport and application state from a resumed 442 session and determining if it is valid to accept early data 444 * Rekeying (both transmit and receive) 446 * Handshake state updates 448 Additional functions might be needed to configure TLS. 450 4.1.1. Handshake Complete 452 In this document, the TLS handshake is considered complete when the 453 TLS stack has reported that the handshake is complete. This happens 454 when the TLS stack has both sent a Finished message and verified the 455 peer's Finished message. Verifying the peer's Finished provides the 456 endpoints with an assurance that previous handshake messages have not 457 been modified. Note that the handshake does not complete at both 458 endpoints simultaneously. Consequently, any requirement that is 459 based on the completion of the handshake depends on the perspective 460 of the endpoint in question. 462 4.1.2. Handshake Confirmed 464 In this document, the TLS handshake is considered confirmed at the 465 server when the handshake completes. At the client, the handshake is 466 considered confirmed when a HANDSHAKE_DONE frame is received. 468 A client MAY consider the handshake to be confirmed when it receives 469 an acknowledgement for a 1-RTT packet. This can be implemented by 470 recording the lowest packet number sent with 1-RTT keys, and 471 comparing it to the Largest Acknowledged field in any received 1-RTT 472 ACK frame: once the latter is greater than or equal to the former, 473 the handshake is confirmed. 475 4.1.3. Sending and Receiving Handshake Messages 477 In order to drive the handshake, TLS depends on being able to send 478 and receive handshake messages. There are two basic functions on 479 this interface: one where QUIC requests handshake messages and one 480 where QUIC provides handshake packets. 482 Before starting the handshake QUIC provides TLS with the transport 483 parameters (see Section 8.2) that it wishes to carry. 485 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 486 The client acquires handshake bytes before sending its first packet. 487 A QUIC server starts the process by providing TLS with the client's 488 handshake bytes. 490 At any time, the TLS stack at an endpoint will have a current sending 491 encryption level and receiving encryption level. Encryption levels 492 determine the packet type and keys that are used for protecting data. 494 Each encryption level is associated with a different sequence of 495 bytes, which is reliably transmitted to the peer in CRYPTO frames. 496 When TLS provides handshake bytes to be sent, they are appended to 497 the current flow. Any packet that includes the CRYPTO frame is 498 protected using keys from the corresponding encryption level. Four 499 encryption levels are used, producing keys for Initial, 0-RTT, 500 Handshake, and 1-RTT packets. CRYPTO frames are carried in just 501 three of these levels, omitting the 0-RTT level. These four levels 502 correspond to three packet number spaces: Initial and Handshake 503 encrypted packets use their own separate spaces; 0-RTT and 1-RTT 504 packets use the application data packet number space. 506 QUIC takes the unprotected content of TLS handshake records as the 507 content of CRYPTO frames. TLS record protection is not used by QUIC. 508 QUIC assembles CRYPTO frames into QUIC packets, which are protected 509 using QUIC packet protection. 511 QUIC is only capable of conveying TLS handshake records in CRYPTO 512 frames. TLS alerts are turned into QUIC CONNECTION_CLOSE error 513 codes; see Section 4.10. TLS application data and other message 514 types cannot be carried by QUIC at any encryption level and is an 515 error if they are received from the TLS stack. 517 When an endpoint receives a QUIC packet containing a CRYPTO frame 518 from the network, it proceeds as follows: 520 * If the packet was in the TLS receiving encryption level, sequence 521 the data into the input flow as usual. As with STREAM frames, the 522 offset is used to find the proper location in the data sequence. 523 If the result of this process is that new data is available, then 524 it is delivered to TLS in order. 526 * If the packet is from a previously installed encryption level, it 527 MUST NOT contain data which extends past the end of previously 528 received data in that flow. Implementations MUST treat any 529 violations of this requirement as a connection error of type 530 PROTOCOL_VIOLATION. 532 * If the packet is from a new encryption level, it is saved for 533 later processing by TLS. Once TLS moves to receiving from this 534 encryption level, saved data can be provided. When providing data 535 from any new encryption level to TLS, if there is data from a 536 previous encryption level that TLS has not consumed, this MUST be 537 treated as a connection error of type PROTOCOL_VIOLATION. 539 Each time that TLS is provided with new data, new handshake bytes are 540 requested from TLS. TLS might not provide any bytes if the handshake 541 messages it has received are incomplete or it has no data to send. 543 Once the TLS handshake is complete, this is indicated to QUIC along 544 with any final handshake bytes that TLS needs to send. TLS also 545 provides QUIC with the transport parameters that the peer advertised 546 during the handshake. 548 Once the handshake is complete, TLS becomes passive. TLS can still 549 receive data from its peer and respond in kind, but it will not need 550 to send more data unless specifically requested - either by an 551 application or QUIC. One reason to send data is that the server 552 might wish to provide additional or updated session tickets to a 553 client. 555 When the handshake is complete, QUIC only needs to provide TLS with 556 any data that arrives in CRYPTO streams. In the same way that is 557 done during the handshake, new data is requested from TLS after 558 providing received data. 560 4.1.4. Encryption Level Changes 562 As keys for new encryption levels become available, TLS provides QUIC 563 with those keys. Separately, as keys at a given encryption level 564 become available to TLS, TLS indicates to QUIC that reading or 565 writing keys at that encryption level are available. These events 566 are not asynchronous; they always occur immediately after TLS is 567 provided with new handshake bytes, or after TLS produces handshake 568 bytes. 570 TLS provides QUIC with three items as a new encryption level becomes 571 available: 573 * A secret 575 * An Authenticated Encryption with Associated Data (AEAD) function 577 * A Key Derivation Function (KDF) 579 These values are based on the values that TLS negotiates and are used 580 by QUIC to generate packet and header protection keys (see Section 5 581 and Section 5.4). 583 If 0-RTT is possible, it is ready after the client sends a TLS 584 ClientHello message or the server receives that message. After 585 providing a QUIC client with the first handshake bytes, the TLS stack 586 might signal the change to 0-RTT keys. On the server, after 587 receiving handshake bytes that contain a ClientHello message, a TLS 588 server might signal that 0-RTT keys are available. 590 Although TLS only uses one encryption level at a time, QUIC may use 591 more than one level. For instance, after sending its Finished 592 message (using a CRYPTO frame at the Handshake encryption level) an 593 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 594 message is lost, the endpoint uses the Handshake encryption level to 595 retransmit the lost message. Reordering or loss of packets can mean 596 that QUIC will need to handle packets at multiple encryption levels. 597 During the handshake, this means potentially handling packets at 598 higher and lower encryption levels than the current encryption level 599 used by TLS. 601 In particular, server implementations need to be able to read packets 602 at the Handshake encryption level at the same time as the 0-RTT 603 encryption level. A client could interleave ACK frames that are 604 protected with Handshake keys with 0-RTT data and the server needs to 605 process those acknowledgments in order to detect lost Handshake 606 packets. 608 QUIC also needs access to keys that might not ordinarily be available 609 to a TLS implementation. For instance, a client might need to 610 acknowledge Handshake packets before it is ready to send CRYPTO 611 frames at that encryption level. TLS therefore needs to provide keys 612 to QUIC before it might produce them for its own use. 614 4.1.5. TLS Interface Summary 616 Figure 5 summarizes the exchange between QUIC and TLS for both client 617 and server. Each arrow is tagged with the encryption level used for 618 that transmission. 620 Client Server 622 Get Handshake 623 Initial -------------> 624 Handshake Received 625 Install tx 0-RTT Keys 626 0-RTT ---------------> 627 Get Handshake 628 <------------- Initial 629 Handshake Received 630 Install Handshake keys 631 Install rx 0-RTT keys 632 Install Handshake keys 633 Get Handshake 634 <----------- Handshake 635 Handshake Received 636 Install tx 1-RTT keys 637 <--------------- 1-RTT 638 Get Handshake 639 Handshake Complete 640 Handshake -----------> 641 Handshake Received 642 Install rx 1-RTT keys 643 Handshake Complete 644 Install 1-RTT keys 645 1-RTT ---------------> 646 Get Handshake 647 <--------------- 1-RTT 648 Handshake Received 650 Figure 5: Interaction Summary between QUIC and TLS 652 Figure 5 shows the multiple packets that form a single "flight" of 653 messages being processed individually, to show what incoming messages 654 trigger different actions. New handshake messages are requested 655 after all incoming packets have been processed. This process might 656 vary depending on how QUIC implementations and the packets they 657 receive are structured. 659 4.2. TLS Version 661 This document describes how TLS 1.3 [TLS13] is used with QUIC. 663 In practice, the TLS handshake will negotiate a version of TLS to 664 use. This could result in a newer version of TLS than 1.3 being 665 negotiated if both endpoints support that version. This is 666 acceptable provided that the features of TLS 1.3 that are used by 667 QUIC are supported by the newer version. 669 A badly configured TLS implementation could negotiate TLS 1.2 or 670 another older version of TLS. An endpoint MUST terminate the 671 connection if a version of TLS older than 1.3 is negotiated. 673 4.3. ClientHello Size 675 The first Initial packet from a client contains the start or all of 676 its first cryptographic handshake message, which for TLS is the 677 ClientHello. Servers might need to parse the entire ClientHello 678 (e.g., to access extensions such as Server Name Identification (SNI) 679 or Application Layer Protocol Negotiation (ALPN)) in order to decide 680 whether to accept the new incoming QUIC connection. If the 681 ClientHello spans multiple Initial packets, such servers would need 682 to buffer the first received fragments, which could consume excessive 683 resources if the client's address has not yet been validated. To 684 avoid this, servers MAY use the Retry feature (see Section 8.1 of 685 [QUIC-TRANSPORT]) to only buffer partial ClientHello messages from 686 clients with a validated address. 688 QUIC packet and framing add at least 36 bytes of overhead to the 689 ClientHello message. That overhead increases if the client chooses a 690 connection ID without zero length. Overheads also do not include the 691 token or a connection ID longer than 8 bytes, both of which might be 692 required if a server sends a Retry packet. 694 A typical TLS ClientHello can easily fit into a 1200 byte packet. 695 However, in addition to the overheads added by QUIC, there are 696 several variables that could cause this limit to be exceeded. Large 697 session tickets, multiple or large key shares, and long lists of 698 supported ciphers, signature algorithms, versions, QUIC transport 699 parameters, and other negotiable parameters and extensions could 700 cause this message to grow. 702 For servers, in addition to connection IDs and tokens, the size of 703 TLS session tickets can have an effect on a client's ability to 704 connect efficiently. Minimizing the size of these values increases 705 the probability that clients can use them and still fit their 706 ClientHello message in their first Initial packet. 708 The TLS implementation does not need to ensure that the ClientHello 709 is sufficiently large. QUIC PADDING frames are added to increase the 710 size of the packet as necessary. 712 4.4. Peer Authentication 714 The requirements for authentication depend on the application 715 protocol that is in use. TLS provides server authentication and 716 permits the server to request client authentication. 718 A client MUST authenticate the identity of the server. This 719 typically involves verification that the identity of the server is 720 included in a certificate and that the certificate is issued by a 721 trusted entity (see for example [RFC2818]). 723 A server MAY request that the client authenticate during the 724 handshake. A server MAY refuse a connection if the client is unable 725 to authenticate when requested. The requirements for client 726 authentication vary based on application protocol and deployment. 728 A server MUST NOT use post-handshake client authentication (as 729 defined in Section 4.6.2 of [TLS13]), because the multiplexing 730 offered by QUIC prevents clients from correlating the certificate 731 request with the application-level event that triggered it (see 732 [HTTP2-TLS13]). More specifically, servers MUST NOT send post- 733 handshake TLS CertificateRequest messages and clients MUST treat 734 receipt of such messages as a connection error of type 735 PROTOCOL_VIOLATION. 737 4.5. Session Resumption 739 QUIC can use the session resumption feature of TLS 1.3. It does this 740 by carrying NewSessionTicket messages in CRYPTO frames after the 741 handshake is complete. Session resumption is the basis of 0-RTT, but 742 can be used without also enabling 0-RTT. 744 Endpoints that use session resumption might need to remember some 745 information about the current connection when creating a resumed 746 connection. TLS requires that some information be retained; see 747 Section 4.6.1 of [TLS13]. QUIC itself does not depend on any state 748 being retained when resuming a connection, unless 0-RTT is also used; 749 see Section 4.6 and Section 7.3.1 of [QUIC-TRANSPORT]. Application 750 protocols could depend on state that is retained between resumed 751 connections. 753 Clients can store any state required for resumption along with the 754 session ticket. Servers can use the session ticket to help carry 755 state. 757 Session resumption allows servers to link activity on the original 758 connection with the resumed connection, which might be a privacy 759 issue for clients. Clients can choose not to enable resumption to 760 avoid creating this correlation. Client SHOULD NOT reuse tickets as 761 that allows entities other than the server to correlate connections; 762 see Section C.4 of [TLS13]. 764 4.6. Enabling 0-RTT 766 To communicate their willingness to process 0-RTT data, servers send 767 a NewSessionTicket message that contains the "early_data" extension 768 with a max_early_data_size of 0xffffffff; the amount of data which 769 the client can send in 0-RTT is controlled by the "initial_max_data" 770 transport parameter supplied by the server. Servers MUST NOT send 771 the "early_data" extension with a max_early_data_size set to any 772 value other than 0xffffffff. A client MUST treat receipt of a 773 NewSessionTicket that contains an "early_data" extension with any 774 other value as a connection error of type PROTOCOL_VIOLATION. 776 A client that wishes to send 0-RTT packets uses the "early_data" 777 extension in the ClientHello message of a subsequent handshake (see 778 Section 4.2.10 of [TLS13]). It then sends the application data in 779 0-RTT packets. 781 4.7. Accepting and Rejecting 0-RTT 783 A server accepts 0-RTT by sending an early_data extension in the 784 EncryptedExtensions (see Section 4.2.10 of [TLS13]). The server then 785 processes and acknowledges the 0-RTT packets that it receives. 787 A server rejects 0-RTT by sending the EncryptedExtensions without an 788 early_data extension. A server will always reject 0-RTT if it sends 789 a TLS HelloRetryRequest. When rejecting 0-RTT, a server MUST NOT 790 process any 0-RTT packets, even if it could. When 0-RTT was 791 rejected, a client SHOULD treat receipt of an acknowledgement for a 792 0-RTT packet as a connection error of type PROTOCOL_VIOLATION, if it 793 is able to detect the condition. 795 When 0-RTT is rejected, all connection characteristics that the 796 client assumed might be incorrect. This includes the choice of 797 application protocol, transport parameters, and any application 798 configuration. The client therefore MUST reset the state of all 799 streams, including application state bound to those streams. 801 A client MAY attempt to send 0-RTT again if it receives a Retry or 802 Version Negotiation packet. These packets do not signify rejection 803 of 0-RTT. 805 4.8. Validating 0-RTT Configuration 807 When a server receives a ClientHello with the "early_data" extension, 808 it has to decide whether to accept or reject early data from the 809 client. Some of this decision is made by the TLS stack (e.g., 810 checking that the cipher suite being resumed was included in the 811 ClientHello; see Section 4.2.10 of [TLS13]). Even when the TLS stack 812 has no reason to reject early data, the QUIC stack or the application 813 protocol using QUIC might reject early data because the configuration 814 of the transport or application associated with the resumed session 815 is not compatible with the server's current configuration. 817 QUIC requires additional transport state to be associated with a 818 0-RTT session ticket. One common way to implement this is using 819 stateless session tickets and storing this state in the session 820 ticket. Application protocols that use QUIC might have similar 821 requirements regarding associating or storing state. This associated 822 state is used for deciding whether early data must be rejected. For 823 example, HTTP/3 ([QUIC-HTTP]) settings determine how early data from 824 the client is interpreted. Other applications using QUIC could have 825 different requirements for determining whether to accept or reject 826 early data. 828 4.9. HelloRetryRequest 830 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 831 [TLS13]) can be used to correct a client's incorrect KeyShare 832 extension as well as for a stateless round-trip check. From the 833 perspective of QUIC, this just looks like additional messages carried 834 in Initial packets. Although it is in principle possible to use this 835 feature for address verification in QUIC, QUIC implementations SHOULD 836 instead use the Retry feature (see Section 8.1 of [QUIC-TRANSPORT]). 837 HelloRetryRequest is still used to request key shares. 839 4.10. TLS Errors 841 If TLS experiences an error, it generates an appropriate alert as 842 defined in Section 6 of [TLS13]. 844 A TLS alert is converted into a QUIC connection error. The alert 845 description is added to 0x100 to produce a QUIC error code from the 846 range reserved for CRYPTO_ERROR. The resulting value is sent in a 847 QUIC CONNECTION_CLOSE frame of type 0x1c. 849 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 850 generate alerts at the "warning" level. 852 QUIC permits the use of a generic code in place of a specific error 853 code; see Section 11 of [QUIC-TRANSPORT]. For TLS alerts, this 854 includes replacing any alert with a generic alert, such as 855 handshake_failure (0x128 in QUIC). Endpoints MAY use a generic error 856 code to avoid possibly exposing confidential information. 858 4.11. Discarding Unused Keys 860 After QUIC moves to a new encryption level, packet protection keys 861 for previous encryption levels can be discarded. This occurs several 862 times during the handshake, as well as when keys are updated; see 863 Section 6. 865 Packet protection keys are not discarded immediately when new keys 866 are available. If packets from a lower encryption level contain 867 CRYPTO frames, frames that retransmit that data MUST be sent at the 868 same encryption level. Similarly, an endpoint generates 869 acknowledgements for packets at the same encryption level as the 870 packet being acknowledged. Thus, it is possible that keys for a 871 lower encryption level are needed for a short time after keys for a 872 newer encryption level are available. 874 An endpoint cannot discard keys for a given encryption level unless 875 it has both received and acknowledged all CRYPTO frames for that 876 encryption level and when all CRYPTO frames for that encryption level 877 have been acknowledged by its peer. However, this does not guarantee 878 that no further packets will need to be received or sent at that 879 encryption level because a peer might not have received all the 880 acknowledgements necessary to reach the same state. 882 Though an endpoint might retain older keys, new data MUST be sent at 883 the highest currently-available encryption level. Only ACK frames 884 and retransmissions of data in CRYPTO frames are sent at a previous 885 encryption level. These packets MAY also include PADDING frames. 887 4.11.1. Discarding Initial Keys 889 Packets protected with Initial secrets (Section 5.2) are not 890 authenticated, meaning that an attacker could spoof packets with the 891 intent to disrupt a connection. To limit these attacks, Initial 892 packet protection keys can be discarded more aggressively than other 893 keys. 895 The successful use of Handshake packets indicates that no more 896 Initial packets need to be exchanged, as these keys can only be 897 produced after receiving all CRYPTO frames from Initial packets. 898 Thus, a client MUST discard Initial keys when it first sends a 899 Handshake packet and a server MUST discard Initial keys when it first 900 successfully processes a Handshake packet. Endpoints MUST NOT send 901 Initial packets after this point. 903 This results in abandoning loss recovery state for the Initial 904 encryption level and ignoring any outstanding Initial packets. 906 4.11.2. Discarding Handshake Keys 908 An endpoint MUST discard its handshake keys when the TLS handshake is 909 confirmed (Section 4.1.2). The server MUST send a HANDSHAKE_DONE 910 frame as soon as it completes the handshake. 912 4.11.3. Discarding 0-RTT Keys 914 0-RTT and 1-RTT packets share the same packet number space, and 915 clients do not send 0-RTT packets after sending a 1-RTT packet 916 (Section 5.6). 918 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 919 1-RTT keys, since they have no use after that moment. 921 Additionally, a server MAY discard 0-RTT keys as soon as it receives 922 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 923 could arrive after a 1-RTT packet. Servers MAY temporarily retain 924 0-RTT keys to allow decrypting reordered packets without requiring 925 their contents to be retransmitted with 1-RTT keys. After receiving 926 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 927 the RECOMMENDED time period is three times the Probe Timeout (PTO, 928 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 929 determines that it has received all 0-RTT packets, which can be done 930 by keeping track of missing packet numbers. 932 5. Packet Protection 934 As with TLS over TCP, QUIC protects packets with keys derived from 935 the TLS handshake, using the AEAD algorithm negotiated by TLS. 937 5.1. Packet Protection Keys 939 QUIC derives packet protection keys in the same way that TLS derives 940 record protection keys. 942 Each encryption level has separate secret values for protection of 943 packets sent in each direction. These traffic secrets are derived by 944 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 945 encryption levels except the Initial encryption level. The secrets 946 for the Initial encryption level are computed based on the client's 947 initial Destination Connection ID, as described in Section 5.2. 949 The keys used for packet protection are computed from the TLS secrets 950 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 951 function described in Section 7.1 of [TLS13] is used, using the hash 952 function from the negotiated cipher suite. Other versions of TLS 953 MUST provide a similar function in order to be used with QUIC. 955 The current encryption level secret and the label "quic key" are 956 input to the KDF to produce the AEAD key; the label "quic iv" is used 957 to derive the IV; see Section 5.3. The header protection key uses 958 the "quic hp" label; see Section 5.4. Using these labels provides 959 key separation between QUIC and TLS; see Section 9.6. 961 The KDF used for initial secrets is always the HKDF-Expand-Label 962 function from TLS 1.3 (see Section 5.2). 964 5.2. Initial Secrets 966 Initial packets are protected with a secret derived from the 967 Destination Connection ID field from the client's Initial packet. 968 Specifically: 970 initial_salt = 0xc3eef712c72ebb5a11a7d2432bb46365bef9f502 971 initial_secret = HKDF-Extract(initial_salt, 972 client_dst_connection_id) 974 client_initial_secret = HKDF-Expand-Label(initial_secret, 975 "client in", "", 976 Hash.length) 977 server_initial_secret = HKDF-Expand-Label(initial_secret, 978 "server in", "", 979 Hash.length) 981 The hash function for HKDF when deriving initial secrets and keys is 982 SHA-256 [SHA]. 984 The connection ID used with HKDF-Expand-Label is the Destination 985 Connection ID in the Initial packet sent by the client. This will be 986 a randomly-selected value unless the client creates the Initial 987 packet after receiving a Retry packet, where the Destination 988 Connection ID is selected by the server. 990 The value of initial_salt is a 20 byte sequence shown in the figure 991 in hexadecimal notation. Future versions of QUIC SHOULD generate a 992 new salt value, thus ensuring that the keys are different for each 993 version of QUIC. This prevents a middlebox that only recognizes one 994 version of QUIC from seeing or modifying the contents of packets from 995 future versions. 997 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 998 Initial packets even where the TLS versions offered do not include 999 TLS 1.3. 1001 The secrets used for protecting Initial packets change when a server 1002 sends a Retry packet to use the connection ID value selected by the 1003 server. The secrets do not change when a client changes the 1004 Destination Connection ID it uses in response to an Initial packet 1005 from the server. 1007 Note: The Destination Connection ID is of arbitrary length, and it 1008 could be zero length if the server sends a Retry packet with a 1009 zero-length Source Connection ID field. In this case, the Initial 1010 keys provide no assurance to the client that the server received 1011 its packet; the client has to rely on the exchange that included 1012 the Retry packet for that property. 1014 Appendix A contains test vectors for packet encryption. 1016 5.3. AEAD Usage 1018 The Authentication Encryption with Associated Data (AEAD) [AEAD] 1019 function used for QUIC packet protection is the AEAD that is 1020 negotiated for use with the TLS connection. For example, if TLS is 1021 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 1022 used. 1024 Packets are protected prior to applying header protection 1025 (Section 5.4). The unprotected packet header is part of the 1026 associated data (A). When removing packet protection, an endpoint 1027 first removes the header protection. 1029 All QUIC packets other than Version Negotiation and Retry packets are 1030 protected with an AEAD algorithm [AEAD]. Prior to establishing a 1031 shared secret, packets are protected with AEAD_AES_128_GCM and a key 1032 derived from the Destination Connection ID in the client's first 1033 Initial packet (see Section 5.2). This provides protection against 1034 off-path attackers and robustness against QUIC version unaware 1035 middleboxes, but not against on-path attackers. 1037 QUIC can use any of the ciphersuites defined in [TLS13] with the 1038 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 1039 negotiated unless a header protection scheme is defined for the 1040 ciphersuite. This document defines a header protection scheme for 1041 all ciphersuites defined in [TLS13] aside from 1042 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 1043 authentication tag and produce an output 16 bytes larger than their 1044 input. 1046 Note: An endpoint MUST NOT reject a ClientHello that offers a 1047 ciphersuite that it does not support, or it would be impossible to 1048 deploy a new ciphersuite. This also applies to 1049 TLS_AES_128_CCM_8_SHA256. 1051 The key and IV for the packet are computed as described in 1052 Section 5.1. The nonce, N, is formed by combining the packet 1053 protection IV with the packet number. The 62 bits of the 1054 reconstructed QUIC packet number in network byte order are left- 1055 padded with zeros to the size of the IV. The exclusive OR of the 1056 padded packet number and the IV forms the AEAD nonce. 1058 The associated data, A, for the AEAD is the contents of the QUIC 1059 header, starting from the flags byte in either the short or long 1060 header, up to and including the unprotected packet number. 1062 The input plaintext, P, for the AEAD is the payload of the QUIC 1063 packet, as described in [QUIC-TRANSPORT]. 1065 The output ciphertext, C, of the AEAD is transmitted in place of P. 1067 Some AEAD functions have limits for how many packets can be encrypted 1068 under the same key and IV (see for example [AEBounds]). This might 1069 be lower than the packet number limit. An endpoint MUST initiate a 1070 key update (Section 6) prior to exceeding any limit set for the AEAD 1071 that is in use. 1073 5.4. Header Protection 1075 Parts of QUIC packet headers, in particular the Packet Number field, 1076 are protected using a key that is derived separate to the packet 1077 protection key and IV. The key derived using the "quic hp" label is 1078 used to provide confidentiality protection for those fields that are 1079 not exposed to on-path elements. 1081 This protection applies to the least-significant bits of the first 1082 byte, plus the Packet Number field. The four least-significant bits 1083 of the first byte are protected for packets with long headers; the 1084 five least significant bits of the first byte are protected for 1085 packets with short headers. For both header forms, this covers the 1086 reserved bits and the Packet Number Length field; the Key Phase bit 1087 is also protected for packets with a short header. 1089 The same header protection key is used for the duration of the 1090 connection, with the value not changing after a key update (see 1091 Section 6). This allows header protection to be used to protect the 1092 key phase. 1094 This process does not apply to Retry or Version Negotiation packets, 1095 which do not contain a protected payload or any of the fields that 1096 are protected by this process. 1098 5.4.1. Header Protection Application 1100 Header protection is applied after packet protection is applied (see 1101 Section 5.3). The ciphertext of the packet is sampled and used as 1102 input to an encryption algorithm. The algorithm used depends on the 1103 negotiated AEAD. 1105 The output of this algorithm is a 5 byte mask which is applied to the 1106 protected header fields using exclusive OR. The least significant 1107 bits of the first byte of the packet are masked by the least 1108 significant bits of the first mask byte, and the packet number is 1109 masked with the remaining bytes. Any unused bytes of mask that might 1110 result from a shorter packet number encoding are unused. 1112 Figure 6 shows a sample algorithm for applying header protection. 1113 Removing header protection only differs in the order in which the 1114 packet number length (pn_length) is determined. 1116 mask = header_protection(hp_key, sample) 1118 pn_length = (packet[0] & 0x03) + 1 1119 if (packet[0] & 0x80) == 0x80: 1120 # Long header: 4 bits masked 1121 packet[0] ^= mask[0] & 0x0f 1122 else: 1123 # Short header: 5 bits masked 1124 packet[0] ^= mask[0] & 0x1f 1126 # pn_offset is the start of the Packet Number field. 1127 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 1129 Figure 6: Header Protection Pseudocode 1131 Figure 7 shows an example long header packet (Initial) and a short 1132 header packet. Figure 7 shows the fields in each header that are 1133 covered by header protection and the portion of the protected packet 1134 payload that is sampled. 1136 Initial Packet { 1137 Header Form (1) = 1, 1138 Fixed Bit (1) = 1, 1139 Long Packet Type (2) = 0, 1140 Reserved Bits (2), # Protected 1141 Packet Number Length (2), # Protected 1142 Version (32), 1143 DCID Len (8), 1144 Destination Connection ID (0..160), 1145 SCID Len (8), 1146 Source Connection ID (0..160), 1147 Token Length (i), 1148 Token (..), 1149 Packet Number (8..32), # Protected 1150 Protected Payload (0..24), # Skipped Part 1151 Protected Payload (128), # Sampled Part 1152 Protected Payload (..) # Remainder 1153 } 1155 Short Header Packet { 1156 Header Form (1) = 0, 1157 Fixed Bit (1) = 1, 1158 Spin Bit (1), 1159 Reserved Bits (2), # Protected 1160 Key Phase (1), # Protected 1161 Packet Number Length (2), # Protected 1162 Destination Connection ID (0..160), 1163 Packet Number (8..32), # Protected 1164 Protected Payload (0..24), # Skipped Part 1165 Protected Payload (128), # Sampled Part 1166 Protected Payload (..), # Remainder 1167 } 1169 Figure 7: Header Protection and Ciphertext Sample 1171 Before a TLS ciphersuite can be used with QUIC, a header protection 1172 algorithm MUST be specified for the AEAD used with that ciphersuite. 1173 This document defines algorithms for AEAD_AES_128_GCM, 1174 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1175 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1176 a ciphersuite, AES header protection is used (Section 5.4.3), 1177 matching the AEAD_AES_128_GCM packet protection. 1179 5.4.2. Header Protection Sample 1181 The header protection algorithm uses both the header protection key 1182 and a sample of the ciphertext from the packet Payload field. 1184 The same number of bytes are always sampled, but an allowance needs 1185 to be made for the endpoint removing protection, which will not know 1186 the length of the Packet Number field. In sampling the packet 1187 ciphertext, the Packet Number field is assumed to be 4 bytes long 1188 (its maximum possible encoded length). 1190 An endpoint MUST discard packets that are not long enough to contain 1191 a complete sample. 1193 To ensure that sufficient data is available for sampling, packets are 1194 padded so that the combined lengths of the encoded packet number and 1195 protected payload is at least 4 bytes longer than the sample required 1196 for header protection. The ciphersuites defined in [TLS13] - other 1197 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1198 is not defined in this document - have 16-byte expansions and 16-byte 1199 header protection samples. This results in needing at least 3 bytes 1200 of frames in the unprotected payload if the packet number is encoded 1201 on a single byte, or 2 bytes of frames for a 2-byte packet number 1202 encoding. 1204 The sampled ciphertext for a packet with a short header can be 1205 determined by the following pseudocode: 1207 sample_offset = 1 + len(connection_id) + 4 1209 sample = packet[sample_offset..sample_offset+sample_length] 1211 For example, for a packet with a short header, an 8 byte connection 1212 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1213 28 inclusive (using zero-based indexing). 1215 A packet with a long header is sampled in the same way, noting that 1216 multiple QUIC packets might be included in the same UDP datagram and 1217 that each one is handled separately. 1219 sample_offset = 7 + len(destination_connection_id) + 1220 len(source_connection_id) + 1221 len(payload_length) + 4 1222 if packet_type == Initial: 1223 sample_offset += len(token_length) + 1224 len(token) 1226 sample = packet[sample_offset..sample_offset+sample_length] 1228 5.4.3. AES-Based Header Protection 1230 This section defines the packet protection algorithm for 1231 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1232 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1233 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1234 in ECB mode. 1236 This algorithm samples 16 bytes from the packet ciphertext. This 1237 value is used as the input to AES-ECB. In pseudocode: 1239 mask = AES-ECB(hp_key, sample) 1241 5.4.4. ChaCha20-Based Header Protection 1243 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1244 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1245 256-bit key and 16 bytes sampled from the packet protection output. 1247 The first 4 bytes of the sampled ciphertext are the block counter. A 1248 ChaCha20 implementation could take a 32-bit integer in place of a 1249 byte sequence, in which case the byte sequence is interpreted as a 1250 little-endian value. 1252 The remaining 12 bytes are used as the nonce. A ChaCha20 1253 implementation might take an array of three 32-bit integers in place 1254 of a byte sequence, in which case the nonce bytes are interpreted as 1255 a sequence of 32-bit little-endian integers. 1257 The encryption mask is produced by invoking ChaCha20 to protect 5 1258 zero bytes. In pseudocode: 1260 counter = sample[0..3] 1261 nonce = sample[4..15] 1262 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1264 5.5. Receiving Protected Packets 1266 Once an endpoint successfully receives a packet with a given packet 1267 number, it MUST discard all packets in the same packet number space 1268 with higher packet numbers if they cannot be successfully unprotected 1269 with either the same key, or - if there is a key update - the next 1270 packet protection key (see Section 6). Similarly, a packet that 1271 appears to trigger a key update, but cannot be unprotected 1272 successfully MUST be discarded. 1274 Failure to unprotect a packet does not necessarily indicate the 1275 existence of a protocol error in a peer or an attack. The truncated 1276 packet number encoding used in QUIC can cause packet numbers to be 1277 decoded incorrectly if they are delayed significantly. 1279 5.6. Use of 0-RTT Keys 1281 If 0-RTT keys are available (see Section 4.6), the lack of replay 1282 protection means that restrictions on their use are necessary to 1283 avoid replay attacks on the protocol. 1285 A client MUST only use 0-RTT keys to protect data that is idempotent. 1286 A client MAY wish to apply additional restrictions on what data it 1287 sends prior to the completion of the TLS handshake. A client 1288 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1289 it MUST NOT send ACKs with 0-RTT keys. 1291 A client that receives an indication that its 0-RTT data has been 1292 accepted by a server can send 0-RTT data until it receives all of the 1293 server's handshake messages. A client SHOULD stop sending 0-RTT data 1294 if it receives an indication that 0-RTT data has been rejected. 1296 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1297 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1298 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1299 them. 1301 Once a client has installed 1-RTT keys, it MUST NOT send any more 1302 0-RTT packets. 1304 Note: 0-RTT data can be acknowledged by the server as it receives 1305 it, but any packets containing acknowledgments of 0-RTT data 1306 cannot have packet protection removed by the client until the TLS 1307 handshake is complete. The 1-RTT keys necessary to remove packet 1308 protection cannot be derived until the client receives all server 1309 handshake messages. 1311 5.7. Receiving Out-of-Order Protected Frames 1313 Due to reordering and loss, protected packets might be received by an 1314 endpoint before the final TLS handshake messages are received. A 1315 client will be unable to decrypt 1-RTT packets from the server, 1316 whereas a server will be able to decrypt 1-RTT packets from the 1317 client. Endpoints in either role MUST NOT decrypt 1-RTT packets from 1318 their peer prior to completing the handshake. 1320 Even though 1-RTT keys are available to a server after receiving the 1321 first handshake messages from a client, it is missing assurances on 1322 the client state: 1324 * The client is not authenticated, unless the server has chosen to 1325 use a pre-shared key and validated the client's pre-shared key 1326 binder; see Section 4.2.11 of [TLS13]. 1328 * The client has not demonstrated liveness, unless a RETRY packet 1329 was used. 1331 * Any received 0-RTT data that the server responds to might be due 1332 to a replay attack. 1334 Therefore, the server's use of 1-RTT keys MUST be limited to sending 1335 data before the handshake is complete. A server MUST NOT process 1336 incoming 1-RTT protected packets before the TLS handshake is 1337 complete. Because sending acknowledgments indicates that all frames 1338 in a packet have been processed, a server cannot send acknowledgments 1339 for 1-RTT packets until the TLS handshake is complete. Received 1340 packets protected with 1-RTT keys MAY be stored and later decrypted 1341 and used once the handshake is complete. 1343 Note: TLS implementations might provide all 1-RTT secrets prior to 1344 handshake completion. Even where QUIC implementations have 1-RTT 1345 read keys, those keys cannot be used prior to completing the 1346 handshake. 1348 The requirement for the server to wait for the client Finished 1349 message creates a dependency on that message being delivered. A 1350 client can avoid the potential for head-of-line blocking that this 1351 implies by sending its 1-RTT packets coalesced with a handshake 1352 packet containing a copy of the CRYPTO frame that carries the 1353 Finished message, until one of the handshake packets is acknowledged. 1354 This enables immediate server processing for those packets. 1356 A server could receive packets protected with 0-RTT keys prior to 1357 receiving a TLS ClientHello. The server MAY retain these packets for 1358 later decryption in anticipation of receiving a ClientHello. 1360 5.8. Retry Packet Integrity 1362 Retry packets (see the Retry Packet section of [QUIC-TRANSPORT]) 1363 carry a Retry Integrity Tag that provides two properties: it allows 1364 discarding packets that have accidentally been corrupted by the 1365 network, and it diminishes off-path attackers' ability to send valid 1366 Retry packets. 1368 The Retry Integrity Tag is a 128-bit field that is computed as the 1369 output of AEAD_AES_128_GCM [AEAD] used with the following inputs: 1371 * The secret key, K, is 128 bits equal to 1372 0x4d32ecdb2a2133c841e4043df27d4430. 1374 * The nonce, N, is 96 bits equal to 0x4d1611d05513a552c587d575. 1376 * The plaintext, P, is empty. 1378 * The associated data, A, is the contents of the Retry Pseudo- 1379 Packet, as illustrated in Figure 8: 1381 The secret key and the nonce are values derived by calling HKDF- 1382 Expand-Label using 1383 0x656e61e336ae9417f7f0edd8d78d461e2aa7084aba7a14c1e9f726d55709169a as 1384 the secret, with labels being "quic key" and "quic iv" (Section 5.1). 1386 Retry Pseudo-Packet { 1387 ODCID Length (8), 1388 Original Destination Connection ID (0..160), 1389 Header Form (1) = 1, 1390 Fixed Bit (1) = 1, 1391 Long Packet Type (2) = 3, 1392 Type-Specific Bits (4), 1393 Version (32), 1394 DCID Len (8), 1395 Destination Connection ID (0..160), 1396 SCID Len (8), 1397 Retry Token (..), 1398 } 1400 Figure 8: Retry Pseudo-Packet 1402 The Retry Pseudo-Packet is not sent over the wire. It is computed by 1403 taking the transmitted Retry packet, removing the Retry Integrity Tag 1404 and prepending the two following fields: 1406 ODCID Length: The ODCID Len contains the length in bytes of the 1407 Original Destination Connection ID field that follows it, encoded 1408 as an 8-bit unsigned integer. 1410 Original Destination Connection ID: The Original Destination 1411 Connection ID contains the value of the Destination Connection ID 1412 from the Initial packet that this Retry is in response to. The 1413 length of this field is given in ODCID Len. The presence of this 1414 field mitigates an off-path attacker's ability to inject a Retry 1415 packet. 1417 6. Key Update 1419 Once the handshake is confirmed (see Section 4.1.2), an endpoint MAY 1420 initiate a key update. 1422 The Key Phase bit indicates which packet protection keys are used to 1423 protect the packet. The Key Phase bit is initially set to 0 for the 1424 first set of 1-RTT packets and toggled to signal each subsequent key 1425 update. 1427 The Key Phase bit allows a recipient to detect a change in keying 1428 material without needing to receive the first packet that triggered 1429 the change. An endpoint that notices a changed Key Phase bit updates 1430 keys and decrypts the packet that contains the changed value. 1432 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1433 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1434 of a TLS KeyUpdate message as a connection error of type 0x10a, 1435 equivalent to a fatal TLS alert of unexpected_message (see 1436 Section 4.10). 1438 Figure 9 shows a key update process, where the initial set of keys 1439 used (identified with @M) are replaced by updated keys (identified 1440 with @N). The value of the Key Phase bit is indicated in brackets 1441 []. 1443 Initiating Peer Responding Peer 1445 @M [0] QUIC Packets 1447 ... Update to @N 1448 @N [1] QUIC Packets 1449 --------> 1450 Update to @N ... 1451 QUIC Packets [1] @N 1452 <-------- 1453 QUIC Packets [1] @N 1454 containing ACK 1455 <-------- 1456 ... Key Update Permitted 1458 @N [1] QUIC Packets 1459 containing ACK for @N packets 1460 --------> 1461 Key Update Permitted ... 1463 Figure 9: Key Update 1465 6.1. Initiating a Key Update 1467 Endpoints maintain separate read and write secrets for packet 1468 protection. An endpoint initiates a key update by updating its 1469 packet protection write secret and using that to protect new packets. 1470 The endpoint creates a new write secret from the existing write 1471 secret as performed in Section 7.2 of [TLS13]. This uses the KDF 1472 function provided by TLS with a label of "quic ku". The 1473 corresponding key and IV are created from that secret as defined in 1474 Section 5.1. The header protection key is not updated. 1476 For example, to update write keys with TLS 1.3, HKDF-Expand-Label is 1477 used as: 1479 secret_ = HKDF-Expand-Label(secret_, "quic ku", 1480 "", Hash.length) 1482 The endpoint toggles the value of the Key Phase bit and uses the 1483 updated key and IV to protect all subsequent packets. 1485 An endpoint MUST NOT initiate a key update prior to having confirmed 1486 the handshake (Section 4.1.2). An endpoint MUST NOT initiate a 1487 subsequent key update prior unless it has received an acknowledgment 1488 for a packet that was sent protected with keys from the current key 1489 phase. This ensures that keys are available to both peers before 1490 another key update can be initiated. This can be implemented by 1491 tracking the lowest packet number sent with each key phase, and the 1492 highest acknowledged packet number in the 1-RTT space: once the 1493 latter is higher than or equal to the former, another key update can 1494 be initiated. 1496 Note: Keys of packets other than the 1-RTT packets are never 1497 updated; their keys are derived solely from the TLS handshake 1498 state. 1500 The endpoint that initiates a key update also updates the keys that 1501 it uses for receiving packets. These keys will be needed to process 1502 packets the peer sends after updating. 1504 An endpoint SHOULD retain old keys so that packets sent by its peer 1505 prior to receiving the key update can be processed. Discarding old 1506 keys too early can cause delayed packets to be discarded. Discarding 1507 packets will be interpreted as packet loss by the peer and could 1508 adversely affect performance. 1510 6.2. Responding to a Key Update 1512 A peer is permitted to initiate a key update after receiving an 1513 acknowledgement of a packet in the current key phase. An endpoint 1514 detects a key update when processing a packet with a key phase that 1515 differs from the value last used to protect the last packet it sent. 1516 To process this packet, the endpoint uses the next packet protection 1517 key and IV. See Section 6.3 for considerations about generating 1518 these keys. 1520 If a packet is successfully processed using the next key and IV, then 1521 the peer has initiated a key update. The endpoint MUST update its 1522 send keys to the corresponding key phase in response, as described in 1523 Section 6.1. Sending keys MUST be updated before sending an 1524 acknowledgement for the packet that was received with updated keys. 1525 By acknowledging the packet that triggered the key update in a packet 1526 protected with the updated keys, the endpoint signals that the key 1527 update is complete. 1529 An endpoint can defer sending the packet or acknowledgement according 1530 to its normal packet sending behaviour; it is not necessary to 1531 immediately generate a packet in response to a key update. The next 1532 packet sent by the endpoint will use the updated keys. The next 1533 packet that contains an acknowledgement will cause the key update to 1534 be completed. If an endpoint detects a second update before it has 1535 sent any packets with updated keys containing an acknowledgement for 1536 the packet that initiated the key update, it indicates that its peer 1537 has updated keys twice without awaiting confirmation. An endpoint 1538 MAY treat consecutive key updates as a connection error of type 1539 KEY_UPDATE_ERROR. 1541 An endpoint that receives an acknowledgement that is carried in a 1542 packet protected with old keys where any acknowledged packet was 1543 protected with newer keys MAY treat that as a connection error of 1544 type KEY_UPDATE_ERROR. This indicates that a peer has received and 1545 acknowledged a packet that initiates a key update, but has not 1546 updated keys in response. 1548 6.3. Timing of Receive Key Generation 1550 Endpoints responding to an apparent key update MUST NOT generate a 1551 timing side-channel signal that might indicate that the Key Phase bit 1552 was invalid (see Section 9.4). Endpoints can use dummy packet 1553 protection keys in place of discarded keys when key updates are not 1554 yet permitted. Using dummy keys will generate no variation in the 1555 timing signal produced by attempting to remove packet protection, and 1556 results in all packets with an invalid Key Phase bit being rejected. 1558 The process of creating new packet protection keys for receiving 1559 packets could reveal that a key update has occurred. An endpoint MAY 1560 perform this process as part of packet processing, but this creates a 1561 timing signal that can be used by an attacker to learn when key 1562 updates happen and thus the value of the Key Phase bit in certain 1563 packets. Endpoints MAY instead defer the creation of the next set of 1564 receive packet protection keys until some time after a key update 1565 completes, up to three times the PTO; see Section 6.5. 1567 Once generated, the next set of packet protection keys SHOULD be 1568 retained, even if the packet that was received was subsequently 1569 discarded. Packets containing apparent key updates are easy to forge 1570 and - while the process of key update does not require significant 1571 effort - triggering this process could be used by an attacker for 1572 DoS. 1574 For this reason, endpoints MUST be able to retain two sets of packet 1575 protection keys for receiving packets: the current and the next. 1576 Retaining the previous keys in addition to these might improve 1577 performance, but this is not essential. 1579 6.4. Sending with Updated Keys 1581 An endpoint always sends packets that are protected with the newest 1582 keys. Keys used for packet protection can be discarded immediately 1583 after switching to newer keys. 1585 Packets with higher packet numbers MUST be protected with either the 1586 same or newer packet protection keys than packets with lower packet 1587 numbers. An endpoint that successfully removes protection with old 1588 keys when newer keys were used for packets with lower packet numbers 1589 MUST treat this as a connection error of type KEY_UPDATE_ERROR. 1591 6.5. Receiving with Different Keys 1593 For receiving packets during a key update, packets protected with 1594 older keys might arrive if they were delayed by the network. 1595 Retaining old packet protection keys allows these packets to be 1596 successfully processed. 1598 As packets protected with keys from the next key phase use the same 1599 Key Phase value as those protected with keys from the previous key 1600 phase, it can be necessary to distinguish between the two. This can 1601 be done using packet numbers. A recovered packet number that is 1602 lower than any packet number from the current key phase uses the 1603 previous packet protection keys; a recovered packet number that is 1604 higher than any packet number from the current key phase requires the 1605 use of the next packet protection keys. 1607 Some care is necessary to ensure that any process for selecting 1608 between previous, current, and next packet protection keys does not 1609 expose a timing side channel that might reveal which keys were used 1610 to remove packet protection. See Section 9.5 for more information. 1612 Alternatively, endpoints can retain only two sets of packet 1613 protection keys, swapping previous for next after enough time has 1614 passed to allow for reordering in the network. In this case, the Key 1615 Phase bit alone can be used to select keys. 1617 An endpoint MAY allow a period of approximately the Probe Timeout 1618 (PTO; see [QUIC-RECOVERY]) after a key update before it creates the 1619 next set of packet protection keys. These updated keys MAY replace 1620 the previous keys at that time. With the caveat that PTO is a 1621 subjective measure - that is, a peer could have a different view of 1622 the RTT - this time is expected to be long enough that any reordered 1623 packets would be declared lost by a peer even if they were 1624 acknowledged and short enough to allow for subsequent key updates. 1626 Endpoints need to allow for the possibility that a peer might not be 1627 able to decrypt packets that initiate a key update during the period 1628 when it retains old keys. Endpoints SHOULD wait three times the PTO 1629 before initiating a key update after receiving an acknowledgment that 1630 confirms that the previous key update was received. Failing to allow 1631 sufficient time could lead to packets being discarded. 1633 An endpoint SHOULD retain old read keys for no more than three times 1634 the PTO. After this period, old read keys and their corresponding 1635 secrets SHOULD be discarded. 1637 6.6. Key Update Frequency 1639 Key updates MUST be initiated before usage limits on packet 1640 protection keys are exceeded. For the cipher suites mentioned in 1641 this document, the limits in Section 5.5 of [TLS13] apply. Other 1642 cipher suites MUST define usage limits in order to be used with QUIC. 1644 6.7. Key Update Error Code 1646 The KEY_UPDATE_ERROR error code (0xE) is used to signal errors 1647 related to key updates. 1649 7. Security of Initial Messages 1651 Initial packets are not protected with a secret key, so they are 1652 subject to potential tampering by an attacker. QUIC provides 1653 protection against attackers that cannot read packets, but does not 1654 attempt to provide additional protection against attacks where the 1655 attacker can observe and inject packets. Some forms of tampering - 1656 such as modifying the TLS messages themselves - are detectable, but 1657 some - such as modifying ACKs - are not. 1659 For example, an attacker could inject a packet containing an ACK 1660 frame that makes it appear that a packet had not been received or to 1661 create a false impression of the state of the connection (e.g., by 1662 modifying the ACK Delay). Note that such a packet could cause a 1663 legitimate packet to be dropped as a duplicate. Implementations 1664 SHOULD use caution in relying on any data which is contained in 1665 Initial packets that is not otherwise authenticated. 1667 It is also possible for the attacker to tamper with data that is 1668 carried in Handshake packets, but because that tampering requires 1669 modifying TLS handshake messages, that tampering will cause the TLS 1670 handshake to fail. 1672 8. QUIC-Specific Adjustments to the TLS Handshake 1674 QUIC uses the TLS handshake for more than just negotiation of 1675 cryptographic parameters. The TLS handshake provides preliminary 1676 values for QUIC transport parameters and allows a server to perform 1677 return routability checks on clients. 1679 8.1. Protocol Negotiation 1681 QUIC requires that the cryptographic handshake provide authenticated 1682 protocol negotiation. TLS uses Application Layer Protocol 1683 Negotiation (ALPN) [ALPN] to select an application protocol. Unless 1684 another mechanism is used for agreeing on an application protocol, 1685 endpoints MUST use ALPN for this purpose. 1687 When using ALPN, endpoints MUST immediately close a connection (see 1688 Section 10.3 of [QUIC-TRANSPORT]) with a no_application_protocol TLS 1689 alert (QUIC error code 0x178; see Section 4.10) if an application 1690 protocol is not negotiated. While [ALPN] only specifies that servers 1691 use this alert, QUIC clients MUST use error 0x178 to terminate a 1692 connection when ALPN negotiation fails. 1694 An application protocol MAY restrict the QUIC versions that it can 1695 operate over. Servers MUST select an application protocol compatible 1696 with the QUIC version that the client has selected. The server MUST 1697 treat the inability to select a compatible application protocol as a 1698 connection error of type 0x178 (no_application_protocol). Similarly, 1699 a client MUST treat the selection of an incompatible application 1700 protocol by a server as a connection error of type 0x178. 1702 8.2. QUIC Transport Parameters Extension 1704 QUIC transport parameters are carried in a TLS extension. Different 1705 versions of QUIC might define a different method for negotiating 1706 transport configuration. 1708 Including transport parameters in the TLS handshake provides 1709 integrity protection for these values. 1711 enum { 1712 quic_transport_parameters(0xffa5), (65535) 1713 } ExtensionType; 1715 The extension_data field of the quic_transport_parameters extension 1716 contains a value that is defined by the version of QUIC that is in 1717 use. 1719 The quic_transport_parameters extension is carried in the ClientHello 1720 and the EncryptedExtensions messages during the handshake. Endpoints 1721 MUST send the quic_transport_parameters extension; endpoints that 1722 receive ClientHello or EncryptedExtensions messages without the 1723 quic_transport_parameters extension MUST close the connection with an 1724 error of type 0x16d (equivalent to a fatal TLS missing_extension 1725 alert, see Section 4.10). 1727 While the transport parameters are technically available prior to the 1728 completion of the handshake, they cannot be fully trusted until the 1729 handshake completes, and reliance on them should be minimized. 1730 However, any tampering with the parameters will cause the handshake 1731 to fail. 1733 Endpoints MUST NOT send this extension in a TLS connection that does 1734 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1735 fatal unsupported_extension alert MUST be sent by an implementation 1736 that supports this extension if the extension is received when the 1737 transport is not QUIC. 1739 8.3. Removing the EndOfEarlyData Message 1741 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1742 rely on this message to mark the end of 0-RTT data or to signal the 1743 change to Handshake keys. 1745 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1746 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1747 error of type PROTOCOL_VIOLATION. 1749 As a result, EndOfEarlyData does not appear in the TLS handshake 1750 transcript. 1752 8.4. Prohibit TLS Middlebox Compatibility Mode 1754 Appendix D.4 of [TLS13] describes an alteration to the TLS 1.3 1755 handshake as a workaround for bugs in some middleboxes. The TLS 1.3 1756 middlebox compatibility mode involves setting the legacy_session_id 1757 field to a 32-byte value in the ClientHello and ServerHello, then 1758 sending a change_cipher_spec record. Both field and record carry no 1759 semantic content and are ignored. 1761 This mode has no use in QUIC as it only applies to middleboxes that 1762 interfere with TLS over TCP. QUIC also provides no means to carry a 1763 change_cipher_spec record. A client MUST NOT request the use of the 1764 TLS 1.3 compatibility mode. A server SHOULD treat the receipt of a 1765 TLS ClientHello that with a non-empty legacy_session_id field as a 1766 connection error of type PROTOCOL_VIOLATION. 1768 9. Security Considerations 1770 All of the security considerations that apply to TLS also apply to 1771 the use of TLS in QUIC. Reading all of [TLS13] and its appendices is 1772 the best way to gain an understanding of the security properties of 1773 QUIC. 1775 This section summarizes some of the more important security aspects 1776 specific to the TLS integration, though there are many security- 1777 relevant details in the remainder of the document. 1779 9.1. Session Linkability 1781 Use of TLS session tickets allows servers and possibly other entities 1782 to correlate connections made by the same client; see Section 4.5 for 1783 details. 1785 9.2. Replay Attacks with 0-RTT 1787 As described in Section 8 of [TLS13], use of TLS early data comes 1788 with an exposure to replay attack. The use of 0-RTT in QUIC is 1789 similarly vulnerable to replay attack. 1791 Endpoints MUST implement and use the replay protections described in 1792 [TLS13], however it is recognized that these protections are 1793 imperfect. Therefore, additional consideration of the risk of replay 1794 is needed. 1796 QUIC is not vulnerable to replay attack, except via the application 1797 protocol information it might carry. The management of QUIC protocol 1798 state based on the frame types defined in [QUIC-TRANSPORT] is not 1799 vulnerable to replay. Processing of QUIC frames is idempotent and 1800 cannot result in invalid connection states if frames are replayed, 1801 reordered or lost. QUIC connections do not produce effects that last 1802 beyond the lifetime of the connection, except for those produced by 1803 the application protocol that QUIC serves. 1805 Note: TLS session tickets and address validation tokens are used to 1806 carry QUIC configuration information between connections. These 1807 MUST NOT be used to carry application semantics. The potential 1808 for reuse of these tokens means that they require stronger 1809 protections against replay. 1811 A server that accepts 0-RTT on a connection incurs a higher cost than 1812 accepting a connection without 0-RTT. This includes higher 1813 processing and computation costs. Servers need to consider the 1814 probability of replay and all associated costs when accepting 0-RTT. 1816 Ultimately, the responsibility for managing the risks of replay 1817 attacks with 0-RTT lies with an application protocol. An application 1818 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1819 the measures that are employed to protect against replay attack. An 1820 analysis of replay risk needs to consider all QUIC protocol features 1821 that carry application semantics. 1823 Disabling 0-RTT entirely is the most effective defense against replay 1824 attack. 1826 QUIC extensions MUST describe how replay attacks affect their 1827 operation, or prohibit their use in 0-RTT. Application protocols 1828 MUST either prohibit the use of extensions that carry application 1829 semantics in 0-RTT or provide replay mitigation strategies. 1831 9.3. Packet Reflection Attack Mitigation 1833 A small ClientHello that results in a large block of handshake 1834 messages from a server can be used in packet reflection attacks to 1835 amplify the traffic generated by an attacker. 1837 QUIC includes three defenses against this attack. First, the packet 1838 containing a ClientHello MUST be padded to a minimum size. Second, 1839 if responding to an unverified source address, the server is 1840 forbidden to send more than three UDP datagrams in its first flight 1841 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1842 acknowledgements of Handshake packets are authenticated, a blind 1843 attacker cannot forge them. Put together, these defenses limit the 1844 level of amplification. 1846 9.4. Header Protection Analysis 1848 [NAN] analyzes authenticated encryption algorithms which provide 1849 nonce privacy, referred to as "Hide Nonce" (HN) transforms. The 1850 general header protection construction in this document is one of 1851 those algorithms (HN1). Header protection uses the output of the 1852 packet protection AEAD to derive "sample", and then encrypts the 1853 header field using a pseudorandom function (PRF) as follows: 1855 protected_field = field XOR PRF(hp_key, sample) 1857 The header protection variants in this document use a pseudorandom 1858 permutation (PRP) in place of a generic PRF. However, since all PRPs 1859 are also PRFs [IMC], these variants do not deviate from the HN1 1860 construction. 1862 As "hp_key" is distinct from the packet protection key, it follows 1863 that header protection achieves AE2 security as defined in [NAN] and 1864 therefore guarantees privacy of "field", the protected packet header. 1865 Future header protection variants based on this construction MUST use 1866 a PRF to ensure equivalent security guarantees. 1868 Use of the same key and ciphertext sample more than once risks 1869 compromising header protection. Protecting two different headers 1870 with the same key and ciphertext sample reveals the exclusive OR of 1871 the protected fields. Assuming that the AEAD acts as a PRF, if L 1872 bits are sampled, the odds of two ciphertext samples being identical 1873 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1874 described in this document, that probability is one in 2^64. 1876 To prevent an attacker from modifying packet headers, the header is 1877 transitively authenticated using packet protection; the entire packet 1878 header is part of the authenticated additional data. Protected 1879 fields that are falsified or modified can only be detected once the 1880 packet protection is removed. 1882 9.5. Header Protection Timing Side-Channels 1884 An attacker could guess values for packet numbers or Key Phase and 1885 have an endpoint confirm guesses through timing side channels. 1886 Similarly, guesses for the packet number length can be trialed and 1887 exposed. If the recipient of a packet discards packets with 1888 duplicate packet numbers without attempting to remove packet 1889 protection they could reveal through timing side-channels that the 1890 packet number matches a received packet. For authentication to be 1891 free from side-channels, the entire process of header protection 1892 removal, packet number recovery, and packet protection removal MUST 1893 be applied together without timing and other side-channels. 1895 For the sending of packets, construction and protection of packet 1896 payloads and packet numbers MUST be free from side-channels that 1897 would reveal the packet number or its encoded size. 1899 During a key update, the time taken to generate new keys could reveal 1900 through timing side-channels that a key update has occurred. 1901 Alternatively, where an attacker injects packets this side-channel 1902 could reveal the value of the Key Phase on injected packets. After 1903 receiving a key update, an endpoint SHOULD generate and save the next 1904 set of receive packet protection keys, as described in Section 6.3. 1905 By generating new keys before a key update is received, receipt of 1906 packets will not create timing signals that leak the value of the Key 1907 Phase. 1909 This depends on not doing this key generation during packet 1910 processing and it can require that endpoints maintain three sets of 1911 packet protection keys for receiving: for the previous key phase, for 1912 the current key phase, and for the next key phase. Endpoints can 1913 instead choose to defer generation of the next receive packet 1914 protection keys until they discard old keys so that only two sets of 1915 receive keys need to be retained at any point in time. 1917 9.6. Key Diversity 1919 In using TLS, the central key schedule of TLS is used. As a result 1920 of the TLS handshake messages being integrated into the calculation 1921 of secrets, the inclusion of the QUIC transport parameters extension 1922 ensures that handshake and 1-RTT keys are not the same as those that 1923 might be produced by a server running TLS over TCP. To avoid the 1924 possibility of cross-protocol key synchronization, additional 1925 measures are provided to improve key separation. 1927 The QUIC packet protection keys and IVs are derived using a different 1928 label than the equivalent keys in TLS. 1930 To preserve this separation, a new version of QUIC SHOULD define new 1931 labels for key derivation for packet protection key and IV, plus the 1932 header protection keys. This version of QUIC uses the string "quic". 1933 Other versions can use a version-specific label in place of that 1934 string. 1936 The initial secrets use a key that is specific to the negotiated QUIC 1937 version. New QUIC versions SHOULD define a new salt value used in 1938 calculating initial secrets. 1940 10. IANA Considerations 1942 This document does not create any new IANA registries, but it 1943 registers the values in the following registries: 1945 * TLS ExtensionType Values Registry [TLS-REGISTRIES] - IANA is to 1946 register the quic_transport_parameters extension found in 1947 Section 8.2. The Recommended column is to be marked Yes. The TLS 1948 1.3 Column is to include CH and EE. 1950 * QUIC Transport Error Codes Registry [QUIC-TRANSPORT] - IANA is to 1951 register the KEY_UPDATE_ERROR (0xE), as described in Section 6.7. 1953 11. References 1955 11.1. Normative References 1957 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1958 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1959 . 1961 [AES] "Advanced encryption standard (AES)", 1962 DOI 10.6028/nist.fips.197, National Institute of Standards 1963 and Technology report, November 2001, 1964 . 1966 [ALPN] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1967 "Transport Layer Security (TLS) Application-Layer Protocol 1968 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1969 July 2014, . 1971 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1972 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1973 . 1975 [QUIC-RECOVERY] 1976 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1977 and Congestion Control", Work in Progress, Internet-Draft, 1978 draft-ietf-quic-recovery-28, 20 May 2020, 1979 . 1981 [QUIC-TRANSPORT] 1982 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1983 Multiplexed and Secure Transport", Work in Progress, 1984 Internet-Draft, draft-ietf-quic-transport-28, 20 May 2020, 1985 . 1988 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1989 Requirement Levels", BCP 14, RFC 2119, 1990 DOI 10.17487/RFC2119, March 1997, 1991 . 1993 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1994 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1995 May 2017, . 1997 [SHA] Dang, Q., "Secure Hash Standard", 1998 DOI 10.6028/nist.fips.180-4, National Institute of 1999 Standards and Technology report, July 2015, 2000 . 2002 [TLS-REGISTRIES] 2003 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 2004 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 2005 . 2007 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2008 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2009 . 2011 11.2. Informative References 2013 [AEBounds] Luykx, A. and K. Paterson, "Limits on Authenticated 2014 Encryption Use in TLS", 8 March 2016, 2015 . 2017 [HTTP2-TLS13] 2018 Benjamin, D., "Using TLS 1.3 with HTTP/2", RFC 8740, 2019 DOI 10.17487/RFC8740, February 2020, 2020 . 2022 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 2023 Cryptography, Second Edition", ISBN 978-1466570269, 6 2024 November 2014. 2026 [NAN] Bellare, M., Ng, R., and B. Tackmann, "Nonces Are Noticed: 2027 AEAD Revisited", DOI 10.1007/978-3-030-26948-7_9, Advances 2028 in Cryptology - CRYPTO 2019 pp. 235-265, 2019, 2029 . 2031 [QUIC-HTTP] 2032 Bishop, M., Ed., "Hypertext Transfer Protocol Version 3 2033 (HTTP/3)", Work in Progress, Internet-Draft, draft-ietf- 2034 quic-http-28, 20 May 2020, 2035 . 2037 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 2038 DOI 10.17487/RFC2818, May 2000, 2039 . 2041 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 2042 Housley, R., and W. Polk, "Internet X.509 Public Key 2043 Infrastructure Certificate and Certificate Revocation List 2044 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 2045 . 2047 Appendix A. Sample Packet Protection 2049 This section shows examples of packet protection so that 2050 implementations can be verified incrementally. Samples of Initial 2051 packets from both client and server, plus a Retry packet are defined. 2052 These packets use an 8-byte client-chosen Destination Connection ID 2053 of 0x8394c8f03e515708. Some intermediate values are included. All 2054 values are shown in hexadecimal. 2056 A.1. Keys 2058 The labels generated by the HKDF-Expand-Label function are: 2060 client in: 00200f746c73313320636c69656e7420696e00 2062 server in: 00200f746c7331332073657276657220696e00 2064 quic key: 00100e746c7331332071756963206b657900 2066 quic iv: 000c0d746c733133207175696320697600 2068 quic hp: 00100d746c733133207175696320687000 2069 The initial secret is common: 2071 initial_secret = HKDF-Extract(initial_salt, cid) 2072 = 524e374c6da8cf8b496f4bcb69678350 2073 7aafee6198b202b4bc823ebf7514a423 2075 The secrets for protecting client packets are: 2077 client_initial_secret 2078 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 2079 = fda3953aecc040e48b34e27ef87de3a6 2080 098ecf0e38b7e032c5c57bcbd5975b84 2082 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 2083 = af7fd7efebd21878ff66811248983694 2085 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 2086 = 8681359410a70bb9c92f0420 2088 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 2089 = a980b8b4fb7d9fbc13e814c23164253d 2091 The secrets for protecting server packets are: 2093 server_initial_secret 2094 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 2095 = 554366b81912ff90be41f17e80222130 2096 90ab17d8149179bcadf222f29ff2ddd5 2098 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 2099 = 5d51da9ee897a21b2659ccc7e5bfa577 2101 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 2102 = 5e5ae651fd1e8495af13508b 2104 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 2105 = a8ed82e6664f865aedf6106943f95fb8 2107 A.2. Client Initial 2109 The client sends an Initial packet. The unprotected payload of this 2110 packet contains the following CRYPTO frame, plus enough PADDING 2111 frames to make a 1162 byte payload: 2113 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 2114 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 2115 736572766572ff01000100000a001400 12001d00170018001901000101010201 2116 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 2117 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 2118 05030603020308040805080604010501 060102010402050206020202002d0002 2119 0101001c00024001 2121 The unprotected header includes the connection ID and a 4 byte packet 2122 number encoding for a packet number of 2: 2124 c3ff00001c088394c8f03e5157080000449e00000002 2126 Protecting the payload produces output that is sampled for header 2127 protection. Because the header uses a 4 byte packet number encoding, 2128 the first 16 bytes of the protected payload is sampled, then applied 2129 to the header: 2131 sample = 535064a4268a0d9d7b1c9d250ae35516 2133 mask = AES-ECB(hp, sample)[0..4] 2134 = 833b343aaa 2136 header[0] ^= mask[0] & 0x0f 2137 = c0 2138 header[18..21] ^= mask[1..4] 2139 = 3b343aa8 2140 header = c0ff00001c088394c8f03e5157080000449e3b343aa8 2142 The resulting protected packet is: 2144 c0ff00001c088394c8f03e5157080000 449e3b343aa8535064a4268a0d9d7b1c 2145 9d250ae355162276e9b1e3011ef6bbc0 ab48ad5bcc2681e953857ca62becd752 2146 4daac473e68d7405fbba4e9ee616c870 38bdbe908c06d9605d9ac49030359eec 2147 b1d05a14e117db8cede2bb09d0dbbfee 271cb374d8f10abec82d0f59a1dee29f 2148 e95638ed8dd41da07487468791b719c5 5c46968eb3b54680037102a28e53dc1d 2149 12903db0af5821794b41c4a93357fa59 ce69cfe7f6bdfa629eef78616447e1d6 2150 11c4baf71bf33febcb03137c2c75d253 17d3e13b684370f668411c0f00304b50 2151 1c8fd422bd9b9ad81d643b20da89ca05 25d24d2b142041cae0af205092e43008 2152 0cd8559ea4c5c6e4fa3f66082b7d303e 52ce0162baa958532b0bbc2bc785681f 2153 cf37485dff6595e01e739c8ac9efba31 b985d5f656cc092432d781db95221724 2154 87641c4d3ab8ece01e39bc85b1543661 4775a98ba8fa12d46f9b35e2a55eb72d 2155 7f85181a366663387ddc20551807e007 673bd7e26bf9b29b5ab10a1ca87cbb7a 2156 d97e99eb66959c2a9bc3cbde4707ff77 20b110fa95354674e395812e47a0ae53 2157 b464dcb2d1f345df360dc227270c7506 76f6724eb479f0d2fbb6124429990457 2158 ac6c9167f40aab739998f38b9eccb24f d47c8410131bf65a52af841275d5b3d1 2159 880b197df2b5dea3e6de56ebce3ffb6e 9277a82082f8d9677a6767089b671ebd 2160 244c214f0bde95c2beb02cd1172d58bd f39dce56ff68eb35ab39b49b4eac7c81 2161 5ea60451d6e6ab82119118df02a58684 4a9ffe162ba006d0669ef57668cab38b 2162 62f71a2523a084852cd1d079b3658dc2 f3e87949b550bab3e177cfc49ed190df 2163 f0630e43077c30de8f6ae081537f1e83 da537da980afa668e7b7fb25301cf741 2164 524be3c49884b42821f17552fbd1931a 813017b6b6590a41ea18b6ba49cd48a4 2165 40bd9a3346a7623fb4ba34a3ee571e3c 731f35a7a3cf25b551a680fa68763507 2166 b7fde3aaf023c50b9d22da6876ba337e b5e9dd9ec3daf970242b6c5aab3aa4b2 2167 96ad8b9f6832f686ef70fa938b31b4e5 ddd7364442d3ea72e73d668fb0937796 2168 f462923a81a47e1cee7426ff6d922126 9b5a62ec03d6ec94d12606cb485560ba 2169 b574816009e96504249385bb61a819be 04f62c2066214d8360a2022beb316240 2170 b6c7d78bbe56c13082e0ca272661210a bf020bf3b5783f1426436cf9ff418405 2171 93a5d0638d32fc51c5c65ff291a3a7a5 2fd6775e623a4439cc08dd25582febc9 2172 44ef92d8dbd329c91de3e9c9582e41f1 7f3d186f104ad3f90995116c682a2a14 2173 a3b4b1f547c335f0be710fc9fc03e0e5 87b8cda31ce65b969878a4ad4283e6d5 2174 b0373f43da86e9e0ffe1ae0fddd35162 55bd74566f36a38703d5f34249ded1f6 2175 6b3d9b45b9af2ccfefe984e13376b1b2 c6404aa48c8026132343da3f3a33659e 2176 c1b3e95080540b28b7f3fcd35fa5d843 b579a84c089121a60d8c1754915c344e 2177 eaf45a9bf27dc0c1e784161691220913 13eb0e87555abd706626e557fc36a04f 2178 cd191a58829104d6075c5594f627ca50 6bf181daec940f4a4f3af0074eee89da 2179 acde6758312622d4fa675b39f728e062 d2bee680d8f41a597c262648bb18bcfc 2180 13c8b3d97b1a77b2ac3af745d61a34cc 4709865bac824a94bb19058015e4e42d 2181 ea5388b911e76d2856d68cf6cf394185 2183 A.3. Server Initial 2185 The server sends the following payload in response, including an ACK 2186 frame, a CRYPTO frame, and no PADDING frames: 2188 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 2189 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 2190 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 2191 0304 2192 The header from the server includes a new connection ID and a 2-byte 2193 packet number encoding for a packet number of 1: 2195 c1ff00001c0008f067a5502a4262b50040740001 2197 As a result, after protection, the header protection sample is taken 2198 starting from the third protected octet: 2200 sample = 7002596f99ae67abf65a5852f54f58c3 2201 mask = 38168a0c25 2202 header = c9ff00001c0008f067a5502a4262b5004074168b 2204 The final protected packet is then: 2206 c9ff00001c0008f067a5502a4262b500 4074168bf22b7002596f99ae67abf65a 2207 5852f54f58c37c808682e2e40492d8a3 899fb04fc0afe9aabc8767b18a0aa493 2208 537426373b48d502214dd856d63b78ce e37bc664b3fe86d487ac7a77c53038a3 2209 cd32f0b5004d9f5754c4f7f2d1f35cf3 f7116351c92bda5b23c81034ab74f54c 2210 b1bd72951256 2212 A.4. Retry 2214 This shows a Retry packet that might be sent in response to the 2215 Initial packet in Appendix A.2. The integrity check includes the 2216 client-chosen connection ID value of 0x8394c8f03e515708, but that 2217 value is not included in the final Retry packet: 2219 ffff00001c0008f067a5502a4262b574 6f6b656ef71a5f12afe3ecf8001a920e 2220 6fdf1d63 2222 Appendix B. Change Log 2224 *RFC Editor's Note:* Please remove this section prior to 2225 publication of a final version of this document. 2227 Issue and pull request numbers are listed with a leading octothorp. 2229 B.1. Since draft-ietf-quic-tls-27 2231 * Allowed CONNECTION_CLOSE in any packet number space, with 2232 restrictions on use of the application-specific variant (#3430, 2233 #3435, #3440) 2235 * Prohibit the use of the compatibility mode from TLS 1.3 (#3594, 2236 #3595) 2238 B.2. Since draft-ietf-quic-tls-26 2239 * No changes 2241 B.3. Since draft-ietf-quic-tls-25 2243 * No changes 2245 B.4. Since draft-ietf-quic-tls-24 2247 * Rewrite key updates (#3050) 2249 - Allow but don't recommend deferring key updates (#2792, #3263) 2251 - More completely define received behavior (#2791) 2253 - Define the label used with HKDF-Expand-Label (#3054) 2255 B.5. Since draft-ietf-quic-tls-23 2257 * Key update text update (#3050): 2259 - Recommend constant-time key replacement (#2792) 2261 - Provide explicit labels for key update key derivation (#3054) 2263 * Allow first Initial from a client to span multiple packets (#2928, 2264 #3045) 2266 * PING can be sent at any encryption level (#3034, #3035) 2268 B.6. Since draft-ietf-quic-tls-22 2270 * Update the salt used for Initial secrets (#2887, #2980) 2272 B.7. Since draft-ietf-quic-tls-21 2274 * No changes 2276 B.8. Since draft-ietf-quic-tls-20 2278 * Mandate the use of the QUIC transport parameters extension (#2528, 2279 #2560) 2281 * Define handshake completion and confirmation; define clearer rules 2282 when it encryption keys should be discarded (#2214, #2267, #2673) 2284 B.9. Since draft-ietf-quic-tls-18 2286 * Increased the set of permissible frames in 0-RTT (#2344, #2355) 2288 * Transport parameter extension is mandatory (#2528, #2560) 2290 B.10. Since draft-ietf-quic-tls-17 2292 * Endpoints discard initial keys as soon as handshake keys are 2293 available (#1951, #2045) 2295 * Use of ALPN or equivalent is mandatory (#2263, #2284) 2297 B.11. Since draft-ietf-quic-tls-14 2299 * Update the salt used for Initial secrets (#1970) 2301 * Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 2303 * Change header protection 2305 - Sample from a fixed offset (#1575, #2030) 2307 - Cover part of the first byte, including the key phase (#1322, 2308 #2006) 2310 * TLS provides an AEAD and KDF function (#2046) 2312 - Clarify that the TLS KDF is used with TLS (#1997) 2314 - Change the labels for calculation of QUIC keys (#1845, #1971, 2315 #1991) 2317 * Initial keys are discarded once Handshake keys are available 2318 (#1951, #2045) 2320 B.12. Since draft-ietf-quic-tls-13 2322 * Updated to TLS 1.3 final (#1660) 2324 B.13. Since draft-ietf-quic-tls-12 2326 * Changes to integration of the TLS handshake (#829, #1018, #1094, 2327 #1165, #1190, #1233, #1242, #1252, #1450) 2329 - The cryptographic handshake uses CRYPTO frames, not stream 0 2330 - QUIC packet protection is used in place of TLS record 2331 protection 2333 - Separate QUIC packet number spaces are used for the handshake 2335 - Changed Retry to be independent of the cryptographic handshake 2337 - Limit the use of HelloRetryRequest to address TLS needs (like 2338 key shares) 2340 * Changed codepoint of TLS extension (#1395, #1402) 2342 B.14. Since draft-ietf-quic-tls-11 2344 * Encrypted packet numbers. 2346 B.15. Since draft-ietf-quic-tls-10 2348 * No significant changes. 2350 B.16. Since draft-ietf-quic-tls-09 2352 * Cleaned up key schedule and updated the salt used for handshake 2353 packet protection (#1077) 2355 B.17. Since draft-ietf-quic-tls-08 2357 * Specify value for max_early_data_size to enable 0-RTT (#942) 2359 * Update key derivation function (#1003, #1004) 2361 B.18. Since draft-ietf-quic-tls-07 2363 * Handshake errors can be reported with CONNECTION_CLOSE (#608, 2364 #891) 2366 B.19. Since draft-ietf-quic-tls-05 2368 No significant changes. 2370 B.20. Since draft-ietf-quic-tls-04 2372 * Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 2374 B.21. Since draft-ietf-quic-tls-03 2376 No significant changes. 2378 B.22. Since draft-ietf-quic-tls-02 2380 * Updates to match changes in transport draft 2382 B.23. Since draft-ietf-quic-tls-01 2384 * Use TLS alerts to signal TLS errors (#272, #374) 2386 * Require ClientHello to fit in a single packet (#338) 2388 * The second client handshake flight is now sent in the clear (#262, 2389 #337) 2391 * The QUIC header is included as AEAD Associated Data (#226, #243, 2392 #302) 2394 * Add interface necessary for client address validation (#275) 2396 * Define peer authentication (#140) 2398 * Require at least TLS 1.3 (#138) 2400 * Define transport parameters as a TLS extension (#122) 2402 * Define handling for protected packets before the handshake 2403 completes (#39) 2405 * Decouple QUIC version and ALPN (#12) 2407 B.24. Since draft-ietf-quic-tls-00 2409 * Changed bit used to signal key phase 2411 * Updated key phase markings during the handshake 2413 * Added TLS interface requirements section 2415 * Moved to use of TLS exporters for key derivation 2417 * Moved TLS error code definitions into this document 2419 B.25. Since draft-thomson-quic-tls-01 2421 * Adopted as base for draft-ietf-quic-tls 2423 * Updated authors/editors list 2425 * Added status note 2427 Contributors 2429 The IETF QUIC Working Group received an enormous amount of support 2430 from many people. The following people provided substantive 2431 contributions to this document: 2433 * Adam Langley 2435 * Alessandro Ghedini 2437 * Christian Huitema 2439 * Christopher Wood 2441 * David Schinazi 2443 * Dragana Damjanovic 2445 * Eric Rescorla 2447 * Ian Swett 2449 * Jana Iyengar 2451 * 奥 一穂 (Kazuho Oku) 2453 * Marten Seemann 2455 * Martin Duke 2457 * Mike Bishop 2459 * Mikkel Fahnøe Jørgensen 2461 * Nick Banks 2463 * Nick Harper 2465 * Roberto Peon 2467 * Rui Paulo 2469 * Ryan Hamilton 2471 * Victor Vasiliev 2473 Authors' Addresses 2474 Martin Thomson (editor) 2475 Mozilla 2477 Email: mt@lowentropy.net 2479 Sean Turner (editor) 2480 sn3rd 2482 Email: sean@sn3rd.com