idnits 2.17.1 draft-ietf-quic-tls-29.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 3 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 (9 June 2020) is 1416 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 2207 -- Looks like a reference, but probably isn't: '1' on line 1463 -- 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-29 == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-29 -- 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-29 -- 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: 11 December 2020 sn3rd 6 9 June 2020 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-29 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 11 December 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 . . . . . . . . . . . . . . . . . . . . . . 5 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. Minimum Key Update Frequency . . . . . . . . . . . . . . 36 105 6.7. Key Update Error Code . . . . . . . . . . . . . . . . . . 37 106 7. Security of Initial Messages . . . . . . . . . . . . . . . . 38 107 8. QUIC-Specific Adjustments to the TLS Handshake . . . . . . . 38 108 8.1. Protocol Negotiation . . . . . . . . . . . . . . . . . . 38 109 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 39 110 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 39 111 8.4. Prohibit TLS Middlebox Compatibility Mode . . . . . . . . 40 112 9. Security Considerations . . . . . . . . . . . . . . . . . . . 40 113 9.1. Session Linkability . . . . . . . . . . . . . . . . . . . 40 114 9.2. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 40 115 9.3. Packet Reflection Attack Mitigation . . . . . . . . . . . 41 116 9.4. Header Protection Analysis . . . . . . . . . . . . . . . 42 117 9.5. Header Protection Timing Side-Channels . . . . . . . . . 43 118 9.6. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 43 119 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 120 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 44 121 11.1. Normative References . . . . . . . . . . . . . . . . . . 44 122 11.2. Informative References . . . . . . . . . . . . . . . . . 45 123 Appendix A. Sample Packet Protection . . . . . . . . . . . . . . 46 124 A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 47 125 A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 48 126 A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 49 127 A.4. Retry . . . . . . . . . . . . . . . . . . . . . . . . . . 50 128 A.5. ChaCha20-Poly1305 Short Header Packet . . . . . . . . . . 50 129 Appendix B. Analysis of Limits on AEAD_AES_128_CCM Usage . . . . 52 130 B.1. Confidentiality Limits . . . . . . . . . . . . . . . . . 53 131 B.2. Integrity Limits . . . . . . . . . . . . . . . . . . . . 53 132 Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 53 133 C.1. Since draft-ietf-quic-tls-28 . . . . . . . . . . . . . . 53 134 C.2. Since draft-ietf-quic-tls-27 . . . . . . . . . . . . . . 54 135 C.3. Since draft-ietf-quic-tls-26 . . . . . . . . . . . . . . 54 136 C.4. Since draft-ietf-quic-tls-25 . . . . . . . . . . . . . . 54 137 C.5. Since draft-ietf-quic-tls-24 . . . . . . . . . . . . . . 54 138 C.6. Since draft-ietf-quic-tls-23 . . . . . . . . . . . . . . 54 139 C.7. Since draft-ietf-quic-tls-22 . . . . . . . . . . . . . . 54 140 C.8. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 55 141 C.9. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 55 142 C.10. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 55 143 C.11. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 55 144 C.12. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 55 145 C.13. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 56 146 C.14. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 56 147 C.15. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 56 148 C.16. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 56 149 C.17. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 56 150 C.18. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 56 151 C.19. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 56 152 C.20. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 57 153 C.21. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 57 154 C.22. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 57 155 C.23. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 57 156 C.24. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 57 157 C.25. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 57 158 C.26. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 58 159 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 58 160 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 59 162 1. Introduction 164 This document describes how QUIC [QUIC-TRANSPORT] is secured using 165 TLS [TLS13]. 167 TLS 1.3 provides critical latency improvements for connection 168 establishment over previous versions. Absent packet loss, most new 169 connections can be established and secured within a single round 170 trip; on subsequent connections between the same client and server, 171 the client can often send application data immediately, that is, 172 using a zero round trip setup. 174 This document describes how TLS acts as a security component of QUIC. 176 2. Notational Conventions 178 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 179 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 180 "OPTIONAL" in this document are to be interpreted as described in 181 BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all 182 capitals, as shown here. 184 This document uses the terminology established in [QUIC-TRANSPORT]. 186 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 187 newer version could be used (see Section 4.2). 189 2.1. TLS Overview 191 TLS provides two endpoints with a way to establish a means of 192 communication over an untrusted medium (that is, the Internet) that 193 ensures that messages they exchange cannot be observed, modified, or 194 forged. 196 Internally, TLS is a layered protocol, with the structure shown in 197 Figure 1. 199 +-------------+------------+--------------+---------+ 200 Handshake | | | Application | | 201 Layer | Handshake | Alerts | Data | ... | 202 | | | | | 203 +-------------+------------+--------------+---------+ 204 Record | | 205 Layer | Records | 206 | | 207 +---------------------------------------------------+ 209 Figure 1: TLS Layers 211 Each Handshake layer message (e.g., Handshake, Alerts, and 212 Application Data) is carried as a series of typed TLS records by the 213 Record layer. Records are individually cryptographically protected 214 and then transmitted over a reliable transport (typically TCP) which 215 provides sequencing and guaranteed delivery. 217 The TLS authenticated key exchange occurs between two endpoints: 218 client and server. The client initiates the exchange and the server 219 responds. If the key exchange completes successfully, both client 220 and server will agree on a secret. TLS supports both pre-shared key 221 (PSK) and Diffie-Hellman over either finite fields or elliptic curves 222 ((EC)DHE) key exchanges. PSK is the basis for 0-RTT; the latter 223 provides perfect forward secrecy (PFS) when the (EC)DHE keys are 224 destroyed. 226 After completing the TLS handshake, the client will have learned and 227 authenticated an identity for the server and the server is optionally 228 able to learn and authenticate an identity for the client. TLS 229 supports X.509 [RFC5280] certificate-based authentication for both 230 server and client. 232 The TLS key exchange is resistant to tampering by attackers and it 233 produces shared secrets that cannot be controlled by either 234 participating peer. 236 TLS provides two basic handshake modes of interest to QUIC: 238 * A full 1-RTT handshake in which the client is able to send 239 Application Data after one round trip and the server immediately 240 responds after receiving the first handshake message from the 241 client. 243 * A 0-RTT handshake in which the client uses information it has 244 previously learned about the server to send Application Data 245 immediately. This Application Data can be replayed by an attacker 246 so it MUST NOT carry a self-contained trigger for any non- 247 idempotent action. 249 A simplified TLS handshake with 0-RTT application data is shown in 250 Figure 2. 252 Client Server 254 ClientHello 255 (0-RTT Application Data) --------> 256 ServerHello 257 {EncryptedExtensions} 258 {Finished} 259 <-------- [Application Data] 260 {Finished} --------> 262 [Application Data] <-------> [Application Data] 264 () Indicates messages protected by Early Data (0-RTT) Keys 265 {} Indicates messages protected using Handshake Keys 266 [] Indicates messages protected using Application Data 267 (1-RTT) Keys 269 Figure 2: TLS Handshake with 0-RTT 271 Figure 2 omits the EndOfEarlyData message, which is not used in QUIC; 272 see Section 8.3. Likewise, neither ChangeCipherSpec nor KeyUpdate 273 messages are used by QUIC. ChangeCipherSpec is redundant in TLS 1.3; 274 see Section 8.4. QUIC has its own key update mechanism; see 275 Section 6. 277 Data is protected using a number of encryption levels: 279 * Initial Keys 281 * Early Data (0-RTT) Keys 283 * Handshake Keys 285 * Application Data (1-RTT) Keys 286 Application Data may appear only in the Early Data and Application 287 Data levels. Handshake and Alert messages may appear in any level. 289 The 0-RTT handshake is only possible if the client and server have 290 previously communicated. In the 1-RTT handshake, the client is 291 unable to send protected Application Data until it has received all 292 of the Handshake messages sent by the server. 294 3. Protocol Overview 296 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 297 and integrity protection of packets. For this it uses keys derived 298 from a TLS handshake [TLS13], but instead of carrying TLS records 299 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 300 directly over the QUIC transport, which takes over the 301 responsibilities of the TLS record layer, as shown in Figure 3. 303 +--------------+--------------+ +-------------+ 304 | TLS | TLS | | QUIC | 305 | Handshake | Alerts | | Applications| 306 | | | | (h3, etc.) | 307 +--------------+--------------+-+-------------+ 308 | | 309 | QUIC Transport | 310 | (streams, reliability, congestion, etc.) | 311 | | 312 +---------------------------------------------+ 313 | | 314 | QUIC Packet Protection | 315 | | 316 +---------------------------------------------+ 318 Figure 3: QUIC Layers 320 QUIC also relies on TLS for authentication and negotiation of 321 parameters that are critical to security and performance. 323 Rather than a strict layering, these two protocols cooperate: QUIC 324 uses the TLS handshake; TLS uses the reliability, ordered delivery, 325 and record layer provided by QUIC. 327 At a high level, there are two main interactions between the TLS and 328 QUIC components: 330 * The TLS component sends and receives messages via the QUIC 331 component, with QUIC providing a reliable stream abstraction to 332 TLS. 334 * The TLS component provides a series of updates to the QUIC 335 component, including (a) new packet protection keys to install (b) 336 state changes such as handshake completion, the server 337 certificate, etc. 339 Figure 4 shows these interactions in more detail, with the QUIC 340 packet protection being called out specially. 342 +------------+ +------------+ 343 | |<---- Handshake Messages ----->| | 344 | |<- Validate 0-RTT parameters ->| | 345 | |<--------- 0-RTT Keys ---------| | 346 | QUIC |<------- Handshake Keys -------| TLS | 347 | |<--------- 1-RTT Keys ---------| | 348 | |<------- Handshake Done -------| | 349 +------------+ +------------+ 350 | ^ 351 | Protect | Protected 352 v | Packet 353 +------------+ 354 | QUIC | 355 | Packet | 356 | Protection | 357 +------------+ 359 Figure 4: QUIC and TLS Interactions 361 Unlike TLS over TCP, QUIC applications which want to send data do not 362 send it through TLS "application_data" records. Rather, they send it 363 as QUIC STREAM frames or other frame types which are then carried in 364 QUIC packets. 366 4. Carrying TLS Messages 368 QUIC carries TLS handshake data in CRYPTO frames, each of which 369 consists of a contiguous block of handshake data identified by an 370 offset and length. Those frames are packaged into QUIC packets and 371 encrypted under the current TLS encryption level. As with TLS over 372 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 373 responsibility to deliver it reliably. Each chunk of data that is 374 produced by TLS is associated with the set of keys that TLS is 375 currently using. If QUIC needs to retransmit that data, it MUST use 376 the same keys even if TLS has already updated to newer keys. 378 One important difference between TLS records (used with TCP) and QUIC 379 CRYPTO frames is that in QUIC multiple frames may appear in the same 380 QUIC packet as long as they are associated with the same packet 381 number space. For instance, an endpoint can bundle a Handshake 382 message and an ACK for some Handshake data into the same packet. 384 Some frames are prohibited in different packet number spaces. The 385 rules here generalize those of TLS, in that frames associated with 386 establishing the connection can usually appear in packets in any 387 packet number space, whereas those associated with transferring data 388 can only appear in the application data packet number space: 390 * PADDING, PING, and CRYPTO frames MAY appear in any packet number 391 space. 393 * CONNECTION_CLOSE frames signaling errors at the QUIC layer (type 394 0x1c) MAY appear in any packet number space. CONNECTION_CLOSE 395 frames signaling application errors (type 0x1d) MUST only appear 396 in the application data packet number space. 398 * ACK frames MAY appear in any packet number space, but can only 399 acknowledge packets which appeared in that packet number space. 400 However, as noted below, 0-RTT packets cannot contain ACK frames. 402 * All other frame types MUST only be sent in the application data 403 packet number space. 405 Note that it is not possible to send the following frames in 0-RTT 406 packets for various reasons: ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN, 407 PATH_RESPONSE, and RETIRE_CONNECTION_ID. A server MAY treat receipt 408 of these frames in 0-RTT packets as a connection error of type 409 PROTOCOL_VIOLATION. 411 Because packets could be reordered on the wire, QUIC uses the packet 412 type to indicate which keys were used to protect a given packet, as 413 shown in Table 1. When packets of different types need to be sent, 414 endpoints SHOULD use coalesced packets to send them in the same UDP 415 datagram. 417 +---------------------+-----------------+------------------+ 418 | Packet Type | Encryption Keys | PN Space | 419 +=====================+=================+==================+ 420 | Initial | Initial secrets | Initial | 421 +---------------------+-----------------+------------------+ 422 | 0-RTT Protected | 0-RTT | Application data | 423 +---------------------+-----------------+------------------+ 424 | Handshake | Handshake | Handshake | 425 +---------------------+-----------------+------------------+ 426 | Retry | Retry | N/A | 427 +---------------------+-----------------+------------------+ 428 | Version Negotiation | N/A | N/A | 429 +---------------------+-----------------+------------------+ 430 | Short Header | 1-RTT | Application data | 431 +---------------------+-----------------+------------------+ 433 Table 1: Encryption Keys by Packet Type 435 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 436 encryption levels fit into the handshake process. 438 4.1. Interface to TLS 440 As shown in Figure 4, the interface from QUIC to TLS consists of four 441 primary functions: 443 * Sending and receiving handshake messages 445 * Processing stored transport and application state from a resumed 446 session and determining if it is valid to accept early data 448 * Rekeying (both transmit and receive) 450 * Handshake state updates 452 Additional functions might be needed to configure TLS. 454 4.1.1. Handshake Complete 456 In this document, the TLS handshake is considered complete when the 457 TLS stack has reported that the handshake is complete. This happens 458 when the TLS stack has both sent a Finished message and verified the 459 peer's Finished message. Verifying the peer's Finished provides the 460 endpoints with an assurance that previous handshake messages have not 461 been modified. Note that the handshake does not complete at both 462 endpoints simultaneously. Consequently, any requirement that is 463 based on the completion of the handshake depends on the perspective 464 of the endpoint in question. 466 4.1.2. Handshake Confirmed 468 In this document, the TLS handshake is considered confirmed at the 469 server when the handshake completes. At the client, the handshake is 470 considered confirmed when a HANDSHAKE_DONE frame is received. 472 A client MAY consider the handshake to be confirmed when it receives 473 an acknowledgement for a 1-RTT packet. This can be implemented by 474 recording the lowest packet number sent with 1-RTT keys, and 475 comparing it to the Largest Acknowledged field in any received 1-RTT 476 ACK frame: once the latter is greater than or equal to the former, 477 the handshake is confirmed. 479 4.1.3. Sending and Receiving Handshake Messages 481 In order to drive the handshake, TLS depends on being able to send 482 and receive handshake messages. There are two basic functions on 483 this interface: one where QUIC requests handshake messages and one 484 where QUIC provides handshake packets. 486 Before starting the handshake QUIC provides TLS with the transport 487 parameters (see Section 8.2) that it wishes to carry. 489 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 490 The client acquires handshake bytes before sending its first packet. 491 A QUIC server starts the process by providing TLS with the client's 492 handshake bytes. 494 At any time, the TLS stack at an endpoint will have a current sending 495 encryption level and receiving encryption level. Encryption levels 496 determine the packet type and keys that are used for protecting data. 498 Each encryption level is associated with a different sequence of 499 bytes, which is reliably transmitted to the peer in CRYPTO frames. 500 When TLS provides handshake bytes to be sent, they are appended to 501 the current flow. Any packet that includes the CRYPTO frame is 502 protected using keys from the corresponding encryption level. Four 503 encryption levels are used, producing keys for Initial, 0-RTT, 504 Handshake, and 1-RTT packets. CRYPTO frames are carried in just 505 three of these levels, omitting the 0-RTT level. These four levels 506 correspond to three packet number spaces: Initial and Handshake 507 encrypted packets use their own separate spaces; 0-RTT and 1-RTT 508 packets use the application data packet number space. 510 QUIC takes the unprotected content of TLS handshake records as the 511 content of CRYPTO frames. TLS record protection is not used by QUIC. 512 QUIC assembles CRYPTO frames into QUIC packets, which are protected 513 using QUIC packet protection. 515 QUIC is only capable of conveying TLS handshake records in CRYPTO 516 frames. TLS alerts are turned into QUIC CONNECTION_CLOSE error 517 codes; see Section 4.10. TLS application data and other message 518 types cannot be carried by QUIC at any encryption level and is an 519 error if they are received from the TLS stack. 521 When an endpoint receives a QUIC packet containing a CRYPTO frame 522 from the network, it proceeds as follows: 524 * If the packet was in the TLS receiving encryption level, sequence 525 the data into the input flow as usual. As with STREAM frames, the 526 offset is used to find the proper location in the data sequence. 527 If the result of this process is that new data is available, then 528 it is delivered to TLS in order. 530 * If the packet is from a previously installed encryption level, it 531 MUST NOT contain data which extends past the end of previously 532 received data in that flow. Implementations MUST treat any 533 violations of this requirement as a connection error of type 534 PROTOCOL_VIOLATION. 536 * If the packet is from a new encryption level, it is saved for 537 later processing by TLS. Once TLS moves to receiving from this 538 encryption level, saved data can be provided. When providing data 539 from any new encryption level to TLS, if there is data from a 540 previous encryption level that TLS has not consumed, this MUST be 541 treated as a connection error of type PROTOCOL_VIOLATION. 543 Each time that TLS is provided with new data, new handshake bytes are 544 requested from TLS. TLS might not provide any bytes if the handshake 545 messages it has received are incomplete or it has no data to send. 547 Once the TLS handshake is complete, this is indicated to QUIC along 548 with any final handshake bytes that TLS needs to send. TLS also 549 provides QUIC with the transport parameters that the peer advertised 550 during the handshake. 552 Once the handshake is complete, TLS becomes passive. TLS can still 553 receive data from its peer and respond in kind, but it will not need 554 to send more data unless specifically requested - either by an 555 application or QUIC. One reason to send data is that the server 556 might wish to provide additional or updated session tickets to a 557 client. 559 When the handshake is complete, QUIC only needs to provide TLS with 560 any data that arrives in CRYPTO streams. In the same way that is 561 done during the handshake, new data is requested from TLS after 562 providing received data. 564 4.1.4. Encryption Level Changes 566 As keys for new encryption levels become available, TLS provides QUIC 567 with those keys. Separately, as keys at a given encryption level 568 become available to TLS, TLS indicates to QUIC that reading or 569 writing keys at that encryption level are available. These events 570 are not asynchronous; they always occur immediately after TLS is 571 provided with new handshake bytes, or after TLS produces handshake 572 bytes. 574 TLS provides QUIC with three items as a new encryption level becomes 575 available: 577 * A secret 579 * An Authenticated Encryption with Associated Data (AEAD) function 581 * A Key Derivation Function (KDF) 583 These values are based on the values that TLS negotiates and are used 584 by QUIC to generate packet and header protection keys (see Section 5 585 and Section 5.4). 587 If 0-RTT is possible, it is ready after the client sends a TLS 588 ClientHello message or the server receives that message. After 589 providing a QUIC client with the first handshake bytes, the TLS stack 590 might signal the change to 0-RTT keys. On the server, after 591 receiving handshake bytes that contain a ClientHello message, a TLS 592 server might signal that 0-RTT keys are available. 594 Although TLS only uses one encryption level at a time, QUIC may use 595 more than one level. For instance, after sending its Finished 596 message (using a CRYPTO frame at the Handshake encryption level) an 597 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 598 message is lost, the endpoint uses the Handshake encryption level to 599 retransmit the lost message. Reordering or loss of packets can mean 600 that QUIC will need to handle packets at multiple encryption levels. 601 During the handshake, this means potentially handling packets at 602 higher and lower encryption levels than the current encryption level 603 used by TLS. 605 In particular, server implementations need to be able to read packets 606 at the Handshake encryption level at the same time as the 0-RTT 607 encryption level. A client could interleave ACK frames that are 608 protected with Handshake keys with 0-RTT data and the server needs to 609 process those acknowledgments in order to detect lost Handshake 610 packets. 612 QUIC also needs access to keys that might not ordinarily be available 613 to a TLS implementation. For instance, a client might need to 614 acknowledge Handshake packets before it is ready to send CRYPTO 615 frames at that encryption level. TLS therefore needs to provide keys 616 to QUIC before it might produce them for its own use. 618 4.1.5. TLS Interface Summary 620 Figure 5 summarizes the exchange between QUIC and TLS for both client 621 and server. Each arrow is tagged with the encryption level used for 622 that transmission. 624 Client Server 626 Get Handshake 627 Initial -------------> 628 Handshake Received 629 Install tx 0-RTT Keys 630 0-RTT ---------------> 631 Get Handshake 632 <------------- Initial 633 Handshake Received 634 Install Handshake keys 635 Install rx 0-RTT keys 636 Install Handshake keys 637 Get Handshake 638 <----------- Handshake 639 Handshake Received 640 Install tx 1-RTT keys 641 <--------------- 1-RTT 642 Get Handshake 643 Handshake Complete 644 Handshake -----------> 645 Handshake Received 646 Install rx 1-RTT keys 647 Handshake Complete 648 Install 1-RTT keys 649 1-RTT ---------------> 650 Get Handshake 651 <--------------- 1-RTT 652 Handshake Received 654 Figure 5: Interaction Summary between QUIC and TLS 656 Figure 5 shows the multiple packets that form a single "flight" of 657 messages being processed individually, to show what incoming messages 658 trigger different actions. New handshake messages are requested 659 after all incoming packets have been processed. This process might 660 vary depending on how QUIC implementations and the packets they 661 receive are structured. 663 4.2. TLS Version 665 This document describes how TLS 1.3 [TLS13] is used with QUIC. 667 In practice, the TLS handshake will negotiate a version of TLS to 668 use. This could result in a newer version of TLS than 1.3 being 669 negotiated if both endpoints support that version. This is 670 acceptable provided that the features of TLS 1.3 that are used by 671 QUIC are supported by the newer version. 673 A badly configured TLS implementation could negotiate TLS 1.2 or 674 another older version of TLS. An endpoint MUST terminate the 675 connection if a version of TLS older than 1.3 is negotiated. 677 4.3. ClientHello Size 679 The first Initial packet from a client contains the start or all of 680 its first cryptographic handshake message, which for TLS is the 681 ClientHello. Servers might need to parse the entire ClientHello 682 (e.g., to access extensions such as Server Name Identification (SNI) 683 or Application Layer Protocol Negotiation (ALPN)) in order to decide 684 whether to accept the new incoming QUIC connection. If the 685 ClientHello spans multiple Initial packets, such servers would need 686 to buffer the first received fragments, which could consume excessive 687 resources if the client's address has not yet been validated. To 688 avoid this, servers MAY use the Retry feature (see Section 8.1 of 689 [QUIC-TRANSPORT]) to only buffer partial ClientHello messages from 690 clients with a validated address. 692 QUIC packet and framing add at least 36 bytes of overhead to the 693 ClientHello message. That overhead increases if the client chooses a 694 connection ID without zero length. Overheads also do not include the 695 token or a connection ID longer than 8 bytes, both of which might be 696 required if a server sends a Retry packet. 698 A typical TLS ClientHello can easily fit into a 1200 byte packet. 699 However, in addition to the overheads added by QUIC, there are 700 several variables that could cause this limit to be exceeded. Large 701 session tickets, multiple or large key shares, and long lists of 702 supported ciphers, signature algorithms, versions, QUIC transport 703 parameters, and other negotiable parameters and extensions could 704 cause this message to grow. 706 For servers, in addition to connection IDs and tokens, the size of 707 TLS session tickets can have an effect on a client's ability to 708 connect efficiently. Minimizing the size of these values increases 709 the probability that clients can use them and still fit their 710 ClientHello message in their first Initial packet. 712 The TLS implementation does not need to ensure that the ClientHello 713 is sufficiently large. QUIC PADDING frames are added to increase the 714 size of the packet as necessary. 716 4.4. Peer Authentication 718 The requirements for authentication depend on the application 719 protocol that is in use. TLS provides server authentication and 720 permits the server to request client authentication. 722 A client MUST authenticate the identity of the server. This 723 typically involves verification that the identity of the server is 724 included in a certificate and that the certificate is issued by a 725 trusted entity (see for example [RFC2818]). 727 A server MAY request that the client authenticate during the 728 handshake. A server MAY refuse a connection if the client is unable 729 to authenticate when requested. The requirements for client 730 authentication vary based on application protocol and deployment. 732 A server MUST NOT use post-handshake client authentication (as 733 defined in Section 4.6.2 of [TLS13]), because the multiplexing 734 offered by QUIC prevents clients from correlating the certificate 735 request with the application-level event that triggered it (see 736 [HTTP2-TLS13]). More specifically, servers MUST NOT send post- 737 handshake TLS CertificateRequest messages and clients MUST treat 738 receipt of such messages as a connection error of type 739 PROTOCOL_VIOLATION. 741 4.5. Session Resumption 743 QUIC can use the session resumption feature of TLS 1.3. It does this 744 by carrying NewSessionTicket messages in CRYPTO frames after the 745 handshake is complete. Session resumption is the basis of 0-RTT, but 746 can be used without also enabling 0-RTT. 748 Endpoints that use session resumption might need to remember some 749 information about the current connection when creating a resumed 750 connection. TLS requires that some information be retained; see 751 Section 4.6.1 of [TLS13]. QUIC itself does not depend on any state 752 being retained when resuming a connection, unless 0-RTT is also used; 753 see Section 4.6 and Section 7.4.1 of [QUIC-TRANSPORT]. Application 754 protocols could depend on state that is retained between resumed 755 connections. 757 Clients can store any state required for resumption along with the 758 session ticket. Servers can use the session ticket to help carry 759 state. 761 Session resumption allows servers to link activity on the original 762 connection with the resumed connection, which might be a privacy 763 issue for clients. Clients can choose not to enable resumption to 764 avoid creating this correlation. Client SHOULD NOT reuse tickets as 765 that allows entities other than the server to correlate connections; 766 see Section C.4 of [TLS13]. 768 4.6. Enabling 0-RTT 770 To communicate their willingness to process 0-RTT data, servers send 771 a NewSessionTicket message that contains the "early_data" extension 772 with a max_early_data_size of 0xffffffff; the amount of data which 773 the client can send in 0-RTT is controlled by the "initial_max_data" 774 transport parameter supplied by the server. Servers MUST NOT send 775 the "early_data" extension with a max_early_data_size set to any 776 value other than 0xffffffff. A client MUST treat receipt of a 777 NewSessionTicket that contains an "early_data" extension with any 778 other value as a connection error of type PROTOCOL_VIOLATION. 780 A client that wishes to send 0-RTT packets uses the "early_data" 781 extension in the ClientHello message of a subsequent handshake (see 782 Section 4.2.10 of [TLS13]). It then sends the application data in 783 0-RTT packets. 785 4.7. Accepting and Rejecting 0-RTT 787 A server accepts 0-RTT by sending an early_data extension in the 788 EncryptedExtensions (see Section 4.2.10 of [TLS13]). The server then 789 processes and acknowledges the 0-RTT packets that it receives. 791 A server rejects 0-RTT by sending the EncryptedExtensions without an 792 early_data extension. A server will always reject 0-RTT if it sends 793 a TLS HelloRetryRequest. When rejecting 0-RTT, a server MUST NOT 794 process any 0-RTT packets, even if it could. When 0-RTT was 795 rejected, a client SHOULD treat receipt of an acknowledgement for a 796 0-RTT packet as a connection error of type PROTOCOL_VIOLATION, if it 797 is able to detect the condition. 799 When 0-RTT is rejected, all connection characteristics that the 800 client assumed might be incorrect. This includes the choice of 801 application protocol, transport parameters, and any application 802 configuration. The client therefore MUST reset the state of all 803 streams, including application state bound to those streams. 805 A client MAY attempt to send 0-RTT again if it receives a Retry or 806 Version Negotiation packet. These packets do not signify rejection 807 of 0-RTT. 809 4.8. Validating 0-RTT Configuration 811 When a server receives a ClientHello with the "early_data" extension, 812 it has to decide whether to accept or reject early data from the 813 client. Some of this decision is made by the TLS stack (e.g., 814 checking that the cipher suite being resumed was included in the 815 ClientHello; see Section 4.2.10 of [TLS13]). Even when the TLS stack 816 has no reason to reject early data, the QUIC stack or the application 817 protocol using QUIC might reject early data because the configuration 818 of the transport or application associated with the resumed session 819 is not compatible with the server's current configuration. 821 QUIC requires additional transport state to be associated with a 822 0-RTT session ticket. One common way to implement this is using 823 stateless session tickets and storing this state in the session 824 ticket. Application protocols that use QUIC might have similar 825 requirements regarding associating or storing state. This associated 826 state is used for deciding whether early data must be rejected. For 827 example, HTTP/3 ([QUIC-HTTP]) settings determine how early data from 828 the client is interpreted. Other applications using QUIC could have 829 different requirements for determining whether to accept or reject 830 early data. 832 4.9. HelloRetryRequest 834 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 835 [TLS13]) can be used to correct a client's incorrect KeyShare 836 extension as well as for a stateless round-trip check. From the 837 perspective of QUIC, this just looks like additional messages carried 838 in Initial packets. Although it is in principle possible to use this 839 feature for address verification in QUIC, QUIC implementations SHOULD 840 instead use the Retry feature (see Section 8.1 of [QUIC-TRANSPORT]). 841 HelloRetryRequest is still used to request key shares. 843 4.10. TLS Errors 845 If TLS experiences an error, it generates an appropriate alert as 846 defined in Section 6 of [TLS13]. 848 A TLS alert is converted into a QUIC connection error. The alert 849 description is added to 0x100 to produce a QUIC error code from the 850 range reserved for CRYPTO_ERROR. The resulting value is sent in a 851 QUIC CONNECTION_CLOSE frame of type 0x1c. 853 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 854 generate alerts at the "warning" level. 856 QUIC permits the use of a generic code in place of a specific error 857 code; see Section 11 of [QUIC-TRANSPORT]. For TLS alerts, this 858 includes replacing any alert with a generic alert, such as 859 handshake_failure (0x128 in QUIC). Endpoints MAY use a generic error 860 code to avoid possibly exposing confidential information. 862 4.11. Discarding Unused Keys 864 After QUIC moves to a new encryption level, packet protection keys 865 for previous encryption levels can be discarded. This occurs several 866 times during the handshake, as well as when keys are updated; see 867 Section 6. 869 Packet protection keys are not discarded immediately when new keys 870 are available. If packets from a lower encryption level contain 871 CRYPTO frames, frames that retransmit that data MUST be sent at the 872 same encryption level. Similarly, an endpoint generates 873 acknowledgements for packets at the same encryption level as the 874 packet being acknowledged. Thus, it is possible that keys for a 875 lower encryption level are needed for a short time after keys for a 876 newer encryption level are available. 878 An endpoint cannot discard keys for a given encryption level unless 879 it has both received and acknowledged all CRYPTO frames for that 880 encryption level and when all CRYPTO frames for that encryption level 881 have been acknowledged by its peer. However, this does not guarantee 882 that no further packets will need to be received or sent at that 883 encryption level because a peer might not have received all the 884 acknowledgements necessary to reach the same state. 886 Though an endpoint might retain older keys, new data MUST be sent at 887 the highest currently-available encryption level. Only ACK frames 888 and retransmissions of data in CRYPTO frames are sent at a previous 889 encryption level. These packets MAY also include PADDING frames. 891 4.11.1. Discarding Initial Keys 893 Packets protected with Initial secrets (Section 5.2) are not 894 authenticated, meaning that an attacker could spoof packets with the 895 intent to disrupt a connection. To limit these attacks, Initial 896 packet protection keys can be discarded more aggressively than other 897 keys. 899 The successful use of Handshake packets indicates that no more 900 Initial packets need to be exchanged, as these keys can only be 901 produced after receiving all CRYPTO frames from Initial packets. 902 Thus, a client MUST discard Initial keys when it first sends a 903 Handshake packet and a server MUST discard Initial keys when it first 904 successfully processes a Handshake packet. Endpoints MUST NOT send 905 Initial packets after this point. 907 This results in abandoning loss recovery state for the Initial 908 encryption level and ignoring any outstanding Initial packets. 910 4.11.2. Discarding Handshake Keys 912 An endpoint MUST discard its handshake keys when the TLS handshake is 913 confirmed (Section 4.1.2). The server MUST send a HANDSHAKE_DONE 914 frame as soon as it completes the handshake. 916 4.11.3. Discarding 0-RTT Keys 918 0-RTT and 1-RTT packets share the same packet number space, and 919 clients do not send 0-RTT packets after sending a 1-RTT packet 920 (Section 5.6). 922 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 923 1-RTT keys, since they have no use after that moment. 925 Additionally, a server MAY discard 0-RTT keys as soon as it receives 926 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 927 could arrive after a 1-RTT packet. Servers MAY temporarily retain 928 0-RTT keys to allow decrypting reordered packets without requiring 929 their contents to be retransmitted with 1-RTT keys. After receiving 930 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 931 the RECOMMENDED time period is three times the Probe Timeout (PTO, 932 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 933 determines that it has received all 0-RTT packets, which can be done 934 by keeping track of missing packet numbers. 936 5. Packet Protection 938 As with TLS over TCP, QUIC protects packets with keys derived from 939 the TLS handshake, using the AEAD algorithm negotiated by TLS. 941 5.1. Packet Protection Keys 943 QUIC derives packet protection keys in the same way that TLS derives 944 record protection keys. 946 Each encryption level has separate secret values for protection of 947 packets sent in each direction. These traffic secrets are derived by 948 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 949 encryption levels except the Initial encryption level. The secrets 950 for the Initial encryption level are computed based on the client's 951 initial Destination Connection ID, as described in Section 5.2. 953 The keys used for packet protection are computed from the TLS secrets 954 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 955 function described in Section 7.1 of [TLS13] is used, using the hash 956 function from the negotiated cipher suite. Other versions of TLS 957 MUST provide a similar function in order to be used with QUIC. 959 The current encryption level secret and the label "quic key" are 960 input to the KDF to produce the AEAD key; the label "quic iv" is used 961 to derive the IV; see Section 5.3. The header protection key uses 962 the "quic hp" label; see Section 5.4. Using these labels provides 963 key separation between QUIC and TLS; see Section 9.6. 965 The KDF used for initial secrets is always the HKDF-Expand-Label 966 function from TLS 1.3 (see Section 5.2). 968 5.2. Initial Secrets 970 Initial packets are protected with a secret derived from the 971 Destination Connection ID field from the client's Initial packet. 972 Specifically: 974 initial_salt = 0xafbfec289993d24c9e9786f19c6111e04390a899 975 initial_secret = HKDF-Extract(initial_salt, 976 client_dst_connection_id) 978 client_initial_secret = HKDF-Expand-Label(initial_secret, 979 "client in", "", 980 Hash.length) 981 server_initial_secret = HKDF-Expand-Label(initial_secret, 982 "server in", "", 983 Hash.length) 985 The hash function for HKDF when deriving initial secrets and keys is 986 SHA-256 [SHA]. 988 The connection ID used with HKDF-Expand-Label is the Destination 989 Connection ID in the Initial packet sent by the client. This will be 990 a randomly-selected value unless the client creates the Initial 991 packet after receiving a Retry packet, where the Destination 992 Connection ID is selected by the server. 994 The value of initial_salt is a 20 byte sequence shown in the figure 995 in hexadecimal notation. Future versions of QUIC SHOULD generate a 996 new salt value, thus ensuring that the keys are different for each 997 version of QUIC. This prevents a middlebox that only recognizes one 998 version of QUIC from seeing or modifying the contents of packets from 999 future versions. 1001 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 1002 Initial packets even where the TLS versions offered do not include 1003 TLS 1.3. 1005 The secrets used for protecting Initial packets change when a server 1006 sends a Retry packet to use the connection ID value selected by the 1007 server. The secrets do not change when a client changes the 1008 Destination Connection ID it uses in response to an Initial packet 1009 from the server. 1011 Note: The Destination Connection ID is of arbitrary length, and it 1012 could be zero length if the server sends a Retry packet with a 1013 zero-length Source Connection ID field. In this case, the Initial 1014 keys provide no assurance to the client that the server received 1015 its packet; the client has to rely on the exchange that included 1016 the Retry packet for that property. 1018 Appendix A contains test vectors for packet encryption. 1020 5.3. AEAD Usage 1022 The Authentication Encryption with Associated Data (AEAD) [AEAD] 1023 function used for QUIC packet protection is the AEAD that is 1024 negotiated for use with the TLS connection. For example, if TLS is 1025 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 1026 used. 1028 Packets are protected prior to applying header protection 1029 (Section 5.4). The unprotected packet header is part of the 1030 associated data (A). When removing packet protection, an endpoint 1031 first removes the header protection. 1033 All QUIC packets other than Version Negotiation and Retry packets are 1034 protected with an AEAD algorithm [AEAD]. Prior to establishing a 1035 shared secret, packets are protected with AEAD_AES_128_GCM and a key 1036 derived from the Destination Connection ID in the client's first 1037 Initial packet (see Section 5.2). This provides protection against 1038 off-path attackers and robustness against QUIC version unaware 1039 middleboxes, but not against on-path attackers. 1041 QUIC can use any of the ciphersuites defined in [TLS13] with the 1042 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 1043 negotiated unless a header protection scheme is defined for the 1044 ciphersuite. This document defines a header protection scheme for 1045 all ciphersuites defined in [TLS13] aside from 1046 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 1047 authentication tag and produce an output 16 bytes larger than their 1048 input. 1050 Note: An endpoint MUST NOT reject a ClientHello that offers a 1051 ciphersuite that it does not support, or it would be impossible to 1052 deploy a new ciphersuite. This also applies to 1053 TLS_AES_128_CCM_8_SHA256. 1055 The key and IV for the packet are computed as described in 1056 Section 5.1. The nonce, N, is formed by combining the packet 1057 protection IV with the packet number. The 62 bits of the 1058 reconstructed QUIC packet number in network byte order are left- 1059 padded with zeros to the size of the IV. The exclusive OR of the 1060 padded packet number and the IV forms the AEAD nonce. 1062 The associated data, A, for the AEAD is the contents of the QUIC 1063 header, starting from the flags byte in either the short or long 1064 header, up to and including the unprotected packet number. 1066 The input plaintext, P, for the AEAD is the payload of the QUIC 1067 packet, as described in [QUIC-TRANSPORT]. 1069 The output ciphertext, C, of the AEAD is transmitted in place of P. 1071 Some AEAD functions have limits for how many packets can be encrypted 1072 under the same key and IV (see for example [AEBounds]). This might 1073 be lower than the packet number limit. An endpoint MUST initiate a 1074 key update (Section 6) prior to exceeding any limit set for the AEAD 1075 that is in use. 1077 5.4. Header Protection 1079 Parts of QUIC packet headers, in particular the Packet Number field, 1080 are protected using a key that is derived separate to the packet 1081 protection key and IV. The key derived using the "quic hp" label is 1082 used to provide confidentiality protection for those fields that are 1083 not exposed to on-path elements. 1085 This protection applies to the least-significant bits of the first 1086 byte, plus the Packet Number field. The four least-significant bits 1087 of the first byte are protected for packets with long headers; the 1088 five least significant bits of the first byte are protected for 1089 packets with short headers. For both header forms, this covers the 1090 reserved bits and the Packet Number Length field; the Key Phase bit 1091 is also protected for packets with a short header. 1093 The same header protection key is used for the duration of the 1094 connection, with the value not changing after a key update (see 1095 Section 6). This allows header protection to be used to protect the 1096 key phase. 1098 This process does not apply to Retry or Version Negotiation packets, 1099 which do not contain a protected payload or any of the fields that 1100 are protected by this process. 1102 5.4.1. Header Protection Application 1104 Header protection is applied after packet protection is applied (see 1105 Section 5.3). The ciphertext of the packet is sampled and used as 1106 input to an encryption algorithm. The algorithm used depends on the 1107 negotiated AEAD. 1109 The output of this algorithm is a 5 byte mask which is applied to the 1110 protected header fields using exclusive OR. The least significant 1111 bits of the first byte of the packet are masked by the least 1112 significant bits of the first mask byte, and the packet number is 1113 masked with the remaining bytes. Any unused bytes of mask that might 1114 result from a shorter packet number encoding are unused. 1116 Figure 6 shows a sample algorithm for applying header protection. 1117 Removing header protection only differs in the order in which the 1118 packet number length (pn_length) is determined. 1120 mask = header_protection(hp_key, sample) 1122 pn_length = (packet[0] & 0x03) + 1 1123 if (packet[0] & 0x80) == 0x80: 1124 # Long header: 4 bits masked 1125 packet[0] ^= mask[0] & 0x0f 1126 else: 1127 # Short header: 5 bits masked 1128 packet[0] ^= mask[0] & 0x1f 1130 # pn_offset is the start of the Packet Number field. 1131 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 1133 Figure 6: Header Protection Pseudocode 1135 Figure 7 shows an example long header packet (Initial) and a short 1136 header packet. Figure 7 shows the fields in each header that are 1137 covered by header protection and the portion of the protected packet 1138 payload that is sampled. 1140 Initial Packet { 1141 Header Form (1) = 1, 1142 Fixed Bit (1) = 1, 1143 Long Packet Type (2) = 0, 1144 Reserved Bits (2), # Protected 1145 Packet Number Length (2), # Protected 1146 Version (32), 1147 DCID Len (8), 1148 Destination Connection ID (0..160), 1149 SCID Len (8), 1150 Source Connection ID (0..160), 1151 Token Length (i), 1152 Token (..), 1153 Length (i), 1154 Packet Number (8..32), # Protected 1155 Protected Payload (0..24), # Skipped Part 1156 Protected Payload (128), # Sampled Part 1157 Protected Payload (..) # Remainder 1158 } 1160 Short Header Packet { 1161 Header Form (1) = 0, 1162 Fixed Bit (1) = 1, 1163 Spin Bit (1), 1164 Reserved Bits (2), # Protected 1165 Key Phase (1), # Protected 1166 Packet Number Length (2), # Protected 1167 Destination Connection ID (0..160), 1168 Packet Number (8..32), # Protected 1169 Protected Payload (0..24), # Skipped Part 1170 Protected Payload (128), # Sampled Part 1171 Protected Payload (..), # Remainder 1172 } 1174 Figure 7: Header Protection and Ciphertext Sample 1176 Before a TLS ciphersuite can be used with QUIC, a header protection 1177 algorithm MUST be specified for the AEAD used with that ciphersuite. 1178 This document defines algorithms for AEAD_AES_128_GCM, 1179 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1180 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1181 a ciphersuite, AES header protection is used (Section 5.4.3), 1182 matching the AEAD_AES_128_GCM packet protection. 1184 5.4.2. Header Protection Sample 1186 The header protection algorithm uses both the header protection key 1187 and a sample of the ciphertext from the packet Payload field. 1189 The same number of bytes are always sampled, but an allowance needs 1190 to be made for the endpoint removing protection, which will not know 1191 the length of the Packet Number field. In sampling the packet 1192 ciphertext, the Packet Number field is assumed to be 4 bytes long 1193 (its maximum possible encoded length). 1195 An endpoint MUST discard packets that are not long enough to contain 1196 a complete sample. 1198 To ensure that sufficient data is available for sampling, packets are 1199 padded so that the combined lengths of the encoded packet number and 1200 protected payload is at least 4 bytes longer than the sample required 1201 for header protection. The ciphersuites defined in [TLS13] - other 1202 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1203 is not defined in this document - have 16-byte expansions and 16-byte 1204 header protection samples. This results in needing at least 3 bytes 1205 of frames in the unprotected payload if the packet number is encoded 1206 on a single byte, or 2 bytes of frames for a 2-byte packet number 1207 encoding. 1209 The sampled ciphertext for a packet with a short header can be 1210 determined by the following pseudocode: 1212 sample_offset = 1 + len(connection_id) + 4 1214 sample = packet[sample_offset..sample_offset+sample_length] 1216 For example, for a packet with a short header, an 8 byte connection 1217 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1218 28 inclusive (using zero-based indexing). 1220 A packet with a long header is sampled in the same way, noting that 1221 multiple QUIC packets might be included in the same UDP datagram and 1222 that each one is handled separately. 1224 sample_offset = 7 + len(destination_connection_id) + 1225 len(source_connection_id) + 1226 len(payload_length) + 4 1227 if packet_type == Initial: 1228 sample_offset += len(token_length) + 1229 len(token) 1231 sample = packet[sample_offset..sample_offset+sample_length] 1233 5.4.3. AES-Based Header Protection 1235 This section defines the packet protection algorithm for 1236 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1237 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1238 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1239 in ECB mode. 1241 This algorithm samples 16 bytes from the packet ciphertext. This 1242 value is used as the input to AES-ECB. In pseudocode: 1244 mask = AES-ECB(hp_key, sample) 1246 5.4.4. ChaCha20-Based Header Protection 1248 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1249 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1250 256-bit key and 16 bytes sampled from the packet protection output. 1252 The first 4 bytes of the sampled ciphertext are the block counter. A 1253 ChaCha20 implementation could take a 32-bit integer in place of a 1254 byte sequence, in which case the byte sequence is interpreted as a 1255 little-endian value. 1257 The remaining 12 bytes are used as the nonce. A ChaCha20 1258 implementation might take an array of three 32-bit integers in place 1259 of a byte sequence, in which case the nonce bytes are interpreted as 1260 a sequence of 32-bit little-endian integers. 1262 The encryption mask is produced by invoking ChaCha20 to protect 5 1263 zero bytes. In pseudocode: 1265 counter = sample[0..3] 1266 nonce = sample[4..15] 1267 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1269 5.5. Receiving Protected Packets 1271 Once an endpoint successfully receives a packet with a given packet 1272 number, it MUST discard all packets in the same packet number space 1273 with higher packet numbers if they cannot be successfully unprotected 1274 with either the same key, or - if there is a key update - the next 1275 packet protection key (see Section 6). Similarly, a packet that 1276 appears to trigger a key update, but cannot be unprotected 1277 successfully MUST be discarded. 1279 Failure to unprotect a packet does not necessarily indicate the 1280 existence of a protocol error in a peer or an attack. The truncated 1281 packet number encoding used in QUIC can cause packet numbers to be 1282 decoded incorrectly if they are delayed significantly. 1284 5.6. Use of 0-RTT Keys 1286 If 0-RTT keys are available (see Section 4.6), the lack of replay 1287 protection means that restrictions on their use are necessary to 1288 avoid replay attacks on the protocol. 1290 A client MUST only use 0-RTT keys to protect data that is idempotent. 1291 A client MAY wish to apply additional restrictions on what data it 1292 sends prior to the completion of the TLS handshake. A client 1293 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1294 it MUST NOT send ACKs with 0-RTT keys. 1296 A client that receives an indication that its 0-RTT data has been 1297 accepted by a server can send 0-RTT data until it receives all of the 1298 server's handshake messages. A client SHOULD stop sending 0-RTT data 1299 if it receives an indication that 0-RTT data has been rejected. 1301 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1302 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1303 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1304 them. 1306 Once a client has installed 1-RTT keys, it MUST NOT send any more 1307 0-RTT packets. 1309 Note: 0-RTT data can be acknowledged by the server as it receives 1310 it, but any packets containing acknowledgments of 0-RTT data 1311 cannot have packet protection removed by the client until the TLS 1312 handshake is complete. The 1-RTT keys necessary to remove packet 1313 protection cannot be derived until the client receives all server 1314 handshake messages. 1316 5.7. Receiving Out-of-Order Protected Frames 1318 Due to reordering and loss, protected packets might be received by an 1319 endpoint before the final TLS handshake messages are received. A 1320 client will be unable to decrypt 1-RTT packets from the server, 1321 whereas a server will be able to decrypt 1-RTT packets from the 1322 client. Endpoints in either role MUST NOT decrypt 1-RTT packets from 1323 their peer prior to completing the handshake. 1325 Even though 1-RTT keys are available to a server after receiving the 1326 first handshake messages from a client, it is missing assurances on 1327 the client state: 1329 * The client is not authenticated, unless the server has chosen to 1330 use a pre-shared key and validated the client's pre-shared key 1331 binder; see Section 4.2.11 of [TLS13]. 1333 * The client has not demonstrated liveness, unless a RETRY packet 1334 was used. 1336 * Any received 0-RTT data that the server responds to might be due 1337 to a replay attack. 1339 Therefore, the server's use of 1-RTT keys MUST be limited to sending 1340 data before the handshake is complete. A server MUST NOT process 1341 incoming 1-RTT protected packets before the TLS handshake is 1342 complete. Because sending acknowledgments indicates that all frames 1343 in a packet have been processed, a server cannot send acknowledgments 1344 for 1-RTT packets until the TLS handshake is complete. Received 1345 packets protected with 1-RTT keys MAY be stored and later decrypted 1346 and used once the handshake is complete. 1348 Note: TLS implementations might provide all 1-RTT secrets prior to 1349 handshake completion. Even where QUIC implementations have 1-RTT 1350 read keys, those keys cannot be used prior to completing the 1351 handshake. 1353 The requirement for the server to wait for the client Finished 1354 message creates a dependency on that message being delivered. A 1355 client can avoid the potential for head-of-line blocking that this 1356 implies by sending its 1-RTT packets coalesced with a handshake 1357 packet containing a copy of the CRYPTO frame that carries the 1358 Finished message, until one of the handshake packets is acknowledged. 1359 This enables immediate server processing for those packets. 1361 A server could receive packets protected with 0-RTT keys prior to 1362 receiving a TLS ClientHello. The server MAY retain these packets for 1363 later decryption in anticipation of receiving a ClientHello. 1365 5.8. Retry Packet Integrity 1367 Retry packets (see the Retry Packet section of [QUIC-TRANSPORT]) 1368 carry a Retry Integrity Tag that provides two properties: it allows 1369 discarding packets that have accidentally been corrupted by the 1370 network, and it diminishes off-path attackers' ability to send valid 1371 Retry packets. 1373 The Retry Integrity Tag is a 128-bit field that is computed as the 1374 output of AEAD_AES_128_GCM [AEAD] used with the following inputs: 1376 * The secret key, K, is 128 bits equal to 1377 0xccce187ed09a09d05728155a6cb96be1. 1379 * The nonce, N, is 96 bits equal to 0xe54930f97f2136f0530a8c1c. 1381 * The plaintext, P, is empty. 1383 * The associated data, A, is the contents of the Retry Pseudo- 1384 Packet, as illustrated in Figure 8: 1386 The secret key and the nonce are values derived by calling HKDF- 1387 Expand-Label using 1388 0x8b0d37eb8535022ebc8d76a207d80df22646ec06dc809642c30a8baa2baaff4c as 1389 the secret, with labels being "quic key" and "quic iv" (Section 5.1). 1391 Retry Pseudo-Packet { 1392 ODCID Length (8), 1393 Original Destination Connection ID (0..160), 1394 Header Form (1) = 1, 1395 Fixed Bit (1) = 1, 1396 Long Packet Type (2) = 3, 1397 Type-Specific Bits (4), 1398 Version (32), 1399 DCID Len (8), 1400 Destination Connection ID (0..160), 1401 SCID Len (8), 1402 Retry Token (..), 1403 } 1405 Figure 8: Retry Pseudo-Packet 1407 The Retry Pseudo-Packet is not sent over the wire. It is computed by 1408 taking the transmitted Retry packet, removing the Retry Integrity Tag 1409 and prepending the two following fields: 1411 ODCID Length: The ODCID Len contains the length in bytes of the 1412 Original Destination Connection ID field that follows it, encoded 1413 as an 8-bit unsigned integer. 1415 Original Destination Connection ID: The Original Destination 1416 Connection ID contains the value of the Destination Connection ID 1417 from the Initial packet that this Retry is in response to. The 1418 length of this field is given in ODCID Len. The presence of this 1419 field mitigates an off-path attacker's ability to inject a Retry 1420 packet. 1422 6. Key Update 1424 Once the handshake is confirmed (see Section 4.1.2), an endpoint MAY 1425 initiate a key update. 1427 The Key Phase bit indicates which packet protection keys are used to 1428 protect the packet. The Key Phase bit is initially set to 0 for the 1429 first set of 1-RTT packets and toggled to signal each subsequent key 1430 update. 1432 The Key Phase bit allows a recipient to detect a change in keying 1433 material without needing to receive the first packet that triggered 1434 the change. An endpoint that notices a changed Key Phase bit updates 1435 keys and decrypts the packet that contains the changed value. 1437 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1438 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1439 of a TLS KeyUpdate message as a connection error of type 0x10a, 1440 equivalent to a fatal TLS alert of unexpected_message (see 1441 Section 4.10). 1443 Figure 9 shows a key update process, where the initial set of keys 1444 used (identified with @M) are replaced by updated keys (identified 1445 with @N). The value of the Key Phase bit is indicated in brackets 1446 []. 1448 Initiating Peer Responding Peer 1450 @M [0] QUIC Packets 1452 ... Update to @N 1453 @N [1] QUIC Packets 1454 --------> 1455 Update to @N ... 1456 QUIC Packets [1] @N 1457 <-------- 1458 QUIC Packets [1] @N 1459 containing ACK 1460 <-------- 1461 ... Key Update Permitted 1463 @N [1] QUIC Packets 1464 containing ACK for @N packets 1465 --------> 1466 Key Update Permitted ... 1468 Figure 9: Key Update 1470 6.1. Initiating a Key Update 1472 Endpoints maintain separate read and write secrets for packet 1473 protection. An endpoint initiates a key update by updating its 1474 packet protection write secret and using that to protect new packets. 1475 The endpoint creates a new write secret from the existing write 1476 secret as performed in Section 7.2 of [TLS13]. This uses the KDF 1477 function provided by TLS with a label of "quic ku". The 1478 corresponding key and IV are created from that secret as defined in 1479 Section 5.1. The header protection key is not updated. 1481 For example, to update write keys with TLS 1.3, HKDF-Expand-Label is 1482 used as: 1484 secret_ = HKDF-Expand-Label(secret_, "quic ku", 1485 "", Hash.length) 1487 The endpoint toggles the value of the Key Phase bit and uses the 1488 updated key and IV to protect all subsequent packets. 1490 An endpoint MUST NOT initiate a key update prior to having confirmed 1491 the handshake (Section 4.1.2). An endpoint MUST NOT initiate a 1492 subsequent key update prior unless it has received an acknowledgment 1493 for a packet that was sent protected with keys from the current key 1494 phase. This ensures that keys are available to both peers before 1495 another key update can be initiated. This can be implemented by 1496 tracking the lowest packet number sent with each key phase, and the 1497 highest acknowledged packet number in the 1-RTT space: once the 1498 latter is higher than or equal to the former, another key update can 1499 be initiated. 1501 Note: Keys of packets other than the 1-RTT packets are never 1502 updated; their keys are derived solely from the TLS handshake 1503 state. 1505 The endpoint that initiates a key update also updates the keys that 1506 it uses for receiving packets. These keys will be needed to process 1507 packets the peer sends after updating. 1509 An endpoint SHOULD retain old keys so that packets sent by its peer 1510 prior to receiving the key update can be processed. Discarding old 1511 keys too early can cause delayed packets to be discarded. Discarding 1512 packets will be interpreted as packet loss by the peer and could 1513 adversely affect performance. 1515 6.2. Responding to a Key Update 1517 A peer is permitted to initiate a key update after receiving an 1518 acknowledgement of a packet in the current key phase. An endpoint 1519 detects a key update when processing a packet with a key phase that 1520 differs from the value last used to protect the last packet it sent. 1521 To process this packet, the endpoint uses the next packet protection 1522 key and IV. See Section 6.3 for considerations about generating 1523 these keys. 1525 If a packet is successfully processed using the next key and IV, then 1526 the peer has initiated a key update. The endpoint MUST update its 1527 send keys to the corresponding key phase in response, as described in 1528 Section 6.1. Sending keys MUST be updated before sending an 1529 acknowledgement for the packet that was received with updated keys. 1530 By acknowledging the packet that triggered the key update in a packet 1531 protected with the updated keys, the endpoint signals that the key 1532 update is complete. 1534 An endpoint can defer sending the packet or acknowledgement according 1535 to its normal packet sending behaviour; it is not necessary to 1536 immediately generate a packet in response to a key update. The next 1537 packet sent by the endpoint will use the updated keys. The next 1538 packet that contains an acknowledgement will cause the key update to 1539 be completed. If an endpoint detects a second update before it has 1540 sent any packets with updated keys containing an acknowledgement for 1541 the packet that initiated the key update, it indicates that its peer 1542 has updated keys twice without awaiting confirmation. An endpoint 1543 MAY treat consecutive key updates as a connection error of type 1544 KEY_UPDATE_ERROR. 1546 An endpoint that receives an acknowledgement that is carried in a 1547 packet protected with old keys where any acknowledged packet was 1548 protected with newer keys MAY treat that as a connection error of 1549 type KEY_UPDATE_ERROR. This indicates that a peer has received and 1550 acknowledged a packet that initiates a key update, but has not 1551 updated keys in response. 1553 6.3. Timing of Receive Key Generation 1555 Endpoints responding to an apparent key update MUST NOT generate a 1556 timing side-channel signal that might indicate that the Key Phase bit 1557 was invalid (see Section 9.4). Endpoints can use dummy packet 1558 protection keys in place of discarded keys when key updates are not 1559 yet permitted. Using dummy keys will generate no variation in the 1560 timing signal produced by attempting to remove packet protection, and 1561 results in all packets with an invalid Key Phase bit being rejected. 1563 The process of creating new packet protection keys for receiving 1564 packets could reveal that a key update has occurred. An endpoint MAY 1565 perform this process as part of packet processing, but this creates a 1566 timing signal that can be used by an attacker to learn when key 1567 updates happen and thus the value of the Key Phase bit in certain 1568 packets. Endpoints MAY instead defer the creation of the next set of 1569 receive packet protection keys until some time after a key update 1570 completes, up to three times the PTO; see Section 6.5. 1572 Once generated, the next set of packet protection keys SHOULD be 1573 retained, even if the packet that was received was subsequently 1574 discarded. Packets containing apparent key updates are easy to forge 1575 and - while the process of key update does not require significant 1576 effort - triggering this process could be used by an attacker for 1577 DoS. 1579 For this reason, endpoints MUST be able to retain two sets of packet 1580 protection keys for receiving packets: the current and the next. 1581 Retaining the previous keys in addition to these might improve 1582 performance, but this is not essential. 1584 6.4. Sending with Updated Keys 1586 An endpoint always sends packets that are protected with the newest 1587 keys. Keys used for packet protection can be discarded immediately 1588 after switching to newer keys. 1590 Packets with higher packet numbers MUST be protected with either the 1591 same or newer packet protection keys than packets with lower packet 1592 numbers. An endpoint that successfully removes protection with old 1593 keys when newer keys were used for packets with lower packet numbers 1594 MUST treat this as a connection error of type KEY_UPDATE_ERROR. 1596 6.5. Receiving with Different Keys 1598 For receiving packets during a key update, packets protected with 1599 older keys might arrive if they were delayed by the network. 1600 Retaining old packet protection keys allows these packets to be 1601 successfully processed. 1603 As packets protected with keys from the next key phase use the same 1604 Key Phase value as those protected with keys from the previous key 1605 phase, it can be necessary to distinguish between the two. This can 1606 be done using packet numbers. A recovered packet number that is 1607 lower than any packet number from the current key phase uses the 1608 previous packet protection keys; a recovered packet number that is 1609 higher than any packet number from the current key phase requires the 1610 use of the next packet protection keys. 1612 Some care is necessary to ensure that any process for selecting 1613 between previous, current, and next packet protection keys does not 1614 expose a timing side channel that might reveal which keys were used 1615 to remove packet protection. See Section 9.5 for more information. 1617 Alternatively, endpoints can retain only two sets of packet 1618 protection keys, swapping previous for next after enough time has 1619 passed to allow for reordering in the network. In this case, the Key 1620 Phase bit alone can be used to select keys. 1622 An endpoint MAY allow a period of approximately the Probe Timeout 1623 (PTO; see [QUIC-RECOVERY]) after a key update before it creates the 1624 next set of packet protection keys. These updated keys MAY replace 1625 the previous keys at that time. With the caveat that PTO is a 1626 subjective measure - that is, a peer could have a different view of 1627 the RTT - this time is expected to be long enough that any reordered 1628 packets would be declared lost by a peer even if they were 1629 acknowledged and short enough to allow for subsequent key updates. 1631 Endpoints need to allow for the possibility that a peer might not be 1632 able to decrypt packets that initiate a key update during the period 1633 when it retains old keys. Endpoints SHOULD wait three times the PTO 1634 before initiating a key update after receiving an acknowledgment that 1635 confirms that the previous key update was received. Failing to allow 1636 sufficient time could lead to packets being discarded. 1638 An endpoint SHOULD retain old read keys for no more than three times 1639 the PTO. After this period, old read keys and their corresponding 1640 secrets SHOULD be discarded. 1642 6.6. Minimum Key Update Frequency 1644 Key updates MUST be initiated before usage limits on packet 1645 protection keys are exceeded. For the cipher suites mentioned in 1646 this document, the limits in Section 5.5 of [TLS13] apply. [TLS13] 1647 does not specify a limit for AEAD_AES_128_CCM, but the analysis in 1648 Appendix B shows that a limit of 2^23 packets can be used to obtain 1649 the same confidentiality protection as the limits specified in TLS. 1651 The usage limits defined in TLS 1.3 exist for protection against 1652 attacks on confidentiality and apply to successful applications of 1653 AEAD protection. The integrity protections in authenticated 1654 encryption also depend on limiting the number of attempts to forge 1655 packets. TLS achieves this by closing connections after any record 1656 fails an authentication check. In comparison, QUIC ignores any 1657 packet that cannot be authenticated, allowing multiple forgery 1658 attempts. 1660 Endpoints MUST count the number of received packets that fail 1661 authentication for each set of keys. If the number of packets that 1662 fail authentication with the same key exceeds a limit that is 1663 specific to the AEAD in use, the endpoint MUST stop using those keys. 1664 Endpoints MUST initiate a key update before reaching this limit. If 1665 a key update is not possible, the endpoint MUST immediately close the 1666 connection. Applying a limit reduces the probability that an 1667 attacker is able to successfully forge a packet; see [AEBounds] and 1668 [ROBUST]. 1670 Note: Due to the way that header protection protects the Key Phase, 1671 packets that are discarded are likely to have an even distribution 1672 of both Key Phase values. This means that packets that fail 1673 authentication will often use the packet protection keys from the 1674 next key phase. It is therefore necessary to also track the 1675 number of packets that fail authentication with the next set of 1676 packet protection keys. To avoid exhaustion of both sets of keys, 1677 it might be necessary to initiate two key updates in succession. 1679 For AEAD_AES_128_GCM, AEAD_AES_256_GCM, and AEAD_CHACHA20_POLY1305, 1680 the limit on the number of packets that fail authentication is 2^36. 1681 Note that the analysis in [AEBounds] supports a higher limit for the 1682 AEAD_AES_128_GCM and AEAD_AES_256_GCM, but this specification 1683 recommends a lower limit. For AEAD_AES_128_CCM, the limit on the 1684 number of packets that fail authentication is 2^23.5; see Appendix B. 1686 Note: These limits were originally calculated using assumptions 1687 about the limits on TLS record size. The maximum size of a TLS 1688 record is 2^14 bytes. In comparison, QUIC packets can be up to 1689 2^16 bytes. However, it is expected that QUIC packets will 1690 generally be smaller than TLS records. Where packets might be 1691 larger than 2^14 bytes in length, smaller limits might be needed. 1693 Any TLS cipher suite that is specified for use with QUIC MUST define 1694 limits on the use of the associated AEAD function that preserves 1695 margins for confidentiality and integrity. That is, limits MUST be 1696 specified for the number of packets that can be authenticated and for 1697 the number packets that can fail authentication. Providing a 1698 reference to any analysis upon which values are based - and any 1699 assumptions used in that analysis - allows limits to be adapted to 1700 varying usage conditions. 1702 6.7. Key Update Error Code 1704 The KEY_UPDATE_ERROR error code (0xE) is used to signal errors 1705 related to key updates. 1707 7. Security of Initial Messages 1709 Initial packets are not protected with a secret key, so they are 1710 subject to potential tampering by an attacker. QUIC provides 1711 protection against attackers that cannot read packets, but does not 1712 attempt to provide additional protection against attacks where the 1713 attacker can observe and inject packets. Some forms of tampering - 1714 such as modifying the TLS messages themselves - are detectable, but 1715 some - such as modifying ACKs - are not. 1717 For example, an attacker could inject a packet containing an ACK 1718 frame that makes it appear that a packet had not been received or to 1719 create a false impression of the state of the connection (e.g., by 1720 modifying the ACK Delay). Note that such a packet could cause a 1721 legitimate packet to be dropped as a duplicate. Implementations 1722 SHOULD use caution in relying on any data which is contained in 1723 Initial packets that is not otherwise authenticated. 1725 It is also possible for the attacker to tamper with data that is 1726 carried in Handshake packets, but because that tampering requires 1727 modifying TLS handshake messages, that tampering will cause the TLS 1728 handshake to fail. 1730 8. QUIC-Specific Adjustments to the TLS Handshake 1732 QUIC uses the TLS handshake for more than just negotiation of 1733 cryptographic parameters. The TLS handshake provides preliminary 1734 values for QUIC transport parameters and allows a server to perform 1735 return routability checks on clients. 1737 8.1. Protocol Negotiation 1739 QUIC requires that the cryptographic handshake provide authenticated 1740 protocol negotiation. TLS uses Application Layer Protocol 1741 Negotiation (ALPN) [ALPN] to select an application protocol. Unless 1742 another mechanism is used for agreeing on an application protocol, 1743 endpoints MUST use ALPN for this purpose. 1745 When using ALPN, endpoints MUST immediately close a connection (see 1746 Section 10.3 of [QUIC-TRANSPORT]) with a no_application_protocol TLS 1747 alert (QUIC error code 0x178; see Section 4.10) if an application 1748 protocol is not negotiated. While [ALPN] only specifies that servers 1749 use this alert, QUIC clients MUST use error 0x178 to terminate a 1750 connection when ALPN negotiation fails. 1752 An application protocol MAY restrict the QUIC versions that it can 1753 operate over. Servers MUST select an application protocol compatible 1754 with the QUIC version that the client has selected. The server MUST 1755 treat the inability to select a compatible application protocol as a 1756 connection error of type 0x178 (no_application_protocol). Similarly, 1757 a client MUST treat the selection of an incompatible application 1758 protocol by a server as a connection error of type 0x178. 1760 8.2. QUIC Transport Parameters Extension 1762 QUIC transport parameters are carried in a TLS extension. Different 1763 versions of QUIC might define a different method for negotiating 1764 transport configuration. 1766 Including transport parameters in the TLS handshake provides 1767 integrity protection for these values. 1769 enum { 1770 quic_transport_parameters(0xffa5), (65535) 1771 } ExtensionType; 1773 The extension_data field of the quic_transport_parameters extension 1774 contains a value that is defined by the version of QUIC that is in 1775 use. 1777 The quic_transport_parameters extension is carried in the ClientHello 1778 and the EncryptedExtensions messages during the handshake. Endpoints 1779 MUST send the quic_transport_parameters extension; endpoints that 1780 receive ClientHello or EncryptedExtensions messages without the 1781 quic_transport_parameters extension MUST close the connection with an 1782 error of type 0x16d (equivalent to a fatal TLS missing_extension 1783 alert, see Section 4.10). 1785 While the transport parameters are technically available prior to the 1786 completion of the handshake, they cannot be fully trusted until the 1787 handshake completes, and reliance on them should be minimized. 1788 However, any tampering with the parameters will cause the handshake 1789 to fail. 1791 Endpoints MUST NOT send this extension in a TLS connection that does 1792 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1793 fatal unsupported_extension alert MUST be sent by an implementation 1794 that supports this extension if the extension is received when the 1795 transport is not QUIC. 1797 8.3. Removing the EndOfEarlyData Message 1799 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1800 rely on this message to mark the end of 0-RTT data or to signal the 1801 change to Handshake keys. 1803 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1804 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1805 error of type PROTOCOL_VIOLATION. 1807 As a result, EndOfEarlyData does not appear in the TLS handshake 1808 transcript. 1810 8.4. Prohibit TLS Middlebox Compatibility Mode 1812 Appendix D.4 of [TLS13] describes an alteration to the TLS 1.3 1813 handshake as a workaround for bugs in some middleboxes. The TLS 1.3 1814 middlebox compatibility mode involves setting the legacy_session_id 1815 field to a 32-byte value in the ClientHello and ServerHello, then 1816 sending a change_cipher_spec record. Both field and record carry no 1817 semantic content and are ignored. 1819 This mode has no use in QUIC as it only applies to middleboxes that 1820 interfere with TLS over TCP. QUIC also provides no means to carry a 1821 change_cipher_spec record. A client MUST NOT request the use of the 1822 TLS 1.3 compatibility mode. A server SHOULD treat the receipt of a 1823 TLS ClientHello with a non-empty legacy_session_id field as a 1824 connection error of type PROTOCOL_VIOLATION. 1826 9. Security Considerations 1828 All of the security considerations that apply to TLS also apply to 1829 the use of TLS in QUIC. Reading all of [TLS13] and its appendices is 1830 the best way to gain an understanding of the security properties of 1831 QUIC. 1833 This section summarizes some of the more important security aspects 1834 specific to the TLS integration, though there are many security- 1835 relevant details in the remainder of the document. 1837 9.1. Session Linkability 1839 Use of TLS session tickets allows servers and possibly other entities 1840 to correlate connections made by the same client; see Section 4.5 for 1841 details. 1843 9.2. Replay Attacks with 0-RTT 1845 As described in Section 8 of [TLS13], use of TLS early data comes 1846 with an exposure to replay attack. The use of 0-RTT in QUIC is 1847 similarly vulnerable to replay attack. 1849 Endpoints MUST implement and use the replay protections described in 1850 [TLS13], however it is recognized that these protections are 1851 imperfect. Therefore, additional consideration of the risk of replay 1852 is needed. 1854 QUIC is not vulnerable to replay attack, except via the application 1855 protocol information it might carry. The management of QUIC protocol 1856 state based on the frame types defined in [QUIC-TRANSPORT] is not 1857 vulnerable to replay. Processing of QUIC frames is idempotent and 1858 cannot result in invalid connection states if frames are replayed, 1859 reordered or lost. QUIC connections do not produce effects that last 1860 beyond the lifetime of the connection, except for those produced by 1861 the application protocol that QUIC serves. 1863 Note: TLS session tickets and address validation tokens are used to 1864 carry QUIC configuration information between connections. These 1865 MUST NOT be used to carry application semantics. The potential 1866 for reuse of these tokens means that they require stronger 1867 protections against replay. 1869 A server that accepts 0-RTT on a connection incurs a higher cost than 1870 accepting a connection without 0-RTT. This includes higher 1871 processing and computation costs. Servers need to consider the 1872 probability of replay and all associated costs when accepting 0-RTT. 1874 Ultimately, the responsibility for managing the risks of replay 1875 attacks with 0-RTT lies with an application protocol. An application 1876 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1877 the measures that are employed to protect against replay attack. An 1878 analysis of replay risk needs to consider all QUIC protocol features 1879 that carry application semantics. 1881 Disabling 0-RTT entirely is the most effective defense against replay 1882 attack. 1884 QUIC extensions MUST describe how replay attacks affect their 1885 operation, or prohibit their use in 0-RTT. Application protocols 1886 MUST either prohibit the use of extensions that carry application 1887 semantics in 0-RTT or provide replay mitigation strategies. 1889 9.3. Packet Reflection Attack Mitigation 1891 A small ClientHello that results in a large block of handshake 1892 messages from a server can be used in packet reflection attacks to 1893 amplify the traffic generated by an attacker. 1895 QUIC includes three defenses against this attack. First, the packet 1896 containing a ClientHello MUST be padded to a minimum size. Second, 1897 if responding to an unverified source address, the server is 1898 forbidden to send more than three UDP datagrams in its first flight 1899 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1900 acknowledgements of Handshake packets are authenticated, a blind 1901 attacker cannot forge them. Put together, these defenses limit the 1902 level of amplification. 1904 9.4. Header Protection Analysis 1906 [NAN] analyzes authenticated encryption algorithms which provide 1907 nonce privacy, referred to as "Hide Nonce" (HN) transforms. The 1908 general header protection construction in this document is one of 1909 those algorithms (HN1). Header protection uses the output of the 1910 packet protection AEAD to derive "sample", and then encrypts the 1911 header field using a pseudorandom function (PRF) as follows: 1913 protected_field = field XOR PRF(hp_key, sample) 1915 The header protection variants in this document use a pseudorandom 1916 permutation (PRP) in place of a generic PRF. However, since all PRPs 1917 are also PRFs [IMC], these variants do not deviate from the HN1 1918 construction. 1920 As "hp_key" is distinct from the packet protection key, it follows 1921 that header protection achieves AE2 security as defined in [NAN] and 1922 therefore guarantees privacy of "field", the protected packet header. 1923 Future header protection variants based on this construction MUST use 1924 a PRF to ensure equivalent security guarantees. 1926 Use of the same key and ciphertext sample more than once risks 1927 compromising header protection. Protecting two different headers 1928 with the same key and ciphertext sample reveals the exclusive OR of 1929 the protected fields. Assuming that the AEAD acts as a PRF, if L 1930 bits are sampled, the odds of two ciphertext samples being identical 1931 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1932 described in this document, that probability is one in 2^64. 1934 To prevent an attacker from modifying packet headers, the header is 1935 transitively authenticated using packet protection; the entire packet 1936 header is part of the authenticated additional data. Protected 1937 fields that are falsified or modified can only be detected once the 1938 packet protection is removed. 1940 9.5. Header Protection Timing Side-Channels 1942 An attacker could guess values for packet numbers or Key Phase and 1943 have an endpoint confirm guesses through timing side channels. 1944 Similarly, guesses for the packet number length can be trialed and 1945 exposed. If the recipient of a packet discards packets with 1946 duplicate packet numbers without attempting to remove packet 1947 protection they could reveal through timing side-channels that the 1948 packet number matches a received packet. For authentication to be 1949 free from side-channels, the entire process of header protection 1950 removal, packet number recovery, and packet protection removal MUST 1951 be applied together without timing and other side-channels. 1953 For the sending of packets, construction and protection of packet 1954 payloads and packet numbers MUST be free from side-channels that 1955 would reveal the packet number or its encoded size. 1957 During a key update, the time taken to generate new keys could reveal 1958 through timing side-channels that a key update has occurred. 1959 Alternatively, where an attacker injects packets this side-channel 1960 could reveal the value of the Key Phase on injected packets. After 1961 receiving a key update, an endpoint SHOULD generate and save the next 1962 set of receive packet protection keys, as described in Section 6.3. 1963 By generating new keys before a key update is received, receipt of 1964 packets will not create timing signals that leak the value of the Key 1965 Phase. 1967 This depends on not doing this key generation during packet 1968 processing and it can require that endpoints maintain three sets of 1969 packet protection keys for receiving: for the previous key phase, for 1970 the current key phase, and for the next key phase. Endpoints can 1971 instead choose to defer generation of the next receive packet 1972 protection keys until they discard old keys so that only two sets of 1973 receive keys need to be retained at any point in time. 1975 9.6. Key Diversity 1977 In using TLS, the central key schedule of TLS is used. As a result 1978 of the TLS handshake messages being integrated into the calculation 1979 of secrets, the inclusion of the QUIC transport parameters extension 1980 ensures that handshake and 1-RTT keys are not the same as those that 1981 might be produced by a server running TLS over TCP. To avoid the 1982 possibility of cross-protocol key synchronization, additional 1983 measures are provided to improve key separation. 1985 The QUIC packet protection keys and IVs are derived using a different 1986 label than the equivalent keys in TLS. 1988 To preserve this separation, a new version of QUIC SHOULD define new 1989 labels for key derivation for packet protection key and IV, plus the 1990 header protection keys. This version of QUIC uses the string "quic". 1991 Other versions can use a version-specific label in place of that 1992 string. 1994 The initial secrets use a key that is specific to the negotiated QUIC 1995 version. New QUIC versions SHOULD define a new salt value used in 1996 calculating initial secrets. 1998 10. IANA Considerations 2000 This document does not create any new IANA registries, but it 2001 registers the values in the following registries: 2003 * TLS ExtensionType Values Registry [TLS-REGISTRIES] - IANA is to 2004 register the quic_transport_parameters extension found in 2005 Section 8.2. The Recommended column is to be marked Yes. The TLS 2006 1.3 Column is to include CH and EE. 2008 * QUIC Transport Error Codes Registry [QUIC-TRANSPORT] - IANA is to 2009 register the KEY_UPDATE_ERROR (0xE), as described in Section 6.7. 2011 11. References 2013 11.1. Normative References 2015 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 2016 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 2017 . 2019 [AES] "Advanced encryption standard (AES)", 2020 DOI 10.6028/nist.fips.197, National Institute of Standards 2021 and Technology report, November 2001, 2022 . 2024 [ALPN] Friedl, S., Popov, A., Langley, A., and E. Stephan, 2025 "Transport Layer Security (TLS) Application-Layer Protocol 2026 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 2027 July 2014, . 2029 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 2030 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 2031 . 2033 [QUIC-RECOVERY] 2034 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 2035 and Congestion Control", Work in Progress, Internet-Draft, 2036 draft-ietf-quic-recovery-29, 9 June 2020, 2037 . 2039 [QUIC-TRANSPORT] 2040 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 2041 Multiplexed and Secure Transport", Work in Progress, 2042 Internet-Draft, draft-ietf-quic-transport-29, 9 June 2020, 2043 . 2046 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2047 Requirement Levels", BCP 14, RFC 2119, 2048 DOI 10.17487/RFC2119, March 1997, 2049 . 2051 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2052 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2053 May 2017, . 2055 [SHA] Dang, Q., "Secure Hash Standard", 2056 DOI 10.6028/nist.fips.180-4, National Institute of 2057 Standards and Technology report, July 2015, 2058 . 2060 [TLS-REGISTRIES] 2061 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 2062 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 2063 . 2065 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2066 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2067 . 2069 11.2. Informative References 2071 [AEBounds] Luykx, A. and K. Paterson, "Limits on Authenticated 2072 Encryption Use in TLS", 8 March 2016, 2073 . 2075 [CCM-ANALYSIS] 2076 Jonsson, J., "On the Security of CTR + CBC-MAC", 2077 DOI 10.1007/3-540-36492-7_7, Selected Areas in 2078 Cryptography pp. 76-93, 2003, 2079 . 2081 [HTTP2-TLS13] 2082 Benjamin, D., "Using TLS 1.3 with HTTP/2", RFC 8740, 2083 DOI 10.17487/RFC8740, February 2020, 2084 . 2086 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 2087 Cryptography, Second Edition", ISBN 978-1466570269, 6 2088 November 2014. 2090 [NAN] Bellare, M., Ng, R., and B. Tackmann, "Nonces Are Noticed: 2091 AEAD Revisited", DOI 10.1007/978-3-030-26948-7_9, Advances 2092 in Cryptology - CRYPTO 2019 pp. 235-265, 2019, 2093 . 2095 [QUIC-HTTP] 2096 Bishop, M., Ed., "Hypertext Transfer Protocol Version 3 2097 (HTTP/3)", Work in Progress, Internet-Draft, draft-ietf- 2098 quic-http-29, 9 June 2020, 2099 . 2101 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 2102 DOI 10.17487/RFC2818, May 2000, 2103 . 2105 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 2106 Housley, R., and W. Polk, "Internet X.509 Public Key 2107 Infrastructure Certificate and Certificate Revocation List 2108 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 2109 . 2111 [ROBUST] Fischlin, M., Günther, F., and C. Janson, "Robust 2112 Channels: Handling Unreliable Networks in the Record 2113 Layers of QUIC and DTLS", 21 February 2020, 2114 . 2117 Appendix A. Sample Packet Protection 2119 This section shows examples of packet protection so that 2120 implementations can be verified incrementally. Samples of Initial 2121 packets from both client and server, plus a Retry packet are defined. 2122 These packets use an 8-byte client-chosen Destination Connection ID 2123 of 0x8394c8f03e515708. Some intermediate values are included. All 2124 values are shown in hexadecimal. 2126 A.1. Keys 2128 The labels generated by the HKDF-Expand-Label function are: 2130 client in: 00200f746c73313320636c69656e7420696e00 2132 server in: 00200f746c7331332073657276657220696e00 2134 quic key: 00100e746c7331332071756963206b657900 2136 quic iv: 000c0d746c733133207175696320697600 2138 quic hp: 00100d746c733133207175696320687000 2140 The initial secret is common: 2142 initial_secret = HKDF-Extract(initial_salt, cid) 2143 = 1e7e7764529715b1e0ddc8e9753c6157 2144 6769605187793ed366f8bbf8c9e986eb 2146 The secrets for protecting client packets are: 2148 client_initial_secret 2149 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 2150 = 0088119288f1d866733ceeed15ff9d50 2151 902cf82952eee27e9d4d4918ea371d87 2153 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 2154 = 175257a31eb09dea9366d8bb79ad80ba 2156 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 2157 = 6b26114b9cba2b63a9e8dd4f 2159 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 2160 = 9ddd12c994c0698b89374a9c077a3077 2162 The secrets for protecting server packets are: 2164 server_initial_secret 2165 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 2166 = 006f881359244dd9ad1acf85f595bad6 2167 7c13f9f5586f5e64e1acae1d9ea8f616 2169 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 2170 = 149d0b1662ab871fbe63c49b5e655a5d 2172 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 2173 = bab2b12a4c76016ace47856d 2175 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 2176 = c0c499a65a60024a18a250974ea01dfa 2178 A.2. Client Initial 2180 The client sends an Initial packet. The unprotected payload of this 2181 packet contains the following CRYPTO frame, plus enough PADDING 2182 frames to make a 1162 byte payload: 2184 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 2185 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 2186 736572766572ff01000100000a001400 12001d00170018001901000101010201 2187 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 2188 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 2189 05030603020308040805080604010501 060102010402050206020202002d0002 2190 0101001c00024001 2192 The unprotected header includes the connection ID and a 4 byte packet 2193 number encoding for a packet number of 2: 2195 c3ff00001d088394c8f03e5157080000449e00000002 2197 Protecting the payload produces output that is sampled for header 2198 protection. Because the header uses a 4 byte packet number encoding, 2199 the first 16 bytes of the protected payload is sampled, then applied 2200 to the header: 2202 sample = fb66bc5f93032b7ddd89fe0ff15d9c4f 2204 mask = AES-ECB(hp, sample)[0..4] 2205 = d64a952459 2207 header[0] ^= mask[0] & 0x0f 2208 = c5 2209 header[18..21] ^= mask[1..4] 2210 = 4a95245b 2211 header = c5ff00001d088394c8f03e5157080000449e4a95245b 2212 The resulting protected packet is: 2214 c5ff00001d088394c8f03e5157080000 449e4a95245bfb66bc5f93032b7ddd89 2215 fe0ff15d9c4f7050fccdb71c1cd80512 d4431643a53aafa1b0b518b44968b18b 2216 8d3e7a4d04c30b3ed9410325b2abb2da fb1c12f8b70479eb8df98abcaf95dd8f 2217 3d1c78660fbc719f88b23c8aef6771f3 d50e10fdfb4c9d92386d44481b6c52d5 2218 9e5538d3d3942de9f13a7f8b702dc317 24180da9df22714d01003fc5e3d165c9 2219 50e630b8540fbd81c9df0ee63f949970 26c4f2e1887a2def79050ac2d86ba318 2220 e0b3adc4c5aa18bcf63c7cf8e85f5692 49813a2236a7e72269447cd1c755e451 2221 f5e77470eb3de64c8849d29282069802 9cfa18e5d66176fe6e5ba4ed18026f90 2222 900a5b4980e2f58e39151d5cd685b109 29636d4f02e7fad2a5a458249f5c0298 2223 a6d53acbe41a7fc83fa7cc01973f7a74 d1237a51974e097636b6203997f921d0 2224 7bc1940a6f2d0de9f5a11432946159ed 6cc21df65c4ddd1115f86427259a196c 2225 7148b25b6478b0dc7766e1c4d1b1f515 9f90eabc61636226244642ee148b464c 2226 9e619ee50a5e3ddc836227cad938987c 4ea3c1fa7c75bbf88d89e9ada642b2b8 2227 8fe8107b7ea375b1b64889a4e9e5c38a 1c896ce275a5658d250e2d76e1ed3a34 2228 ce7e3a3f383d0c996d0bed106c2899ca 6fc263ef0455e74bb6ac1640ea7bfedc 2229 59f03fee0e1725ea150ff4d69a7660c5 542119c71de270ae7c3ecfd1af2c4ce5 2230 51986949cc34a66b3e216bfe18b347e6 c05fd050f85912db303a8f054ec23e38 2231 f44d1c725ab641ae929fecc8e3cefa56 19df4231f5b4c009fa0c0bbc60bc75f7 2232 6d06ef154fc8577077d9d6a1d2bd9bf0 81dc783ece60111bea7da9e5a9748069 2233 d078b2bef48de04cabe3755b197d52b3 2046949ecaa310274b4aac0d008b1948 2234 c1082cdfe2083e386d4fd84c0ed0666d 3ee26c4515c4fee73433ac703b690a9f 2235 7bf278a77486ace44c489a0c7ac8dfe4 d1a58fb3a730b993ff0f0d61b4d89557 2236 831eb4c752ffd39c10f6b9f46d8db278 da624fd800e4af85548a294c1518893a 2237 8778c4f6d6d73c93df200960104e062b 388ea97dcf4016bced7f62b4f062cb6c 2238 04c20693d9a0e3b74ba8fe74cc012378 84f40d765ae56a51688d985cf0ceaef4 2239 3045ed8c3f0c33bced08537f6882613a cd3b08d665fce9dd8aa73171e2d3771a 2240 61dba2790e491d413d93d987e2745af2 9418e428be34941485c93447520ffe23 2241 1da2304d6a0fd5d07d08372202369661 59bef3cf904d722324dd852513df39ae 2242 030d8173908da6364786d3c1bfcb19ea 77a63b25f1e7fc661def480c5d00d444 2243 56269ebd84efd8e3a8b2c257eec76060 682848cbf5194bc99e49ee75e4d0d254 2244 bad4bfd74970c30e44b65511d4ad0e6e c7398e08e01307eeeea14e46ccd87cf3 2245 6b285221254d8fc6a6765c524ded0085 dca5bd688ddf722e2c0faf9d0fb2ce7a 2246 0c3f2cee19ca0ffba461ca8dc5d2c817 8b0762cf67135558494d2a96f1a139f0 2247 edb42d2af89a9c9122b07acbc29e5e72 2df8615c343702491098478a389c9872 2248 a10b0c9875125e257c7bfdf27eef4060 bd3d00f4c14fd3e3496c38d3c5d1a566 2249 8c39350effbc2d16ca17be4ce29f02ed 969504dda2a8c6b9ff919e693ee79e09 2250 089316e7d1d89ec099db3b2b268725d8 88536a4b8bf9aee8fb43e82a4d919d48 2251 43b1ca70a2d8d3f725ead1391377dcc0 2253 A.3. Server Initial 2255 The server sends the following payload in response, including an ACK 2256 frame, a CRYPTO frame, and no PADDING frames: 2258 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 2259 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 2260 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 2261 0304 2263 The header from the server includes a new connection ID and a 2-byte 2264 packet number encoding for a packet number of 1: 2266 c1ff00001d0008f067a5502a4262b50040740001 2268 As a result, after protection, the header protection sample is taken 2269 starting from the third protected octet: 2271 sample = 823a5d3a1207c86ee49132824f046524 2272 mask = abaaf34fdc 2273 header = caff00001d0008f067a5502a4262b5004074aaf2 2275 The final protected packet is then: 2277 caff00001d0008f067a5502a4262b500 4074aaf2f007823a5d3a1207c86ee491 2278 32824f0465243d082d868b107a38092b c80528664cbf9456ebf27673fb5fa506 2279 1ab573c9f001b81da028a00d52ab00b1 5bebaa70640e106cf2acd043e9c6b441 2280 1c0a79637134d8993701fe779e58c2fe 753d14b0564021565ea92e57bc6faf56 2281 dfc7a40870e6 2283 A.4. Retry 2285 This shows a Retry packet that might be sent in response to the 2286 Initial packet in Appendix A.2. The integrity check includes the 2287 client-chosen connection ID value of 0x8394c8f03e515708, but that 2288 value is not included in the final Retry packet: 2290 ffff00001d0008f067a5502a4262b574 6f6b656ed16926d81f6f9ca2953a8aa4 2291 575e1e49 2293 A.5. ChaCha20-Poly1305 Short Header Packet 2295 This example shows some of the steps required to protect a packet 2296 with a short header. This example uses AEAD_CHACHA20_POLY1305. 2298 In this example, TLS produces an application write secret from which 2299 a server uses HKDF-Expand-Label to produce four values: a key, an IV, 2300 a header protection key, and the secret that will be used after keys 2301 are updated (this last value is not used further in this example). 2303 secret 2304 = 9ac312a7f877468ebe69422748ad00a1 2305 5443f18203a07d6060f688f30f21632b 2307 key = HKDF-Expand-Label(secret, "quic key", _, 32) 2308 = c6d98ff3441c3fe1b2182094f69caa2e 2309 d4b716b65488960a7a984979fb23e1c8 2311 iv = HKDF-Expand-Label(secret, "quic iv", _, 12) 2312 = e0459b3474bdd0e44a41c144 2314 hp = HKDF-Expand-Label(secret, "quic hp", _, 32) 2315 = 25a282b9e82f06f21f488917a4fc8f1b 2316 73573685608597d0efcb076b0ab7a7a4 2318 ku = HKDF-Expand-Label(secret, "quic ku", _, 32) 2319 = 1223504755036d556342ee9361d25342 2320 1a826c9ecdf3c7148684b36b714881f9 2322 The following shows the steps involved in protecting a minimal packet 2323 with an empty Destination Connection ID. This packet contains a 2324 single PING frame (that is, a payload of just 0x01) and has a packet 2325 number of 654360564. In this example, using a packet number of 2326 length 3 (that is, 49140 is encoded) avoids having to pad the payload 2327 of the packet; PADDING frames would be needed if the packet number is 2328 encoded on fewer octets. 2330 pn = 654360564 (decimal) 2331 nonce = e0459b3474bdd0e46d417eb0 2332 unprotected header = 4200bff4 2333 payload plaintext = 01 2334 payload ciphertext = 655e5cd55c41f69080575d7999c25a5bfb 2336 The resulting ciphertext is the minimum size possible. One byte is 2337 skipped to produce the sample for header protection. 2339 sample = 5e5cd55c41f69080575d7999c25a5bfb 2340 mask = aefefe7d03 2341 header = 4cfe4189 2343 The protected packet is the smallest possible packet size of 21 2344 bytes. 2346 packet = 4cfe4189655e5cd55c41f69080575d7999c25a5bfb 2348 Appendix B. Analysis of Limits on AEAD_AES_128_CCM Usage 2350 TLS [TLS13] and [AEBounds] do not specify limits on usage for 2351 AEAD_AES_128_CCM. However, any AEAD that is used with QUIC requires 2352 limits on use that ensure that both confidentiality and integrity are 2353 preserved. This section documents that analysis. 2355 [CCM-ANALYSIS] is used as the basis of this analysis. The results of 2356 that analysis are used to derive usage limits that are based on those 2357 chosen in [TLS13]. 2359 This analysis uses symbols for multiplication (*), division (/), and 2360 exponentiation (^), plus parentheses for establishing precedence. 2361 The following symbols are also used: 2363 t: The size of the authentication tag in bits. For this cipher, t 2364 is 128. 2366 n: The size of the block function in bits. For this cipher, n is 2367 128. 2369 l: The number of blocks in each packet (see below). 2371 q: The number of genuine packets created and protected by endpoints. 2372 This value is the bound on the number of packets that can be 2373 protected before updating keys. 2375 v: The number of forged packets that endpoints will accept. This 2376 value is the bound on the number of forged packets that an 2377 endpoint can reject before updating keys. 2379 The analysis of AEAD_AES_128_CCM relies on a count of the number of 2380 block operations involved in producing each message. For simplicity, 2381 and to match the analysis of other AEAD functions in [AEBounds], this 2382 analysis assumes a packet length of 2^10 blocks and a packet size 2383 limit of 2^14. 2385 For AEAD_AES_128_CCM, the total number of block cipher operations is 2386 the sum of: the length of the associated data in blocks, the length 2387 of the ciphertext in blocks, the length of the plaintext in blocks, 2388 plus 1. In this analysis, this is simplified to a value of twice the 2389 length of the packet in blocks (that is, "2l = 2^11"). This 2390 simplification is based on the packet containing all of the 2391 associated data and ciphertext. This results in a negligible 1 to 3 2392 block overestimation of the number of operations. 2394 B.1. Confidentiality Limits 2396 For confidentiality, Theorem 2 in [CCM-ANALYSIS] establishes that an 2397 attacker gains a distinguishing advantage over an ideal pseudorandom 2398 permutation (PRP) of no more than: 2400 (2l * q)^2 / 2^n 2402 For a target advantage of 2^-60, which matches that used by [TLS13], 2403 this results in the relation: 2405 q <= 2^23 2407 That is, endpoints cannot protect more than 2^23 packets with the 2408 same set of keys without causing an attacker to gain an larger 2409 advantage than the target of 2^-60. 2411 B.2. Integrity Limits 2413 For integrity, Theorem 1 in [CCM-ANALYSIS] establishes that an 2414 attacker gains an advantage over an ideal PRP of no more than: 2416 v / 2^t + (2l * (v + q))^2 / 2^n 2418 The goal is to limit this advantage to 2^-57, to match the target in 2419 [TLS13]. As "t" and "n" are both 128, the first term is negligible 2420 relative to the second, so that term can be removed without a 2421 significant effect on the result. This produces the relation: 2423 v + q <= 2^24.5 2425 Using the previously-established value of 2^23 for "q" and rounding, 2426 this leads to an upper limit on "v" of 2^23.5. That is, endpoints 2427 cannot attempt to authenticate more than 2^23.5 packets with the same 2428 set of keys without causing an attacker to gain an larger advantage 2429 than the target of 2^-57. 2431 Appendix C. Change Log 2433 *RFC Editor's Note:* Please remove this section prior to 2434 publication of a final version of this document. 2436 Issue and pull request numbers are listed with a leading octothorp. 2438 C.1. Since draft-ietf-quic-tls-28 2439 * Defined limits on the number of packets that can be protected with 2440 a single key and limits on the number of packets that can fail 2441 authentication (#3619, #3620) 2443 C.2. Since draft-ietf-quic-tls-27 2445 * Allowed CONNECTION_CLOSE in any packet number space, with 2446 restrictions on use of the application-specific variant (#3430, 2447 #3435, #3440) 2449 * Prohibit the use of the compatibility mode from TLS 1.3 (#3594, 2450 #3595) 2452 C.3. Since draft-ietf-quic-tls-26 2454 * No changes 2456 C.4. Since draft-ietf-quic-tls-25 2458 * No changes 2460 C.5. Since draft-ietf-quic-tls-24 2462 * Rewrite key updates (#3050) 2464 - Allow but don't recommend deferring key updates (#2792, #3263) 2466 - More completely define received behavior (#2791) 2468 - Define the label used with HKDF-Expand-Label (#3054) 2470 C.6. Since draft-ietf-quic-tls-23 2472 * Key update text update (#3050): 2474 - Recommend constant-time key replacement (#2792) 2476 - Provide explicit labels for key update key derivation (#3054) 2478 * Allow first Initial from a client to span multiple packets (#2928, 2479 #3045) 2481 * PING can be sent at any encryption level (#3034, #3035) 2483 C.7. Since draft-ietf-quic-tls-22 2485 * Update the salt used for Initial secrets (#2887, #2980) 2487 C.8. Since draft-ietf-quic-tls-21 2489 * No changes 2491 C.9. Since draft-ietf-quic-tls-20 2493 * Mandate the use of the QUIC transport parameters extension (#2528, 2494 #2560) 2496 * Define handshake completion and confirmation; define clearer rules 2497 when it encryption keys should be discarded (#2214, #2267, #2673) 2499 C.10. Since draft-ietf-quic-tls-18 2501 * Increased the set of permissible frames in 0-RTT (#2344, #2355) 2503 * Transport parameter extension is mandatory (#2528, #2560) 2505 C.11. Since draft-ietf-quic-tls-17 2507 * Endpoints discard initial keys as soon as handshake keys are 2508 available (#1951, #2045) 2510 * Use of ALPN or equivalent is mandatory (#2263, #2284) 2512 C.12. Since draft-ietf-quic-tls-14 2514 * Update the salt used for Initial secrets (#1970) 2516 * Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 2518 * Change header protection 2520 - Sample from a fixed offset (#1575, #2030) 2522 - Cover part of the first byte, including the key phase (#1322, 2523 #2006) 2525 * TLS provides an AEAD and KDF function (#2046) 2527 - Clarify that the TLS KDF is used with TLS (#1997) 2529 - Change the labels for calculation of QUIC keys (#1845, #1971, 2530 #1991) 2532 * Initial keys are discarded once Handshake keys are available 2533 (#1951, #2045) 2535 C.13. Since draft-ietf-quic-tls-13 2537 * Updated to TLS 1.3 final (#1660) 2539 C.14. Since draft-ietf-quic-tls-12 2541 * Changes to integration of the TLS handshake (#829, #1018, #1094, 2542 #1165, #1190, #1233, #1242, #1252, #1450) 2544 - The cryptographic handshake uses CRYPTO frames, not stream 0 2546 - QUIC packet protection is used in place of TLS record 2547 protection 2549 - Separate QUIC packet number spaces are used for the handshake 2551 - Changed Retry to be independent of the cryptographic handshake 2553 - Limit the use of HelloRetryRequest to address TLS needs (like 2554 key shares) 2556 * Changed codepoint of TLS extension (#1395, #1402) 2558 C.15. Since draft-ietf-quic-tls-11 2560 * Encrypted packet numbers. 2562 C.16. Since draft-ietf-quic-tls-10 2564 * No significant changes. 2566 C.17. Since draft-ietf-quic-tls-09 2568 * Cleaned up key schedule and updated the salt used for handshake 2569 packet protection (#1077) 2571 C.18. Since draft-ietf-quic-tls-08 2573 * Specify value for max_early_data_size to enable 0-RTT (#942) 2575 * Update key derivation function (#1003, #1004) 2577 C.19. Since draft-ietf-quic-tls-07 2579 * Handshake errors can be reported with CONNECTION_CLOSE (#608, 2580 #891) 2582 C.20. Since draft-ietf-quic-tls-05 2584 No significant changes. 2586 C.21. Since draft-ietf-quic-tls-04 2588 * Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 2590 C.22. Since draft-ietf-quic-tls-03 2592 No significant changes. 2594 C.23. Since draft-ietf-quic-tls-02 2596 * Updates to match changes in transport draft 2598 C.24. Since draft-ietf-quic-tls-01 2600 * Use TLS alerts to signal TLS errors (#272, #374) 2602 * Require ClientHello to fit in a single packet (#338) 2604 * The second client handshake flight is now sent in the clear (#262, 2605 #337) 2607 * The QUIC header is included as AEAD Associated Data (#226, #243, 2608 #302) 2610 * Add interface necessary for client address validation (#275) 2612 * Define peer authentication (#140) 2614 * Require at least TLS 1.3 (#138) 2616 * Define transport parameters as a TLS extension (#122) 2618 * Define handling for protected packets before the handshake 2619 completes (#39) 2621 * Decouple QUIC version and ALPN (#12) 2623 C.25. Since draft-ietf-quic-tls-00 2625 * Changed bit used to signal key phase 2627 * Updated key phase markings during the handshake 2629 * Added TLS interface requirements section 2630 * Moved to use of TLS exporters for key derivation 2632 * Moved TLS error code definitions into this document 2634 C.26. Since draft-thomson-quic-tls-01 2636 * Adopted as base for draft-ietf-quic-tls 2638 * Updated authors/editors list 2640 * Added status note 2642 Contributors 2644 The IETF QUIC Working Group received an enormous amount of support 2645 from many people. The following people provided substantive 2646 contributions to this document: 2648 * Adam Langley 2650 * Alessandro Ghedini 2652 * Christian Huitema 2654 * Christopher Wood 2656 * David Schinazi 2658 * Dragana Damjanovic 2660 * Eric Rescorla 2662 * Felix Guenther 2664 * Ian Swett 2666 * Jana Iyengar 2668 * 奥 一穂 (Kazuho Oku) 2670 * Marten Seemann 2672 * Martin Duke 2674 * Mike Bishop 2676 * Mikkel Fahnøe Jørgensen 2677 * Nick Banks 2679 * Nick Harper 2681 * Roberto Peon 2683 * Rui Paulo 2685 * Ryan Hamilton 2687 * Victor Vasiliev 2689 Authors' Addresses 2691 Martin Thomson (editor) 2692 Mozilla 2694 Email: mt@lowentropy.net 2696 Sean Turner (editor) 2697 sn3rd 2699 Email: sean@sn3rd.com