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