idnits 2.17.1 draft-ietf-quic-tls-27.txt: -(2355): 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 1519 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 2067 -- Looks like a reference, but probably isn't: '1' on line 1410 -- 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-27 == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-27 -- Possible downref: Non-RFC (?) normative reference: ref. 'SHA' == Outdated reference: A later version (-34) exists of draft-ietf-quic-http-27 -- 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-27 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-26 . . . . . . . . . . . . . . 47 127 B.2. Since draft-ietf-quic-tls-25 . . . . . . . . . . . . . . 47 128 B.3. Since draft-ietf-quic-tls-24 . . . . . . . . . . . . . . 48 129 B.4. Since draft-ietf-quic-tls-23 . . . . . . . . . . . . . . 48 130 B.5. Since draft-ietf-quic-tls-22 . . . . . . . . . . . . . . 48 131 B.6. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 48 132 B.7. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 48 133 B.8. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 48 134 B.9. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 48 135 B.10. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 49 136 B.11. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 49 137 B.12. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 49 138 B.13. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 50 139 B.14. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 50 140 B.15. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 50 141 B.16. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 50 142 B.17. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 50 143 B.18. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 50 144 B.19. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 50 145 B.20. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 50 146 B.21. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 50 147 B.22. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 50 148 B.23. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 51 149 B.24. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 51 150 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 52 151 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 52 153 1. Introduction 155 This document describes how QUIC [QUIC-TRANSPORT] is secured using 156 TLS [TLS13]. 158 TLS 1.3 provides critical latency improvements for connection 159 establishment over previous versions. Absent packet loss, most new 160 connections can be established and secured within a single round 161 trip; on subsequent connections between the same client and server, 162 the client can often send application data immediately, that is, 163 using a zero round trip setup. 165 This document describes how TLS acts as a security component of QUIC. 167 2. Notational Conventions 169 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 170 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 171 "OPTIONAL" in this document are to be interpreted as described in BCP 172 14 [RFC2119] [RFC8174] when, and only when, they appear in all 173 capitals, as shown here. 175 This document uses the terminology established in [QUIC-TRANSPORT]. 177 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 178 newer version could be used (see Section 4.2). 180 2.1. TLS Overview 182 TLS provides two endpoints with a way to establish a means of 183 communication over an untrusted medium (that is, the Internet) that 184 ensures that messages they exchange cannot be observed, modified, or 185 forged. 187 Internally, TLS is a layered protocol, with the structure shown in 188 Figure 1. 190 +-------------+------------+--------------+---------+ 191 Handshake | | | Application | | 192 Layer | Handshake | Alerts | Data | ... | 193 | | | | | 194 +-------------+------------+--------------+---------+ 195 Record | | 196 Layer | Records | 197 | | 198 +---------------------------------------------------+ 200 Figure 1: TLS Layers 202 Each Handshake layer message (e.g., Handshake, Alerts, and 203 Application Data) is carried as a series of typed TLS records by the 204 Record layer. Records are individually cryptographically protected 205 and then transmitted over a reliable transport (typically TCP) which 206 provides sequencing and guaranteed delivery. 208 The TLS authenticated key exchange occurs between two endpoints: 209 client and server. The client initiates the exchange and the server 210 responds. If the key exchange completes successfully, both client 211 and server will agree on a secret. TLS supports both pre-shared key 212 (PSK) and Diffie-Hellman over either finite fields or elliptic curves 213 ((EC)DHE) key exchanges. PSK is the basis for 0-RTT; the latter 214 provides perfect forward secrecy (PFS) when the (EC)DHE keys are 215 destroyed. 217 After completing the TLS handshake, the client will have learned and 218 authenticated an identity for the server and the server is optionally 219 able to learn and authenticate an identity for the client. TLS 220 supports X.509 [RFC5280] certificate-based authentication for both 221 server and client. 223 The TLS key exchange is resistant to tampering by attackers and it 224 produces shared secrets that cannot be controlled by either 225 participating peer. 227 TLS provides two basic handshake modes of interest to QUIC: 229 * A full 1-RTT handshake in which the client is able to send 230 Application Data after one round trip and the server immediately 231 responds after receiving the first handshake message from the 232 client. 234 * A 0-RTT handshake in which the client uses information it has 235 previously learned about the server to send Application Data 236 immediately. This Application Data can be replayed by an attacker 237 so it MUST NOT carry a self-contained trigger for any non- 238 idempotent action. 240 A simplified TLS handshake with 0-RTT application data is shown in 241 Figure 2. Note that this omits the EndOfEarlyData message, which is 242 not used in QUIC (see Section 8.3). Likewise, neither 243 ChangeCipherSpec nor KeyUpdate messages are used by QUIC; 244 ChangeCipherSpec is redundant in TLS 1.3 and QUIC has defined its own 245 key update mechanism Section 6. 247 Client Server 249 ClientHello 250 (0-RTT Application Data) --------> 251 ServerHello 252 {EncryptedExtensions} 253 {Finished} 254 <-------- [Application Data] 255 {Finished} --------> 257 [Application Data] <-------> [Application Data] 259 () Indicates messages protected by Early Data (0-RTT) Keys 260 {} Indicates messages protected using Handshake Keys 261 [] Indicates messages protected using Application Data 262 (1-RTT) Keys 264 Figure 2: TLS Handshake with 0-RTT 266 Data is protected using a number of encryption levels: 268 * Initial Keys 270 * Early Data (0-RTT) Keys 272 * Handshake Keys 274 * Application Data (1-RTT) Keys 276 Application Data may appear only in the Early Data and Application 277 Data levels. Handshake and Alert messages may appear in any level. 279 The 0-RTT handshake is only possible if the client and server have 280 previously communicated. In the 1-RTT handshake, the client is 281 unable to send protected Application Data until it has received all 282 of the Handshake messages sent by the server. 284 3. Protocol Overview 286 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 287 and integrity protection of packets. For this it uses keys derived 288 from a TLS handshake [TLS13], but instead of carrying TLS records 289 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 290 directly over the QUIC transport, which takes over the 291 responsibilities of the TLS record layer, as shown in Figure 3. 293 +--------------+--------------+ +-------------+ 294 | TLS | TLS | | QUIC | 295 | Handshake | Alerts | | Applications| 296 | | | | (h3, etc.) | 297 +--------------+--------------+-+-------------+ 298 | | 299 | QUIC Transport | 300 | (streams, reliability, congestion, etc.) | 301 | | 302 +---------------------------------------------+ 303 | | 304 | QUIC Packet Protection | 305 | | 306 +---------------------------------------------+ 308 Figure 3: QUIC Layers 310 QUIC also relies on TLS for authentication and negotiation of 311 parameters that are critical to security and performance. 313 Rather than a strict layering, these two protocols cooperate: QUIC 314 uses the TLS handshake; TLS uses the reliability, ordered delivery, 315 and record layer provided by QUIC. 317 At a high level, there are two main interactions between the TLS and 318 QUIC components: 320 * The TLS component sends and receives messages via the QUIC 321 component, with QUIC providing a reliable stream abstraction to 322 TLS. 324 * The TLS component provides a series of updates to the QUIC 325 component, including (a) new packet protection keys to install (b) 326 state changes such as handshake completion, the server 327 certificate, etc. 329 Figure 4 shows these interactions in more detail, with the QUIC 330 packet protection being called out specially. 332 +------------+ +------------+ 333 | |<---- Handshake Messages ----->| | 334 | |<- Validate 0-RTT parameters ->| | 335 | |<--------- 0-RTT Keys ---------| | 336 | QUIC |<------- Handshake Keys -------| TLS | 337 | |<--------- 1-RTT Keys ---------| | 338 | |<------- Handshake Done -------| | 339 +------------+ +------------+ 340 | ^ 341 | Protect | Protected 342 v | Packet 343 +------------+ 344 | QUIC | 345 | Packet | 346 | Protection | 347 +------------+ 349 Figure 4: QUIC and TLS Interactions 351 Unlike TLS over TCP, QUIC applications which want to send data do not 352 send it through TLS "application_data" records. Rather, they send it 353 as QUIC STREAM frames or other frame types which are then carried in 354 QUIC packets. 356 4. Carrying TLS Messages 358 QUIC carries TLS handshake data in CRYPTO frames, each of which 359 consists of a contiguous block of handshake data identified by an 360 offset and length. Those frames are packaged into QUIC packets and 361 encrypted under the current TLS encryption level. As with TLS over 362 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 363 responsibility to deliver it reliably. Each chunk of data that is 364 produced by TLS is associated with the set of keys that TLS is 365 currently using. If QUIC needs to retransmit that data, it MUST use 366 the same keys even if TLS has already updated to newer keys. 368 One important difference between TLS records (used with TCP) and QUIC 369 CRYPTO frames is that in QUIC multiple frames may appear in the same 370 QUIC packet as long as they are associated with the same encryption 371 level. For instance, an implementation might bundle a Handshake 372 message and an ACK for some Handshake data into the same packet. 374 Some frames are prohibited in different encryption levels, others 375 cannot be sent. The rules here generalize those of TLS, in that 376 frames associated with establishing the connection can usually appear 377 at any encryption level, whereas those associated with transferring 378 data can only appear in the 0-RTT and 1-RTT encryption levels: 380 * PADDING and PING frames MAY appear in packets of any encryption 381 level. 383 * CRYPTO frames and CONNECTION_CLOSE frames signaling errors at the 384 QUIC layer (type 0x1c) MAY appear in packets of any encryption 385 level except 0-RTT. 387 * CONNECTION_CLOSE frames signaling application errors (type 0x1d) 388 MUST only be sent in packets at the 1-RTT encryption level. 390 * ACK frames MAY appear in packets of any encryption level other 391 than 0-RTT, but can only acknowledge packets which appeared in 392 that packet number space. 394 * All other frame types MUST only be sent in the 0-RTT and 1-RTT 395 levels. 397 Note that it is not possible to send the following frames in 0-RTT 398 for various reasons: ACK, CRYPTO, HANDSHAKE_DONE, NEW_TOKEN, 399 PATH_RESPONSE, and RETIRE_CONNECTION_ID. 401 Because packets could be reordered on the wire, QUIC uses the packet 402 type to indicate which level a given packet was encrypted under, as 403 shown in Table 1. When multiple packets of different encryption 404 levels need to be sent, endpoints SHOULD use coalesced packets to 405 send them in the same UDP datagram. 407 +---------------------+------------------+-----------+ 408 | Packet Type | Encryption Level | PN Space | 409 +=====================+==================+===========+ 410 | Initial | Initial secrets | Initial | 411 +---------------------+------------------+-----------+ 412 | 0-RTT Protected | 0-RTT | 0/1-RTT | 413 +---------------------+------------------+-----------+ 414 | Handshake | Handshake | Handshake | 415 +---------------------+------------------+-----------+ 416 | Retry | N/A | N/A | 417 +---------------------+------------------+-----------+ 418 | Version Negotiation | N/A | N/A | 419 +---------------------+------------------+-----------+ 420 | Short Header | 1-RTT | 0/1-RTT | 421 +---------------------+------------------+-----------+ 423 Table 1: Encryption Levels by Packet Type 425 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 426 encryption levels fit into the handshake process. 428 4.1. Interface to TLS 430 As shown in Figure 4, the interface from QUIC to TLS consists of four 431 primary functions: 433 * Sending and receiving handshake messages 435 * Processing stored transport and application state from a resumed 436 session and determining if it is valid to accept early data 438 * Rekeying (both transmit and receive) 440 * Handshake state updates 442 Additional functions might be needed to configure TLS. 444 4.1.1. Handshake Complete 446 In this document, the TLS handshake is considered complete when the 447 TLS stack has reported that the handshake is complete. This happens 448 when the TLS stack has both sent a Finished message and verified the 449 peer's Finished message. Verifying the peer's Finished provides the 450 endpoints with an assurance that previous handshake messages have not 451 been modified. Note that the handshake does not complete at both 452 endpoints simultaneously. Consequently, any requirement that is 453 based on the completion of the handshake depends on the perspective 454 of the endpoint in question. 456 4.1.2. Handshake Confirmed 458 In this document, the TLS handshake is considered confirmed at the 459 server when the handshake completes. At the client, the handshake is 460 considered confirmed when a HANDSHAKE_DONE frame is received. 462 A client MAY consider the handshake to be confirmed when it receives 463 an acknowledgement for a 1-RTT packet. This can be implemented by 464 recording the lowest packet number sent with 1-RTT keys, and 465 comparing it to the Largest Acknowledged field in any received 1-RTT 466 ACK frame: once the latter is greater than or equal to the former, 467 the handshake is confirmed. 469 4.1.3. Sending and Receiving Handshake Messages 471 In order to drive the handshake, TLS depends on being able to send 472 and receive handshake messages. There are two basic functions on 473 this interface: one where QUIC requests handshake messages and one 474 where QUIC provides handshake packets. 476 Before starting the handshake QUIC provides TLS with the transport 477 parameters (see Section 8.2) that it wishes to carry. 479 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 480 The client acquires handshake bytes before sending its first packet. 481 A QUIC server starts the process by providing TLS with the client's 482 handshake bytes. 484 At any time, the TLS stack at an endpoint will have a current sending 485 encryption level and receiving encryption level. Each encryption 486 level is associated with a different flow of bytes, which is reliably 487 transmitted to the peer in CRYPTO frames. When TLS provides 488 handshake bytes to be sent, they are appended to the current flow and 489 any packet that includes the CRYPTO frame is protected using keys 490 from the corresponding encryption level. 492 QUIC takes the unprotected content of TLS handshake records as the 493 content of CRYPTO frames. TLS record protection is not used by QUIC. 494 QUIC assembles CRYPTO frames into QUIC packets, which are protected 495 using QUIC packet protection. 497 QUIC is only capable of conveying TLS handshake records in CRYPTO 498 frames. TLS alerts are turned into QUIC CONNECTION_CLOSE error 499 codes; see Section 4.9. TLS application data and other message types 500 cannot be carried by QUIC at any encryption level and is an error if 501 they are received from the TLS stack. 503 When an endpoint receives a QUIC packet containing a CRYPTO frame 504 from the network, it proceeds as follows: 506 * If the packet was in the TLS receiving encryption level, sequence 507 the data into the input flow as usual. As with STREAM frames, the 508 offset is used to find the proper location in the data sequence. 509 If the result of this process is that new data is available, then 510 it is delivered to TLS in order. 512 * If the packet is from a previously installed encryption level, it 513 MUST not contain data which extends past the end of previously 514 received data in that flow. Implementations MUST treat any 515 violations of this requirement as a connection error of type 516 PROTOCOL_VIOLATION. 518 * If the packet is from a new encryption level, it is saved for 519 later processing by TLS. Once TLS moves to receiving from this 520 encryption level, saved data can be provided. When providing data 521 from any new encryption level to TLS, if there is data from a 522 previous encryption level that TLS has not consumed, this MUST be 523 treated as a connection error of type PROTOCOL_VIOLATION. 525 Each time that TLS is provided with new data, new handshake bytes are 526 requested from TLS. TLS might not provide any bytes if the handshake 527 messages it has received are incomplete or it has no data to send. 529 Once the TLS handshake is complete, this is indicated to QUIC along 530 with any final handshake bytes that TLS needs to send. TLS also 531 provides QUIC with the transport parameters that the peer advertised 532 during the handshake. 534 Once the handshake is complete, TLS becomes passive. TLS can still 535 receive data from its peer and respond in kind, but it will not need 536 to send more data unless specifically requested - either by an 537 application or QUIC. One reason to send data is that the server 538 might wish to provide additional or updated session tickets to a 539 client. 541 When the handshake is complete, QUIC only needs to provide TLS with 542 any data that arrives in CRYPTO streams. In the same way that is 543 done during the handshake, new data is requested from TLS after 544 providing received data. 546 4.1.4. Encryption Level Changes 548 As keys for new encryption levels become available, TLS provides QUIC 549 with those keys. Separately, as keys at a given encryption level 550 become available to TLS, TLS indicates to QUIC that reading or 551 writing keys at that encryption level are available. These events 552 are not asynchronous; they always occur immediately after TLS is 553 provided with new handshake bytes, or after TLS produces handshake 554 bytes. 556 TLS provides QUIC with three items as a new encryption level becomes 557 available: 559 * A secret 561 * An Authenticated Encryption with Associated Data (AEAD) function 563 * A Key Derivation Function (KDF) 565 These values are based on the values that TLS negotiates and are used 566 by QUIC to generate packet and header protection keys (see Section 5 567 and Section 5.4). 569 If 0-RTT is possible, it is ready after the client sends a TLS 570 ClientHello message or the server receives that message. After 571 providing a QUIC client with the first handshake bytes, the TLS stack 572 might signal the change to 0-RTT keys. On the server, after 573 receiving handshake bytes that contain a ClientHello message, a TLS 574 server might signal that 0-RTT keys are available. 576 Although TLS only uses one encryption level at a time, QUIC may use 577 more than one level. For instance, after sending its Finished 578 message (using a CRYPTO frame at the Handshake encryption level) an 579 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 580 message is lost, the endpoint uses the Handshake encryption level to 581 retransmit the lost message. Reordering or loss of packets can mean 582 that QUIC will need to handle packets at multiple encryption levels. 583 During the handshake, this means potentially handling packets at 584 higher and lower encryption levels than the current encryption level 585 used by TLS. 587 In particular, server implementations need to be able to read packets 588 at the Handshake encryption level at the same time as the 0-RTT 589 encryption level. A client could interleave ACK frames that are 590 protected with Handshake keys with 0-RTT data and the server needs to 591 process those acknowledgments in order to detect lost Handshake 592 packets. 594 QUIC also needs access to keys that might not ordinarily be available 595 to a TLS implementation. For instance, a client might need to 596 acknowledge Handshake packets before it is ready to send CRYPTO 597 frames at that encryption level. TLS therefore needs to provide keys 598 to QUIC before it might produce them for its own use. 600 4.1.5. TLS Interface Summary 602 Figure 5 summarizes the exchange between QUIC and TLS for both client 603 and server. Each arrow is tagged with the encryption level used for 604 that transmission. 606 Client Server 608 Get Handshake 609 Initial -------------> 610 Handshake Received 611 Install tx 0-RTT Keys 612 0-RTT ---------------> 613 Get Handshake 614 <------------- Initial 615 Handshake Received 616 Install Handshake keys 617 Install rx 0-RTT keys 618 Install Handshake keys 619 Get Handshake 620 <----------- Handshake 621 Handshake Received 622 Install tx 1-RTT keys 623 <--------------- 1-RTT 624 Get Handshake 625 Handshake Complete 626 Handshake -----------> 627 Handshake Received 628 Install rx 1-RTT keys 629 Handshake Complete 630 Install 1-RTT keys 631 1-RTT ---------------> 632 Get Handshake 633 <--------------- 1-RTT 634 Handshake Received 636 Figure 5: Interaction Summary between QUIC and TLS 638 Figure 5 shows the multiple packets that form a single "flight" of 639 messages being processed individually, to show what incoming messages 640 trigger different actions. New handshake messages are requested 641 after all incoming packets have been processed. This process might 642 vary depending on how QUIC implementations and the packets they 643 receive are structured. 645 4.2. TLS Version 647 This document describes how TLS 1.3 [TLS13] is used with QUIC. 649 In practice, the TLS handshake will negotiate a version of TLS to 650 use. This could result in a newer version of TLS than 1.3 being 651 negotiated if both endpoints support that version. This is 652 acceptable provided that the features of TLS 1.3 that are used by 653 QUIC are supported by the newer version. 655 A badly configured TLS implementation could negotiate TLS 1.2 or 656 another older version of TLS. An endpoint MUST terminate the 657 connection if a version of TLS older than 1.3 is negotiated. 659 4.3. ClientHello Size 661 The first Initial packet from a client contains the start or all of 662 its first cryptographic handshake message, which for TLS is the 663 ClientHello. Servers might need to parse the entire ClientHello 664 (e.g., to access extensions such as Server Name Identification (SNI) 665 or Application Layer Protocol Negotiation (ALPN)) in order to decide 666 whether to accept the new incoming QUIC connection. If the 667 ClientHello spans multiple Initial packets, such servers would need 668 to buffer the first received fragments, which could consume excessive 669 resources if the client's address has not yet been validated. To 670 avoid this, servers MAY use the Retry feature (see Section 8.1 of 671 [QUIC-TRANSPORT]) to only buffer partial ClientHello messages from 672 clients with a validated address. 674 QUIC packet and framing add at least 36 bytes of overhead to the 675 ClientHello message. That overhead increases if the client chooses a 676 connection ID without zero length. Overheads also do not include the 677 token or a connection ID longer than 8 bytes, both of which might be 678 required if a server sends a Retry packet. 680 A typical TLS ClientHello can easily fit into a 1200 byte packet. 681 However, in addition to the overheads added by QUIC, there are 682 several variables that could cause this limit to be exceeded. Large 683 session tickets, multiple or large key shares, and long lists of 684 supported ciphers, signature algorithms, versions, QUIC transport 685 parameters, and other negotiable parameters and extensions could 686 cause this message to grow. 688 For servers, in addition to connection IDs and tokens, the size of 689 TLS session tickets can have an effect on a client's ability to 690 connect efficiently. Minimizing the size of these values increases 691 the probability that clients can use them and still fit their 692 ClientHello message in their first Initial packet. 694 The TLS implementation does not need to ensure that the ClientHello 695 is sufficiently large. QUIC PADDING frames are added to increase the 696 size of the packet as necessary. 698 4.4. Peer Authentication 700 The requirements for authentication depend on the application 701 protocol that is in use. TLS provides server authentication and 702 permits the server to request client authentication. 704 A client MUST authenticate the identity of the server. This 705 typically involves verification that the identity of the server is 706 included in a certificate and that the certificate is issued by a 707 trusted entity (see for example [RFC2818]). 709 A server MAY request that the client authenticate during the 710 handshake. A server MAY refuse a connection if the client is unable 711 to authenticate when requested. The requirements for client 712 authentication vary based on application protocol and deployment. 714 A server MUST NOT use post-handshake client authentication (as 715 defined in Section 4.6.2 of [TLS13]), because the multiplexing 716 offered by QUIC prevents clients from correlating the certificate 717 request with the application-level event that triggered it (see 718 [HTTP2-TLS13]). More specifically, servers MUST NOT send post- 719 handshake TLS CertificateRequest messages and clients MUST treat 720 receipt of such messages as a connection error of type 721 PROTOCOL_VIOLATION. 723 4.5. Enabling 0-RTT 725 To communicate their willingness to process 0-RTT data, servers send 726 a NewSessionTicket message that contains the "early_data" extension 727 with a max_early_data_size of 0xffffffff; the amount of data which 728 the client can send in 0-RTT is controlled by the "initial_max_data" 729 transport parameter supplied by the server. Servers MUST NOT send 730 the "early_data" extension with a max_early_data_size set to any 731 value other than 0xffffffff. A client MUST treat receipt of a 732 NewSessionTicket that contains an "early_data" extension with any 733 other value as a connection error of type PROTOCOL_VIOLATION. 735 A client that wishes to send 0-RTT packets uses the "early_data" 736 extension in the ClientHello message of a subsequent handshake (see 737 Section 4.2.10 of [TLS13]). It then sends the application data in 738 0-RTT packets. 740 4.6. Accepting and Rejecting 0-RTT 742 A server accepts 0-RTT by sending an early_data extension in the 743 EncryptedExtensions (see Section 4.2.10 of [TLS13]). The server then 744 processes and acknowledges the 0-RTT packets that it receives. 746 A server rejects 0-RTT by sending the EncryptedExtensions without an 747 early_data extension. A server will always reject 0-RTT if it sends 748 a TLS HelloRetryRequest. When rejecting 0-RTT, a server MUST NOT 749 process any 0-RTT packets, even if it could. When 0-RTT was 750 rejected, a client SHOULD treat receipt of an acknowledgement for a 751 0-RTT packet as a connection error of type PROTOCOL_VIOLATION, if it 752 is able to detect the condition. 754 When 0-RTT is rejected, all connection characteristics that the 755 client assumed might be incorrect. This includes the choice of 756 application protocol, transport parameters, and any application 757 configuration. The client therefore MUST reset the state of all 758 streams, including application state bound to those streams. 760 A client MAY attempt to send 0-RTT again if it receives a Retry or 761 Version Negotiation packet. These packets do not signify rejection 762 of 0-RTT. 764 4.7. Validating 0-RTT Configuration 766 When a server receives a ClientHello with the "early_data" extension, 767 it has to decide whether to accept or reject early data from the 768 client. Some of this decision is made by the TLS stack (e.g., 769 checking that the cipher suite being resumed was included in the 770 ClientHello; see Section 4.2.10 of [TLS13]). Even when the TLS stack 771 has no reason to reject early data, the QUIC stack or the application 772 protocol using QUIC might reject early data because the configuration 773 of the transport or application associated with the resumed session 774 is not compatible with the server's current configuration. 776 QUIC requires additional transport state to be associated with a 777 0-RTT session ticket. One common way to implement this is using 778 stateless session tickets and storing this state in the session 779 ticket. Application protocols that use QUIC might have similar 780 requirements regarding associating or storing state. This associated 781 state is used for deciding whether early data must be rejected. For 782 example, HTTP/3 ([QUIC-HTTP]) settings determine how early data from 783 the client is interpreted. Other applications using QUIC could have 784 different requirements for determining whether to accept or reject 785 early data. 787 4.8. HelloRetryRequest 789 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 790 [TLS13]) can be used to correct a client's incorrect KeyShare 791 extension as well as for a stateless round-trip check. From the 792 perspective of QUIC, this just looks like additional messages carried 793 in the Initial encryption level. Although it is in principle 794 possible to use this feature for address verification in QUIC, QUIC 795 implementations SHOULD instead use the Retry feature (see Section 8.1 796 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 797 shares. 799 4.9. TLS Errors 801 If TLS experiences an error, it generates an appropriate alert as 802 defined in Section 6 of [TLS13]. 804 A TLS alert is turned into a QUIC connection error by converting the 805 one-byte alert description into a QUIC error code. The alert 806 description is added to 0x100 to produce a QUIC error code from the 807 range reserved for CRYPTO_ERROR. The resulting value is sent in a 808 QUIC CONNECTION_CLOSE frame. 810 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 811 generate alerts at the "warning" level. 813 4.10. Discarding Unused Keys 815 After QUIC moves to a new encryption level, packet protection keys 816 for previous encryption levels can be discarded. This occurs several 817 times during the handshake, as well as when keys are updated; see 818 Section 6. 820 Packet protection keys are not discarded immediately when new keys 821 are available. If packets from a lower encryption level contain 822 CRYPTO frames, frames that retransmit that data MUST be sent at the 823 same encryption level. Similarly, an endpoint generates 824 acknowledgements for packets at the same encryption level as the 825 packet being acknowledged. Thus, it is possible that keys for a 826 lower encryption level are needed for a short time after keys for a 827 newer encryption level are available. 829 An endpoint cannot discard keys for a given encryption level unless 830 it has both received and acknowledged all CRYPTO frames for that 831 encryption level and when all CRYPTO frames for that encryption level 832 have been acknowledged by its peer. However, this does not guarantee 833 that no further packets will need to be received or sent at that 834 encryption level because a peer might not have received all the 835 acknowledgements necessary to reach the same state. 837 Though an endpoint might retain older keys, new data MUST be sent at 838 the highest currently-available encryption level. Only ACK frames 839 and retransmissions of data in CRYPTO frames are sent at a previous 840 encryption level. These packets MAY also include PADDING frames. 842 4.10.1. Discarding Initial Keys 844 Packets protected with Initial secrets (Section 5.2) are not 845 authenticated, meaning that an attacker could spoof packets with the 846 intent to disrupt a connection. To limit these attacks, Initial 847 packet protection keys can be discarded more aggressively than other 848 keys. 850 The successful use of Handshake packets indicates that no more 851 Initial packets need to be exchanged, as these keys can only be 852 produced after receiving all CRYPTO frames from Initial packets. 853 Thus, a client MUST discard Initial keys when it first sends a 854 Handshake packet and a server MUST discard Initial keys when it first 855 successfully processes a Handshake packet. Endpoints MUST NOT send 856 Initial packets after this point. 858 This results in abandoning loss recovery state for the Initial 859 encryption level and ignoring any outstanding Initial packets. 861 4.10.2. Discarding Handshake Keys 863 An endpoint MUST discard its handshake keys when the TLS handshake is 864 confirmed (Section 4.1.2). The server MUST send a HANDSHAKE_DONE 865 frame as soon as it completes the handshake. 867 4.10.3. Discarding 0-RTT Keys 869 0-RTT and 1-RTT packets share the same packet number space, and 870 clients do not send 0-RTT packets after sending a 1-RTT packet 871 (Section 5.6). 873 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 874 1-RTT keys, since they have no use after that moment. 876 Additionally, a server MAY discard 0-RTT keys as soon as it receives 877 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 878 could arrive after a 1-RTT packet. Servers MAY temporarily retain 879 0-RTT keys to allow decrypting reordered packets without requiring 880 their contents to be retransmitted with 1-RTT keys. After receiving 881 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 882 the RECOMMENDED time period is three times the Probe Timeout (PTO, 883 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 884 determines that it has received all 0-RTT packets, which can be done 885 by keeping track of missing packet numbers. 887 5. Packet Protection 889 As with TLS over TCP, QUIC protects packets with keys derived from 890 the TLS handshake, using the AEAD algorithm negotiated by TLS. 892 5.1. Packet Protection Keys 894 QUIC derives packet protection keys in the same way that TLS derives 895 record protection keys. 897 Each encryption level has separate secret values for protection of 898 packets sent in each direction. These traffic secrets are derived by 899 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 900 encryption levels except the Initial encryption level. The secrets 901 for the Initial encryption level are computed based on the client's 902 initial Destination Connection ID, as described in Section 5.2. 904 The keys used for packet protection are computed from the TLS secrets 905 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 906 function described in Section 7.1 of [TLS13] is used, using the hash 907 function from the negotiated cipher suite. Other versions of TLS 908 MUST provide a similar function in order to be used with QUIC. 910 The current encryption level secret and the label "quic key" are 911 input to the KDF to produce the AEAD key; the label "quic iv" is used 912 to derive the IV; see Section 5.3. The header protection key uses 913 the "quic hp" label; see Section 5.4. Using these labels provides 914 key separation between QUIC and TLS; see Section 9.5. 916 The KDF used for initial secrets is always the HKDF-Expand-Label 917 function from TLS 1.3 (see Section 5.2). 919 5.2. Initial Secrets 921 Initial packets are protected with a secret derived from the 922 Destination Connection ID field from the client's Initial packet. 923 Specifically: 925 initial_salt = 0xc3eef712c72ebb5a11a7d2432bb46365bef9f502 926 initial_secret = HKDF-Extract(initial_salt, 927 client_dst_connection_id) 929 client_initial_secret = HKDF-Expand-Label(initial_secret, 930 "client in", "", 931 Hash.length) 932 server_initial_secret = HKDF-Expand-Label(initial_secret, 933 "server in", "", 934 Hash.length) 936 The hash function for HKDF when deriving initial secrets and keys is 937 SHA-256 [SHA]. 939 The connection ID used with HKDF-Expand-Label is the Destination 940 Connection ID in the Initial packet sent by the client. This will be 941 a randomly-selected value unless the client creates the Initial 942 packet after receiving a Retry packet, where the Destination 943 Connection ID is selected by the server. 945 The value of initial_salt is a 20 byte sequence shown in the figure 946 in hexadecimal notation. Future versions of QUIC SHOULD generate a 947 new salt value, thus ensuring that the keys are different for each 948 version of QUIC. This prevents a middlebox that only recognizes one 949 version of QUIC from seeing or modifying the contents of packets from 950 future versions. 952 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 953 Initial packets even where the TLS versions offered do not include 954 TLS 1.3. 956 The secrets used for protecting Initial packets change when a server 957 sends a Retry packet to use the connection ID value selected by the 958 server. The secrets do not change when a client changes the 959 Destination Connection ID it uses in response to an Initial packet 960 from the server. 962 Note: The Destination Connection ID is of arbitrary length, and it 963 could be zero length if the server sends a Retry packet with a 964 zero-length Source Connection ID field. In this case, the Initial 965 keys provide no assurance to the client that the server received 966 its packet; the client has to rely on the exchange that included 967 the Retry packet for that property. 969 Appendix A contains test vectors for packet encryption. 971 5.3. AEAD Usage 973 The Authentication Encryption with Associated Data (AEAD) [AEAD] 974 function used for QUIC packet protection is the AEAD that is 975 negotiated for use with the TLS connection. For example, if TLS is 976 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 977 used. 979 Packets are protected prior to applying header protection 980 (Section 5.4). The unprotected packet header is part of the 981 associated data (A). When removing packet protection, an endpoint 982 first removes the header protection. 984 All QUIC packets other than Version Negotiation and Retry packets are 985 protected with an AEAD algorithm [AEAD]. Prior to establishing a 986 shared secret, packets are protected with AEAD_AES_128_GCM and a key 987 derived from the Destination Connection ID in the client's first 988 Initial packet (see Section 5.2). This provides protection against 989 off-path attackers and robustness against QUIC version unaware 990 middleboxes, but not against on-path attackers. 992 QUIC can use any of the ciphersuites defined in [TLS13] with the 993 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 994 negotiated unless a header protection scheme is defined for the 995 ciphersuite. This document defines a header protection scheme for 996 all ciphersuites defined in [TLS13] aside from 997 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 998 authentication tag and produce an output 16 bytes larger than their 999 input. 1001 Note: An endpoint MUST NOT reject a ClientHello that offers a 1002 ciphersuite that it does not support, or it would be impossible to 1003 deploy a new ciphersuite. This also applies to 1004 TLS_AES_128_CCM_8_SHA256. 1006 The key and IV for the packet are computed as described in 1007 Section 5.1. The nonce, N, is formed by combining the packet 1008 protection IV with the packet number. The 62 bits of the 1009 reconstructed QUIC packet number in network byte order are left- 1010 padded with zeros to the size of the IV. The exclusive OR of the 1011 padded packet number and the IV forms the AEAD nonce. 1013 The associated data, A, for the AEAD is the contents of the QUIC 1014 header, starting from the flags byte in either the short or long 1015 header, up to and including the unprotected packet number. 1017 The input plaintext, P, for the AEAD is the payload of the QUIC 1018 packet, as described in [QUIC-TRANSPORT]. 1020 The output ciphertext, C, of the AEAD is transmitted in place of P. 1022 Some AEAD functions have limits for how many packets can be encrypted 1023 under the same key and IV (see for example [AEBounds]). This might 1024 be lower than the packet number limit. An endpoint MUST initiate a 1025 key update (Section 6) prior to exceeding any limit set for the AEAD 1026 that is in use. 1028 5.4. Header Protection 1030 Parts of QUIC packet headers, in particular the Packet Number field, 1031 are protected using a key that is derived separate to the packet 1032 protection key and IV. The key derived using the "quic hp" label is 1033 used to provide confidentiality protection for those fields that are 1034 not exposed to on-path elements. 1036 This protection applies to the least-significant bits of the first 1037 byte, plus the Packet Number field. The four least-significant bits 1038 of the first byte are protected for packets with long headers; the 1039 five least significant bits of the first byte are protected for 1040 packets with short headers. For both header forms, this covers the 1041 reserved bits and the Packet Number Length field; the Key Phase bit 1042 is also protected for packets with a short header. 1044 The same header protection key is used for the duration of the 1045 connection, with the value not changing after a key update (see 1046 Section 6). This allows header protection to be used to protect the 1047 key phase. 1049 This process does not apply to Retry or Version Negotiation packets, 1050 which do not contain a protected payload or any of the fields that 1051 are protected by this process. 1053 5.4.1. Header Protection Application 1055 Header protection is applied after packet protection is applied (see 1056 Section 5.3). The ciphertext of the packet is sampled and used as 1057 input to an encryption algorithm. The algorithm used depends on the 1058 negotiated AEAD. 1060 The output of this algorithm is a 5 byte mask which is applied to the 1061 protected header fields using exclusive OR. The least significant 1062 bits of the first byte of the packet are masked by the least 1063 significant bits of the first mask byte, and the packet number is 1064 masked with the remaining bytes. Any unused bytes of mask that might 1065 result from a shorter packet number encoding are unused. 1067 Figure 6 shows a sample algorithm for applying header protection. 1068 Removing header protection only differs in the order in which the 1069 packet number length (pn_length) is determined. 1071 mask = header_protection(hp_key, sample) 1073 pn_length = (packet[0] & 0x03) + 1 1074 if (packet[0] & 0x80) == 0x80: 1075 # Long header: 4 bits masked 1076 packet[0] ^= mask[0] & 0x0f 1077 else: 1078 # Short header: 5 bits masked 1079 packet[0] ^= mask[0] & 0x1f 1081 # pn_offset is the start of the Packet Number field. 1082 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 1084 Figure 6: Header Protection Pseudocode 1086 Figure 7 shows the protected fields of long and short headers marked 1087 with an E. Figure 7 also shows the sampled fields. 1089 Long Header: 1090 +-+-+-+-+-+-+-+-+ 1091 |1|1|T T|E E E E| 1092 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1093 | Version -> Length Fields ... 1094 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1096 Short Header: 1097 +-+-+-+-+-+-+-+-+ 1098 |0|1|S|E E E E E| 1099 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1100 | Destination Connection ID (0/32..144) ... 1101 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1103 Common Fields: 1104 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1105 |E E E E E E E E E Packet Number (8/16/24/32) E E E E E E E E... 1106 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1107 | [Protected Payload (8/16/24)] ... 1108 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1109 | Sampled part of Protected Payload (128) ... 1110 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1111 | Protected Payload Remainder (*) ... 1112 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1114 Figure 7: Header Protection and Ciphertext Sample 1116 Before a TLS ciphersuite can be used with QUIC, a header protection 1117 algorithm MUST be specified for the AEAD used with that ciphersuite. 1118 This document defines algorithms for AEAD_AES_128_GCM, 1119 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1120 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1121 a ciphersuite, AES header protection is used (Section 5.4.3), 1122 matching the AEAD_AES_128_GCM packet protection. 1124 5.4.2. Header Protection Sample 1126 The header protection algorithm uses both the header protection key 1127 and a sample of the ciphertext from the packet Payload field. 1129 The same number of bytes are always sampled, but an allowance needs 1130 to be made for the endpoint removing protection, which will not know 1131 the length of the Packet Number field. In sampling the packet 1132 ciphertext, the Packet Number field is assumed to be 4 bytes long 1133 (its maximum possible encoded length). 1135 An endpoint MUST discard packets that are not long enough to contain 1136 a complete sample. 1138 To ensure that sufficient data is available for sampling, packets are 1139 padded so that the combined lengths of the encoded packet number and 1140 protected payload is at least 4 bytes longer than the sample required 1141 for header protection. The ciphersuites defined in [TLS13] - other 1142 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1143 is not defined in this document - have 16-byte expansions and 16-byte 1144 header protection samples. This results in needing at least 3 bytes 1145 of frames in the unprotected payload if the packet number is encoded 1146 on a single byte, or 2 bytes of frames for a 2-byte packet number 1147 encoding. 1149 The sampled ciphertext for a packet with a short header can be 1150 determined by the following pseudocode: 1152 sample_offset = 1 + len(connection_id) + 4 1154 sample = packet[sample_offset..sample_offset+sample_length] 1156 For example, for a packet with a short header, an 8 byte connection 1157 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1158 28 inclusive (using zero-based indexing). 1160 A packet with a long header is sampled in the same way, noting that 1161 multiple QUIC packets might be included in the same UDP datagram and 1162 that each one is handled separately. 1164 sample_offset = 7 + len(destination_connection_id) + 1165 len(source_connection_id) + 1166 len(payload_length) + 4 1167 if packet_type == Initial: 1168 sample_offset += len(token_length) + 1169 len(token) 1171 sample = packet[sample_offset..sample_offset+sample_length] 1173 5.4.3. AES-Based Header Protection 1175 This section defines the packet protection algorithm for 1176 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1177 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1178 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1179 in ECB mode. 1181 This algorithm samples 16 bytes from the packet ciphertext. This 1182 value is used as the input to AES-ECB. In pseudocode: 1184 mask = AES-ECB(hp_key, sample) 1186 5.4.4. ChaCha20-Based Header Protection 1188 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1189 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1190 256-bit key and 16 bytes sampled from the packet protection output. 1192 The first 4 bytes of the sampled ciphertext are the block counter. A 1193 ChaCha20 implementation could take a 32-bit integer in place of a 1194 byte sequence, in which case the byte sequence is interpreted as a 1195 little-endian value. 1197 The remaining 12 bytes are used as the nonce. A ChaCha20 1198 implementation might take an array of three 32-bit integers in place 1199 of a byte sequence, in which case the nonce bytes are interpreted as 1200 a sequence of 32-bit little-endian integers. 1202 The encryption mask is produced by invoking ChaCha20 to protect 5 1203 zero bytes. In pseudocode: 1205 counter = sample[0..3] 1206 nonce = sample[4..15] 1207 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1209 5.5. Receiving Protected Packets 1211 Once an endpoint successfully receives a packet with a given packet 1212 number, it MUST discard all packets in the same packet number space 1213 with higher packet numbers if they cannot be successfully unprotected 1214 with either the same key, or - if there is a key update - the next 1215 packet protection key (see Section 6). Similarly, a packet that 1216 appears to trigger a key update, but cannot be unprotected 1217 successfully MUST be discarded. 1219 Failure to unprotect a packet does not necessarily indicate the 1220 existence of a protocol error in a peer or an attack. The truncated 1221 packet number encoding used in QUIC can cause packet numbers to be 1222 decoded incorrectly if they are delayed significantly. 1224 5.6. Use of 0-RTT Keys 1226 If 0-RTT keys are available (see Section 4.5), the lack of replay 1227 protection means that restrictions on their use are necessary to 1228 avoid replay attacks on the protocol. 1230 A client MUST only use 0-RTT keys to protect data that is idempotent. 1231 A client MAY wish to apply additional restrictions on what data it 1232 sends prior to the completion of the TLS handshake. A client 1233 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1234 it MUST NOT send ACKs with 0-RTT keys. 1236 A client that receives an indication that its 0-RTT data has been 1237 accepted by a server can send 0-RTT data until it receives all of the 1238 server's handshake messages. A client SHOULD stop sending 0-RTT data 1239 if it receives an indication that 0-RTT data has been rejected. 1241 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1242 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1243 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1244 them. 1246 Once a client has installed 1-RTT keys, it MUST NOT send any more 1247 0-RTT packets. 1249 Note: 0-RTT data can be acknowledged by the server as it receives 1250 it, but any packets containing acknowledgments of 0-RTT data 1251 cannot have packet protection removed by the client until the TLS 1252 handshake is complete. The 1-RTT keys necessary to remove packet 1253 protection cannot be derived until the client receives all server 1254 handshake messages. 1256 5.7. Receiving Out-of-Order Protected Frames 1258 Due to reordering and loss, protected packets might be received by an 1259 endpoint before the final TLS handshake messages are received. A 1260 client will be unable to decrypt 1-RTT packets from the server, 1261 whereas a server will be able to decrypt 1-RTT packets from the 1262 client. Endpoints in either role MUST NOT decrypt 1-RTT packets from 1263 their peer prior to completing the handshake. 1265 Even though 1-RTT keys are available to a server after receiving the 1266 first handshake messages from a client, it is missing assurances on 1267 the client state: 1269 * The client is not authenticated, unless the server has chosen to 1270 use a pre-shared key and validated the client's pre-shared key 1271 binder; see Section 4.2.11 of [TLS13]. 1273 * The client has not demonstrated liveness, unless a RETRY packet 1274 was used. 1276 * Any received 0-RTT data that the server responds to might be due 1277 to a replay attack. 1279 Therefore, the server's use of 1-RTT keys MUST be limited to sending 1280 data before the handshake is complete. A server MUST NOT process 1281 incoming 1-RTT protected packets before the TLS handshake is 1282 complete. Because sending acknowledgments indicates that all frames 1283 in a packet have been processed, a server cannot send acknowledgments 1284 for 1-RTT packets until the TLS handshake is complete. Received 1285 packets protected with 1-RTT keys MAY be stored and later decrypted 1286 and used once the handshake is complete. 1288 Note: TLS implementations might provide all 1-RTT secrets prior to 1289 handshake completion. Even where QUIC implementations have 1-RTT 1290 read keys, those keys cannot be used prior to completing the 1291 handshake. 1293 The requirement for the server to wait for the client Finished 1294 message creates a dependency on that message being delivered. A 1295 client can avoid the potential for head-of-line blocking that this 1296 implies by sending its 1-RTT packets coalesced with a handshake 1297 packet containing a copy of the CRYPTO frame that carries the 1298 Finished message, until one of the handshake packets is acknowledged. 1299 This enables immediate server processing for those packets. 1301 A server could receive packets protected with 0-RTT keys prior to 1302 receiving a TLS ClientHello. The server MAY retain these packets for 1303 later decryption in anticipation of receiving a ClientHello. 1305 5.8. Retry Packet Integrity 1307 Retry packets (see the Retry Packet section of [QUIC-TRANSPORT]) 1308 carry a Retry Integrity Tag that provides two properties: it allows 1309 discarding packets that have accidentally been corrupted by the 1310 network, and it diminishes off-path attackers' ability to send valid 1311 Retry packets. 1313 The Retry Integrity Tag is a 128-bit field that is computed as the 1314 output of AEAD_AES_128_GCM [AEAD] used with the following inputs: 1316 * The secret key, K, is 128 bits equal to 1317 0x4d32ecdb2a2133c841e4043df27d4430. 1319 * The nonce, N, is 96 bits equal to 0x4d1611d05513a552c587d575. 1321 * The plaintext, P, is empty. 1323 * The associated data, A, is the contents of the Retry Pseudo- 1324 Packet, as illustrated in Figure 8: 1326 The secret key and the nonce are values derived by calling HKDF- 1327 Expand-Label using 1328 0x656e61e336ae9417f7f0edd8d78d461e2aa7084aba7a14c1e9f726d55709169a as 1329 the secret, with labels being "quic key" and "quic iv" (Section 5.1). 1331 0 1 2 3 1332 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 1333 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1334 | ODCID Len (8) | 1335 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1336 | Original Destination Connection ID (0..160) ... 1337 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1338 |1|1| 3 | Unused| 1339 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1340 | Version (32) | 1341 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1342 | DCID Len (8) | 1343 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1344 | Destination Connection ID (0..160) ... 1345 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1346 | SCID Len (8) | 1347 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1348 | Source Connection ID (0..160) ... 1349 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1350 | Retry Token (*) ... 1351 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1352 Figure 8: Retry Pseudo-Packet 1354 The Retry Pseudo-Packet is not sent over the wire. It is computed by 1355 taking the transmitted Retry packet, removing the Retry Integrity Tag 1356 and prepending the two following fields: 1358 ODCID Len: The ODCID Len contains the length in bytes of the 1359 Original Destination Connection ID field that follows it, encoded 1360 as an 8-bit unsigned integer. 1362 Original Destination Connection ID: The Original Destination 1363 Connection ID contains the value of the Destination Connection ID 1364 from the Initial packet that this Retry is in response to. The 1365 length of this field is given in ODCID Len. The presence of this 1366 field mitigates an off-path attacker's ability to inject a Retry 1367 packet. 1369 6. Key Update 1371 Once the handshake is confirmed (see Section 4.1.2), an endpoint MAY 1372 initiate a key update. 1374 The Key Phase bit indicates which packet protection keys are used to 1375 protect the packet. The Key Phase bit is initially set to 0 for the 1376 first set of 1-RTT packets and toggled to signal each subsequent key 1377 update. 1379 The Key Phase bit allows a recipient to detect a change in keying 1380 material without needing to receive the first packet that triggered 1381 the change. An endpoint that notices a changed Key Phase bit updates 1382 keys and decrypts the packet that contains the changed value. 1384 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1385 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1386 of a TLS KeyUpdate message as a connection error of type 0x10a, 1387 equivalent to a fatal TLS alert of unexpected_message (see 1388 Section 4.9). 1390 Figure 9 shows a key update process, where the initial set of keys 1391 used (identified with @M) are replaced by updated keys (identified 1392 with @N). The value of the Key Phase bit is indicated in brackets 1393 []. 1395 Initiating Peer Responding Peer 1397 @M [0] QUIC Packets 1399 ... Update to @N 1400 @N [1] QUIC Packets 1401 --------> 1402 Update to @N ... 1403 QUIC Packets [1] @N 1404 <-------- 1405 QUIC Packets [1] @N 1406 containing ACK 1407 <-------- 1408 ... Key Update Permitted 1410 @N [1] QUIC Packets 1411 containing ACK for @N packets 1412 --------> 1413 Key Update Permitted ... 1415 Figure 9: Key Update 1417 6.1. Initiating a Key Update 1419 Endpoints maintain separate read and write secrets for packet 1420 protection. An endpoint initiates a key update by updating its 1421 packet protection write secret and using that to protect new packets. 1422 The endpoint creates a new write secret from the existing write 1423 secret as performed in Section 7.2 of [TLS13]. This uses the KDF 1424 function provided by TLS with a label of "quic ku". The 1425 corresponding key and IV are created from that secret as defined in 1426 Section 5.1. The header protection key is not updated. 1428 For example, to update write keys with TLS 1.3, HKDF-Expand-Label is 1429 used as: 1431 secret_ = HKDF-Expand-Label(secret_, "quic ku", 1432 "", Hash.length) 1434 The endpoint toggles the value of the Key Phase bit and uses the 1435 updated key and IV to protect all subsequent packets. 1437 An endpoint MUST NOT initiate a key update prior to having confirmed 1438 the handshake (Section 4.1.2). An endpoint MUST NOT initiate a 1439 subsequent key update prior unless it has received an acknowledgment 1440 for a packet that was sent protected with keys from the current key 1441 phase. This ensures that keys are available to both peers before 1442 another key update can be initiated. This can be implemented by 1443 tracking the lowest packet number sent with each key phase, and the 1444 highest acknowledged packet number in the 1-RTT space: once the 1445 latter is higher than or equal to the former, another key update can 1446 be initiated. 1448 Note: Keys of packets other than the 1-RTT packets are never 1449 updated; their keys are derived solely from the TLS handshake 1450 state. 1452 The endpoint that initiates a key update also updates the keys that 1453 it uses for receiving packets. These keys will be needed to process 1454 packets the peer sends after updating. 1456 An endpoint SHOULD retain old keys so that packets sent by its peer 1457 prior to receiving the key update can be processed. Discarding old 1458 keys too early can cause delayed packets to be discarded. Discarding 1459 packets will be interpreted as packet loss by the peer and could 1460 adversely affect performance. 1462 6.2. Responding to a Key Update 1464 A peer is permitted to initiate a key update after receiving an 1465 acknowledgement of a packet in the current key phase. An endpoint 1466 detects a key update when processing a packet with a key phase that 1467 differs from the value last used to protect the last packet it sent. 1468 To process this packet, the endpoint uses the next packet protection 1469 key and IV. See Section 6.3 for considerations about generating 1470 these keys. 1472 If a packet is successfully processed using the next key and IV, then 1473 the peer has initiated a key update. The endpoint MUST update its 1474 send keys to the corresponding key phase in response, as described in 1475 Section 6.1. Sending keys MUST be updated before sending an 1476 acknowledgement for the packet that was received with updated keys. 1477 By acknowledging the packet that triggered the key update in a packet 1478 protected with the updated keys, the endpoint signals that the key 1479 update is complete. 1481 An endpoint can defer sending the packet or acknowledgement according 1482 to its normal packet sending behaviour; it is not necessary to 1483 immediately generate a packet in response to a key update. The next 1484 packet sent by the endpoint will use the updated keys. The next 1485 packet that contains an acknowledgement will cause the key update to 1486 be completed. If an endpoint detects a second update before it has 1487 sent any packets with updated keys containing an acknowledgement for 1488 the packet that initiated the key update, it indicates that its peer 1489 has updated keys twice without awaiting confirmation. An endpoint 1490 MAY treat consecutive key updates as a connection error of type 1491 KEY_UPDATE_ERROR. 1493 An endpoint that receives an acknowledgement that is carried in a 1494 packet protected with old keys where any acknowledged packet was 1495 protected with newer keys MAY treat that as a connection error of 1496 type KEY_UPDATE_ERROR. This indicates that a peer has received and 1497 acknowledged a packet that initiates a key update, but has not 1498 updated keys in response. 1500 6.3. Timing of Receive Key Generation 1502 Endpoints responding to an apparent key update MUST NOT generate a 1503 timing side-channel signal that might indicate that the Key Phase bit 1504 was invalid (see Section 9.3). Endpoints can use dummy packet 1505 protection keys in place of discarded keys when key updates are not 1506 yet permitted. Using dummy keys will generate no variation in the 1507 timing signal produced by attempting to remove packet protection, and 1508 results in all packets with an invalid Key Phase bit being rejected. 1510 The process of creating new packet protection keys for receiving 1511 packets could reveal that a key update has occurred. An endpoint MAY 1512 perform this process as part of packet processing, but this creates a 1513 timing signal that can be used by an attacker to learn when key 1514 updates happen and thus the value of the Key Phase bit in certain 1515 packets. Endpoints MAY instead defer the creation of the next set of 1516 receive packet protection keys until some time after a key update 1517 completes, up to three times the PTO; see Section 6.5. 1519 Once generated, the next set of packet protection keys SHOULD be 1520 retained, even if the packet that was received was subsequently 1521 discarded. Packets containing apparent key updates are easy to forge 1522 and - while the process of key update does not require significant 1523 effort - triggering this process could be used by an attacker for 1524 DoS. 1526 For this reason, endpoints MUST be able to retain two sets of packet 1527 protection keys for receiving packets: the current and the next. 1528 Retaining the previous keys in addition to these might improve 1529 performance, but this is not essential. 1531 6.4. Sending with Updated Keys 1533 An endpoint always sends packets that are protected with the newest 1534 keys. Keys used for packet protection can be discarded immediately 1535 after switching to newer keys. 1537 Packets with higher packet numbers MUST be protected with either the 1538 same or newer packet protection keys than packets with lower packet 1539 numbers. An endpoint that successfully removes protection with old 1540 keys when newer keys were used for packets with lower packet numbers 1541 MUST treat this as a connection error of type KEY_UPDATE_ERROR. 1543 6.5. Receiving with Different Keys 1545 For receiving packets during a key update, packets protected with 1546 older keys might arrive if they were delayed by the network. 1547 Retaining old packet protection keys allows these packets to be 1548 successfully processed. 1550 As packets protected with keys from the next key phase use the same 1551 Key Phase value as those protected with keys from the previous key 1552 phase, it can be necessary to distinguish between the two. This can 1553 be done using packet numbers. A recovered packet number that is 1554 lower than any packet number from the current key phase uses the 1555 previous packet protection keys; a recovered packet number that is 1556 higher than any packet number from the current key phase requires the 1557 use of the next packet protection keys. 1559 Some care is necessary to ensure that any process for selecting 1560 between previous, current, and next packet protection keys does not 1561 expose a timing side channel that might reveal which keys were used 1562 to remove packet protection. See Section 9.4 for more information. 1564 Alternatively, endpoints can retain only two sets of packet 1565 protection keys, swapping previous for next after enough time has 1566 passed to allow for reordering in the network. In this case, the Key 1567 Phase bit alone can be used to select keys. 1569 An endpoint MAY allow a period of approximately the Probe Timeout 1570 (PTO; see [QUIC-RECOVERY]) after a key update before it creates the 1571 next set of packet protection keys. These updated keys MAY replace 1572 the previous keys at that time. With the caveat that PTO is a 1573 subjective measure - that is, a peer could have a different view of 1574 the RTT - this time is expected to be long enough that any reordered 1575 packets would be declared lost by a peer even if they were 1576 acknowledged and short enough to allow for subsequent key updates. 1578 Endpoints need to allow for the possibility that a peer might not be 1579 able to decrypt packets that initiate a key update during the period 1580 when it retains old keys. Endpoints SHOULD wait three times the PTO 1581 before initiating a key update after receiving an acknowledgment that 1582 confirms that the previous key update was received. Failing to allow 1583 sufficient time could lead to packets being discarded. 1585 An endpoint SHOULD retain old read keys for no more than three times 1586 the PTO. After this period, old read keys and their corresponding 1587 secrets SHOULD be discarded. 1589 6.6. Key Update Frequency 1591 Key updates MUST be initiated before usage limits on packet 1592 protection keys are exceeded. For the cipher suites mentioned in 1593 this document, the limits in Section 5.5 of [TLS13] apply. Other 1594 cipher suites MUST define usage limits in order to be used with QUIC. 1596 6.7. Key Update Error Code 1598 The KEY_UPDATE_ERROR error code (0xE) is used to signal errors 1599 related to key updates. 1601 7. Security of Initial Messages 1603 Initial packets are not protected with a secret key, so they are 1604 subject to potential tampering by an attacker. QUIC provides 1605 protection against attackers that cannot read packets, but does not 1606 attempt to provide additional protection against attacks where the 1607 attacker can observe and inject packets. Some forms of tampering - 1608 such as modifying the TLS messages themselves - are detectable, but 1609 some - such as modifying ACKs - are not. 1611 For example, an attacker could inject a packet containing an ACK 1612 frame that makes it appear that a packet had not been received or to 1613 create a false impression of the state of the connection (e.g., by 1614 modifying the ACK Delay). Note that such a packet could cause a 1615 legitimate packet to be dropped as a duplicate. Implementations 1616 SHOULD use caution in relying on any data which is contained in 1617 Initial packets that is not otherwise authenticated. 1619 It is also possible for the attacker to tamper with data that is 1620 carried in Handshake packets, but because that tampering requires 1621 modifying TLS handshake messages, that tampering will cause the TLS 1622 handshake to fail. 1624 8. QUIC-Specific Additions to the TLS Handshake 1626 QUIC uses the TLS handshake for more than just negotiation of 1627 cryptographic parameters. The TLS handshake provides preliminary 1628 values for QUIC transport parameters and allows a server to perform 1629 return routability checks on clients. 1631 8.1. Protocol Negotiation 1633 QUIC requires that the cryptographic handshake provide authenticated 1634 protocol negotiation. TLS uses Application Layer Protocol 1635 Negotiation (ALPN) [ALPN] to select an application protocol. Unless 1636 another mechanism is used for agreeing on an application protocol, 1637 endpoints MUST use ALPN for this purpose. When using ALPN, endpoints 1638 MUST immediately close a connection (see Section 10.3 in 1639 [QUIC-TRANSPORT]) if an application protocol is not negotiated with a 1640 no_application_protocol TLS alert (QUIC error code 0x178, see 1641 Section 4.9). While [ALPN] only specifies that servers use this 1642 alert, QUIC clients MUST also use it to terminate a connection when 1643 ALPN negotiation fails. 1645 An application protocol MAY restrict the QUIC versions that it can 1646 operate over. Servers MUST select an application protocol compatible 1647 with the QUIC version that the client has selected. The server MUST 1648 treat the inability to select a compatible application protocol as a 1649 connection error of type 0x178 (no_application_protocol). Similarly, 1650 a client MUST treat the selection of an incompatible application 1651 protocol by a server as a connection error of type 0x178. 1653 8.2. QUIC Transport Parameters Extension 1655 QUIC transport parameters are carried in a TLS extension. Different 1656 versions of QUIC might define a different method for negotiating 1657 transport configuration. 1659 Including transport parameters in the TLS handshake provides 1660 integrity protection for these values. 1662 enum { 1663 quic_transport_parameters(0xffa5), (65535) 1664 } ExtensionType; 1666 The "extension_data" field of the quic_transport_parameters extension 1667 contains a value that is defined by the version of QUIC that is in 1668 use. 1670 The quic_transport_parameters extension is carried in the ClientHello 1671 and the EncryptedExtensions messages during the handshake. Endpoints 1672 MUST send the quic_transport_parameters extension; endpoints that 1673 receive ClientHello or EncryptedExtensions messages without the 1674 quic_transport_parameters extension MUST close the connection with an 1675 error of type 0x16d (equivalent to a fatal TLS missing_extension 1676 alert, see Section 4.9). 1678 While the transport parameters are technically available prior to the 1679 completion of the handshake, they cannot be fully trusted until the 1680 handshake completes, and reliance on them should be minimized. 1681 However, any tampering with the parameters will cause the handshake 1682 to fail. 1684 Endpoints MUST NOT send this extension in a TLS connection that does 1685 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1686 fatal unsupported_extension alert MUST be sent by an implementation 1687 that supports this extension if the extension is received when the 1688 transport is not QUIC. 1690 8.3. Removing the EndOfEarlyData Message 1692 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1693 rely on this message to mark the end of 0-RTT data or to signal the 1694 change to Handshake keys. 1696 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1697 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1698 error of type PROTOCOL_VIOLATION. 1700 As a result, EndOfEarlyData does not appear in the TLS handshake 1701 transcript. 1703 9. Security Considerations 1705 There are likely to be some real clangers here eventually, but the 1706 current set of issues is well captured in the relevant sections of 1707 the main text. 1709 Never assume that because it isn't in the security considerations 1710 section it doesn't affect security. Most of this document does. 1712 9.1. Replay Attacks with 0-RTT 1714 As described in Section 8 of [TLS13], use of TLS early data comes 1715 with an exposure to replay attack. The use of 0-RTT in QUIC is 1716 similarly vulnerable to replay attack. 1718 Endpoints MUST implement and use the replay protections described in 1719 [TLS13], however it is recognized that these protections are 1720 imperfect. Therefore, additional consideration of the risk of replay 1721 is needed. 1723 QUIC is not vulnerable to replay attack, except via the application 1724 protocol information it might carry. The management of QUIC protocol 1725 state based on the frame types defined in [QUIC-TRANSPORT] is not 1726 vulnerable to replay. Processing of QUIC frames is idempotent and 1727 cannot result in invalid connection states if frames are replayed, 1728 reordered or lost. QUIC connections do not produce effects that last 1729 beyond the lifetime of the connection, except for those produced by 1730 the application protocol that QUIC serves. 1732 Note: TLS session tickets and address validation tokens are used to 1733 carry QUIC configuration information between connections. These 1734 MUST NOT be used to carry application semantics. The potential 1735 for reuse of these tokens means that they require stronger 1736 protections against replay. 1738 A server that accepts 0-RTT on a connection incurs a higher cost than 1739 accepting a connection without 0-RTT. This includes higher 1740 processing and computation costs. Servers need to consider the 1741 probability of replay and all associated costs when accepting 0-RTT. 1743 Ultimately, the responsibility for managing the risks of replay 1744 attacks with 0-RTT lies with an application protocol. An application 1745 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1746 the measures that are employed to protect against replay attack. An 1747 analysis of replay risk needs to consider all QUIC protocol features 1748 that carry application semantics. 1750 Disabling 0-RTT entirely is the most effective defense against replay 1751 attack. 1753 QUIC extensions MUST describe how replay attacks affect their 1754 operation, or prohibit their use in 0-RTT. Application protocols 1755 MUST either prohibit the use of extensions that carry application 1756 semantics in 0-RTT or provide replay mitigation strategies. 1758 9.2. Packet Reflection Attack Mitigation 1760 A small ClientHello that results in a large block of handshake 1761 messages from a server can be used in packet reflection attacks to 1762 amplify the traffic generated by an attacker. 1764 QUIC includes three defenses against this attack. First, the packet 1765 containing a ClientHello MUST be padded to a minimum size. Second, 1766 if responding to an unverified source address, the server is 1767 forbidden to send more than three UDP datagrams in its first flight 1768 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1769 acknowledgements of Handshake packets are authenticated, a blind 1770 attacker cannot forge them. Put together, these defenses limit the 1771 level of amplification. 1773 9.3. Header Protection Analysis 1775 [NAN] analyzes authenticated encryption algorithms which provide 1776 nonce privacy, referred to as "Hide Nonce" (HN) transforms. The 1777 general header protection construction in this document is one of 1778 those algorithms (HN1). Header protection uses the output of the 1779 packet protection AEAD to derive "sample", and then encrypts the 1780 header field using a pseudorandom function (PRF) as follows: 1782 protected_field = field XOR PRF(hp_key, sample) 1784 The header protection variants in this document use a pseudorandom 1785 permutation (PRP) in place of a generic PRF. However, since all PRPs 1786 are also PRFs [IMC], these variants do not deviate from the HN1 1787 construction. 1789 As "hp_key" is distinct from the packet protection key, it follows 1790 that header protection achieves AE2 security as defined in [NAN] and 1791 therefore guarantees privacy of "field", the protected packet header. 1792 Future header protection variants based on this construction MUST use 1793 a PRF to ensure equivalent security guarantees. 1795 Use of the same key and ciphertext sample more than once risks 1796 compromising header protection. Protecting two different headers 1797 with the same key and ciphertext sample reveals the exclusive OR of 1798 the protected fields. Assuming that the AEAD acts as a PRF, if L 1799 bits are sampled, the odds of two ciphertext samples being identical 1800 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1801 described in this document, that probability is one in 2^64. 1803 Note: In some cases, inputs shorter than the full size required by 1804 the packet protection algorithm might be used. 1806 To prevent an attacker from modifying packet headers, the header is 1807 transitively authenticated using packet protection; the entire packet 1808 header is part of the authenticated additional data. Protected 1809 fields that are falsified or modified can only be detected once the 1810 packet protection is removed. 1812 9.4. Header Protection Timing Side-Channels 1814 An attacker could guess values for packet numbers or Key Phase and 1815 have an endpoint confirm guesses through timing side channels. 1816 Similarly, guesses for the packet number length can be trialed and 1817 exposed. If the recipient of a packet discards packets with 1818 duplicate packet numbers without attempting to remove packet 1819 protection they could reveal through timing side-channels that the 1820 packet number matches a received packet. For authentication to be 1821 free from side-channels, the entire process of header protection 1822 removal, packet number recovery, and packet protection removal MUST 1823 be applied together without timing and other side-channels. 1825 For the sending of packets, construction and protection of packet 1826 payloads and packet numbers MUST be free from side-channels that 1827 would reveal the packet number or its encoded size. 1829 During a key update, the time taken to generate new keys could reveal 1830 through timing side-channels that a key update has occurred. 1831 Alternatively, where an attacker injects packets this side-channel 1832 could reveal the value of the Key Phase on injected packets. After 1833 receiving a key update, an endpoint SHOULD generate and save the next 1834 set of receive packet protection keys, as described in Section 6.3. 1835 By generating new keys before a key update is received, receipt of 1836 packets will not create timing signals that leak the value of the Key 1837 Phase. 1839 This depends on not doing this key generation during packet 1840 processing and it can require that endpoints maintain three sets of 1841 packet protection keys for receiving: for the previous key phase, for 1842 the current key phase, and for the next key phase. Endpoints can 1843 instead choose to defer generation of the next receive packet 1844 protection keys until they discard old keys so that only two sets of 1845 receive keys need to be retained at any point in time. 1847 9.5. Key Diversity 1849 In using TLS, the central key schedule of TLS is used. As a result 1850 of the TLS handshake messages being integrated into the calculation 1851 of secrets, the inclusion of the QUIC transport parameters extension 1852 ensures that handshake and 1-RTT keys are not the same as those that 1853 might be produced by a server running TLS over TCP. To avoid the 1854 possibility of cross-protocol key synchronization, additional 1855 measures are provided to improve key separation. 1857 The QUIC packet protection keys and IVs are derived using a different 1858 label than the equivalent keys in TLS. 1860 To preserve this separation, a new version of QUIC SHOULD define new 1861 labels for key derivation for packet protection key and IV, plus the 1862 header protection keys. This version of QUIC uses the string "quic". 1863 Other versions can use a version-specific label in place of that 1864 string. 1866 The initial secrets use a key that is specific to the negotiated QUIC 1867 version. New QUIC versions SHOULD define a new salt value used in 1868 calculating initial secrets. 1870 10. IANA Considerations 1872 This document does not create any new IANA registries, but it 1873 registers the values in the following registries: 1875 * TLS ExtensionType Values Registry [TLS-REGISTRIES] - IANA is to 1876 register the quic_transport_parameters extension found in 1877 Section 8.2. The Recommended column is to be marked Yes. The TLS 1878 1.3 Column is to include CH and EE. 1880 * QUIC Transport Error Codes Registry [QUIC-TRANSPORT] - IANA is to 1881 register the KEY_UPDATE_ERROR (0xE), as described in Section 6.7. 1883 11. References 1885 11.1. Normative References 1887 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1888 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1889 . 1891 [AES] "Advanced encryption standard (AES)", 1892 DOI 10.6028/nist.fips.197, National Institute of Standards 1893 and Technology report, November 2001, 1894 . 1896 [ALPN] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1897 "Transport Layer Security (TLS) Application-Layer Protocol 1898 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1899 July 2014, . 1901 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1902 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1903 . 1905 [QUIC-RECOVERY] 1906 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1907 and Congestion Control", Work in Progress, Internet-Draft, 1908 draft-ietf-quic-recovery-27, 21 February 2020, 1909 . 1911 [QUIC-TRANSPORT] 1912 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1913 Multiplexed and Secure Transport", Work in Progress, 1914 Internet-Draft, draft-ietf-quic-transport-27, 21 February 1915 2020, . 1918 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1919 Requirement Levels", BCP 14, RFC 2119, 1920 DOI 10.17487/RFC2119, March 1997, 1921 . 1923 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1924 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1925 May 2017, . 1927 [SHA] Dang, Q., "Secure Hash Standard", 1928 DOI 10.6028/nist.fips.180-4, National Institute of 1929 Standards and Technology report, July 2015, 1930 . 1932 [TLS-REGISTRIES] 1933 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 1934 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 1935 . 1937 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1938 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1939 . 1941 11.2. Informative References 1943 [AEBounds] Luykx, A. and K. Paterson, "Limits on Authenticated 1944 Encryption Use in TLS", 8 March 2016, 1945 . 1947 [HTTP2-TLS13] 1948 Benjamin, D., "Using TLS 1.3 with HTTP/2", Work in 1949 Progress, Internet-Draft, draft-ietf-httpbis- 1950 http2-tls13-03, 17 October 2019, . 1953 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1954 Cryptography, Second Edition", ISBN 978-1466570269, 6 1955 November 2014. 1957 [NAN] Bellare, M., Ng, R., and B. Tackmann, "Nonces Are Noticed: 1958 AEAD Revisited", DOI 10.1007/978-3-030-26948-7_9, Advances 1959 in Cryptology - CRYPTO 2019 pp. 235-265, 2019, 1960 . 1962 [QUIC-HTTP] 1963 Bishop, M., Ed., "Hypertext Transfer Protocol Version 3 1964 (HTTP/3)", Work in Progress, Internet-Draft, draft-ietf- 1965 quic-http-27, 21 February 2020, 1966 . 1968 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1969 DOI 10.17487/RFC2818, May 2000, 1970 . 1972 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1973 Housley, R., and W. Polk, "Internet X.509 Public Key 1974 Infrastructure Certificate and Certificate Revocation List 1975 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1976 . 1978 Appendix A. Sample Packet Protection 1980 This section shows examples of packet protection so that 1981 implementations can be verified incrementally. Samples of Initial 1982 packets from both client and server, plus a Retry packet are defined. 1983 These packets use an 8-byte client-chosen Destination Connection ID 1984 of 0x8394c8f03e515708. Some intermediate values are included. All 1985 values are shown in hexadecimal. 1987 A.1. Keys 1989 The labels generated by the HKDF-Expand-Label function are: 1991 client in: 00200f746c73313320636c69656e7420696e00 1993 server in: 00200f746c7331332073657276657220696e00 1995 quic key: 00100e746c7331332071756963206b657900 1997 quic iv: 000c0d746c733133207175696320697600 1999 quic hp: 00100d746c733133207175696320687000 2001 The initial secret is common: 2003 initial_secret = HKDF-Extract(initial_salt, cid) 2004 = 524e374c6da8cf8b496f4bcb69678350 2005 7aafee6198b202b4bc823ebf7514a423 2007 The secrets for protecting client packets are: 2009 client_initial_secret 2010 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 2011 = fda3953aecc040e48b34e27ef87de3a6 2012 098ecf0e38b7e032c5c57bcbd5975b84 2014 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 2015 = af7fd7efebd21878ff66811248983694 2017 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 2018 = 8681359410a70bb9c92f0420 2020 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 2021 = a980b8b4fb7d9fbc13e814c23164253d 2023 The secrets for protecting server packets are: 2025 server_initial_secret 2026 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 2027 = 554366b81912ff90be41f17e80222130 2028 90ab17d8149179bcadf222f29ff2ddd5 2030 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 2031 = 5d51da9ee897a21b2659ccc7e5bfa577 2033 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 2034 = 5e5ae651fd1e8495af13508b 2036 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 2037 = a8ed82e6664f865aedf6106943f95fb8 2039 A.2. Client Initial 2041 The client sends an Initial packet. The unprotected payload of this 2042 packet contains the following CRYPTO frame, plus enough PADDING 2043 frames to make a 1162 byte payload: 2045 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 2046 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 2047 736572766572ff01000100000a001400 12001d00170018001901000101010201 2048 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 2049 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 2050 05030603020308040805080604010501 060102010402050206020202002d0002 2051 0101001c00024001 2053 The unprotected header includes the connection ID and a 4 byte packet 2054 number encoding for a packet number of 2: 2056 c3ff00001b088394c8f03e5157080000449e00000002 2057 Protecting the payload produces output that is sampled for header 2058 protection. Because the header uses a 4 byte packet number encoding, 2059 the first 16 bytes of the protected payload is sampled, then applied 2060 to the header: 2062 sample = 535064a4268a0d9d7b1c9d250ae35516 2064 mask = AES-ECB(hp, sample)[0..4] 2065 = 833b343aaa 2067 header[0] ^= mask[0] & 0x0f 2068 = c0 2069 header[18..21] ^= mask[1..4] 2070 = 3b343aa8 2071 header = c0ff00001b088394c8f03e5157080000449e3b343aa8 2073 The resulting protected packet is: 2075 c0ff00001b088394c8f03e5157080000 449e3b343aa8535064a4268a0d9d7b1c 2076 9d250ae355162276e9b1e3011ef6bbc0 ab48ad5bcc2681e953857ca62becd752 2077 4daac473e68d7405fbba4e9ee616c870 38bdbe908c06d9605d9ac49030359eec 2078 b1d05a14e117db8cede2bb09d0dbbfee 271cb374d8f10abec82d0f59a1dee29f 2079 e95638ed8dd41da07487468791b719c5 5c46968eb3b54680037102a28e53dc1d 2080 12903db0af5821794b41c4a93357fa59 ce69cfe7f6bdfa629eef78616447e1d6 2081 11c4baf71bf33febcb03137c2c75d253 17d3e13b684370f668411c0f00304b50 2082 1c8fd422bd9b9ad81d643b20da89ca05 25d24d2b142041cae0af205092e43008 2083 0cd8559ea4c5c6e4fa3f66082b7d303e 52ce0162baa958532b0bbc2bc785681f 2084 cf37485dff6595e01e739c8ac9efba31 b985d5f656cc092432d781db95221724 2085 87641c4d3ab8ece01e39bc85b1543661 4775a98ba8fa12d46f9b35e2a55eb72d 2086 7f85181a366663387ddc20551807e007 673bd7e26bf9b29b5ab10a1ca87cbb7a 2087 d97e99eb66959c2a9bc3cbde4707ff77 20b110fa95354674e395812e47a0ae53 2088 b464dcb2d1f345df360dc227270c7506 76f6724eb479f0d2fbb6124429990457 2089 ac6c9167f40aab739998f38b9eccb24f d47c8410131bf65a52af841275d5b3d1 2090 880b197df2b5dea3e6de56ebce3ffb6e 9277a82082f8d9677a6767089b671ebd 2091 244c214f0bde95c2beb02cd1172d58bd f39dce56ff68eb35ab39b49b4eac7c81 2092 5ea60451d6e6ab82119118df02a58684 4a9ffe162ba006d0669ef57668cab38b 2093 62f71a2523a084852cd1d079b3658dc2 f3e87949b550bab3e177cfc49ed190df 2094 f0630e43077c30de8f6ae081537f1e83 da537da980afa668e7b7fb25301cf741 2095 524be3c49884b42821f17552fbd1931a 813017b6b6590a41ea18b6ba49cd48a4 2096 40bd9a3346a7623fb4ba34a3ee571e3c 731f35a7a3cf25b551a680fa68763507 2097 b7fde3aaf023c50b9d22da6876ba337e b5e9dd9ec3daf970242b6c5aab3aa4b2 2098 96ad8b9f6832f686ef70fa938b31b4e5 ddd7364442d3ea72e73d668fb0937796 2099 f462923a81a47e1cee7426ff6d922126 9b5a62ec03d6ec94d12606cb485560ba 2100 b574816009e96504249385bb61a819be 04f62c2066214d8360a2022beb316240 2101 b6c7d78bbe56c13082e0ca272661210a bf020bf3b5783f1426436cf9ff418405 2102 93a5d0638d32fc51c5c65ff291a3a7a5 2fd6775e623a4439cc08dd25582febc9 2103 44ef92d8dbd329c91de3e9c9582e41f1 7f3d186f104ad3f90995116c682a2a14 2104 a3b4b1f547c335f0be710fc9fc03e0e5 87b8cda31ce65b969878a4ad4283e6d5 2105 b0373f43da86e9e0ffe1ae0fddd35162 55bd74566f36a38703d5f34249ded1f6 2106 6b3d9b45b9af2ccfefe984e13376b1b2 c6404aa48c8026132343da3f3a33659e 2107 c1b3e95080540b28b7f3fcd35fa5d843 b579a84c089121a60d8c1754915c344e 2108 eaf45a9bf27dc0c1e784161691220913 13eb0e87555abd706626e557fc36a04f 2109 cd191a58829104d6075c5594f627ca50 6bf181daec940f4a4f3af0074eee89da 2110 acde6758312622d4fa675b39f728e062 d2bee680d8f41a597c262648bb18bcfc 2111 13c8b3d97b1a77b2ac3af745d61a34cc 4709865bac824a94bb19058015e4e42d 2112 38d3b779d72edc00c5cd088eff802b05 2114 A.3. Server Initial 2116 The server sends the following payload in response, including an ACK 2117 frame, a CRYPTO frame, and no PADDING frames: 2119 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 2120 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 2121 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 2122 0304 2123 The header from the server includes a new connection ID and a 2-byte 2124 packet number encoding for a packet number of 1: 2126 c1ff00001b0008f067a5502a4262b50040740001 2128 As a result, after protection, the header protection sample is taken 2129 starting from the third protected octet: 2131 sample = 7002596f99ae67abf65a5852f54f58c3 2132 mask = 38168a0c25 2133 header = c9ff00001b0008f067a5502a4262b5004074168b 2135 The final protected packet is then: 2137 c9ff00001b0008f067a5502a4262b500 4074168bf22b7002596f99ae67abf65a 2138 5852f54f58c37c808682e2e40492d8a3 899fb04fc0afe9aabc8767b18a0aa493 2139 537426373b48d502214dd856d63b78ce e37bc664b3fe86d487ac7a77c53038a3 2140 cd32f0b5004d9f5754c4f7f2d1f35cf3 f7116351c92bd8c3a9528d2b6aca20f0 2141 8047d9f017f0 2143 A.4. Retry 2145 This shows a Retry packet that might be sent in response to the 2146 Initial packet in Appendix A.2. The integrity check includes the 2147 client-chosen connection ID value of 0x8394c8f03e515708, but that 2148 value is not included in the final Retry packet: 2150 ffff00001b0008f067a5502a4262b574 6f6b656ea523cb5ba524695f6569f293 2151 a1359d8e 2153 Appendix B. Change Log 2155 *RFC Editor's Note:* Please remove this section prior to 2156 publication of a final version of this document. 2158 Issue and pull request numbers are listed with a leading octothorp. 2160 B.1. Since draft-ietf-quic-tls-26 2162 * Updated examples 2164 B.2. Since draft-ietf-quic-tls-25 2166 * No changes 2168 B.3. Since draft-ietf-quic-tls-24 2170 * Rewrite key updates (#3050) 2172 - Allow but don't recommend deferring key updates (#2792, #3263) 2174 - More completely define received behavior (#2791) 2176 - Define the label used with HKDF-Expand-Label (#3054) 2178 B.4. Since draft-ietf-quic-tls-23 2180 * Key update text update (#3050): 2182 - Recommend constant-time key replacement (#2792) 2184 - Provide explicit labels for key update key derivation (#3054) 2186 * Allow first Initial from a client to span multiple packets (#2928, 2187 #3045) 2189 * PING can be sent at any encryption level (#3034, #3035) 2191 B.5. Since draft-ietf-quic-tls-22 2193 * Update the salt used for Initial secrets (#2887, #2980) 2195 B.6. Since draft-ietf-quic-tls-21 2197 * No changes 2199 B.7. Since draft-ietf-quic-tls-20 2201 * Mandate the use of the QUIC transport parameters extension (#2528, 2202 #2560) 2204 * Define handshake completion and confirmation; define clearer rules 2205 when it encryption keys should be discarded (#2214, #2267, #2673) 2207 B.8. Since draft-ietf-quic-tls-18 2209 * Increased the set of permissible frames in 0-RTT (#2344, #2355) 2211 * Transport parameter extension is mandatory (#2528, #2560) 2213 B.9. Since draft-ietf-quic-tls-17 2214 * Endpoints discard initial keys as soon as handshake keys are 2215 available (#1951, #2045) 2217 * Use of ALPN or equivalent is mandatory (#2263, #2284) 2219 B.10. Since draft-ietf-quic-tls-14 2221 * Update the salt used for Initial secrets (#1970) 2223 * Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 2225 * Change header protection 2227 - Sample from a fixed offset (#1575, #2030) 2229 - Cover part of the first byte, including the key phase (#1322, 2230 #2006) 2232 * TLS provides an AEAD and KDF function (#2046) 2234 - Clarify that the TLS KDF is used with TLS (#1997) 2236 - Change the labels for calculation of QUIC keys (#1845, #1971, 2237 #1991) 2239 * Initial keys are discarded once Handshake keys are available 2240 (#1951, #2045) 2242 B.11. Since draft-ietf-quic-tls-13 2244 * Updated to TLS 1.3 final (#1660) 2246 B.12. Since draft-ietf-quic-tls-12 2248 * Changes to integration of the TLS handshake (#829, #1018, #1094, 2249 #1165, #1190, #1233, #1242, #1252, #1450) 2251 - The cryptographic handshake uses CRYPTO frames, not stream 0 2253 - QUIC packet protection is used in place of TLS record 2254 protection 2256 - Separate QUIC packet number spaces are used for the handshake 2258 - Changed Retry to be independent of the cryptographic handshake 2260 - Limit the use of HelloRetryRequest to address TLS needs (like 2261 key shares) 2263 * Changed codepoint of TLS extension (#1395, #1402) 2265 B.13. Since draft-ietf-quic-tls-11 2267 * Encrypted packet numbers. 2269 B.14. Since draft-ietf-quic-tls-10 2271 * No significant changes. 2273 B.15. Since draft-ietf-quic-tls-09 2275 * Cleaned up key schedule and updated the salt used for handshake 2276 packet protection (#1077) 2278 B.16. Since draft-ietf-quic-tls-08 2280 * Specify value for max_early_data_size to enable 0-RTT (#942) 2282 * Update key derivation function (#1003, #1004) 2284 B.17. Since draft-ietf-quic-tls-07 2286 * Handshake errors can be reported with CONNECTION_CLOSE (#608, 2287 #891) 2289 B.18. Since draft-ietf-quic-tls-05 2291 No significant changes. 2293 B.19. Since draft-ietf-quic-tls-04 2295 * Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 2297 B.20. Since draft-ietf-quic-tls-03 2299 No significant changes. 2301 B.21. Since draft-ietf-quic-tls-02 2303 * Updates to match changes in transport draft 2305 B.22. Since draft-ietf-quic-tls-01 2307 * Use TLS alerts to signal TLS errors (#272, #374) 2309 * Require ClientHello to fit in a single packet (#338) 2310 * The second client handshake flight is now sent in the clear (#262, 2311 #337) 2313 * The QUIC header is included as AEAD Associated Data (#226, #243, 2314 #302) 2316 * Add interface necessary for client address validation (#275) 2318 * Define peer authentication (#140) 2320 * Require at least TLS 1.3 (#138) 2322 * Define transport parameters as a TLS extension (#122) 2324 * Define handling for protected packets before the handshake 2325 completes (#39) 2327 * Decouple QUIC version and ALPN (#12) 2329 B.23. Since draft-ietf-quic-tls-00 2331 * Changed bit used to signal key phase 2333 * Updated key phase markings during the handshake 2335 * Added TLS interface requirements section 2337 * Moved to use of TLS exporters for key derivation 2339 * Moved TLS error code definitions into this document 2341 B.24. Since draft-thomson-quic-tls-01 2343 * Adopted as base for draft-ietf-quic-tls 2345 * Updated authors/editors list 2347 * Added status note 2349 Contributors 2351 The IETF QUIC Working Group received an enormous amount of support 2352 from many people. The following people provided substantive 2353 contributions to this document: Adam Langley, Alessandro Ghedini, 2354 Christian Huitema, Christopher Wood, David Schinazi, Dragana 2355 Damjanovic, Eric Rescorla, Ian Swett, Jana Iyengar, 奥 一穂 (Kazuho 2356 Oku), Marten Seemann, Martin Duke, Mike Bishop, Mikkel Fahnøe 2357 Jørgensen, Nick Banks, Nick Harper, Roberto Peon, Rui Paulo, Ryan 2358 Hamilton, and Victor Vasiliev. 2360 Authors' Addresses 2362 Martin Thomson (editor) 2363 Mozilla 2365 Email: mt@lowentropy.net 2367 Sean Turner (editor) 2368 sn3rd 2370 Email: sean@sn3rd.com