idnits 2.17.1 draft-ietf-quic-tls-26.txt: -(2348): Line appears to be too long, but this could be caused by non-ascii characters in UTF-8 encoding 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 == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: * If the packet is from a previously installed encryption level, it MUST not contain data which extends past the end of previously received data in that flow. Implementations MUST treat any violations of this requirement as a connection error of type PROTOCOL_VIOLATION. -- The document date (21 February 2020) is 1527 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 2066 -- Looks like a reference, but probably isn't: '1' on line 1409 -- 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-26 == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-26 -- Possible downref: Non-RFC (?) normative reference: ref. 'SHA' == Outdated reference: A later version (-34) exists of draft-ietf-quic-http-26 -- Obsolete informational reference (is this intentional?): RFC 2818 (Obsoleted by RFC 9110) Summary: 1 error (**), 0 flaws (~~), 6 warnings (==), 7 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: 24 August 2020 sn3rd 6 21 February 2020 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-26 11 Abstract 13 This document describes how Transport Layer Security (TLS) is used to 14 secure QUIC. 16 Note to Readers 18 Discussion of this draft takes place on the QUIC working group 19 mailing list (quic@ietf.org), which is archived at 20 https://mailarchive.ietf.org/arch/search/?email_list=quic 21 (https://mailarchive.ietf.org/arch/search/?email_list=quic). 23 Working Group information can be found at https://github.com/quicwg 24 (https://github.com/quicwg); source code and issues list for this 25 draft can be found at https://github.com/quicwg/base-drafts/labels/- 26 tls (https://github.com/quicwg/base-drafts/labels/-tls). 28 Status of This Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at https://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on 24 August 2020. 45 Copyright Notice 47 Copyright (c) 2020 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 52 license-info) in effect on the date of publication of this document. 53 Please review these documents carefully, as they describe your rights 54 and restrictions with respect to this document. Code Components 55 extracted from this document must include Simplified BSD License text 56 as described in Section 4.e of the Trust Legal Provisions and are 57 provided without warranty as described in the Simplified BSD License. 59 Table of Contents 61 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 62 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4 63 2.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 4 64 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 7 65 4. Carrying TLS Messages . . . . . . . . . . . . . . . . . . . . 8 66 4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 10 67 4.1.1. Handshake Complete . . . . . . . . . . . . . . . . . 10 68 4.1.2. Handshake Confirmed . . . . . . . . . . . . . . . . . 10 69 4.1.3. Sending and Receiving Handshake Messages . . . . . . 10 70 4.1.4. Encryption Level Changes . . . . . . . . . . . . . . 12 71 4.1.5. TLS Interface Summary . . . . . . . . . . . . . . . . 13 72 4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 14 73 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 15 74 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 15 75 4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 16 76 4.6. Accepting and Rejecting 0-RTT . . . . . . . . . . . . . . 16 77 4.7. Validating 0-RTT Configuration . . . . . . . . . . . . . 17 78 4.8. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 17 79 4.9. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 18 80 4.10. Discarding Unused Keys . . . . . . . . . . . . . . . . . 18 81 4.10.1. Discarding Initial Keys . . . . . . . . . . . . . . 19 82 4.10.2. Discarding Handshake Keys . . . . . . . . . . . . . 19 83 4.10.3. Discarding 0-RTT Keys . . . . . . . . . . . . . . . 19 84 5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 20 85 5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 20 86 5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 20 87 5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 21 88 5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 23 89 5.4.1. Header Protection Application . . . . . . . . . . . . 23 90 5.4.2. Header Protection Sample . . . . . . . . . . . . . . 25 91 5.4.3. AES-Based Header Protection . . . . . . . . . . . . . 26 92 5.4.4. ChaCha20-Based Header Protection . . . . . . . . . . 26 93 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 27 94 5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 27 95 5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 28 96 5.8. Retry Packet Integrity . . . . . . . . . . . . . . . . . 29 97 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 30 98 6.1. Initiating a Key Update . . . . . . . . . . . . . . . . . 31 99 6.2. Responding to a Key Update . . . . . . . . . . . . . . . 32 100 6.3. Timing of Receive Key Generation . . . . . . . . . . . . 33 101 6.4. Sending with Updated Keys . . . . . . . . . . . . . . . . 33 102 6.5. Receiving with Different Keys . . . . . . . . . . . . . . 34 103 6.6. Key Update Frequency . . . . . . . . . . . . . . . . . . 35 104 6.7. Key Update Error Code . . . . . . . . . . . . . . . . . . 35 105 7. Security of Initial Messages . . . . . . . . . . . . . . . . 35 106 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 35 107 8.1. Protocol Negotiation . . . . . . . . . . . . . . . . . . 36 108 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 36 109 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 37 110 9. Security Considerations . . . . . . . . . . . . . . . . . . . 37 111 9.1. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 37 112 9.2. Packet Reflection Attack Mitigation . . . . . . . . . . . 38 113 9.3. Header Protection Analysis . . . . . . . . . . . . . . . 39 114 9.4. Header Protection Timing Side-Channels . . . . . . . . . 39 115 9.5. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 40 116 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 41 117 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 41 118 11.1. Normative References . . . . . . . . . . . . . . . . . . 41 119 11.2. Informative References . . . . . . . . . . . . . . . . . 42 120 Appendix A. Sample Packet Protection . . . . . . . . . . . . . . 43 121 A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 43 122 A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 44 123 A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 46 124 A.4. Retry . . . . . . . . . . . . . . . . . . . . . . . . . . 47 125 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 47 126 B.1. Since draft-ietf-quic-tls-25 . . . . . . . . . . . . . . 47 127 B.2. Since draft-ietf-quic-tls-24 . . . . . . . . . . . . . . 47 128 B.3. Since draft-ietf-quic-tls-23 . . . . . . . . . . . . . . 48 129 B.4. Since draft-ietf-quic-tls-22 . . . . . . . . . . . . . . 48 130 B.5. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 48 131 B.6. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 48 132 B.7. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 48 133 B.8. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 48 134 B.9. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 48 135 B.10. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 49 136 B.11. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 49 137 B.12. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 49 138 B.13. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 49 139 B.14. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 50 140 B.15. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 50 141 B.16. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 50 142 B.17. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 50 143 B.18. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 50 144 B.19. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 50 145 B.20. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 50 146 B.21. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 50 147 B.22. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 51 148 B.23. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 51 149 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 51 150 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 51 152 1. Introduction 154 This document describes how QUIC [QUIC-TRANSPORT] is secured using 155 TLS [TLS13]. 157 TLS 1.3 provides critical latency improvements for connection 158 establishment over previous versions. Absent packet loss, most new 159 connections can be established and secured within a single round 160 trip; on subsequent connections between the same client and server, 161 the client can often send application data immediately, that is, 162 using a zero round trip setup. 164 This document describes how TLS acts as a security component of QUIC. 166 2. Notational Conventions 168 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 169 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 170 "OPTIONAL" in this document are to be interpreted as described in BCP 171 14 [RFC2119] [RFC8174] when, and only when, they appear in all 172 capitals, as shown here. 174 This document uses the terminology established in [QUIC-TRANSPORT]. 176 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 177 newer version could be used (see Section 4.2). 179 2.1. TLS Overview 181 TLS provides two endpoints with a way to establish a means of 182 communication over an untrusted medium (that is, the Internet) that 183 ensures that messages they exchange cannot be observed, modified, or 184 forged. 186 Internally, TLS is a layered protocol, with the structure shown in 187 Figure 1. 189 +-------------+------------+--------------+---------+ 190 Handshake | | | Application | | 191 Layer | Handshake | Alerts | Data | ... | 192 | | | | | 193 +-------------+------------+--------------+---------+ 194 Record | | 195 Layer | Records | 196 | | 197 +---------------------------------------------------+ 199 Figure 1: TLS Layers 201 Each Handshake layer message (e.g., Handshake, Alerts, and 202 Application Data) is carried as a series of typed TLS records by the 203 Record layer. Records are individually cryptographically protected 204 and then transmitted over a reliable transport (typically TCP) which 205 provides sequencing and guaranteed delivery. 207 The TLS authenticated key exchange occurs between two endpoints: 208 client and server. The client initiates the exchange and the server 209 responds. If the key exchange completes successfully, both client 210 and server will agree on a secret. TLS supports both pre-shared key 211 (PSK) and Diffie-Hellman over either finite fields or elliptic curves 212 ((EC)DHE) key exchanges. PSK is the basis for 0-RTT; the latter 213 provides perfect forward secrecy (PFS) when the (EC)DHE keys are 214 destroyed. 216 After completing the TLS handshake, the client will have learned and 217 authenticated an identity for the server and the server is optionally 218 able to learn and authenticate an identity for the client. TLS 219 supports X.509 [RFC5280] certificate-based authentication for both 220 server and client. 222 The TLS key exchange is resistant to tampering by attackers and it 223 produces shared secrets that cannot be controlled by either 224 participating peer. 226 TLS provides two basic handshake modes of interest to QUIC: 228 * A full 1-RTT handshake in which the client is able to send 229 Application Data after one round trip and the server immediately 230 responds after receiving the first handshake message from the 231 client. 233 * A 0-RTT handshake in which the client uses information it has 234 previously learned about the server to send Application Data 235 immediately. This Application Data can be replayed by an attacker 236 so it MUST NOT carry a self-contained trigger for any non- 237 idempotent action. 239 A simplified TLS handshake with 0-RTT application data is shown in 240 Figure 2. Note that this omits the EndOfEarlyData message, which is 241 not used in QUIC (see Section 8.3). Likewise, neither 242 ChangeCipherSpec nor KeyUpdate messages are used by QUIC; 243 ChangeCipherSpec is redundant in TLS 1.3 and QUIC has defined its own 244 key update mechanism Section 6. 246 Client Server 248 ClientHello 249 (0-RTT Application Data) --------> 250 ServerHello 251 {EncryptedExtensions} 252 {Finished} 253 <-------- [Application Data] 254 {Finished} --------> 256 [Application Data] <-------> [Application Data] 258 () Indicates messages protected by Early Data (0-RTT) Keys 259 {} Indicates messages protected using Handshake Keys 260 [] Indicates messages protected using Application Data 261 (1-RTT) Keys 263 Figure 2: TLS Handshake with 0-RTT 265 Data is protected using a number of encryption levels: 267 * Initial Keys 269 * Early Data (0-RTT) Keys 271 * Handshake Keys 273 * Application Data (1-RTT) Keys 275 Application Data may appear only in the Early Data and Application 276 Data levels. Handshake and Alert messages may appear in any level. 278 The 0-RTT handshake is only possible if the client and server have 279 previously communicated. In the 1-RTT handshake, the client is 280 unable to send protected Application Data until it has received all 281 of the Handshake messages sent by the server. 283 3. Protocol Overview 285 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 286 and integrity protection of packets. For this it uses keys derived 287 from a TLS handshake [TLS13], but instead of carrying TLS records 288 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 289 directly over the QUIC transport, which takes over the 290 responsibilities of the TLS record layer, as shown in Figure 3. 292 +--------------+--------------+ +-------------+ 293 | TLS | TLS | | QUIC | 294 | Handshake | Alerts | | Applications| 295 | | | | (h3, etc.) | 296 +--------------+--------------+-+-------------+ 297 | | 298 | QUIC Transport | 299 | (streams, reliability, congestion, etc.) | 300 | | 301 +---------------------------------------------+ 302 | | 303 | QUIC Packet Protection | 304 | | 305 +---------------------------------------------+ 307 Figure 3: QUIC Layers 309 QUIC also relies on TLS for authentication and negotiation of 310 parameters that are critical to security and performance. 312 Rather than a strict layering, these two protocols cooperate: QUIC 313 uses the TLS handshake; TLS uses the reliability, ordered delivery, 314 and record layer provided by QUIC. 316 At a high level, there are two main interactions between the TLS and 317 QUIC components: 319 * The TLS component sends and receives messages via the QUIC 320 component, with QUIC providing a reliable stream abstraction to 321 TLS. 323 * The TLS component provides a series of updates to the QUIC 324 component, including (a) new packet protection keys to install (b) 325 state changes such as handshake completion, the server 326 certificate, etc. 328 Figure 4 shows these interactions in more detail, with the QUIC 329 packet protection being called out specially. 331 +------------+ +------------+ 332 | |<---- Handshake Messages ----->| | 333 | |<- Validate 0-RTT parameters ->| | 334 | |<--------- 0-RTT Keys ---------| | 335 | QUIC |<------- Handshake Keys -------| TLS | 336 | |<--------- 1-RTT Keys ---------| | 337 | |<------- Handshake Done -------| | 338 +------------+ +------------+ 339 | ^ 340 | Protect | Protected 341 v | Packet 342 +------------+ 343 | QUIC | 344 | Packet | 345 | Protection | 346 +------------+ 348 Figure 4: QUIC and TLS Interactions 350 Unlike TLS over TCP, QUIC applications which want to send data do not 351 send it through TLS "application_data" records. Rather, they send it 352 as QUIC STREAM frames or other frame types which are then carried in 353 QUIC packets. 355 4. Carrying TLS Messages 357 QUIC carries TLS handshake data in CRYPTO frames, each of which 358 consists of a contiguous block of handshake data identified by an 359 offset and length. Those frames are packaged into QUIC packets and 360 encrypted under the current TLS encryption level. As with TLS over 361 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 362 responsibility to deliver it reliably. Each chunk of data that is 363 produced by TLS is associated with the set of keys that TLS is 364 currently using. If QUIC needs to retransmit that data, it MUST use 365 the same keys even if TLS has already updated to newer keys. 367 One important difference between TLS records (used with TCP) and QUIC 368 CRYPTO frames is that in QUIC multiple frames may appear in the same 369 QUIC packet as long as they are associated with the same encryption 370 level. For instance, an implementation might bundle a Handshake 371 message and an ACK for some Handshake data into the same packet. 373 Some frames are prohibited in different encryption levels, others 374 cannot be sent. The rules here generalize those of TLS, in that 375 frames associated with establishing the connection can usually appear 376 at any encryption level, whereas those associated with transferring 377 data can only appear in the 0-RTT and 1-RTT encryption levels: 379 * PADDING and PING frames MAY appear in packets of any encryption 380 level. 382 * CRYPTO frames and CONNECTION_CLOSE frames signaling errors at the 383 QUIC layer (type 0x1c) MAY appear in packets of any encryption 384 level except 0-RTT. 386 * CONNECTION_CLOSE frames signaling application errors (type 0x1d) 387 MUST only be sent in packets at the 1-RTT encryption level. 389 * ACK frames MAY appear in packets of any encryption level other 390 than 0-RTT, but can only acknowledge packets which appeared in 391 that packet number space. 393 * All other frame types MUST only be sent in the 0-RTT and 1-RTT 394 levels. 396 Note that it is not possible to send the following frames in 0-RTT 397 for various reasons: ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN, 398 PATH_RESPONSE, and RETIRE_CONNECTION_ID. 400 Because packets could be reordered on the wire, QUIC uses the packet 401 type to indicate which level a given packet was encrypted under, as 402 shown in Table 1. When multiple packets of different encryption 403 levels need to be sent, endpoints SHOULD use coalesced packets to 404 send them in the same UDP datagram. 406 +---------------------+------------------+-----------+ 407 | Packet Type | Encryption Level | PN Space | 408 +=====================+==================+===========+ 409 | Initial | Initial secrets | Initial | 410 +---------------------+------------------+-----------+ 411 | 0-RTT Protected | 0-RTT | 0/1-RTT | 412 +---------------------+------------------+-----------+ 413 | Handshake | Handshake | Handshake | 414 +---------------------+------------------+-----------+ 415 | Retry | N/A | N/A | 416 +---------------------+------------------+-----------+ 417 | Version Negotiation | N/A | N/A | 418 +---------------------+------------------+-----------+ 419 | Short Header | 1-RTT | 0/1-RTT | 420 +---------------------+------------------+-----------+ 422 Table 1: Encryption Levels by Packet Type 424 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 425 encryption levels fit into the handshake process. 427 4.1. Interface to TLS 429 As shown in Figure 4, the interface from QUIC to TLS consists of four 430 primary functions: 432 * Sending and receiving handshake messages 434 * Processing stored transport and application state from a resumed 435 session and determining if it is valid to accept early data 437 * Rekeying (both transmit and receive) 439 * Handshake state updates 441 Additional functions might be needed to configure TLS. 443 4.1.1. Handshake Complete 445 In this document, the TLS handshake is considered complete when the 446 TLS stack has reported that the handshake is complete. This happens 447 when the TLS stack has both sent a Finished message and verified the 448 peer's Finished message. Verifying the peer's Finished provides the 449 endpoints with an assurance that previous handshake messages have not 450 been modified. Note that the handshake does not complete at both 451 endpoints simultaneously. Consequently, any requirement that is 452 based on the completion of the handshake depends on the perspective 453 of the endpoint in question. 455 4.1.2. Handshake Confirmed 457 In this document, the TLS handshake is considered confirmed at the 458 server when the handshake completes. At the client, the handshake is 459 considered confirmed when a HANDSHAKE_DONE frame is received. 461 A client MAY consider the handshake to be confirmed when it receives 462 an acknowledgement for a 1-RTT packet. This can be implemented by 463 recording the lowest packet number sent with 1-RTT keys, and 464 comparing it to the Largest Acknowledged field in any received 1-RTT 465 ACK frame: once the latter is greater than or equal to the former, 466 the handshake is confirmed. 468 4.1.3. Sending and Receiving Handshake Messages 470 In order to drive the handshake, TLS depends on being able to send 471 and receive handshake messages. There are two basic functions on 472 this interface: one where QUIC requests handshake messages and one 473 where QUIC provides handshake packets. 475 Before starting the handshake QUIC provides TLS with the transport 476 parameters (see Section 8.2) that it wishes to carry. 478 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 479 The client acquires handshake bytes before sending its first packet. 480 A QUIC server starts the process by providing TLS with the client's 481 handshake bytes. 483 At any time, the TLS stack at an endpoint will have a current sending 484 encryption level and receiving encryption level. Each encryption 485 level is associated with a different flow of bytes, which is reliably 486 transmitted to the peer in CRYPTO frames. When TLS provides 487 handshake bytes to be sent, they are appended to the current flow and 488 any packet that includes the CRYPTO frame is protected using keys 489 from the corresponding encryption level. 491 QUIC takes the unprotected content of TLS handshake records as the 492 content of CRYPTO frames. TLS record protection is not used by QUIC. 493 QUIC assembles CRYPTO frames into QUIC packets, which are protected 494 using QUIC packet protection. 496 QUIC is only capable of conveying TLS handshake records in CRYPTO 497 frames. TLS alerts are turned into QUIC CONNECTION_CLOSE error 498 codes; see Section 4.9. TLS application data and other message types 499 cannot be carried by QUIC at any encryption level and is an error if 500 they are received from the TLS stack. 502 When an endpoint receives a QUIC packet containing a CRYPTO frame 503 from the network, it proceeds as follows: 505 * If the packet was in the TLS receiving encryption level, sequence 506 the data into the input flow as usual. As with STREAM frames, the 507 offset is used to find the proper location in the data sequence. 508 If the result of this process is that new data is available, then 509 it is delivered to TLS in order. 511 * If the packet is from a previously installed encryption level, it 512 MUST not contain data which extends past the end of previously 513 received data in that flow. Implementations MUST treat any 514 violations of this requirement as a connection error of type 515 PROTOCOL_VIOLATION. 517 * If the packet is from a new encryption level, it is saved for 518 later processing by TLS. Once TLS moves to receiving from this 519 encryption level, saved data can be provided. When providing data 520 from any new encryption level to TLS, if there is data from a 521 previous encryption level that TLS has not consumed, this MUST be 522 treated as a connection error of type PROTOCOL_VIOLATION. 524 Each time that TLS is provided with new data, new handshake bytes are 525 requested from TLS. TLS might not provide any bytes if the handshake 526 messages it has received are incomplete or it has no data to send. 528 Once the TLS handshake is complete, this is indicated to QUIC along 529 with any final handshake bytes that TLS needs to send. TLS also 530 provides QUIC with the transport parameters that the peer advertised 531 during the handshake. 533 Once the handshake is complete, TLS becomes passive. TLS can still 534 receive data from its peer and respond in kind, but it will not need 535 to send more data unless specifically requested - either by an 536 application or QUIC. One reason to send data is that the server 537 might wish to provide additional or updated session tickets to a 538 client. 540 When the handshake is complete, QUIC only needs to provide TLS with 541 any data that arrives in CRYPTO streams. In the same way that is 542 done during the handshake, new data is requested from TLS after 543 providing received data. 545 4.1.4. Encryption Level Changes 547 As keys for new encryption levels become available, TLS provides QUIC 548 with those keys. Separately, as keys at a given encryption level 549 become available to TLS, TLS indicates to QUIC that reading or 550 writing keys at that encryption level are available. These events 551 are not asynchronous; they always occur immediately after TLS is 552 provided with new handshake bytes, or after TLS produces handshake 553 bytes. 555 TLS provides QUIC with three items as a new encryption level becomes 556 available: 558 * A secret 560 * An Authenticated Encryption with Associated Data (AEAD) function 562 * A Key Derivation Function (KDF) 564 These values are based on the values that TLS negotiates and are used 565 by QUIC to generate packet and header protection keys (see Section 5 566 and Section 5.4). 568 If 0-RTT is possible, it is ready after the client sends a TLS 569 ClientHello message or the server receives that message. After 570 providing a QUIC client with the first handshake bytes, the TLS stack 571 might signal the change to 0-RTT keys. On the server, after 572 receiving handshake bytes that contain a ClientHello message, a TLS 573 server might signal that 0-RTT keys are available. 575 Although TLS only uses one encryption level at a time, QUIC may use 576 more than one level. For instance, after sending its Finished 577 message (using a CRYPTO frame at the Handshake encryption level) an 578 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 579 message is lost, the endpoint uses the Handshake encryption level to 580 retransmit the lost message. Reordering or loss of packets can mean 581 that QUIC will need to handle packets at multiple encryption levels. 582 During the handshake, this means potentially handling packets at 583 higher and lower encryption levels than the current encryption level 584 used by TLS. 586 In particular, server implementations need to be able to read packets 587 at the Handshake encryption level at the same time as the 0-RTT 588 encryption level. A client could interleave ACK frames that are 589 protected with Handshake keys with 0-RTT data and the server needs to 590 process those acknowledgments in order to detect lost Handshake 591 packets. 593 QUIC also needs access to keys that might not ordinarily be available 594 to a TLS implementation. For instance, a client might need to 595 acknowledge Handshake packets before it is ready to send CRYPTO 596 frames at that encryption level. TLS therefore needs to provide keys 597 to QUIC before it might produce them for its own use. 599 4.1.5. TLS Interface Summary 601 Figure 5 summarizes the exchange between QUIC and TLS for both client 602 and server. Each arrow is tagged with the encryption level used for 603 that transmission. 605 Client Server 607 Get Handshake 608 Initial -------------> 609 Handshake Received 610 Install tx 0-RTT Keys 611 0-RTT ---------------> 612 Get Handshake 613 <------------- Initial 614 Handshake Received 615 Install Handshake keys 616 Install rx 0-RTT keys 617 Install Handshake keys 618 Get Handshake 619 <----------- Handshake 620 Handshake Received 621 Install tx 1-RTT keys 622 <--------------- 1-RTT 623 Get Handshake 624 Handshake Complete 625 Handshake -----------> 626 Handshake Received 627 Install rx 1-RTT keys 628 Handshake Complete 629 Install 1-RTT keys 630 1-RTT ---------------> 631 Get Handshake 632 <--------------- 1-RTT 633 Handshake Received 635 Figure 5: Interaction Summary between QUIC and TLS 637 Figure 5 shows the multiple packets that form a single "flight" of 638 messages being processed individually, to show what incoming messages 639 trigger different actions. New handshake messages are requested 640 after all incoming packets have been processed. This process might 641 vary depending on how QUIC implementations and the packets they 642 receive are structured. 644 4.2. TLS Version 646 This document describes how TLS 1.3 [TLS13] is used with QUIC. 648 In practice, the TLS handshake will negotiate a version of TLS to 649 use. This could result in a newer version of TLS than 1.3 being 650 negotiated if both endpoints support that version. This is 651 acceptable provided that the features of TLS 1.3 that are used by 652 QUIC are supported by the newer version. 654 A badly configured TLS implementation could negotiate TLS 1.2 or 655 another older version of TLS. An endpoint MUST terminate the 656 connection if a version of TLS older than 1.3 is negotiated. 658 4.3. ClientHello Size 660 The first Initial packet from a client contains the start or all of 661 its first cryptographic handshake message, which for TLS is the 662 ClientHello. Servers might need to parse the entire ClientHello 663 (e.g., to access extensions such as Server Name Identification (SNI) 664 or Application Layer Protocol Negotiation (ALPN)) in order to decide 665 whether to accept the new incoming QUIC connection. If the 666 ClientHello spans multiple Initial packets, such servers would need 667 to buffer the first received fragments, which could consume excessive 668 resources if the client's address has not yet been validated. To 669 avoid this, servers MAY use the Retry feature (see Section 8.1 of 670 [QUIC-TRANSPORT]) to only buffer partial ClientHello messages from 671 clients with a validated address. 673 QUIC packet and framing add at least 36 bytes of overhead to the 674 ClientHello message. That overhead increases if the client chooses a 675 connection ID without zero length. Overheads also do not include the 676 token or a connection ID longer than 8 bytes, both of which might be 677 required if a server sends a Retry packet. 679 A typical TLS ClientHello can easily fit into a 1200 byte packet. 680 However, in addition to the overheads added by QUIC, there are 681 several variables that could cause this limit to be exceeded. Large 682 session tickets, multiple or large key shares, and long lists of 683 supported ciphers, signature algorithms, versions, QUIC transport 684 parameters, and other negotiable parameters and extensions could 685 cause this message to grow. 687 For servers, in addition to connection IDs and tokens, the size of 688 TLS session tickets can have an effect on a client's ability to 689 connect efficiently. Minimizing the size of these values increases 690 the probability that clients can use them and still fit their 691 ClientHello message in their first Initial packet. 693 The TLS implementation does not need to ensure that the ClientHello 694 is sufficiently large. QUIC PADDING frames are added to increase the 695 size of the packet as necessary. 697 4.4. Peer Authentication 699 The requirements for authentication depend on the application 700 protocol that is in use. TLS provides server authentication and 701 permits the server to request client authentication. 703 A client MUST authenticate the identity of the server. This 704 typically involves verification that the identity of the server is 705 included in a certificate and that the certificate is issued by a 706 trusted entity (see for example [RFC2818]). 708 A server MAY request that the client authenticate during the 709 handshake. A server MAY refuse a connection if the client is unable 710 to authenticate when requested. The requirements for client 711 authentication vary based on application protocol and deployment. 713 A server MUST NOT use post-handshake client authentication (as 714 defined in Section 4.6.2 of [TLS13]), because the multiplexing 715 offered by QUIC prevents clients from correlating the certificate 716 request with the application-level event that triggered it (see 717 [HTTP2-TLS13]). More specifically, servers MUST NOT send post- 718 handshake TLS CertificateRequest messages and clients MUST treat 719 receipt of such messages as a connection error of type 720 PROTOCOL_VIOLATION. 722 4.5. Enabling 0-RTT 724 To communicate their willingness to process 0-RTT data, servers send 725 a NewSessionTicket message that contains the "early_data" extension 726 with a max_early_data_size of 0xffffffff; the amount of data which 727 the client can send in 0-RTT is controlled by the "initial_max_data" 728 transport parameter supplied by the server. Servers MUST NOT send 729 the "early_data" extension with a max_early_data_size set to any 730 value other than 0xffffffff. A client MUST treat receipt of a 731 NewSessionTicket that contains an "early_data" extension with any 732 other value as a connection error of type PROTOCOL_VIOLATION. 734 A client that wishes to send 0-RTT packets uses the "early_data" 735 extension in the ClientHello message of a subsequent handshake (see 736 Section 4.2.10 of [TLS13]). It then sends the application data in 737 0-RTT packets. 739 4.6. Accepting and Rejecting 0-RTT 741 A server accepts 0-RTT by sending an early_data extension in the 742 EncryptedExtensions (see Section 4.2.10 of [TLS13]). The server then 743 processes and acknowledges the 0-RTT packets that it receives. 745 A server rejects 0-RTT by sending the EncryptedExtensions without an 746 early_data extension. A server will always reject 0-RTT if it sends 747 a TLS HelloRetryRequest. When rejecting 0-RTT, a server MUST NOT 748 process any 0-RTT packets, even if it could. When 0-RTT was 749 rejected, a client SHOULD treat receipt of an acknowledgement for a 750 0-RTT packet as a connection error of type PROTOCOL_VIOLATION, if it 751 is able to detect the condition. 753 When 0-RTT is rejected, all connection characteristics that the 754 client assumed might be incorrect. This includes the choice of 755 application protocol, transport parameters, and any application 756 configuration. The client therefore MUST reset the state of all 757 streams, including application state bound to those streams. 759 A client MAY attempt to send 0-RTT again if it receives a Retry or 760 Version Negotiation packet. These packets do not signify rejection 761 of 0-RTT. 763 4.7. Validating 0-RTT Configuration 765 When a server receives a ClientHello with the "early_data" extension, 766 it has to decide whether to accept or reject early data from the 767 client. Some of this decision is made by the TLS stack (e.g., 768 checking that the cipher suite being resumed was included in the 769 ClientHello; see Section 4.2.10 of [TLS13]). Even when the TLS stack 770 has no reason to reject early data, the QUIC stack or the application 771 protocol using QUIC might reject early data because the configuration 772 of the transport or application associated with the resumed session 773 is not compatible with the server's current configuration. 775 QUIC requires additional transport state to be associated with a 776 0-RTT session ticket. One common way to implement this is using 777 stateless session tickets and storing this state in the session 778 ticket. Application protocols that use QUIC might have similar 779 requirements regarding associating or storing state. This associated 780 state is used for deciding whether early data must be rejected. For 781 example, HTTP/3 ([QUIC-HTTP]) settings determine how early data from 782 the client is interpreted. Other applications using QUIC could have 783 different requirements for determining whether to accept or reject 784 early data. 786 4.8. HelloRetryRequest 788 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 789 [TLS13]) can be used to correct a client's incorrect KeyShare 790 extension as well as for a stateless round-trip check. From the 791 perspective of QUIC, this just looks like additional messages carried 792 in the Initial encryption level. Although it is in principle 793 possible to use this feature for address verification in QUIC, QUIC 794 implementations SHOULD instead use the Retry feature (see Section 8.1 795 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 796 shares. 798 4.9. TLS Errors 800 If TLS experiences an error, it generates an appropriate alert as 801 defined in Section 6 of [TLS13]. 803 A TLS alert is turned into a QUIC connection error by converting the 804 one-byte alert description into a QUIC error code. The alert 805 description is added to 0x100 to produce a QUIC error code from the 806 range reserved for CRYPTO_ERROR. The resulting value is sent in a 807 QUIC CONNECTION_CLOSE frame. 809 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 810 generate alerts at the "warning" level. 812 4.10. Discarding Unused Keys 814 After QUIC moves to a new encryption level, packet protection keys 815 for previous encryption levels can be discarded. This occurs several 816 times during the handshake, as well as when keys are updated; see 817 Section 6. 819 Packet protection keys are not discarded immediately when new keys 820 are available. If packets from a lower encryption level contain 821 CRYPTO frames, frames that retransmit that data MUST be sent at the 822 same encryption level. Similarly, an endpoint generates 823 acknowledgements for packets at the same encryption level as the 824 packet being acknowledged. Thus, it is possible that keys for a 825 lower encryption level are needed for a short time after keys for a 826 newer encryption level are available. 828 An endpoint cannot discard keys for a given encryption level unless 829 it has both received and acknowledged all CRYPTO frames for that 830 encryption level and when all CRYPTO frames for that encryption level 831 have been acknowledged by its peer. However, this does not guarantee 832 that no further packets will need to be received or sent at that 833 encryption level because a peer might not have received all the 834 acknowledgements necessary to reach the same state. 836 Though an endpoint might retain older keys, new data MUST be sent at 837 the highest currently-available encryption level. Only ACK frames 838 and retransmissions of data in CRYPTO frames are sent at a previous 839 encryption level. These packets MAY also include PADDING frames. 841 4.10.1. Discarding Initial Keys 843 Packets protected with Initial secrets (Section 5.2) are not 844 authenticated, meaning that an attacker could spoof packets with the 845 intent to disrupt a connection. To limit these attacks, Initial 846 packet protection keys can be discarded more aggressively than other 847 keys. 849 The successful use of Handshake packets indicates that no more 850 Initial packets need to be exchanged, as these keys can only be 851 produced after receiving all CRYPTO frames from Initial packets. 852 Thus, a client MUST discard Initial keys when it first sends a 853 Handshake packet and a server MUST discard Initial keys when it first 854 successfully processes a Handshake packet. Endpoints MUST NOT send 855 Initial packets after this point. 857 This results in abandoning loss recovery state for the Initial 858 encryption level and ignoring any outstanding Initial packets. 860 4.10.2. Discarding Handshake Keys 862 An endpoint MUST discard its handshake keys when the TLS handshake is 863 confirmed (Section 4.1.2). The server MUST send a HANDSHAKE_DONE 864 frame as soon as it completes the handshake. 866 4.10.3. Discarding 0-RTT Keys 868 0-RTT and 1-RTT packets share the same packet number space, and 869 clients do not send 0-RTT packets after sending a 1-RTT packet 870 (Section 5.6). 872 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 873 1-RTT keys, since they have no use after that moment. 875 Additionally, a server MAY discard 0-RTT keys as soon as it receives 876 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 877 could arrive after a 1-RTT packet. Servers MAY temporarily retain 878 0-RTT keys to allow decrypting reordered packets without requiring 879 their contents to be retransmitted with 1-RTT keys. After receiving 880 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 881 the RECOMMENDED time period is three times the Probe Timeout (PTO, 882 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 883 determines that it has received all 0-RTT packets, which can be done 884 by keeping track of missing packet numbers. 886 5. Packet Protection 888 As with TLS over TCP, QUIC protects packets with keys derived from 889 the TLS handshake, using the AEAD algorithm negotiated by TLS. 891 5.1. Packet Protection Keys 893 QUIC derives packet protection keys in the same way that TLS derives 894 record protection keys. 896 Each encryption level has separate secret values for protection of 897 packets sent in each direction. These traffic secrets are derived by 898 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 899 encryption levels except the Initial encryption level. The secrets 900 for the Initial encryption level are computed based on the client's 901 initial Destination Connection ID, as described in Section 5.2. 903 The keys used for packet protection are computed from the TLS secrets 904 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 905 function described in Section 7.1 of [TLS13] is used, using the hash 906 function from the negotiated cipher suite. Other versions of TLS 907 MUST provide a similar function in order to be used with QUIC. 909 The current encryption level secret and the label "quic key" are 910 input to the KDF to produce the AEAD key; the label "quic iv" is used 911 to derive the IV; see Section 5.3. The header protection key uses 912 the "quic hp" label; see Section 5.4. Using these labels provides 913 key separation between QUIC and TLS; see Section 9.5. 915 The KDF used for initial secrets is always the HKDF-Expand-Label 916 function from TLS 1.3 (see Section 5.2). 918 5.2. Initial Secrets 920 Initial packets are protected with a secret derived from the 921 Destination Connection ID field from the client's Initial packet. 922 Specifically: 924 initial_salt = 0xc3eef712c72ebb5a11a7d2432bb46365bef9f502 925 initial_secret = HKDF-Extract(initial_salt, 926 client_dst_connection_id) 928 client_initial_secret = HKDF-Expand-Label(initial_secret, 929 "client in", "", 930 Hash.length) 931 server_initial_secret = HKDF-Expand-Label(initial_secret, 932 "server in", "", 933 Hash.length) 935 The hash function for HKDF when deriving initial secrets and keys is 936 SHA-256 [SHA]. 938 The connection ID used with HKDF-Expand-Label is the Destination 939 Connection ID in the Initial packet sent by the client. This will be 940 a randomly-selected value unless the client creates the Initial 941 packet after receiving a Retry packet, where the Destination 942 Connection ID is selected by the server. 944 The value of initial_salt is a 20 byte sequence shown in the figure 945 in hexadecimal notation. Future versions of QUIC SHOULD generate a 946 new salt value, thus ensuring that the keys are different for each 947 version of QUIC. This prevents a middlebox that only recognizes one 948 version of QUIC from seeing or modifying the contents of packets from 949 future versions. 951 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 952 Initial packets even where the TLS versions offered do not include 953 TLS 1.3. 955 The secrets used for protecting Initial packets change when a server 956 sends a Retry packet to use the connection ID value selected by the 957 server. The secrets do not change when a client changes the 958 Destination Connection ID it uses in response to an Initial packet 959 from the server. 961 Note: The Destination Connection ID is of arbitrary length, and it 962 could be zero length if the server sends a Retry packet with a 963 zero-length Source Connection ID field. In this case, the Initial 964 keys provide no assurance to the client that the server received 965 its packet; the client has to rely on the exchange that included 966 the Retry packet for that property. 968 Appendix A contains test vectors for packet encryption. 970 5.3. AEAD Usage 972 The Authentication Encryption with Associated Data (AEAD) [AEAD] 973 function used for QUIC packet protection is the AEAD that is 974 negotiated for use with the TLS connection. For example, if TLS is 975 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 976 used. 978 Packets are protected prior to applying header protection 979 (Section 5.4). The unprotected packet header is part of the 980 associated data (A). When removing packet protection, an endpoint 981 first removes the header protection. 983 All QUIC packets other than Version Negotiation and Retry packets are 984 protected with an AEAD algorithm [AEAD]. Prior to establishing a 985 shared secret, packets are protected with AEAD_AES_128_GCM and a key 986 derived from the Destination Connection ID in the client's first 987 Initial packet (see Section 5.2). This provides protection against 988 off-path attackers and robustness against QUIC version unaware 989 middleboxes, but not against on-path attackers. 991 QUIC can use any of the ciphersuites defined in [TLS13] with the 992 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 993 negotiated unless a header protection scheme is defined for the 994 ciphersuite. This document defines a header protection scheme for 995 all ciphersuites defined in [TLS13] aside from 996 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 997 authentication tag and produce an output 16 bytes larger than their 998 input. 1000 Note: An endpoint MUST NOT reject a ClientHello that offers a 1001 ciphersuite that it does not support, or it would be impossible to 1002 deploy a new ciphersuite. This also applies to 1003 TLS_AES_128_CCM_8_SHA256. 1005 The key and IV for the packet are computed as described in 1006 Section 5.1. The nonce, N, is formed by combining the packet 1007 protection IV with the packet number. The 62 bits of the 1008 reconstructed QUIC packet number in network byte order are left- 1009 padded with zeros to the size of the IV. The exclusive OR of the 1010 padded packet number and the IV forms the AEAD nonce. 1012 The associated data, A, for the AEAD is the contents of the QUIC 1013 header, starting from the flags byte in either the short or long 1014 header, up to and including the unprotected packet number. 1016 The input plaintext, P, for the AEAD is the payload of the QUIC 1017 packet, as described in [QUIC-TRANSPORT]. 1019 The output ciphertext, C, of the AEAD is transmitted in place of P. 1021 Some AEAD functions have limits for how many packets can be encrypted 1022 under the same key and IV (see for example [AEBounds]). This might 1023 be lower than the packet number limit. An endpoint MUST initiate a 1024 key update (Section 6) prior to exceeding any limit set for the AEAD 1025 that is in use. 1027 5.4. Header Protection 1029 Parts of QUIC packet headers, in particular the Packet Number field, 1030 are protected using a key that is derived separate to the packet 1031 protection key and IV. The key derived using the "quic hp" label is 1032 used to provide confidentiality protection for those fields that are 1033 not exposed to on-path elements. 1035 This protection applies to the least-significant bits of the first 1036 byte, plus the Packet Number field. The four least-significant bits 1037 of the first byte are protected for packets with long headers; the 1038 five least significant bits of the first byte are protected for 1039 packets with short headers. For both header forms, this covers the 1040 reserved bits and the Packet Number Length field; the Key Phase bit 1041 is also protected for packets with a short header. 1043 The same header protection key is used for the duration of the 1044 connection, with the value not changing after a key update (see 1045 Section 6). This allows header protection to be used to protect the 1046 key phase. 1048 This process does not apply to Retry or Version Negotiation packets, 1049 which do not contain a protected payload or any of the fields that 1050 are protected by this process. 1052 5.4.1. Header Protection Application 1054 Header protection is applied after packet protection is applied (see 1055 Section 5.3). The ciphertext of the packet is sampled and used as 1056 input to an encryption algorithm. The algorithm used depends on the 1057 negotiated AEAD. 1059 The output of this algorithm is a 5 byte mask which is applied to the 1060 protected header fields using exclusive OR. The least significant 1061 bits of the first byte of the packet are masked by the least 1062 significant bits of the first mask byte, and the packet number is 1063 masked with the remaining bytes. Any unused bytes of mask that might 1064 result from a shorter packet number encoding are unused. 1066 Figure 6 shows a sample algorithm for applying header protection. 1067 Removing header protection only differs in the order in which the 1068 packet number length (pn_length) is determined. 1070 mask = header_protection(hp_key, sample) 1072 pn_length = (packet[0] & 0x03) + 1 1073 if (packet[0] & 0x80) == 0x80: 1074 # Long header: 4 bits masked 1075 packet[0] ^= mask[0] & 0x0f 1076 else: 1077 # Short header: 5 bits masked 1078 packet[0] ^= mask[0] & 0x1f 1080 # pn_offset is the start of the Packet Number field. 1081 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 1083 Figure 6: Header Protection Pseudocode 1085 Figure 7 shows the protected fields of long and short headers marked 1086 with an E. Figure 7 also shows the sampled fields. 1088 Long Header: 1089 +-+-+-+-+-+-+-+-+ 1090 |1|1|T T|E E E E| 1091 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1092 | Version -> Length Fields ... 1093 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1095 Short Header: 1096 +-+-+-+-+-+-+-+-+ 1097 |0|1|S|E E E E E| 1098 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1099 | Destination Connection ID (0/32..144) ... 1100 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1102 Common Fields: 1103 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1104 |E E E E E E E E E Packet Number (8/16/24/32) E E E E E E E E... 1105 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1106 | [Protected Payload (8/16/24)] ... 1107 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1108 | Sampled part of Protected Payload (128) ... 1109 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1110 | Protected Payload Remainder (*) ... 1111 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1113 Figure 7: Header Protection and Ciphertext Sample 1115 Before a TLS ciphersuite can be used with QUIC, a header protection 1116 algorithm MUST be specified for the AEAD used with that ciphersuite. 1117 This document defines algorithms for AEAD_AES_128_GCM, 1118 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1119 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1120 a ciphersuite, AES header protection is used (Section 5.4.3), 1121 matching the AEAD_AES_128_GCM packet protection. 1123 5.4.2. Header Protection Sample 1125 The header protection algorithm uses both the header protection key 1126 and a sample of the ciphertext from the packet Payload field. 1128 The same number of bytes are always sampled, but an allowance needs 1129 to be made for the endpoint removing protection, which will not know 1130 the length of the Packet Number field. In sampling the packet 1131 ciphertext, the Packet Number field is assumed to be 4 bytes long 1132 (its maximum possible encoded length). 1134 An endpoint MUST discard packets that are not long enough to contain 1135 a complete sample. 1137 To ensure that sufficient data is available for sampling, packets are 1138 padded so that the combined lengths of the encoded packet number and 1139 protected payload is at least 4 bytes longer than the sample required 1140 for header protection. The ciphersuites defined in [TLS13] - other 1141 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1142 is not defined in this document - have 16-byte expansions and 16-byte 1143 header protection samples. This results in needing at least 3 bytes 1144 of frames in the unprotected payload if the packet number is encoded 1145 on a single byte, or 2 bytes of frames for a 2-byte packet number 1146 encoding. 1148 The sampled ciphertext for a packet with a short header can be 1149 determined by the following pseudocode: 1151 sample_offset = 1 + len(connection_id) + 4 1153 sample = packet[sample_offset..sample_offset+sample_length] 1155 For example, for a packet with a short header, an 8 byte connection 1156 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1157 28 inclusive (using zero-based indexing). 1159 A packet with a long header is sampled in the same way, noting that 1160 multiple QUIC packets might be included in the same UDP datagram and 1161 that each one is handled separately. 1163 sample_offset = 7 + len(destination_connection_id) + 1164 len(source_connection_id) + 1165 len(payload_length) + 4 1166 if packet_type == Initial: 1167 sample_offset += len(token_length) + 1168 len(token) 1170 sample = packet[sample_offset..sample_offset+sample_length] 1172 5.4.3. AES-Based Header Protection 1174 This section defines the packet protection algorithm for 1175 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1176 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1177 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1178 in ECB mode. 1180 This algorithm samples 16 bytes from the packet ciphertext. This 1181 value is used as the input to AES-ECB. In pseudocode: 1183 mask = AES-ECB(hp_key, sample) 1185 5.4.4. ChaCha20-Based Header Protection 1187 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1188 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1189 256-bit key and 16 bytes sampled from the packet protection output. 1191 The first 4 bytes of the sampled ciphertext are the block counter. A 1192 ChaCha20 implementation could take a 32-bit integer in place of a 1193 byte sequence, in which case the byte sequence is interpreted as a 1194 little-endian value. 1196 The remaining 12 bytes are used as the nonce. A ChaCha20 1197 implementation might take an array of three 32-bit integers in place 1198 of a byte sequence, in which case the nonce bytes are interpreted as 1199 a sequence of 32-bit little-endian integers. 1201 The encryption mask is produced by invoking ChaCha20 to protect 5 1202 zero bytes. In pseudocode: 1204 counter = sample[0..3] 1205 nonce = sample[4..15] 1206 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1208 5.5. Receiving Protected Packets 1210 Once an endpoint successfully receives a packet with a given packet 1211 number, it MUST discard all packets in the same packet number space 1212 with higher packet numbers if they cannot be successfully unprotected 1213 with either the same key, or - if there is a key update - the next 1214 packet protection key (see Section 6). Similarly, a packet that 1215 appears to trigger a key update, but cannot be unprotected 1216 successfully MUST be discarded. 1218 Failure to unprotect a packet does not necessarily indicate the 1219 existence of a protocol error in a peer or an attack. The truncated 1220 packet number encoding used in QUIC can cause packet numbers to be 1221 decoded incorrectly if they are delayed significantly. 1223 5.6. Use of 0-RTT Keys 1225 If 0-RTT keys are available (see Section 4.5), the lack of replay 1226 protection means that restrictions on their use are necessary to 1227 avoid replay attacks on the protocol. 1229 A client MUST only use 0-RTT keys to protect data that is idempotent. 1230 A client MAY wish to apply additional restrictions on what data it 1231 sends prior to the completion of the TLS handshake. A client 1232 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1233 it MUST NOT send ACKs with 0-RTT keys. 1235 A client that receives an indication that its 0-RTT data has been 1236 accepted by a server can send 0-RTT data until it receives all of the 1237 server's handshake messages. A client SHOULD stop sending 0-RTT data 1238 if it receives an indication that 0-RTT data has been rejected. 1240 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1241 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1242 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1243 them. 1245 Once a client has installed 1-RTT keys, it MUST NOT send any more 1246 0-RTT packets. 1248 Note: 0-RTT data can be acknowledged by the server as it receives 1249 it, but any packets containing acknowledgments of 0-RTT data 1250 cannot have packet protection removed by the client until the TLS 1251 handshake is complete. The 1-RTT keys necessary to remove packet 1252 protection cannot be derived until the client receives all server 1253 handshake messages. 1255 5.7. Receiving Out-of-Order Protected Frames 1257 Due to reordering and loss, protected packets might be received by an 1258 endpoint before the final TLS handshake messages are received. A 1259 client will be unable to decrypt 1-RTT packets from the server, 1260 whereas a server will be able to decrypt 1-RTT packets from the 1261 client. Endpoints in either role MUST NOT decrypt 1-RTT packets from 1262 their peer prior to completing the handshake. 1264 Even though 1-RTT keys are available to a server after receiving the 1265 first handshake messages from a client, it is missing assurances on 1266 the client state: 1268 * The client is not authenticated, unless the server has chosen to 1269 use a pre-shared key and validated the client's pre-shared key 1270 binder; see Section 4.2.11 of [TLS13]. 1272 * The client has not demonstrated liveness, unless a RETRY packet 1273 was used. 1275 * Any received 0-RTT data that the server responds to might be due 1276 to a replay attack. 1278 Therefore, the server's use of 1-RTT keys MUST be limited to sending 1279 data before the handshake is complete. A server MUST NOT process 1280 incoming 1-RTT protected packets before the TLS handshake is 1281 complete. Because sending acknowledgments indicates that all frames 1282 in a packet have been processed, a server cannot send acknowledgments 1283 for 1-RTT packets until the TLS handshake is complete. Received 1284 packets protected with 1-RTT keys MAY be stored and later decrypted 1285 and used once the handshake is complete. 1287 Note: TLS implementations might provide all 1-RTT secrets prior to 1288 handshake completion. Even where QUIC implementations have 1-RTT 1289 read keys, those keys cannot be used prior to completing the 1290 handshake. 1292 The requirement for the server to wait for the client Finished 1293 message creates a dependency on that message being delivered. A 1294 client can avoid the potential for head-of-line blocking that this 1295 implies by sending its 1-RTT packets coalesced with a handshake 1296 packet containing a copy of the CRYPTO frame that carries the 1297 Finished message, until one of the handshake packets is acknowledged. 1298 This enables immediate server processing for those packets. 1300 A server could receive packets protected with 0-RTT keys prior to 1301 receiving a TLS ClientHello. The server MAY retain these packets for 1302 later decryption in anticipation of receiving a ClientHello. 1304 5.8. Retry Packet Integrity 1306 Retry packets (see the Retry Packet section of [QUIC-TRANSPORT]) 1307 carry a Retry Integrity Tag that provides two properties: it allows 1308 discarding packets that have accidentally been corrupted by the 1309 network, and it diminishes off-path attackers' ability to send valid 1310 Retry packets. 1312 The Retry Integrity Tag is a 128-bit field that is computed as the 1313 output of AEAD_AES_128_GCM [AEAD] used with the following inputs: 1315 * The secret key, K, is 128 bits equal to 1316 0x4d32ecdb2a2133c841e4043df27d4430. 1318 * The nonce, N, is 96 bits equal to 0x4d1611d05513a552c587d575. 1320 * The plaintext, P, is empty. 1322 * The associated data, A, is the contents of the Retry Pseudo- 1323 Packet, as illustrated in Figure 8: 1325 The secret key and the nonce are values derived by calling HKDF- 1326 Expand-Label using 1327 0x656e61e336ae9417f7f0edd8d78d461e2aa7084aba7a14c1e9f726d55709169a as 1328 the secret, with labels being "quic key" and "quic iv" (Section 5.1). 1330 0 1 2 3 1331 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1332 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1333 | ODCID Len (8) | 1334 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1335 | Original Destination Connection ID (0..160) ... 1336 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1337 |1|1| 3 | Unused| 1338 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1339 | Version (32) | 1340 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1341 | DCID Len (8) | 1342 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1343 | Destination Connection ID (0..160) ... 1344 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1345 | SCID Len (8) | 1346 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1347 | Source Connection ID (0..160) ... 1348 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1349 | Retry Token (*) ... 1350 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1351 Figure 8: Retry Pseudo-Packet 1353 The Retry Pseudo-Packet is not sent over the wire. It is computed by 1354 taking the transmitted Retry packet, removing the Retry Integrity Tag 1355 and prepending the two following fields: 1357 ODCID Len: The ODCID Len contains the length in bytes of the 1358 Original Destination Connection ID field that follows it, encoded 1359 as an 8-bit unsigned integer. 1361 Original Destination Connection ID: The Original Destination 1362 Connection ID contains the value of the Destination Connection ID 1363 from the Initial packet that this Retry is in response to. The 1364 length of this field is given in ODCID Len. The presence of this 1365 field mitigates an off-path attacker's ability to inject a Retry 1366 packet. 1368 6. Key Update 1370 Once the handshake is confirmed (see Section 4.1.2), an endpoint MAY 1371 initiate a key update. 1373 The Key Phase bit indicates which packet protection keys are used to 1374 protect the packet. The Key Phase bit is initially set to 0 for the 1375 first set of 1-RTT packets and toggled to signal each subsequent key 1376 update. 1378 The Key Phase bit allows a recipient to detect a change in keying 1379 material without needing to receive the first packet that triggered 1380 the change. An endpoint that notices a changed Key Phase bit updates 1381 keys and decrypts the packet that contains the changed value. 1383 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1384 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1385 of a TLS KeyUpdate message as a connection error of type 0x10a, 1386 equivalent to a fatal TLS alert of unexpected_message (see 1387 Section 4.9). 1389 Figure 9 shows a key update process, where the initial set of keys 1390 used (identified with @M) are replaced by updated keys (identified 1391 with @N). The value of the Key Phase bit is indicated in brackets 1392 []. 1394 Initiating Peer Responding Peer 1396 @M [0] QUIC Packets 1398 ... Update to @N 1399 @N [1] QUIC Packets 1400 --------> 1401 Update to @N ... 1402 QUIC Packets [1] @N 1403 <-------- 1404 QUIC Packets [1] @N 1405 containing ACK 1406 <-------- 1407 ... Key Update Permitted 1409 @N [1] QUIC Packets 1410 containing ACK for @N packets 1411 --------> 1412 Key Update Permitted ... 1414 Figure 9: Key Update 1416 6.1. Initiating a Key Update 1418 Endpoints maintain separate read and write secrets for packet 1419 protection. An endpoint initiates a key update by updating its 1420 packet protection write secret and using that to protect new packets. 1421 The endpoint creates a new write secret from the existing write 1422 secret as performed in Section 7.2 of [TLS13]. This uses the KDF 1423 function provided by TLS with a label of "quic ku". The 1424 corresponding key and IV are created from that secret as defined in 1425 Section 5.1. The header protection key is not updated. 1427 For example, to update write keys with TLS 1.3, HKDF-Expand-Label is 1428 used as: 1430 secret_ = HKDF-Expand-Label(secret_, "quic ku", 1431 "", Hash.length) 1433 The endpoint toggles the value of the Key Phase bit and uses the 1434 updated key and IV to protect all subsequent packets. 1436 An endpoint MUST NOT initiate a key update prior to having confirmed 1437 the handshake (Section 4.1.2). An endpoint MUST NOT initiate a 1438 subsequent key update prior unless it has received an acknowledgment 1439 for a packet that was sent protected with keys from the current key 1440 phase. This ensures that keys are available to both peers before 1441 another key update can be initiated. This can be implemented by 1442 tracking the lowest packet number sent with each key phase, and the 1443 highest acknowledged packet number in the 1-RTT space: once the 1444 latter is higher than or equal to the former, another key update can 1445 be initiated. 1447 Note: Keys of packets other than the 1-RTT packets are never 1448 updated; their keys are derived solely from the TLS handshake 1449 state. 1451 The endpoint that initiates a key update also updates the keys that 1452 it uses for receiving packets. These keys will be needed to process 1453 packets the peer sends after updating. 1455 An endpoint SHOULD retain old keys so that packets sent by its peer 1456 prior to receiving the key update can be processed. Discarding old 1457 keys too early can cause delayed packets to be discarded. Discarding 1458 packets will be interpreted as packet loss by the peer and could 1459 adversely affect performance. 1461 6.2. Responding to a Key Update 1463 A peer is permitted to initiate a key update after receiving an 1464 acknowledgement of a packet in the current key phase. An endpoint 1465 detects a key update when processing a packet with a key phase that 1466 differs from the value last used to protect the last packet it sent. 1467 To process this packet, the endpoint uses the next packet protection 1468 key and IV. See Section 6.3 for considerations about generating 1469 these keys. 1471 If a packet is successfully processed using the next key and IV, then 1472 the peer has initiated a key update. The endpoint MUST update its 1473 send keys to the corresponding key phase in response, as described in 1474 Section 6.1. Sending keys MUST be updated before sending an 1475 acknowledgement for the packet that was received with updated keys. 1476 By acknowledging the packet that triggered the key update in a packet 1477 protected with the updated keys, the endpoint signals that the key 1478 update is complete. 1480 An endpoint can defer sending the packet or acknowledgement according 1481 to its normal packet sending behaviour; it is not necessary to 1482 immediately generate a packet in response to a key update. The next 1483 packet sent by the endpoint will use the updated keys. The next 1484 packet that contains an acknowledgement will cause the key update to 1485 be completed. If an endpoint detects a second update before it has 1486 sent any packets with updated keys containing an acknowledgement for 1487 the packet that initiated the key update, it indicates that its peer 1488 has updated keys twice without awaiting confirmation. An endpoint 1489 MAY treat consecutive key updates as a connection error of type 1490 KEY_UPDATE_ERROR. 1492 An endpoint that receives an acknowledgement that is carried in a 1493 packet protected with old keys where any acknowledged packet was 1494 protected with newer keys MAY treat that as a connection error of 1495 type KEY_UPDATE_ERROR. This indicates that a peer has received and 1496 acknowledged a packet that initiates a key update, but has not 1497 updated keys in response. 1499 6.3. Timing of Receive Key Generation 1501 Endpoints responding to an apparent key update MUST NOT generate a 1502 timing side-channel signal that might indicate that the Key Phase bit 1503 was invalid (see Section 9.3). Endpoints can use dummy packet 1504 protection keys in place of discarded keys when key updates are not 1505 yet permitted. Using dummy keys will generate no variation in the 1506 timing signal produced by attempting to remove packet protection, and 1507 results in all packets with an invalid Key Phase bit being rejected. 1509 The process of creating new packet protection keys for receiving 1510 packets could reveal that a key update has occurred. An endpoint MAY 1511 perform this process as part of packet processing, but this creates a 1512 timing signal that can be used by an attacker to learn when key 1513 updates happen and thus the value of the Key Phase bit in certain 1514 packets. Endpoints MAY instead defer the creation of the next set of 1515 receive packet protection keys until some time after a key update 1516 completes, up to three times the PTO; see Section 6.5. 1518 Once generated, the next set of packet protection keys SHOULD be 1519 retained, even if the packet that was received was subsequently 1520 discarded. Packets containing apparent key updates are easy to forge 1521 and - while the process of key update does not require significant 1522 effort - triggering this process could be used by an attacker for 1523 DoS. 1525 For this reason, endpoints MUST be able to retain two sets of packet 1526 protection keys for receiving packets: the current and the next. 1527 Retaining the previous keys in addition to these might improve 1528 performance, but this is not essential. 1530 6.4. Sending with Updated Keys 1532 An endpoint always sends packets that are protected with the newest 1533 keys. Keys used for packet protection can be discarded immediately 1534 after switching to newer keys. 1536 Packets with higher packet numbers MUST be protected with either the 1537 same or newer packet protection keys than packets with lower packet 1538 numbers. An endpoint that successfully removes protection with old 1539 keys when newer keys were used for packets with lower packet numbers 1540 MUST treat this as a connection error of type KEY_UPDATE_ERROR. 1542 6.5. Receiving with Different Keys 1544 For receiving packets during a key update, packets protected with 1545 older keys might arrive if they were delayed by the network. 1546 Retaining old packet protection keys allows these packets to be 1547 successfully processed. 1549 As packets protected with keys from the next key phase use the same 1550 Key Phase value as those protected with keys from the previous key 1551 phase, it can be necessary to distinguish between the two. This can 1552 be done using packet numbers. A recovered packet number that is 1553 lower than any packet number from the current key phase uses the 1554 previous packet protection keys; a recovered packet number that is 1555 higher than any packet number from the current key phase requires the 1556 use of the next packet protection keys. 1558 Some care is necessary to ensure that any process for selecting 1559 between previous, current, and next packet protection keys does not 1560 expose a timing side channel that might reveal which keys were used 1561 to remove packet protection. See Section 9.4 for more information. 1563 Alternatively, endpoints can retain only two sets of packet 1564 protection keys, swapping previous for next after enough time has 1565 passed to allow for reordering in the network. In this case, the Key 1566 Phase bit alone can be used to select keys. 1568 An endpoint MAY allow a period of approximately the Probe Timeout 1569 (PTO; see [QUIC-RECOVERY]) after a key update before it creates the 1570 next set of packet protection keys. These updated keys MAY replace 1571 the previous keys at that time. With the caveat that PTO is a 1572 subjective measure - that is, a peer could have a different view of 1573 the RTT - this time is expected to be long enough that any reordered 1574 packets would be declared lost by a peer even if they were 1575 acknowledged and short enough to allow for subsequent key updates. 1577 Endpoints need to allow for the possibility that a peer might not be 1578 able to decrypt packets that initiate a key update during the period 1579 when it retains old keys. Endpoints SHOULD wait three times the PTO 1580 before initiating a key update after receiving an acknowledgment that 1581 confirms that the previous key update was received. Failing to allow 1582 sufficient time could lead to packets being discarded. 1584 An endpoint SHOULD retain old read keys for no more than three times 1585 the PTO. After this period, old read keys and their corresponding 1586 secrets SHOULD be discarded. 1588 6.6. Key Update Frequency 1590 Key updates MUST be initiated before usage limits on packet 1591 protection keys are exceeded. For the cipher suites mentioned in 1592 this document, the limits in Section 5.5 of [TLS13] apply. Other 1593 cipher suites MUST define usage limits in order to be used with QUIC. 1595 6.7. Key Update Error Code 1597 The KEY_UPDATE_ERROR error code (0xE) is used to signal errors 1598 related to key updates. 1600 7. Security of Initial Messages 1602 Initial packets are not protected with a secret key, so they are 1603 subject to potential tampering by an attacker. QUIC provides 1604 protection against attackers that cannot read packets, but does not 1605 attempt to provide additional protection against attacks where the 1606 attacker can observe and inject packets. Some forms of tampering - 1607 such as modifying the TLS messages themselves - are detectable, but 1608 some - such as modifying ACKs - are not. 1610 For example, an attacker could inject a packet containing an ACK 1611 frame that makes it appear that a packet had not been received or to 1612 create a false impression of the state of the connection (e.g., by 1613 modifying the ACK Delay). Note that such a packet could cause a 1614 legitimate packet to be dropped as a duplicate. Implementations 1615 SHOULD use caution in relying on any data which is contained in 1616 Initial packets that is not otherwise authenticated. 1618 It is also possible for the attacker to tamper with data that is 1619 carried in Handshake packets, but because that tampering requires 1620 modifying TLS handshake messages, that tampering will cause the TLS 1621 handshake to fail. 1623 8. QUIC-Specific Additions to the TLS Handshake 1625 QUIC uses the TLS handshake for more than just negotiation of 1626 cryptographic parameters. The TLS handshake provides preliminary 1627 values for QUIC transport parameters and allows a server to perform 1628 return routability checks on clients. 1630 8.1. Protocol Negotiation 1632 QUIC requires that the cryptographic handshake provide authenticated 1633 protocol negotiation. TLS uses Application Layer Protocol 1634 Negotiation (ALPN) [ALPN] to select an application protocol. Unless 1635 another mechanism is used for agreeing on an application protocol, 1636 endpoints MUST use ALPN for this purpose. When using ALPN, endpoints 1637 MUST immediately close a connection (see Section 10.3 in 1638 [QUIC-TRANSPORT]) if an application protocol is not negotiated with a 1639 no_application_protocol TLS alert (QUIC error code 0x178, see 1640 Section 4.9). While [ALPN] only specifies that servers use this 1641 alert, QUIC clients MUST also use it to terminate a connection when 1642 ALPN negotiation fails. 1644 An application protocol MAY restrict the QUIC versions that it can 1645 operate over. Servers MUST select an application protocol compatible 1646 with the QUIC version that the client has selected. The server MUST 1647 treat the inability to select a compatible application protocol as a 1648 connection error of type 0x178 (no_application_protocol). Similarly, 1649 a client MUST treat the selection of an incompatible application 1650 protocol by a server as a connection error of type 0x178. 1652 8.2. QUIC Transport Parameters Extension 1654 QUIC transport parameters are carried in a TLS extension. Different 1655 versions of QUIC might define a different method for negotiating 1656 transport configuration. 1658 Including transport parameters in the TLS handshake provides 1659 integrity protection for these values. 1661 enum { 1662 quic_transport_parameters(0xffa5), (65535) 1663 } ExtensionType; 1665 The "extension_data" field of the quic_transport_parameters extension 1666 contains a value that is defined by the version of QUIC that is in 1667 use. 1669 The quic_transport_parameters extension is carried in the ClientHello 1670 and the EncryptedExtensions messages during the handshake. Endpoints 1671 MUST send the quic_transport_parameters extension; endpoints that 1672 receive ClientHello or EncryptedExtensions messages without the 1673 quic_transport_parameters extension MUST close the connection with an 1674 error of type 0x16d (equivalent to a fatal TLS missing_extension 1675 alert, see Section 4.9). 1677 While the transport parameters are technically available prior to the 1678 completion of the handshake, they cannot be fully trusted until the 1679 handshake completes, and reliance on them should be minimized. 1680 However, any tampering with the parameters will cause the handshake 1681 to fail. 1683 Endpoints MUST NOT send this extension in a TLS connection that does 1684 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1685 fatal unsupported_extension alert MUST be sent by an implementation 1686 that supports this extension if the extension is received when the 1687 transport is not QUIC. 1689 8.3. Removing the EndOfEarlyData Message 1691 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1692 rely on this message to mark the end of 0-RTT data or to signal the 1693 change to Handshake keys. 1695 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1696 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1697 error of type PROTOCOL_VIOLATION. 1699 As a result, EndOfEarlyData does not appear in the TLS handshake 1700 transcript. 1702 9. Security Considerations 1704 There are likely to be some real clangers here eventually, but the 1705 current set of issues is well captured in the relevant sections of 1706 the main text. 1708 Never assume that because it isn't in the security considerations 1709 section it doesn't affect security. Most of this document does. 1711 9.1. Replay Attacks with 0-RTT 1713 As described in Section 8 of [TLS13], use of TLS early data comes 1714 with an exposure to replay attack. The use of 0-RTT in QUIC is 1715 similarly vulnerable to replay attack. 1717 Endpoints MUST implement and use the replay protections described in 1718 [TLS13], however it is recognized that these protections are 1719 imperfect. Therefore, additional consideration of the risk of replay 1720 is needed. 1722 QUIC is not vulnerable to replay attack, except via the application 1723 protocol information it might carry. The management of QUIC protocol 1724 state based on the frame types defined in [QUIC-TRANSPORT] is not 1725 vulnerable to replay. Processing of QUIC frames is idempotent and 1726 cannot result in invalid connection states if frames are replayed, 1727 reordered or lost. QUIC connections do not produce effects that last 1728 beyond the lifetime of the connection, except for those produced by 1729 the application protocol that QUIC serves. 1731 Note: TLS session tickets and address validation tokens are used to 1732 carry QUIC configuration information between connections. These 1733 MUST NOT be used to carry application semantics. The potential 1734 for reuse of these tokens means that they require stronger 1735 protections against replay. 1737 A server that accepts 0-RTT on a connection incurs a higher cost than 1738 accepting a connection without 0-RTT. This includes higher 1739 processing and computation costs. Servers need to consider the 1740 probability of replay and all associated costs when accepting 0-RTT. 1742 Ultimately, the responsibility for managing the risks of replay 1743 attacks with 0-RTT lies with an application protocol. An application 1744 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1745 the measures that are employed to protect against replay attack. An 1746 analysis of replay risk needs to consider all QUIC protocol features 1747 that carry application semantics. 1749 Disabling 0-RTT entirely is the most effective defense against replay 1750 attack. 1752 QUIC extensions MUST describe how replay attacks affect their 1753 operation, or prohibit their use in 0-RTT. Application protocols 1754 MUST either prohibit the use of extensions that carry application 1755 semantics in 0-RTT or provide replay mitigation strategies. 1757 9.2. Packet Reflection Attack Mitigation 1759 A small ClientHello that results in a large block of handshake 1760 messages from a server can be used in packet reflection attacks to 1761 amplify the traffic generated by an attacker. 1763 QUIC includes three defenses against this attack. First, the packet 1764 containing a ClientHello MUST be padded to a minimum size. Second, 1765 if responding to an unverified source address, the server is 1766 forbidden to send more than three UDP datagrams in its first flight 1767 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1768 acknowledgements of Handshake packets are authenticated, a blind 1769 attacker cannot forge them. Put together, these defenses limit the 1770 level of amplification. 1772 9.3. Header Protection Analysis 1774 [NAN] analyzes authenticated encryption algorithms which provide 1775 nonce privacy, referred to as "Hide Nonce" (HN) transforms. The 1776 general header protection construction in this document is one of 1777 those algorithms (HN1). Header protection uses the output of the 1778 packet protection AEAD to derive "sample", and then encrypts the 1779 header field using a pseudorandom function (PRF) as follows: 1781 protected_field = field XOR PRF(hp_key, sample) 1783 The header protection variants in this document use a pseudorandom 1784 permutation (PRP) in place of a generic PRF. However, since all PRPs 1785 are also PRFs [IMC], these variants do not deviate from the HN1 1786 construction. 1788 As "hp_key" is distinct from the packet protection key, it follows 1789 that header protection achieves AE2 security as defined in [NAN] and 1790 therefore guarantees privacy of "field", the protected packet header. 1791 Future header protection variants based on this construction MUST use 1792 a PRF to ensure equivalent security guarantees. 1794 Use of the same key and ciphertext sample more than once risks 1795 compromising header protection. Protecting two different headers 1796 with the same key and ciphertext sample reveals the exclusive OR of 1797 the protected fields. Assuming that the AEAD acts as a PRF, if L 1798 bits are sampled, the odds of two ciphertext samples being identical 1799 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1800 described in this document, that probability is one in 2^64. 1802 Note: In some cases, inputs shorter than the full size required by 1803 the packet protection algorithm might be used. 1805 To prevent an attacker from modifying packet headers, the header is 1806 transitively authenticated using packet protection; the entire packet 1807 header is part of the authenticated additional data. Protected 1808 fields that are falsified or modified can only be detected once the 1809 packet protection is removed. 1811 9.4. Header Protection Timing Side-Channels 1813 An attacker could guess values for packet numbers or Key Phase and 1814 have an endpoint confirm guesses through timing side channels. 1815 Similarly, guesses for the packet number length can be trialed and 1816 exposed. If the recipient of a packet discards packets with 1817 duplicate packet numbers without attempting to remove packet 1818 protection they could reveal through timing side-channels that the 1819 packet number matches a received packet. For authentication to be 1820 free from side-channels, the entire process of header protection 1821 removal, packet number recovery, and packet protection removal MUST 1822 be applied together without timing and other side-channels. 1824 For the sending of packets, construction and protection of packet 1825 payloads and packet numbers MUST be free from side-channels that 1826 would reveal the packet number or its encoded size. 1828 During a key update, the time taken to generate new keys could reveal 1829 through timing side-channels that a key update has occurred. 1830 Alternatively, where an attacker injects packets this side-channel 1831 could reveal the value of the Key Phase on injected packets. After 1832 receiving a key update, an endpoint SHOULD generate and save the next 1833 set of receive packet protection keys, as described in Section 6.3. 1834 By generating new keys before a key update is received, receipt of 1835 packets will not create timing signals that leak the value of the Key 1836 Phase. 1838 This depends on not doing this key generation during packet 1839 processing and it can require that endpoints maintain three sets of 1840 packet protection keys for receiving: for the previous key phase, for 1841 the current key phase, and for the next key phase. Endpoints can 1842 instead choose to defer generation of the next receive packet 1843 protection keys until they discard old keys so that only two sets of 1844 receive keys need to be retained at any point in time. 1846 9.5. Key Diversity 1848 In using TLS, the central key schedule of TLS is used. As a result 1849 of the TLS handshake messages being integrated into the calculation 1850 of secrets, the inclusion of the QUIC transport parameters extension 1851 ensures that handshake and 1-RTT keys are not the same as those that 1852 might be produced by a server running TLS over TCP. To avoid the 1853 possibility of cross-protocol key synchronization, additional 1854 measures are provided to improve key separation. 1856 The QUIC packet protection keys and IVs are derived using a different 1857 label than the equivalent keys in TLS. 1859 To preserve this separation, a new version of QUIC SHOULD define new 1860 labels for key derivation for packet protection key and IV, plus the 1861 header protection keys. This version of QUIC uses the string "quic". 1862 Other versions can use a version-specific label in place of that 1863 string. 1865 The initial secrets use a key that is specific to the negotiated QUIC 1866 version. New QUIC versions SHOULD define a new salt value used in 1867 calculating initial secrets. 1869 10. IANA Considerations 1871 This document does not create any new IANA registries, but it 1872 registers the values in the following registries: 1874 * TLS ExtensionType Values Registry [TLS-REGISTRIES] - IANA is to 1875 register the quic_transport_parameters extension found in 1876 Section 8.2. The Recommended column is to be marked Yes. The TLS 1877 1.3 Column is to include CH and EE. 1879 * QUIC Transport Error Codes Registry [QUIC-TRANSPORT] - IANA is to 1880 register the KEY_UPDATE_ERROR (0xE), as described in Section 6.7. 1882 11. References 1884 11.1. Normative References 1886 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1887 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1888 . 1890 [AES] "Advanced encryption standard (AES)", 1891 DOI 10.6028/nist.fips.197, National Institute of Standards 1892 and Technology report, November 2001, 1893 . 1895 [ALPN] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1896 "Transport Layer Security (TLS) Application-Layer Protocol 1897 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1898 July 2014, . 1900 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1901 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1902 . 1904 [QUIC-RECOVERY] 1905 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1906 and Congestion Control", Work in Progress, Internet-Draft, 1907 draft-ietf-quic-recovery-26, 21 February 2020, 1908 . 1910 [QUIC-TRANSPORT] 1911 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1912 Multiplexed and Secure Transport", Work in Progress, 1913 Internet-Draft, draft-ietf-quic-transport-26, 21 February 1914 2020, . 1917 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1918 Requirement Levels", BCP 14, RFC 2119, 1919 DOI 10.17487/RFC2119, March 1997, 1920 . 1922 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1923 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1924 May 2017, . 1926 [SHA] Dang, Q., "Secure Hash Standard", 1927 DOI 10.6028/nist.fips.180-4, National Institute of 1928 Standards and Technology report, July 2015, 1929 . 1931 [TLS-REGISTRIES] 1932 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 1933 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 1934 . 1936 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1937 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1938 . 1940 11.2. Informative References 1942 [AEBounds] Luykx, A. and K. Paterson, "Limits on Authenticated 1943 Encryption Use in TLS", 8 March 2016, 1944 . 1946 [HTTP2-TLS13] 1947 Benjamin, D., "Using TLS 1.3 with HTTP/2", Work in 1948 Progress, Internet-Draft, draft-ietf-httpbis- 1949 http2-tls13-03, 17 October 2019, . 1952 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1953 Cryptography, Second Edition", ISBN 978-1466570269, 6 1954 November 2014. 1956 [NAN] Bellare, M., Ng, R., and B. Tackmann, "Nonces Are Noticed: 1957 AEAD Revisited", DOI 10.1007/978-3-030-26948-7_9, Advances 1958 in Cryptology - CRYPTO 2019 pp. 235-265, 2019, 1959 . 1961 [QUIC-HTTP] 1962 Bishop, M., Ed., "Hypertext Transfer Protocol Version 3 1963 (HTTP/3)", Work in Progress, Internet-Draft, draft-ietf- 1964 quic-http-26, 21 February 2020, 1965 . 1967 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1968 DOI 10.17487/RFC2818, May 2000, 1969 . 1971 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1972 Housley, R., and W. Polk, "Internet X.509 Public Key 1973 Infrastructure Certificate and Certificate Revocation List 1974 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1975 . 1977 Appendix A. Sample Packet Protection 1979 This section shows examples of packet protection so that 1980 implementations can be verified incrementally. Samples of Initial 1981 packets from both client and server, plus a Retry packet are defined. 1982 These packets use an 8-byte client-chosen Destination Connection ID 1983 of 0x8394c8f03e515708. Some intermediate values are included. All 1984 values are shown in hexadecimal. 1986 A.1. Keys 1988 The labels generated by the HKDF-Expand-Label function are: 1990 client in: 00200f746c73313320636c69656e7420696e00 1992 server in: 00200f746c7331332073657276657220696e00 1994 quic key: 00100e746c7331332071756963206b657900 1996 quic iv: 000c0d746c733133207175696320697600 1998 quic hp: 00100d746c733133207175696320687000 2000 The initial secret is common: 2002 initial_secret = HKDF-Extract(initial_salt, cid) 2003 = 524e374c6da8cf8b496f4bcb69678350 2004 7aafee6198b202b4bc823ebf7514a423 2006 The secrets for protecting client packets are: 2008 client_initial_secret 2009 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 2010 = fda3953aecc040e48b34e27ef87de3a6 2011 098ecf0e38b7e032c5c57bcbd5975b84 2013 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 2014 = af7fd7efebd21878ff66811248983694 2016 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 2017 = 8681359410a70bb9c92f0420 2019 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 2020 = a980b8b4fb7d9fbc13e814c23164253d 2022 The secrets for protecting server packets are: 2024 server_initial_secret 2025 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 2026 = 554366b81912ff90be41f17e80222130 2027 90ab17d8149179bcadf222f29ff2ddd5 2029 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 2030 = 5d51da9ee897a21b2659ccc7e5bfa577 2032 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 2033 = 5e5ae651fd1e8495af13508b 2035 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 2036 = a8ed82e6664f865aedf6106943f95fb8 2038 A.2. Client Initial 2040 The client sends an Initial packet. The unprotected payload of this 2041 packet contains the following CRYPTO frame, plus enough PADDING 2042 frames to make a 1162 byte payload: 2044 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 2045 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 2046 736572766572ff01000100000a001400 12001d00170018001901000101010201 2047 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 2048 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 2049 05030603020308040805080604010501 060102010402050206020202002d0002 2050 0101001c00024001 2052 The unprotected header includes the connection ID and a 4 byte packet 2053 number encoding for a packet number of 2: 2055 c3ff000019088394c8f03e5157080000449e00000002 2056 Protecting the payload produces output that is sampled for header 2057 protection. Because the header uses a 4 byte packet number encoding, 2058 the first 16 bytes of the protected payload is sampled, then applied 2059 to the header: 2061 sample = 535064a4268a0d9d7b1c9d250ae35516 2063 mask = AES-ECB(hp, sample)[0..4] 2064 = 833b343aaa 2066 header[0] ^= mask[0] & 0x0f 2067 = c0 2068 header[18..21] ^= mask[1..4] 2069 = 3b343aa8 2070 header = c0ff000019088394c8f03e5157080000449e3b343aa8 2072 The resulting protected packet is: 2074 c0ff000019088394c8f03e5157080000 449e3b343aa8535064a4268a0d9d7b1c 2075 9d250ae355162276e9b1e3011ef6bbc0 ab48ad5bcc2681e953857ca62becd752 2076 4daac473e68d7405fbba4e9ee616c870 38bdbe908c06d9605d9ac49030359eec 2077 b1d05a14e117db8cede2bb09d0dbbfee 271cb374d8f10abec82d0f59a1dee29f 2078 e95638ed8dd41da07487468791b719c5 5c46968eb3b54680037102a28e53dc1d 2079 12903db0af5821794b41c4a93357fa59 ce69cfe7f6bdfa629eef78616447e1d6 2080 11c4baf71bf33febcb03137c2c75d253 17d3e13b684370f668411c0f00304b50 2081 1c8fd422bd9b9ad81d643b20da89ca05 25d24d2b142041cae0af205092e43008 2082 0cd8559ea4c5c6e4fa3f66082b7d303e 52ce0162baa958532b0bbc2bc785681f 2083 cf37485dff6595e01e739c8ac9efba31 b985d5f656cc092432d781db95221724 2084 87641c4d3ab8ece01e39bc85b1543661 4775a98ba8fa12d46f9b35e2a55eb72d 2085 7f85181a366663387ddc20551807e007 673bd7e26bf9b29b5ab10a1ca87cbb7a 2086 d97e99eb66959c2a9bc3cbde4707ff77 20b110fa95354674e395812e47a0ae53 2087 b464dcb2d1f345df360dc227270c7506 76f6724eb479f0d2fbb6124429990457 2088 ac6c9167f40aab739998f38b9eccb24f d47c8410131bf65a52af841275d5b3d1 2089 880b197df2b5dea3e6de56ebce3ffb6e 9277a82082f8d9677a6767089b671ebd 2090 244c214f0bde95c2beb02cd1172d58bd f39dce56ff68eb35ab39b49b4eac7c81 2091 5ea60451d6e6ab82119118df02a58684 4a9ffe162ba006d0669ef57668cab38b 2092 62f71a2523a084852cd1d079b3658dc2 f3e87949b550bab3e177cfc49ed190df 2093 f0630e43077c30de8f6ae081537f1e83 da537da980afa668e7b7fb25301cf741 2094 524be3c49884b42821f17552fbd1931a 813017b6b6590a41ea18b6ba49cd48a4 2095 40bd9a3346a7623fb4ba34a3ee571e3c 731f35a7a3cf25b551a680fa68763507 2096 b7fde3aaf023c50b9d22da6876ba337e b5e9dd9ec3daf970242b6c5aab3aa4b2 2097 96ad8b9f6832f686ef70fa938b31b4e5 ddd7364442d3ea72e73d668fb0937796 2098 f462923a81a47e1cee7426ff6d922126 9b5a62ec03d6ec94d12606cb485560ba 2099 b574816009e96504249385bb61a819be 04f62c2066214d8360a2022beb316240 2100 b6c7d78bbe56c13082e0ca272661210a bf020bf3b5783f1426436cf9ff418405 2101 93a5d0638d32fc51c5c65ff291a3a7a5 2fd6775e623a4439cc08dd25582febc9 2102 44ef92d8dbd329c91de3e9c9582e41f1 7f3d186f104ad3f90995116c682a2a14 2103 a3b4b1f547c335f0be710fc9fc03e0e5 87b8cda31ce65b969878a4ad4283e6d5 2104 b0373f43da86e9e0ffe1ae0fddd35162 55bd74566f36a38703d5f34249ded1f6 2105 6b3d9b45b9af2ccfefe984e13376b1b2 c6404aa48c8026132343da3f3a33659e 2106 c1b3e95080540b28b7f3fcd35fa5d843 b579a84c089121a60d8c1754915c344e 2107 eaf45a9bf27dc0c1e784161691220913 13eb0e87555abd706626e557fc36a04f 2108 cd191a58829104d6075c5594f627ca50 6bf181daec940f4a4f3af0074eee89da 2109 acde6758312622d4fa675b39f728e062 d2bee680d8f41a597c262648bb18bcfc 2110 13c8b3d97b1a77b2ac3af745d61a34cc 4709865bac824a94bb19058015e4e42d 2111 aebe13f98ec51170a4aad0a8324bb768 2113 A.3. Server Initial 2115 The server sends the following payload in response, including an ACK 2116 frame, a CRYPTO frame, and no PADDING frames: 2118 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 2119 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 2120 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 2121 0304 2122 The header from the server includes a new connection ID and a 2-byte 2123 packet number encoding for a packet number of 1: 2125 c1ff0000190008f067a5502a4262b50040740001 2127 As a result, after protection, the header protection sample is taken 2128 starting from the third protected octet: 2130 sample = 7002596f99ae67abf65a5852f54f58c3 2131 mask = 38168a0c25 2132 header = c9ff0000190008f067a5502a4262b5004074168b 2134 The final protected packet is then: 2136 c9ff0000190008f067a5502a4262b500 4074168bf22b7002596f99ae67abf65a 2137 5852f54f58c37c808682e2e40492d8a3 899fb04fc0afe9aabc8767b18a0aa493 2138 537426373b48d502214dd856d63b78ce e37bc664b3fe86d487ac7a77c53038a3 2139 cd32f0b5004d9f5754c4f7f2d1f35cf3 f7116351c92b99c8ae5833225cb51855 2140 20d61e68cf5f 2142 A.4. Retry 2144 This shows a Retry packet that might be sent in response to the 2145 Initial packet in Appendix A.2. The integrity check includes the 2146 client-chosen connection ID value of 0x8394c8f03e515708, but that 2147 value is not included in the final Retry packet: 2149 ffff0000190008f067a5502a4262b574 6f6b656e1e5ec5b014cbb1f0fd93df40 2150 48c446a6 2152 Appendix B. Change Log 2154 *RFC Editor's Note:* Please remove this section prior to 2155 publication of a final version of this document. 2157 Issue and pull request numbers are listed with a leading octothorp. 2159 B.1. Since draft-ietf-quic-tls-25 2161 * No changes 2163 B.2. Since draft-ietf-quic-tls-24 2165 * Rewrite key updates (#3050) 2167 - Allow but don't recommend deferring key updates (#2792, #3263) 2169 - More completely define received behavior (#2791) 2170 - Define the label used with HKDF-Expand-Label (#3054) 2172 B.3. Since draft-ietf-quic-tls-23 2174 * Key update text update (#3050): 2176 - Recommend constant-time key replacement (#2792) 2178 - Provide explicit labels for key update key derivation (#3054) 2180 * Allow first Initial from a client to span multiple packets (#2928, 2181 #3045) 2183 * PING can be sent at any encryption level (#3034, #3035) 2185 B.4. Since draft-ietf-quic-tls-22 2187 * Update the salt used for Initial secrets (#2887, #2980) 2189 B.5. Since draft-ietf-quic-tls-21 2191 * No changes 2193 B.6. Since draft-ietf-quic-tls-20 2195 * Mandate the use of the QUIC transport parameters extension (#2528, 2196 #2560) 2198 * Define handshake completion and confirmation; define clearer rules 2199 when it encryption keys should be discarded (#2214, #2267, #2673) 2201 B.7. Since draft-ietf-quic-tls-18 2203 * Increased the set of permissible frames in 0-RTT (#2344, #2355) 2205 * Transport parameter extension is mandatory (#2528, #2560) 2207 B.8. Since draft-ietf-quic-tls-17 2209 * Endpoints discard initial keys as soon as handshake keys are 2210 available (#1951, #2045) 2212 * Use of ALPN or equivalent is mandatory (#2263, #2284) 2214 B.9. Since draft-ietf-quic-tls-14 2216 * Update the salt used for Initial secrets (#1970) 2217 * Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 2219 * Change header protection 2221 - Sample from a fixed offset (#1575, #2030) 2223 - Cover part of the first byte, including the key phase (#1322, 2224 #2006) 2226 * TLS provides an AEAD and KDF function (#2046) 2228 - Clarify that the TLS KDF is used with TLS (#1997) 2230 - Change the labels for calculation of QUIC keys (#1845, #1971, 2231 #1991) 2233 * Initial keys are discarded once Handshake keys are available 2234 (#1951, #2045) 2236 B.10. Since draft-ietf-quic-tls-13 2238 * Updated to TLS 1.3 final (#1660) 2240 B.11. Since draft-ietf-quic-tls-12 2242 * Changes to integration of the TLS handshake (#829, #1018, #1094, 2243 #1165, #1190, #1233, #1242, #1252, #1450) 2245 - The cryptographic handshake uses CRYPTO frames, not stream 0 2247 - QUIC packet protection is used in place of TLS record 2248 protection 2250 - Separate QUIC packet number spaces are used for the handshake 2252 - Changed Retry to be independent of the cryptographic handshake 2254 - Limit the use of HelloRetryRequest to address TLS needs (like 2255 key shares) 2257 * Changed codepoint of TLS extension (#1395, #1402) 2259 B.12. Since draft-ietf-quic-tls-11 2261 * Encrypted packet numbers. 2263 B.13. Since draft-ietf-quic-tls-10 2264 * No significant changes. 2266 B.14. Since draft-ietf-quic-tls-09 2268 * Cleaned up key schedule and updated the salt used for handshake 2269 packet protection (#1077) 2271 B.15. Since draft-ietf-quic-tls-08 2273 * Specify value for max_early_data_size to enable 0-RTT (#942) 2275 * Update key derivation function (#1003, #1004) 2277 B.16. Since draft-ietf-quic-tls-07 2279 * Handshake errors can be reported with CONNECTION_CLOSE (#608, 2280 #891) 2282 B.17. Since draft-ietf-quic-tls-05 2284 No significant changes. 2286 B.18. Since draft-ietf-quic-tls-04 2288 * Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 2290 B.19. Since draft-ietf-quic-tls-03 2292 No significant changes. 2294 B.20. Since draft-ietf-quic-tls-02 2296 * Updates to match changes in transport draft 2298 B.21. Since draft-ietf-quic-tls-01 2300 * Use TLS alerts to signal TLS errors (#272, #374) 2302 * Require ClientHello to fit in a single packet (#338) 2304 * The second client handshake flight is now sent in the clear (#262, 2305 #337) 2307 * The QUIC header is included as AEAD Associated Data (#226, #243, 2308 #302) 2310 * Add interface necessary for client address validation (#275) 2311 * Define peer authentication (#140) 2313 * Require at least TLS 1.3 (#138) 2315 * Define transport parameters as a TLS extension (#122) 2317 * Define handling for protected packets before the handshake 2318 completes (#39) 2320 * Decouple QUIC version and ALPN (#12) 2322 B.22. Since draft-ietf-quic-tls-00 2324 * Changed bit used to signal key phase 2326 * Updated key phase markings during the handshake 2328 * Added TLS interface requirements section 2330 * Moved to use of TLS exporters for key derivation 2332 * Moved TLS error code definitions into this document 2334 B.23. Since draft-thomson-quic-tls-01 2336 * Adopted as base for draft-ietf-quic-tls 2338 * Updated authors/editors list 2340 * Added status note 2342 Contributors 2344 The IETF QUIC Working Group received an enormous amount of support 2345 from many people. The following people provided substantive 2346 contributions to this document: Adam Langley, Alessandro Ghedini, 2347 Christian Huitema, Christopher Wood, David Schinazi, Dragana 2348 Damjanovic, Eric Rescorla, Ian Swett, Jana Iyengar, 奥 一穂 (Kazuho 2349 Oku), Marten Seemann, Martin Duke, Mike Bishop, Mikkel Fahnøe 2350 Jørgensen, Nick Banks, Nick Harper, Roberto Peon, Rui Paulo, Ryan 2351 Hamilton, and Victor Vasiliev. 2353 Authors' Addresses 2355 Martin Thomson (editor) 2356 Mozilla 2358 Email: mt@lowentropy.net 2359 Sean Turner (editor) 2360 sn3rd 2362 Email: sean@sn3rd.com