idnits 2.17.00 (12 Aug 2021) /tmp/idnits58951/draft-ietf-quic-tls-23.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 (September 12, 2019) is 981 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 1663 -- Looks like a reference, but probably isn't: '2' on line 1665 -- Looks like a reference, but probably isn't: '3' on line 1667 -- Looks like a reference, but probably isn't: '0' on line 1757 == Unused Reference: 'QUIC-HTTP' is defined on line 1646, 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-23 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: March 15, 2020 sn3rd 6 September 12, 2019 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-23 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 March 15, 2020. 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 . . . . . . . . . . . . . . . . . . . . 8 65 4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 9 66 4.1.1. Handshake Complete . . . . . . . . . . . . . . . . . 10 67 4.1.2. Handshake Confirmed . . . . . . . . . . . . . . . . . 10 68 4.1.3. Sending and Receiving Handshake Messages . . . . . . 10 69 4.1.4. Encryption Level Changes . . . . . . . . . . . . . . 12 70 4.1.5. TLS Interface Summary . . . . . . . . . . . . . . . . 13 71 4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 14 72 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 14 73 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 15 74 4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 15 75 4.6. Accepting and Rejecting 0-RTT . . . . . . . . . . . . . . 16 76 4.7. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 16 77 4.8. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 16 78 4.9. Discarding Unused Keys . . . . . . . . . . . . . . . . . 17 79 4.9.1. Discarding Initial Keys . . . . . . . . . . . . . . . 17 80 4.9.2. Discarding Handshake Keys . . . . . . . . . . . . . . 18 81 4.9.3. Discarding 0-RTT Keys . . . . . . . . . . . . . . . . 18 82 5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 18 83 5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 18 84 5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 19 85 5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 20 86 5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 21 87 5.4.1. Header Protection Application . . . . . . . . . . . . 22 88 5.4.2. Header Protection Sample . . . . . . . . . . . . . . 23 89 5.4.3. AES-Based Header Protection . . . . . . . . . . . . . 24 90 5.4.4. ChaCha20-Based Header Protection . . . . . . . . . . 25 91 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 25 92 5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 25 93 5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 26 94 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 27 95 7. Security of Initial Messages . . . . . . . . . . . . . . . . 29 96 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 30 97 8.1. Protocol Negotiation . . . . . . . . . . . . . . . . . . 30 98 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 30 99 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 31 100 9. Security Considerations . . . . . . . . . . . . . . . . . . . 31 101 9.1. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 31 102 9.2. Packet Reflection Attack Mitigation . . . . . . . . . . . 32 103 9.3. Header Protection Analysis . . . . . . . . . . . . . . . 33 104 9.4. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 34 105 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 34 106 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 34 107 11.1. Normative References . . . . . . . . . . . . . . . . . . 34 108 11.2. Informative References . . . . . . . . . . . . . . . . . 36 109 11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 36 110 Appendix A. Sample Initial Packet Protection . . . . . . . . . . 36 111 A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 36 112 A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 38 113 A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 39 114 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 40 115 B.1. Since draft-ietf-quic-tls-22 . . . . . . . . . . . . . . 40 116 B.2. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 40 117 B.3. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 40 118 B.4. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 40 119 B.5. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 41 120 B.6. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 41 121 B.7. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 41 122 B.8. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 41 123 B.9. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 42 124 B.10. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 42 125 B.11. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 42 126 B.12. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 42 127 B.13. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 42 128 B.14. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 42 129 B.15. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 42 130 B.16. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 42 131 B.17. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 42 132 B.18. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 43 133 B.19. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 43 134 B.20. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 43 135 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 44 136 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 44 137 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 44 139 1. Introduction 141 This document describes how QUIC [QUIC-TRANSPORT] is secured using 142 TLS [TLS13]. 144 TLS 1.3 provides critical latency improvements for connection 145 establishment over previous versions. Absent packet loss, most new 146 connections can be established and secured within a single round 147 trip; on subsequent connections between the same client and server, 148 the client can often send application data immediately, that is, 149 using a zero round trip setup. 151 This document describes how TLS acts as a security component of QUIC. 153 2. Notational Conventions 155 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 156 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 157 "OPTIONAL" in this document are to be interpreted as described in BCP 158 14 [RFC2119] [RFC8174] when, and only when, they appear in all 159 capitals, as shown here. 161 This document uses the terminology established in [QUIC-TRANSPORT]. 163 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 164 newer version could be used (see Section 4.2). 166 2.1. TLS Overview 168 TLS provides two endpoints with a way to establish a means of 169 communication over an untrusted medium (that is, the Internet) that 170 ensures that messages they exchange cannot be observed, modified, or 171 forged. 173 Internally, TLS is a layered protocol, with the structure shown 174 below: 176 +--------------+--------------+--------------+ 177 | Handshake | Alerts | Application | 178 | Layer | | Data | 179 | | | | 180 +--------------+--------------+--------------+ 181 | | 182 | Record Layer | 183 | | 184 +--------------------------------------------+ 186 Each upper layer (handshake, alerts, and application data) is carried 187 as a series of typed TLS records. Records are individually 188 cryptographically protected and then transmitted over a reliable 189 transport (typically TCP) which provides sequencing and guaranteed 190 delivery. 192 Change Cipher Spec records cannot be sent in QUIC. 194 The TLS authenticated key exchange occurs between two entities: 195 client and server. The client initiates the exchange and the server 196 responds. If the key exchange completes successfully, both client 197 and server will agree on a secret. TLS supports both pre-shared key 198 (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for 199 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 200 keys are destroyed. 202 After completing the TLS handshake, the client will have learned and 203 authenticated an identity for the server and the server is optionally 204 able to learn and authenticate an identity for the client. TLS 205 supports X.509 [RFC5280] certificate-based authentication for both 206 server and client. 208 The TLS key exchange is resistant to tampering by attackers and it 209 produces shared secrets that cannot be controlled by either 210 participating peer. 212 TLS provides two basic handshake modes of interest to QUIC: 214 o A full 1-RTT handshake in which the client is able to send 215 application data after one round trip and the server immediately 216 responds after receiving the first handshake message from the 217 client. 219 o A 0-RTT handshake in which the client uses information it has 220 previously learned about the server to send application data 221 immediately. This application data can be replayed by an attacker 222 so it MUST NOT carry a self-contained trigger for any non- 223 idempotent action. 225 A simplified TLS handshake with 0-RTT application data is shown in 226 Figure 1. Note that this omits the EndOfEarlyData message, which is 227 not used in QUIC (see Section 8.3). 229 Client Server 231 ClientHello 232 (0-RTT Application Data) --------> 233 ServerHello 234 {EncryptedExtensions} 235 {Finished} 236 <-------- [Application Data] 237 {Finished} --------> 239 [Application Data] <-------> [Application Data] 241 () Indicates messages protected by early data (0-RTT) keys 242 {} Indicates messages protected using handshake keys 243 [] Indicates messages protected using application data 244 (1-RTT) keys 246 Figure 1: TLS Handshake with 0-RTT 248 Data is protected using a number of encryption levels: 250 o Initial Keys 252 o Early Data (0-RTT) Keys 254 o Handshake Keys 256 o Application Data (1-RTT) Keys 258 Application data may appear only in the early data and application 259 data levels. Handshake and Alert messages may appear in any level. 261 The 0-RTT handshake is only possible if the client and server have 262 previously communicated. In the 1-RTT handshake, the client is 263 unable to send protected application data until it has received all 264 of the handshake messages sent by the server. 266 3. Protocol Overview 268 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 269 and integrity protection of packets. For this it uses keys derived 270 from a TLS handshake [TLS13], but instead of carrying TLS records 271 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 272 directly over the QUIC transport, which takes over the 273 responsibilities of the TLS record layer, as shown below. 275 +--------------+--------------+ +-------------+ 276 | TLS | TLS | | QUIC | 277 | Handshake | Alerts | | Applications| 278 | | | | (h3, etc.) | 279 +--------------+--------------+-+-------------+ 280 | | 281 | QUIC Transport | 282 | (streams, reliability, congestion, etc.) | 283 | | 284 +---------------------------------------------+ 285 | | 286 | QUIC Packet Protection | 287 | | 288 +---------------------------------------------+ 290 QUIC also relies on TLS for authentication and negotiation of 291 parameters that are critical to security and performance. 293 Rather than a strict layering, these two protocols are co-dependent: 294 QUIC uses the TLS handshake; TLS uses the reliability, ordered 295 delivery, and record layer provided by QUIC. 297 At a high level, there are two main interactions between the TLS and 298 QUIC components: 300 o The TLS component sends and receives messages via the QUIC 301 component, with QUIC providing a reliable stream abstraction to 302 TLS. 304 o The TLS component provides a series of updates to the QUIC 305 component, including (a) new packet protection keys to install (b) 306 state changes such as handshake completion, the server 307 certificate, etc. 309 Figure 2 shows these interactions in more detail, with the QUIC 310 packet protection being called out specially. 312 +------------+ +------------+ 313 | |<- Handshake Messages ->| | 314 | |<---- 0-RTT Keys -------| | 315 | |<--- Handshake Keys-----| | 316 | QUIC |<---- 1-RTT Keys -------| TLS | 317 | |<--- Handshake Done ----| | 318 +------------+ +------------+ 319 | ^ 320 | Protect | Protected 321 v | Packet 322 +------------+ 323 | QUIC | 324 | Packet | 325 | Protection | 326 +------------+ 328 Figure 2: QUIC and TLS Interactions 330 Unlike TLS over TCP, QUIC applications which want to send data do not 331 send it through TLS "application_data" records. Rather, they send it 332 as QUIC STREAM frames or other frame types which are then carried in 333 QUIC packets. 335 4. Carrying TLS Messages 337 QUIC carries TLS handshake data in CRYPTO frames, each of which 338 consists of a contiguous block of handshake data identified by an 339 offset and length. Those frames are packaged into QUIC packets and 340 encrypted under the current TLS encryption level. As with TLS over 341 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 342 responsibility to deliver it reliably. Each chunk of data that is 343 produced by TLS is associated with the set of keys that TLS is 344 currently using. If QUIC needs to retransmit that data, it MUST use 345 the same keys even if TLS has already updated to newer keys. 347 One important difference between TLS records (used with TCP) and QUIC 348 CRYPTO frames is that in QUIC multiple frames may appear in the same 349 QUIC packet as long as they are associated with the same encryption 350 level. For instance, an implementation might bundle a Handshake 351 message and an ACK for some Handshake data into the same packet. 353 Some frames are prohibited in different encryption levels, others 354 cannot be sent. The rules here generalize those of TLS, in that 355 frames associated with establishing the connection can usually appear 356 at any encryption level, whereas those associated with transferring 357 data can only appear in the 0-RTT and 1-RTT encryption levels: 359 o PADDING frames MAY appear in packets of any encryption level. 361 o CRYPTO and CONNECTION_CLOSE frames MAY appear in packets of any 362 encryption level except 0-RTT. 364 o ACK frames MAY appear in packets of any encryption level other 365 than 0-RTT, but can only acknowledge packets which appeared in 366 that packet number space. 368 o All other frame types MUST only be sent in the 0-RTT and 1-RTT 369 levels. 371 Note that it is not possible to send the following frames in 0-RTT 372 for various reasons: ACK, CRYPTO, NEW_TOKEN, PATH_RESPONSE, and 373 RETIRE_CONNECTION_ID. 375 Because packets could be reordered on the wire, QUIC uses the packet 376 type to indicate which level a given packet was encrypted under, as 377 shown in Table 1. When multiple packets of different encryption 378 levels need to be sent, endpoints SHOULD use coalesced packets to 379 send them in the same UDP datagram. 381 +---------------------+------------------+-----------+ 382 | Packet Type | Encryption Level | PN Space | 383 +---------------------+------------------+-----------+ 384 | Initial | Initial secrets | Initial | 385 | | | | 386 | 0-RTT Protected | 0-RTT | 0/1-RTT | 387 | | | | 388 | Handshake | Handshake | Handshake | 389 | | | | 390 | Retry | N/A | N/A | 391 | | | | 392 | Version Negotiation | N/A | N/A | 393 | | | | 394 | Short Header | 1-RTT | 0/1-RTT | 395 +---------------------+------------------+-----------+ 397 Table 1: Encryption Levels by Packet Type 399 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 400 encryption levels fit into the handshake process. 402 4.1. Interface to TLS 404 As shown in Figure 2, the interface from QUIC to TLS consists of 405 three primary functions: 407 o Sending and receiving handshake messages 408 o Rekeying (both transmit and receive) 410 o Handshake state updates 412 Additional functions might be needed to configure TLS. 414 4.1.1. Handshake Complete 416 In this document, the TLS handshake is considered complete when the 417 TLS stack has reported that the handshake is complete. This happens 418 when the TLS stack has both sent a Finished message and verified the 419 peer's Finished message. Verifying the peer's Finished provides the 420 endpoints with an assurance that previous handshake messages have not 421 been modified. Note that the handshake does not complete at both 422 endpoints simultaneously. Consequently, any requirement that is 423 based on the completion of the handshake depends on the perspective 424 of the endpoint in question. 426 4.1.2. Handshake Confirmed 428 In this document, the TLS handshake is considered confirmed at an 429 endpoint when the following two conditions are met: the handshake is 430 complete, and the endpoint has received an acknowledgment for a 431 packet sent with 1-RTT keys. This second condition can be 432 implemented by recording the lowest packet number sent with 1-RTT 433 keys, and the highest value of the Largest Acknowledged field in any 434 received 1-RTT ACK frame: once the latter is higher than or equal to 435 the former, the handshake is confirmed. 437 4.1.3. Sending and Receiving Handshake Messages 439 In order to drive the handshake, TLS depends on being able to send 440 and receive handshake messages. There are two basic functions on 441 this interface: one where QUIC requests handshake messages and one 442 where QUIC provides handshake packets. 444 Before starting the handshake QUIC provides TLS with the transport 445 parameters (see Section 8.2) that it wishes to carry. 447 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 448 The client acquires handshake bytes before sending its first packet. 449 A QUIC server starts the process by providing TLS with the client's 450 handshake bytes. 452 At any given time, the TLS stack at an endpoint will have a current 453 sending encryption level and receiving encryption level. Each 454 encryption level is associated with a different flow of bytes, which 455 is reliably transmitted to the peer in CRYPTO frames. When TLS 456 provides handshake bytes to be sent, they are appended to the current 457 flow and any packet that includes the CRYPTO frame is protected using 458 keys from the corresponding encryption level. 460 QUIC takes the unprotected content of TLS handshake records as the 461 content of CRYPTO frames. TLS record protection is not used by QUIC. 462 QUIC assembles CRYPTO frames into QUIC packets, which are protected 463 using QUIC packet protection. 465 When an endpoint receives a QUIC packet containing a CRYPTO frame 466 from the network, it proceeds as follows: 468 o If the packet was in the TLS receiving encryption level, sequence 469 the data into the input flow as usual. As with STREAM frames, the 470 offset is used to find the proper location in the data sequence. 471 If the result of this process is that new data is available, then 472 it is delivered to TLS in order. 474 o If the packet is from a previously installed encryption level, it 475 MUST not contain data which extends past the end of previously 476 received data in that flow. Implementations MUST treat any 477 violations of this requirement as a connection error of type 478 PROTOCOL_VIOLATION. 480 o If the packet is from a new encryption level, it is saved for 481 later processing by TLS. Once TLS moves to receiving from this 482 encryption level, saved data can be provided. When providing data 483 from any new encryption level to TLS, if there is data from a 484 previous encryption level that TLS has not consumed, this MUST be 485 treated as a connection error of type PROTOCOL_VIOLATION. 487 Each time that TLS is provided with new data, new handshake bytes are 488 requested from TLS. TLS might not provide any bytes if the handshake 489 messages it has received are incomplete or it has no data to send. 491 Once the TLS handshake is complete, this is indicated to QUIC along 492 with any final handshake bytes that TLS needs to send. TLS also 493 provides QUIC with the transport parameters that the peer advertised 494 during the handshake. 496 Once the handshake is complete, TLS becomes passive. TLS can still 497 receive data from its peer and respond in kind, but it will not need 498 to send more data unless specifically requested - either by an 499 application or QUIC. One reason to send data is that the server 500 might wish to provide additional or updated session tickets to a 501 client. 503 When the handshake is complete, QUIC only needs to provide TLS with 504 any data that arrives in CRYPTO streams. In the same way that is 505 done during the handshake, new data is requested from TLS after 506 providing received data. 508 4.1.4. Encryption Level Changes 510 As keys for new encryption levels become available, TLS provides QUIC 511 with those keys. Separately, as keys at a given encryption level 512 become available to TLS, TLS indicates to QUIC that reading or 513 writing keys at that encryption level are available. These events 514 are not asynchronous; they always occur immediately after TLS is 515 provided with new handshake bytes, or after TLS produces handshake 516 bytes. 518 TLS provides QUIC with three items as a new encryption level becomes 519 available: 521 o A secret 523 o An Authenticated Encryption with Associated Data (AEAD) function 525 o A Key Derivation Function (KDF) 527 These values are based on the values that TLS negotiates and are used 528 by QUIC to generate packet and header protection keys (see Section 5 529 and Section 5.4). 531 If 0-RTT is possible, it is ready after the client sends a TLS 532 ClientHello message or the server receives that message. After 533 providing a QUIC client with the first handshake bytes, the TLS stack 534 might signal the change to 0-RTT keys. On the server, after 535 receiving handshake bytes that contain a ClientHello message, a TLS 536 server might signal that 0-RTT keys are available. 538 Although TLS only uses one encryption level at a time, QUIC may use 539 more than one level. For instance, after sending its Finished 540 message (using a CRYPTO frame at the Handshake encryption level) an 541 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 542 message is lost, the endpoint uses the Handshake encryption level to 543 retransmit the lost message. Reordering or loss of packets can mean 544 that QUIC will need to handle packets at multiple encryption levels. 545 During the handshake, this means potentially handling packets at 546 higher and lower encryption levels than the current encryption level 547 used by TLS. 549 In particular, server implementations need to be able to read packets 550 at the Handshake encryption level at the same time as the 0-RTT 551 encryption level. A client could interleave ACK frames that are 552 protected with Handshake keys with 0-RTT data and the server needs to 553 process those acknowledgments in order to detect lost Handshake 554 packets. 556 QUIC also needs access to keys that might not ordinarily be available 557 to a TLS implementation. For instance, a client might need to 558 acknowledge Handshake packets before it is ready to send CRYPTO 559 frames at that encryption level. TLS therefore needs to provide keys 560 to QUIC before it might produce them for its own use. 562 4.1.5. TLS Interface Summary 564 Figure 3 summarizes the exchange between QUIC and TLS for both client 565 and server. Each arrow is tagged with the encryption level used for 566 that transmission. 568 Client Server 570 Get Handshake 571 Initial -------------> 572 Handshake Received 573 Install tx 0-RTT Keys 574 0-RTT ---------------> 575 Get Handshake 576 <------------- Initial 577 Handshake Received 578 Install Handshake keys 579 Install rx 0-RTT keys 580 Install Handshake keys 581 Get Handshake 582 <----------- Handshake 583 Handshake Received 584 Install tx 1-RTT keys 585 <--------------- 1-RTT 586 Get Handshake 587 Handshake Complete 588 Handshake -----------> 589 Handshake Received 590 Install rx 1-RTT keys 591 Handshake Complete 592 Install 1-RTT keys 593 1-RTT ---------------> 594 Get Handshake 595 <--------------- 1-RTT 596 Handshake Received 598 Figure 3: Interaction Summary between QUIC and TLS 600 Figure 3 shows the multiple packets that form a single "flight" of 601 messages being processed individually, to show what incoming messages 602 trigger different actions. New handshake messages are requested 603 after all incoming packets have been processed. This process might 604 vary depending on how QUIC implementations and the packets they 605 receive are structured. 607 4.2. TLS Version 609 This document describes how TLS 1.3 [TLS13] is used with QUIC. 611 In practice, the TLS handshake will negotiate a version of TLS to 612 use. This could result in a newer version of TLS than 1.3 being 613 negotiated if both endpoints support that version. This is 614 acceptable provided that the features of TLS 1.3 that are used by 615 QUIC are supported by the newer version. 617 A badly configured TLS implementation could negotiate TLS 1.2 or 618 another older version of TLS. An endpoint MUST terminate the 619 connection if a version of TLS older than 1.3 is negotiated. 621 4.3. ClientHello Size 623 QUIC requires that the first Initial packet from a client contain an 624 entire cryptographic handshake message, which for TLS is the 625 ClientHello. Though a packet larger than 1200 bytes might be 626 supported by the path, a client improves the likelihood that a packet 627 is accepted if it ensures that the first ClientHello message is small 628 enough to stay within this limit. 630 QUIC packet and framing add at least 36 bytes of overhead to the 631 ClientHello message. That overhead increases if the client chooses a 632 connection ID without zero length. Overheads also do not include the 633 token or a connection ID longer than 8 bytes, both of which might be 634 required if a server sends a Retry packet. 636 A typical TLS ClientHello can easily fit into a 1200 byte packet. 637 However, in addition to the overheads added by QUIC, there are 638 several variables that could cause this limit to be exceeded. Large 639 session tickets, multiple or large key shares, and long lists of 640 supported ciphers, signature algorithms, versions, QUIC transport 641 parameters, and other negotiable parameters and extensions could 642 cause this message to grow. 644 For servers, in addition to connection IDs and tokens, the size of 645 TLS session tickets can have an effect on a client's ability to 646 connect. Minimizing the size of these values increases the 647 probability that they can be successfully used by a client. 649 A client is not required to fit the ClientHello that it sends in 650 response to a HelloRetryRequest message into a single UDP datagram. 652 The TLS implementation does not need to ensure that the ClientHello 653 is sufficiently large. QUIC PADDING frames are added to increase the 654 size of the packet as necessary. 656 4.4. Peer Authentication 658 The requirements for authentication depend on the application 659 protocol that is in use. TLS provides server authentication and 660 permits the server to request client authentication. 662 A client MUST authenticate the identity of the server. This 663 typically involves verification that the identity of the server is 664 included in a certificate and that the certificate is issued by a 665 trusted entity (see for example [RFC2818]). 667 A server MAY request that the client authenticate during the 668 handshake. A server MAY refuse a connection if the client is unable 669 to authenticate when requested. The requirements for client 670 authentication vary based on application protocol and deployment. 672 A server MUST NOT use post-handshake client authentication (see 673 Section 4.6.2 of [TLS13]). 675 4.5. Enabling 0-RTT 677 In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket 678 message that contains the "early_data" extension with a 679 max_early_data_size of 0xffffffff; the amount of data which the 680 client can send in 0-RTT is controlled by the "initial_max_data" 681 transport parameter supplied by the server. A client MUST treat 682 receipt of a NewSessionTicket that contains an "early_data" extension 683 with any other value as a connection error of type 684 PROTOCOL_VIOLATION. 686 A client that wishes to send 0-RTT packets uses the "early_data" 687 extension in the ClientHello message of a subsequent handshake (see 688 Section 4.2.10 of [TLS13]). It then sends the application data in 689 0-RTT packets. 691 Early data within the TLS connection MUST NOT be used. As it is for 692 other TLS application data, a server MUST treat receiving early data 693 on the TLS connection as a connection error of type 694 PROTOCOL_VIOLATION. 696 4.6. Accepting and Rejecting 0-RTT 698 A server accepts 0-RTT by sending an early_data extension in the 699 EncryptedExtensions (see Section 4.2.10 of [TLS13]). The server then 700 processes and acknowledges the 0-RTT packets that it receives. 702 A server rejects 0-RTT by sending the EncryptedExtensions without an 703 early_data extension. A server will always reject 0-RTT if it sends 704 a TLS HelloRetryRequest. When rejecting 0-RTT, a server MUST NOT 705 process any 0-RTT packets, even if it could. When 0-RTT was 706 rejected, a client SHOULD treat receipt of an acknowledgement for a 707 0-RTT packet as a connection error of type PROTOCOL_VIOLATION, if it 708 is able to detect the condition. 710 When 0-RTT is rejected, all connection characteristics that the 711 client assumed might be incorrect. This includes the choice of 712 application protocol, transport parameters, and any application 713 configuration. The client therefore MUST reset the state of all 714 streams, including application state bound to those streams. 716 A client MAY attempt to send 0-RTT again if it receives a Retry or 717 Version Negotiation packet. These packets do not signify rejection 718 of 0-RTT. 720 4.7. HelloRetryRequest 722 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 723 [TLS13]) can be used to correct a client's incorrect KeyShare 724 extension as well as for a stateless round-trip check. From the 725 perspective of QUIC, this just looks like additional messages carried 726 in the Initial encryption level. Although it is in principle 727 possible to use this feature for address verification in QUIC, QUIC 728 implementations SHOULD instead use the Retry feature (see Section 8.1 729 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 730 shares. 732 4.8. TLS Errors 734 If TLS experiences an error, it generates an appropriate alert as 735 defined in Section 6 of [TLS13]. 737 A TLS alert is turned into a QUIC connection error by converting the 738 one-byte alert description into a QUIC error code. The alert 739 description is added to 0x100 to produce a QUIC error code from the 740 range reserved for CRYPTO_ERROR. The resulting value is sent in a 741 QUIC CONNECTION_CLOSE frame. 743 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 744 generate alerts at the "warning" level. 746 4.9. Discarding Unused Keys 748 After QUIC moves to a new encryption level, packet protection keys 749 for previous encryption levels can be discarded. This occurs several 750 times during the handshake, as well as when keys are updated; see 751 Section 6. 753 Packet protection keys are not discarded immediately when new keys 754 are available. If packets from a lower encryption level contain 755 CRYPTO frames, frames that retransmit that data MUST be sent at the 756 same encryption level. Similarly, an endpoint generates 757 acknowledgements for packets at the same encryption level as the 758 packet being acknowledged. Thus, it is possible that keys for a 759 lower encryption level are needed for a short time after keys for a 760 newer encryption level are available. 762 An endpoint cannot discard keys for a given encryption level unless 763 it has both received and acknowledged all CRYPTO frames for that 764 encryption level and when all CRYPTO frames for that encryption level 765 have been acknowledged by its peer. However, this does not guarantee 766 that no further packets will need to be received or sent at that 767 encryption level because a peer might not have received all the 768 acknowledgements necessary to reach the same state. 770 Though an endpoint might retain older keys, new data MUST be sent at 771 the highest currently-available encryption level. Only ACK frames 772 and retransmissions of data in CRYPTO frames are sent at a previous 773 encryption level. These packets MAY also include PADDING frames. 775 4.9.1. Discarding Initial Keys 777 Packets protected with Initial secrets (Section 5.2) are not 778 authenticated, meaning that an attacker could spoof packets with the 779 intent to disrupt a connection. To limit these attacks, Initial 780 packet protection keys can be discarded more aggressively than other 781 keys. 783 The successful use of Handshake packets indicates that no more 784 Initial packets need to be exchanged, as these keys can only be 785 produced after receiving all CRYPTO frames from Initial packets. 786 Thus, a client MUST discard Initial keys when it first sends a 787 Handshake packet and a server MUST discard Initial keys when it first 788 successfully processes a Handshake packet. Endpoints MUST NOT send 789 Initial packets after this point. 791 This results in abandoning loss recovery state for the Initial 792 encryption level and ignoring any outstanding Initial packets. 794 4.9.2. Discarding Handshake Keys 796 An endpoint MUST NOT discard its handshake keys until the TLS 797 handshake is confirmed (Section 4.1.2). An endpoint SHOULD discard 798 its handshake keys as soon as it has confirmed the handshake. Most 799 application protocols will send data after the handshake, resulting 800 in acknowledgements that allow both endpoints to discard their 801 handshake keys promptly. Endpoints that do not have reason to send 802 immediately after completing the handshake MAY send ack-eliciting 803 frames, such as PING, which will cause the handshake to be confirmed 804 when they are acknowledged. 806 4.9.3. Discarding 0-RTT Keys 808 0-RTT and 1-RTT packets share the same packet number space, and 809 clients do not send 0-RTT packets after sending a 1-RTT packet 810 (Section 5.6). 812 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 813 1-RTT keys, since they have no use after that moment. 815 Additionally, a server MAY discard 0-RTT keys as soon as it receives 816 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 817 could arrive after a 1-RTT packet. Servers MAY temporarily retain 818 0-RTT keys to allow decrypting reordered packets without requiring 819 their contents to be retransmitted with 1-RTT keys. After receiving 820 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 821 the RECOMMENDED time period is three times the Probe Timeout (PTO, 822 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 823 determines that it has received all 0-RTT packets, which can be done 824 by keeping track of missing packet numbers. 826 5. Packet Protection 828 As with TLS over TCP, QUIC protects packets with keys derived from 829 the TLS handshake, using the AEAD algorithm negotiated by TLS. 831 5.1. Packet Protection Keys 833 QUIC derives packet protection keys in the same way that TLS derives 834 record protection keys. 836 Each encryption level has separate secret values for protection of 837 packets sent in each direction. These traffic secrets are derived by 838 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 839 encryption levels except the Initial encryption level. The secrets 840 for the Initial encryption level are computed based on the client's 841 initial Destination Connection ID, as described in Section 5.2. 843 The keys used for packet protection are computed from the TLS secrets 844 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 845 function described in Section 7.1 of [TLS13] is used, using the hash 846 function from the negotiated cipher suite. Other versions of TLS 847 MUST provide a similar function in order to be used with QUIC. 849 The current encryption level secret and the label "quic key" are 850 input to the KDF to produce the AEAD key; the label "quic iv" is used 851 to derive the IV; see Section 5.3. The header protection key uses 852 the "quic hp" label; see Section 5.4. Using these labels provides 853 key separation between QUIC and TLS; see Section 9.4. 855 The KDF used for initial secrets is always the HKDF-Expand-Label 856 function from TLS 1.3 (see Section 5.2). 858 5.2. Initial Secrets 860 Initial packets are protected with a secret derived from the 861 Destination Connection ID field from the client's first Initial 862 packet of the connection. Specifically: 864 initial_salt = 0xc3eef712c72ebb5a11a7d2432bb46365bef9f502 865 initial_secret = HKDF-Extract(initial_salt, 866 client_dst_connection_id) 868 client_initial_secret = HKDF-Expand-Label(initial_secret, 869 "client in", "", 870 Hash.length) 871 server_initial_secret = HKDF-Expand-Label(initial_secret, 872 "server in", "", 873 Hash.length) 875 The hash function for HKDF when deriving initial secrets and keys is 876 SHA-256 [SHA]. 878 The connection ID used with HKDF-Expand-Label is the Destination 879 Connection ID in the Initial packet sent by the client. This will be 880 a randomly-selected value unless the client creates the Initial 881 packet after receiving a Retry packet, where the Destination 882 Connection ID is selected by the server. 884 The value of initial_salt is a 20 byte sequence shown in the figure 885 in hexadecimal notation. Future versions of QUIC SHOULD generate a 886 new salt value, thus ensuring that the keys are different for each 887 version of QUIC. This prevents a middlebox that only recognizes one 888 version of QUIC from seeing or modifying the contents of packets from 889 future versions. 891 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 892 Initial packets even where the TLS versions offered do not include 893 TLS 1.3. 895 Appendix A contains test vectors for the initial packet encryption. 897 Note: The Destination Connection ID is of arbitrary length, and it 898 could be zero length if the server sends a Retry packet with a 899 zero-length Source Connection ID field. In this case, the Initial 900 keys provide no assurance to the client that the server received 901 its packet; the client has to rely on the exchange that included 902 the Retry packet for that property. 904 5.3. AEAD Usage 906 The Authentication Encryption with Associated Data (AEAD) [AEAD] 907 function used for QUIC packet protection is the AEAD that is 908 negotiated for use with the TLS connection. For example, if TLS is 909 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 910 used. 912 Packets are protected prior to applying header protection 913 (Section 5.4). The unprotected packet header is part of the 914 associated data (A). When removing packet protection, an endpoint 915 first removes the header protection. 917 All QUIC packets other than Version Negotiation and Retry packets are 918 protected with an AEAD algorithm [AEAD]. Prior to establishing a 919 shared secret, packets are protected with AEAD_AES_128_GCM and a key 920 derived from the Destination Connection ID in the client's first 921 Initial packet (see Section 5.2). This provides protection against 922 off-path attackers and robustness against QUIC version unaware 923 middleboxes, but not against on-path attackers. 925 QUIC can use any of the ciphersuites defined in [TLS13] with the 926 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 927 negotiated unless a header protection scheme is defined for the 928 ciphersuite. This document defines a header protection scheme for 929 all ciphersuites defined in [TLS13] aside from 930 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 931 authentication tag and produce an output 16 bytes larger than their 932 input. 934 Note: An endpoint MUST NOT reject a ClientHello that offers a 935 ciphersuite that it does not support, or it would be impossible to 936 deploy a new ciphersuite. This also applies to 937 TLS_AES_128_CCM_8_SHA256. 939 The key and IV for the packet are computed as described in 940 Section 5.1. The nonce, N, is formed by combining the packet 941 protection IV with the packet number. The 62 bits of the 942 reconstructed QUIC packet number in network byte order are left- 943 padded with zeros to the size of the IV. The exclusive OR of the 944 padded packet number and the IV forms the AEAD nonce. 946 The associated data, A, for the AEAD is the contents of the QUIC 947 header, starting from the flags byte in either the short or long 948 header, up to and including the unprotected packet number. 950 The input plaintext, P, for the AEAD is the payload of the QUIC 951 packet, as described in [QUIC-TRANSPORT]. 953 The output ciphertext, C, of the AEAD is transmitted in place of P. 955 Some AEAD functions have limits for how many packets can be encrypted 956 under the same key and IV (see for example [AEBounds]). This might 957 be lower than the packet number limit. An endpoint MUST initiate a 958 key update (Section 6) prior to exceeding any limit set for the AEAD 959 that is in use. 961 5.4. Header Protection 963 Parts of QUIC packet headers, in particular the Packet Number field, 964 are protected using a key that is derived separate to the packet 965 protection key and IV. The key derived using the "quic hp" label is 966 used to provide confidentiality protection for those fields that are 967 not exposed to on-path elements. 969 This protection applies to the least-significant bits of the first 970 byte, plus the Packet Number field. The four least-significant bits 971 of the first byte are protected for packets with long headers; the 972 five least significant bits of the first byte are protected for 973 packets with short headers. For both header forms, this covers the 974 reserved bits and the Packet Number Length field; the Key Phase bit 975 is also protected for packets with a short header. 977 The same header protection key is used for the duration of the 978 connection, with the value not changing after a key update (see 979 Section 6). This allows header protection to be used to protect the 980 key phase. 982 This process does not apply to Retry or Version Negotiation packets, 983 which do not contain a protected payload or any of the fields that 984 are protected by this process. 986 5.4.1. Header Protection Application 988 Header protection is applied after packet protection is applied (see 989 Section 5.3). The ciphertext of the packet is sampled and used as 990 input to an encryption algorithm. The algorithm used depends on the 991 negotiated AEAD. 993 The output of this algorithm is a 5 byte mask which is applied to the 994 protected header fields using exclusive OR. The least significant 995 bits of the first byte of the packet are masked by the least 996 significant bits of the first mask byte, and the packet number is 997 masked with the remaining bytes. Any unused bytes of mask that might 998 result from a shorter packet number encoding are unused. 1000 Figure 4 shows a sample algorithm for applying header protection. 1001 Removing header protection only differs in the order in which the 1002 packet number length (pn_length) is determined. 1004 mask = header_protection(hp_key, sample) 1006 pn_length = (packet[0] & 0x03) + 1 1007 if (packet[0] & 0x80) == 0x80: 1008 # Long header: 4 bits masked 1009 packet[0] ^= mask[0] & 0x0f 1010 else: 1011 # Short header: 5 bits masked 1012 packet[0] ^= mask[0] & 0x1f 1014 # pn_offset is the start of the Packet Number field. 1015 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 1017 Figure 4: Header Protection Pseudocode 1019 Figure 5 shows the protected fields of long and short headers marked 1020 with an E. Figure 5 also shows the sampled fields. 1022 Long Header: 1023 +-+-+-+-+-+-+-+-+ 1024 |1|1|T T|E E E E| 1025 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1026 | Version -> Length Fields ... 1027 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1029 Short Header: 1030 +-+-+-+-+-+-+-+-+ 1031 |0|1|S|E E E E E| 1032 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1033 | Destination Connection ID (0/32..144) ... 1034 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1036 Common Fields: 1037 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1038 |E E E E E E E E E Packet Number (8/16/24/32) E E E E E E E E... 1039 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1040 | [Protected Payload (8/16/24)] ... 1041 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1042 | Sampled part of Protected Payload (128) ... 1043 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1044 | Protected Payload Remainder (*) ... 1045 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1047 Figure 5: Header Protection and Ciphertext Sample 1049 Before a TLS ciphersuite can be used with QUIC, a header protection 1050 algorithm MUST be specified for the AEAD used with that ciphersuite. 1051 This document defines algorithms for AEAD_AES_128_GCM, 1052 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1053 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1054 a ciphersuite, AES header protection is used (Section 5.4.3), 1055 matching the AEAD_AES_128_GCM packet protection. 1057 5.4.2. Header Protection Sample 1059 The header protection algorithm uses both the header protection key 1060 and a sample of the ciphertext from the packet Payload field. 1062 The same number of bytes are always sampled, but an allowance needs 1063 to be made for the endpoint removing protection, which will not know 1064 the length of the Packet Number field. In sampling the packet 1065 ciphertext, the Packet Number field is assumed to be 4 bytes long 1066 (its maximum possible encoded length). 1068 An endpoint MUST discard packets that are not long enough to contain 1069 a complete sample. 1071 To ensure that sufficient data is available for sampling, packets are 1072 padded so that the combined lengths of the encoded packet number and 1073 protected payload is at least 4 bytes longer than the sample required 1074 for header protection. The ciphersuites defined in [TLS13] - other 1075 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1076 is not defined in this document - have 16-byte expansions and 16-byte 1077 header protection samples. This results in needing at least 3 bytes 1078 of frames in the unprotected payload if the packet number is encoded 1079 on a single byte, or 2 bytes of frames for a 2-byte packet number 1080 encoding. 1082 The sampled ciphertext for a packet with a short header can be 1083 determined by the following pseudocode: 1085 sample_offset = 1 + len(connection_id) + 4 1087 sample = packet[sample_offset..sample_offset+sample_length] 1089 For example, for a packet with a short header, an 8 byte connection 1090 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1091 28 inclusive (using zero-based indexing). 1093 A packet with a long header is sampled in the same way, noting that 1094 multiple QUIC packets might be included in the same UDP datagram and 1095 that each one is handled separately. 1097 sample_offset = 7 + len(destination_connection_id) + 1098 len(source_connection_id) + 1099 len(payload_length) + 4 1100 if packet_type == Initial: 1101 sample_offset += len(token_length) + 1102 len(token) 1104 sample = packet[sample_offset..sample_offset+sample_length] 1106 5.4.3. AES-Based Header Protection 1108 This section defines the packet protection algorithm for 1109 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1110 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1111 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1112 in ECB mode. 1114 This algorithm samples 16 bytes from the packet ciphertext. This 1115 value is used as the input to AES-ECB. In pseudocode: 1117 mask = AES-ECB(hp_key, sample) 1119 5.4.4. ChaCha20-Based Header Protection 1121 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1122 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1123 256-bit key and 16 bytes sampled from the packet protection output. 1125 The first 4 bytes of the sampled ciphertext are the block counter. A 1126 ChaCha20 implementation could take a 32-bit integer in place of a 1127 byte sequence, in which case the byte sequence is interpreted as a 1128 little-endian value. 1130 The remaining 12 bytes are used as the nonce. A ChaCha20 1131 implementation might take an array of three 32-bit integers in place 1132 of a byte sequence, in which case the nonce bytes are interpreted as 1133 a sequence of 32-bit little-endian integers. 1135 The encryption mask is produced by invoking ChaCha20 to protect 5 1136 zero bytes. In pseudocode: 1138 counter = sample[0..3] 1139 nonce = sample[4..15] 1140 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1142 5.5. Receiving Protected Packets 1144 Once an endpoint successfully receives a packet with a given packet 1145 number, it MUST discard all packets in the same packet number space 1146 with higher packet numbers if they cannot be successfully unprotected 1147 with either the same key, or - if there is a key update - the next 1148 packet protection key (see Section 6). Similarly, a packet that 1149 appears to trigger a key update, but cannot be unprotected 1150 successfully MUST be discarded. 1152 Failure to unprotect a packet does not necessarily indicate the 1153 existence of a protocol error in a peer or an attack. The truncated 1154 packet number encoding used in QUIC can cause packet numbers to be 1155 decoded incorrectly if they are delayed significantly. 1157 5.6. Use of 0-RTT Keys 1159 If 0-RTT keys are available (see Section 4.5), the lack of replay 1160 protection means that restrictions on their use are necessary to 1161 avoid replay attacks on the protocol. 1163 A client MUST only use 0-RTT keys to protect data that is idempotent. 1164 A client MAY wish to apply additional restrictions on what data it 1165 sends prior to the completion of the TLS handshake. A client 1166 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1167 it MUST NOT send ACKs with 0-RTT keys. 1169 A client that receives an indication that its 0-RTT data has been 1170 accepted by a server can send 0-RTT data until it receives all of the 1171 server's handshake messages. A client SHOULD stop sending 0-RTT data 1172 if it receives an indication that 0-RTT data has been rejected. 1174 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1175 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1176 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1177 them. 1179 Once a client has installed 1-RTT keys, it MUST NOT send any more 1180 0-RTT packets. 1182 Note: 0-RTT data can be acknowledged by the server as it receives 1183 it, but any packets containing acknowledgments of 0-RTT data 1184 cannot have packet protection removed by the client until the TLS 1185 handshake is complete. The 1-RTT keys necessary to remove packet 1186 protection cannot be derived until the client receives all server 1187 handshake messages. 1189 5.7. Receiving Out-of-Order Protected Frames 1191 Due to reordering and loss, protected packets might be received by an 1192 endpoint before the final TLS handshake messages are received. A 1193 client will be unable to decrypt 1-RTT packets from the server, 1194 whereas a server will be able to decrypt 1-RTT packets from the 1195 client. 1197 Even though 1-RTT keys are available to a server after receiving the 1198 first handshake messages from a client, it is missing assurances on 1199 the client state: 1201 o The client is not authenticated, unless the server has chosen to 1202 use a pre-shared key and validated the client's pre-shared key 1203 binder; see Section 4.2.11 of [TLS13]. 1205 o The client has not demonstrated liveness, unless a RETRY packet 1206 was used. 1208 o Any received 0-RTT data that the server responds to might be due 1209 to a replay attack. 1211 Therefore, the server's use of 1-RTT keys is limited before the 1212 handshake is complete. A server MUST NOT process data from incoming 1213 1-RTT protected packets before the TLS handshake is complete. 1215 Because sending acknowledgments indicates that all frames in a packet 1216 have been processed, a server cannot send acknowledgments for 1-RTT 1217 packets until the TLS handshake is complete. Received packets 1218 protected with 1-RTT keys MAY be stored and later decrypted and used 1219 once the handshake is complete. 1221 The requirement for the server to wait for the client Finished 1222 message creates a dependency on that message being delivered. A 1223 client can avoid the potential for head-of-line blocking that this 1224 implies by sending its 1-RTT packets coalesced with a handshake 1225 packet containing a copy of the CRYPTO frame that carries the 1226 Finished message, until one of the handshake packets is acknowledged. 1227 This enables immediate server processing for those packets. 1229 A server could receive packets protected with 0-RTT keys prior to 1230 receiving a TLS ClientHello. The server MAY retain these packets for 1231 later decryption in anticipation of receiving a ClientHello. 1233 6. Key Update 1235 Once the handshake is confirmed, it is possible to update the keys. 1236 The KEY_PHASE bit in the short header is used to indicate whether key 1237 updates have occurred. The KEY_PHASE bit is initially set to 0 and 1238 then inverted with each key update. 1240 The KEY_PHASE bit allows a recipient to detect a change in keying 1241 material without necessarily needing to receive the first packet that 1242 triggered the change. An endpoint that notices a changed KEY_PHASE 1243 bit can update keys and decrypt the packet that contains the changed 1244 bit. 1246 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1247 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1248 of a TLS KeyUpdate message as a connection error of type 0x10a, 1249 equivalent to a fatal TLS alert of unexpected_message (see 1250 Section 4.8). 1252 An endpoint MUST NOT initiate the first key update until the 1253 handshake is confirmed (Section 4.1.2). An endpoint MUST NOT 1254 initiate a subsequent key update until it has received an 1255 acknowledgment for a packet sent at the current KEY_PHASE. This can 1256 be implemented by tracking the lowest packet number sent with each 1257 KEY_PHASE, and the highest acknowledged packet number in the 1-RTT 1258 space: once the latter is higher than or equal to the former, another 1259 key update can be initiated. 1261 Endpoints MAY limit the number of keys they retain to two sets for 1262 removing packet protection and one set for protecting packets. Older 1263 keys can be discarded. Updating keys multiple times rapidly can 1264 cause packets to be effectively lost if packets are significantly 1265 reordered. Therefore, an endpoint SHOULD NOT initiate a key update 1266 for some time after it has last updated keys; the RECOMMENDED time 1267 period is three times the PTO. This avoids valid reordered packets 1268 being dropped by the peer as a result of the peer discarding older 1269 keys. 1271 A receiving endpoint detects an update when the KEY_PHASE bit does 1272 not match what it is expecting. It creates a new secret (see 1273 Section 7.2 of [TLS13]) and the corresponding read key and IV using 1274 the KDF function provided by TLS. The header protection key is not 1275 updated. 1277 If the packet can be decrypted and authenticated using the updated 1278 key and IV, then the keys the endpoint uses for packet protection are 1279 also updated. The next packet sent by the endpoint MUST then use the 1280 new keys. Once an endpoint has sent a packet encrypted with a given 1281 key phase, it MUST NOT send a packet encrypted with an older key 1282 phase. 1284 An endpoint does not always need to send packets when it detects that 1285 its peer has updated keys. The next packet that it sends will simply 1286 use the new keys. If an endpoint detects a second update before it 1287 has sent any packets with updated keys, it indicates that its peer 1288 has updated keys twice without awaiting a reciprocal update. An 1289 endpoint MUST treat consecutive key updates as a fatal error and 1290 abort the connection. 1292 An endpoint SHOULD retain old keys for a period of no more than three 1293 times the PTO. After this period, old keys and their corresponding 1294 secrets SHOULD be discarded. Retaining keys allow endpoints to 1295 process packets that were sent with old keys and delayed in the 1296 network. Packets with higher packet numbers always use the updated 1297 keys and MUST NOT be decrypted with old keys. 1299 This ensures that once the handshake is complete, packets with the 1300 same KEY_PHASE will have the same packet protection keys, unless 1301 there are multiple key updates in a short time frame succession and 1302 significant packet reordering. 1304 Initiating Peer Responding Peer 1306 @M QUIC Frames 1307 New Keys -> @N 1308 @N QUIC Frames 1309 --------> 1310 QUIC Frames @M 1311 New Keys -> @N 1312 QUIC Frames @N 1313 <-------- 1315 Figure 6: Key Update 1317 A packet that triggers a key update could arrive after the receiving 1318 endpoint successfully processed a packet with a higher packet number. 1319 This is only possible if there is a key compromise and an attack, or 1320 if the peer is incorrectly reverting to use of old keys. Because the 1321 latter cannot be differentiated from an attack, an endpoint MUST 1322 immediately terminate the connection if it detects this condition. 1324 In deciding when to update keys, endpoints MUST NOT exceed the limits 1325 for use of specific keys, as described in Section 5.5 of [TLS13]. 1327 7. Security of Initial Messages 1329 Initial packets are not protected with a secret key, so they are 1330 subject to potential tampering by an attacker. QUIC provides 1331 protection against attackers that cannot read packets, but does not 1332 attempt to provide additional protection against attacks where the 1333 attacker can observe and inject packets. Some forms of tampering - 1334 such as modifying the TLS messages themselves - are detectable, but 1335 some - such as modifying ACKs - are not. 1337 For example, an attacker could inject a packet containing an ACK 1338 frame that makes it appear that a packet had not been received or to 1339 create a false impression of the state of the connection (e.g., by 1340 modifying the ACK Delay). Note that such a packet could cause a 1341 legitimate packet to be dropped as a duplicate. Implementations 1342 SHOULD use caution in relying on any data which is contained in 1343 Initial packets that is not otherwise authenticated. 1345 It is also possible for the attacker to tamper with data that is 1346 carried in Handshake packets, but because that tampering requires 1347 modifying TLS handshake messages, that tampering will cause the TLS 1348 handshake to fail. 1350 8. QUIC-Specific Additions to the TLS Handshake 1352 QUIC uses the TLS handshake for more than just negotiation of 1353 cryptographic parameters. The TLS handshake provides preliminary 1354 values for QUIC transport parameters and allows a server to perform 1355 return routability checks on clients. 1357 8.1. Protocol Negotiation 1359 QUIC requires that the cryptographic handshake provide authenticated 1360 protocol negotiation. TLS uses Application Layer Protocol 1361 Negotiation (ALPN) [RFC7301] to select an application protocol. 1362 Unless another mechanism is used for agreeing on an application 1363 protocol, endpoints MUST use ALPN for this purpose. When using ALPN, 1364 endpoints MUST immediately close a connection (see Section 10.3 in 1365 [QUIC-TRANSPORT]) if an application protocol is not negotiated with a 1366 no_application_protocol TLS alert (QUIC error code 0x178, see 1367 Section 4.8). While [RFC7301] only specifies that servers use this 1368 alert, QUIC clients MUST also use it to terminate a connection when 1369 ALPN negotiation fails. 1371 An application-layer protocol MAY restrict the QUIC versions that it 1372 can operate over. Servers MUST select an application protocol 1373 compatible with the QUIC version that the client has selected. If 1374 the server cannot select a compatible combination of application 1375 protocol and QUIC version, it MUST abort the connection. A client 1376 MUST abort a connection if the server picks an application protocol 1377 incompatible with the protocol version being used. 1379 8.2. QUIC Transport Parameters Extension 1381 QUIC transport parameters are carried in a TLS extension. Different 1382 versions of QUIC might define a different format for this struct. 1384 Including transport parameters in the TLS handshake provides 1385 integrity protection for these values. 1387 enum { 1388 quic_transport_parameters(0xffa5), (65535) 1389 } ExtensionType; 1391 The "extension_data" field of the quic_transport_parameters extension 1392 contains a value that is defined by the version of QUIC that is in 1393 use. The quic_transport_parameters extension carries a 1394 TransportParameters struct when the version of QUIC defined in 1395 [QUIC-TRANSPORT] is used. 1397 The quic_transport_parameters extension is carried in the ClientHello 1398 and the EncryptedExtensions messages during the handshake. Endpoints 1399 MUST send the quic_transport_parameters extension; endpoints that 1400 receive ClientHello or EncryptedExtensions messages without the 1401 quic_transport_parameters extension MUST close the connection with an 1402 error of type 0x16d (equivalent to a fatal TLS missing_extension 1403 alert, see Section 4.8). 1405 While the transport parameters are technically available prior to the 1406 completion of the handshake, they cannot be fully trusted until the 1407 handshake completes, and reliance on them should be minimized. 1408 However, any tampering with the parameters will cause the handshake 1409 to fail. 1411 Endpoints MUST NOT send this extension in a TLS connection that does 1412 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1413 fatal unsupported_extension alert MUST be sent by an implementation 1414 that supports this extension if the extension is received when the 1415 transport is not QUIC. 1417 8.3. Removing the EndOfEarlyData Message 1419 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1420 rely on this message to mark the end of 0-RTT data or to signal the 1421 change to Handshake keys. 1423 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1424 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1425 error of type PROTOCOL_VIOLATION. 1427 As a result, EndOfEarlyData does not appear in the TLS handshake 1428 transcript. 1430 9. Security Considerations 1432 There are likely to be some real clangers here eventually, but the 1433 current set of issues is well captured in the relevant sections of 1434 the main text. 1436 Never assume that because it isn't in the security considerations 1437 section it doesn't affect security. Most of this document does. 1439 9.1. Replay Attacks with 0-RTT 1441 As described in Section 8 of [TLS13], use of TLS early data comes 1442 with an exposure to replay attack. The use of 0-RTT in QUIC is 1443 similarly vulnerable to replay attack. 1445 Endpoints MUST implement and use the replay protections described in 1446 [TLS13], however it is recognized that these protections are 1447 imperfect. Therefore, additional consideration of the risk of replay 1448 is needed. 1450 QUIC is not vulnerable to replay attack, except via the application 1451 protocol information it might carry. The management of QUIC protocol 1452 state based on the frame types defined in [QUIC-TRANSPORT] is not 1453 vulnerable to replay. Processing of QUIC frames is idempotent and 1454 cannot result in invalid connection states if frames are replayed, 1455 reordered or lost. QUIC connections do not produce effects that last 1456 beyond the lifetime of the connection, except for those produced by 1457 the application protocol that QUIC serves. 1459 Note: TLS session tickets and address validation tokens are used to 1460 carry QUIC configuration information between connections. These 1461 MUST NOT be used to carry application semantics. The potential 1462 for reuse of these tokens means that they require stronger 1463 protections against replay. 1465 A server that accepts 0-RTT on a connection incurs a higher cost than 1466 accepting a connection without 0-RTT. This includes higher 1467 processing and computation costs. Servers need to consider the 1468 probability of replay and all associated costs when accepting 0-RTT. 1470 Ultimately, the responsibility for managing the risks of replay 1471 attacks with 0-RTT lies with an application protocol. An application 1472 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1473 the measures that are employed to protect against replay attack. An 1474 analysis of replay risk needs to consider all QUIC protocol features 1475 that carry application semantics. 1477 Disabling 0-RTT entirely is the most effective defense against replay 1478 attack. 1480 QUIC extensions MUST describe how replay attacks affect their 1481 operation, or prohibit their use in 0-RTT. Application protocols 1482 MUST either prohibit the use of extensions that carry application 1483 semantics in 0-RTT or provide replay mitigation strategies. 1485 9.2. Packet Reflection Attack Mitigation 1487 A small ClientHello that results in a large block of handshake 1488 messages from a server can be used in packet reflection attacks to 1489 amplify the traffic generated by an attacker. 1491 QUIC includes three defenses against this attack. First, the packet 1492 containing a ClientHello MUST be padded to a minimum size. Second, 1493 if responding to an unverified source address, the server is 1494 forbidden to send more than three UDP datagrams in its first flight 1495 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1496 acknowledgements of Handshake packets are authenticated, a blind 1497 attacker cannot forge them. Put together, these defenses limit the 1498 level of amplification. 1500 9.3. Header Protection Analysis 1502 Header protection relies on the packet protection AEAD being a 1503 pseudorandom function (PRF), which is not a property that AEAD 1504 algorithms guarantee. Therefore, no strong assurances about the 1505 general security of this mechanism can be shown in the general case. 1506 The AEAD algorithms described in this document are assumed to be 1507 PRFs. 1509 The header protection algorithms defined in this document take the 1510 form: 1512 protected_field = field XOR PRF(hp_key, sample) 1514 This construction is secure against chosen plaintext attacks (IND- 1515 CPA) [IMC]. 1517 Use of the same key and ciphertext sample more than once risks 1518 compromising header protection. Protecting two different headers 1519 with the same key and ciphertext sample reveals the exclusive OR of 1520 the protected fields. Assuming that the AEAD acts as a PRF, if L 1521 bits are sampled, the odds of two ciphertext samples being identical 1522 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1523 described in this document, that probability is one in 2^64. 1525 Note: In some cases, inputs shorter than the full size required by 1526 the packet protection algorithm might be used. 1528 To prevent an attacker from modifying packet headers, the header is 1529 transitively authenticated using packet protection; the entire packet 1530 header is part of the authenticated additional data. Protected 1531 fields that are falsified or modified can only be detected once the 1532 packet protection is removed. 1534 An attacker could guess values for packet numbers and have an 1535 endpoint confirm guesses through timing side channels. Similarly, 1536 guesses for the packet number length can be trialed and exposed. If 1537 the recipient of a packet discards packets with duplicate packet 1538 numbers without attempting to remove packet protection they could 1539 reveal through timing side-channels that the packet number matches a 1540 received packet. For authentication to be free from side-channels, 1541 the entire process of header protection removal, packet number 1542 recovery, and packet protection removal MUST be applied together 1543 without timing and other side-channels. 1545 For the sending of packets, construction and protection of packet 1546 payloads and packet numbers MUST be free from side-channels that 1547 would reveal the packet number or its encoded size. 1549 9.4. Key Diversity 1551 In using TLS, the central key schedule of TLS is used. As a result 1552 of the TLS handshake messages being integrated into the calculation 1553 of secrets, the inclusion of the QUIC transport parameters extension 1554 ensures that handshake and 1-RTT keys are not the same as those that 1555 might be produced by a server running TLS over TCP. To avoid the 1556 possibility of cross-protocol key synchronization, additional 1557 measures are provided to improve key separation. 1559 The QUIC packet protection keys and IVs are derived using a different 1560 label than the equivalent keys in TLS. 1562 To preserve this separation, a new version of QUIC SHOULD define new 1563 labels for key derivation for packet protection key and IV, plus the 1564 header protection keys. This version of QUIC uses the string "quic". 1565 Other versions can use a version-specific label in place of that 1566 string. 1568 The initial secrets use a key that is specific to the negotiated QUIC 1569 version. New QUIC versions SHOULD define a new salt value used in 1570 calculating initial secrets. 1572 10. IANA Considerations 1574 This document does not create any new IANA registries, but it 1575 registers the values in the following registries: 1577 o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register 1578 the quic_transport_parameters extension found in Section 8.2. The 1579 Recommended column is to be marked Yes. The TLS 1.3 Column is to 1580 include CH and EE. 1582 11. References 1584 11.1. Normative References 1586 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1587 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1588 . 1590 [AES] "Advanced encryption standard (AES)", National Institute 1591 of Standards and Technology report, 1592 DOI 10.6028/nist.fips.197, November 2001. 1594 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1595 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1596 . 1598 [QUIC-RECOVERY] 1599 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1600 and Congestion Control", draft-ietf-quic-recovery-23 (work 1601 in progress), September 2019. 1603 [QUIC-TRANSPORT] 1604 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1605 Multiplexed and Secure Transport", draft-ietf-quic- 1606 transport-23 (work in progress), September 2019. 1608 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1609 Requirement Levels", BCP 14, RFC 2119, 1610 DOI 10.17487/RFC2119, March 1997, 1611 . 1613 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1614 "Transport Layer Security (TLS) Application-Layer Protocol 1615 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1616 July 2014, . 1618 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1619 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1620 May 2017, . 1622 [SHA] Dang, Q., "Secure Hash Standard", National Institute of 1623 Standards and Technology report, 1624 DOI 10.6028/nist.fips.180-4, July 2015. 1626 [TLS-REGISTRIES] 1627 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 1628 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 1629 . 1631 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1632 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1633 . 1635 11.2. Informative References 1637 [AEBounds] 1638 Luykx, A. and K. Paterson, "Limits on Authenticated 1639 Encryption Use in TLS", March 2016, 1640 . 1642 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1643 Cryptography, Second Edition", ISBN 978-1466570269, 1644 November 2014. 1646 [QUIC-HTTP] 1647 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1648 QUIC", draft-ietf-quic-http-23 (work in progress), 1649 September 2019. 1651 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1652 DOI 10.17487/RFC2818, May 2000, 1653 . 1655 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1656 Housley, R., and W. Polk, "Internet X.509 Public Key 1657 Infrastructure Certificate and Certificate Revocation List 1658 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1659 . 1661 11.3. URIs 1663 [1] https://mailarchive.ietf.org/arch/search/?email_list=quic 1665 [2] https://github.com/quicwg 1667 [3] https://github.com/quicwg/base-drafts/labels/-tls 1669 Appendix A. Sample Initial Packet Protection 1671 This section shows examples of packet protection for Initial packets 1672 so that implementations can be verified incrementally. These packets 1673 use an 8-byte client-chosen Destination Connection ID of 1674 0x8394c8f03e515708. Values for both server and client packet 1675 protection are shown together with values in hexadecimal. 1677 A.1. Keys 1679 The labels generated by the HKDF-Expand-Label function are: 1681 client in: 00200f746c73313320636c69656e7420696e00 1682 server in: 00200f746c7331332073657276657220696e00 1684 quic key: 00100e746c7331332071756963206b657900 1686 quic iv: 000c0d746c733133207175696320697600 1688 quic hp: 00100d746c733133207175696320687000 1690 The initial secret is common: 1692 initial_secret = HKDF-Extract(initial_salt, cid) 1693 = 524e374c6da8cf8b496f4bcb69678350 1694 7aafee6198b202b4bc823ebf7514a423 1696 The secrets for protecting client packets are: 1698 client_initial_secret 1699 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 1700 = fda3953aecc040e48b34e27ef87de3a6 1701 098ecf0e38b7e032c5c57bcbd5975b84 1703 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 1704 = af7fd7efebd21878ff66811248983694 1706 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 1707 = 8681359410a70bb9c92f0420 1709 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 1710 = a980b8b4fb7d9fbc13e814c23164253d 1712 The secrets for protecting server packets are: 1714 server_initial_secret 1715 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 1716 = 554366b81912ff90be41f17e80222130 1717 90ab17d8149179bcadf222f29ff2ddd5 1719 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 1720 = 5d51da9ee897a21b2659ccc7e5bfa577 1722 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 1723 = 5e5ae651fd1e8495af13508b 1725 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 1726 = a8ed82e6664f865aedf6106943f95fb8 1728 A.2. Client Initial 1730 The client sends an Initial packet. The unprotected payload of this 1731 packet contains the following CRYPTO frame, plus enough PADDING 1732 frames to make an 1163 byte payload: 1734 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 1735 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 1736 736572766572ff01000100000a001400 12001d00170018001901000101010201 1737 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 1738 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 1739 05030603020308040805080604010501 060102010402050206020202002d0002 1740 0101001c00024001 1742 The unprotected header includes the connection ID and a 4 byte packet 1743 number encoding for a packet number of 2: 1745 c3ff000017088394c8f03e5157080000449e00000002 1747 Protecting the payload produces output that is sampled for header 1748 protection. Because the header uses a 4 byte packet number encoding, 1749 the first 16 bytes of the protected payload is sampled, then applied 1750 to the header: 1752 sample = 535064a4268a0d9d7b1c9d250ae35516 1754 mask = AES-ECB(hp, sample)[0..4] 1755 = 833b343aaa 1757 header[0] ^= mask[0] & 0x0f 1758 = c0 1759 header[17..20] ^= mask[1..4] 1760 = 3b343aa8 1761 header = c0ff000017088394c8f03e5157080000449e3b343aa8 1763 The resulting protected packet is: 1765 c0ff000017088394c8f03e5157080000 449e3b343aa8535064a4268a0d9d7b1c 1766 9d250ae355162276e9b1e3011ef6bbc0 ab48ad5bcc2681e953857ca62becd752 1767 4daac473e68d7405fbba4e9ee616c870 38bdbe908c06d9605d9ac49030359eec 1768 b1d05a14e117db8cede2bb09d0dbbfee 271cb374d8f10abec82d0f59a1dee29f 1769 e95638ed8dd41da07487468791b719c5 5c46968eb3b54680037102a28e53dc1d 1770 12903db0af5821794b41c4a93357fa59 ce69cfe7f6bdfa629eef78616447e1d6 1771 11c4baf71bf33febcb03137c2c75d253 17d3e13b684370f668411c0f00304b50 1772 1c8fd422bd9b9ad81d643b20da89ca05 25d24d2b142041cae0af205092e43008 1773 0cd8559ea4c5c6e4fa3f66082b7d303e 52ce0162baa958532b0bbc2bc785681f 1774 cf37485dff6595e01e739c8ac9efba31 b985d5f656cc092432d781db95221724 1775 87641c4d3ab8ece01e39bc85b1543661 4775a98ba8fa12d46f9b35e2a55eb72d 1776 7f85181a366663387ddc20551807e007 673bd7e26bf9b29b5ab10a1ca87cbb7a 1777 d97e99eb66959c2a9bc3cbde4707ff77 20b110fa95354674e395812e47a0ae53 1778 b464dcb2d1f345df360dc227270c7506 76f6724eb479f0d2fbb6124429990457 1779 ac6c9167f40aab739998f38b9eccb24f d47c8410131bf65a52af841275d5b3d1 1780 880b197df2b5dea3e6de56ebce3ffb6e 9277a82082f8d9677a6767089b671ebd 1781 244c214f0bde95c2beb02cd1172d58bd f39dce56ff68eb35ab39b49b4eac7c81 1782 5ea60451d6e6ab82119118df02a58684 4a9ffe162ba006d0669ef57668cab38b 1783 62f71a2523a084852cd1d079b3658dc2 f3e87949b550bab3e177cfc49ed190df 1784 f0630e43077c30de8f6ae081537f1e83 da537da980afa668e7b7fb25301cf741 1785 524be3c49884b42821f17552fbd1931a 813017b6b6590a41ea18b6ba49cd48a4 1786 40bd9a3346a7623fb4ba34a3ee571e3c 731f35a7a3cf25b551a680fa68763507 1787 b7fde3aaf023c50b9d22da6876ba337e b5e9dd9ec3daf970242b6c5aab3aa4b2 1788 96ad8b9f6832f686ef70fa938b31b4e5 ddd7364442d3ea72e73d668fb0937796 1789 f462923a81a47e1cee7426ff6d922126 9b5a62ec03d6ec94d12606cb485560ba 1790 b574816009e96504249385bb61a819be 04f62c2066214d8360a2022beb316240 1791 b6c7d78bbe56c13082e0ca272661210a bf020bf3b5783f1426436cf9ff418405 1792 93a5d0638d32fc51c5c65ff291a3a7a5 2fd6775e623a4439cc08dd25582febc9 1793 44ef92d8dbd329c91de3e9c9582e41f1 7f3d186f104ad3f90995116c682a2a14 1794 a3b4b1f547c335f0be710fc9fc03e0e5 87b8cda31ce65b969878a4ad4283e6d5 1795 b0373f43da86e9e0ffe1ae0fddd35162 55bd74566f36a38703d5f34249ded1f6 1796 6b3d9b45b9af2ccfefe984e13376b1b2 c6404aa48c8026132343da3f3a33659e 1797 c1b3e95080540b28b7f3fcd35fa5d843 b579a84c089121a60d8c1754915c344e 1798 eaf45a9bf27dc0c1e784161691220913 13eb0e87555abd706626e557fc36a04f 1799 cd191a58829104d6075c5594f627ca50 6bf181daec940f4a4f3af0074eee89da 1800 acde6758312622d4fa675b39f728e062 d2bee680d8f41a597c262648bb18bcfc 1801 13c8b3d97b1a77b2ac3af745d61a34cc 4709865bac824a94bb19058015e4e42d 1802 c9be6c7803567321829dd85853396269 1804 A.3. Server Initial 1806 The server sends the following payload in response, including an ACK 1807 frame, a CRYPTO frame, and no PADDING frames: 1809 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 1810 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 1811 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 1812 0304 1813 The header from the server includes a new connection ID and a 2-byte 1814 packet number encoding for a packet number of 1: 1816 c1ff0000170008f067a5502a4262b50040740001 1818 As a result, after protection, the header protection sample is taken 1819 starting from the third protected octet: 1821 sample = 7002596f99ae67abf65a5852f54f58c3 1822 mask = 38168a0c25 1823 header = c1ff0000170008f067a5502a4262b5004074168b 1825 The final protected packet is then: 1827 c9ff0000170008f067a5502a4262b500 4074168bf22b7002596f99ae67abf65a 1828 5852f54f58c37c808682e2e40492d8a3 899fb04fc0afe9aabc8767b18a0aa493 1829 537426373b48d502214dd856d63b78ce e37bc664b3fe86d487ac7a77c53038a3 1830 cd32f0b5004d9f5754c4f7f2d1f35cf3 f7116351c92b9cf9bb6d091ddfc8b32d 1831 432348a2c413 1833 Appendix B. Change Log 1835 *RFC Editor's Note:* Please remove this section prior to 1836 publication of a final version of this document. 1838 Issue and pull request numbers are listed with a leading octothorp. 1840 B.1. Since draft-ietf-quic-tls-22 1842 o Update the salt used for Initial secrets (#2887, #2980) 1844 B.2. Since draft-ietf-quic-tls-21 1846 o No changes 1848 B.3. Since draft-ietf-quic-tls-20 1850 o Mandate the use of the QUIC transport parameters extension (#2528, 1851 #2560) 1853 o Define handshake completion and confirmation; define clearer rules 1854 when it encryption keys should be discarded (#2214, #2267, #2673) 1856 B.4. Since draft-ietf-quic-tls-18 1858 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 1860 o Transport parameter extension is mandatory (#2528, #2560) 1862 B.5. Since draft-ietf-quic-tls-17 1864 o Endpoints discard initial keys as soon as handshake keys are 1865 available (#1951, #2045) 1867 o Use of ALPN or equivalent is mandatory (#2263, #2284) 1869 B.6. Since draft-ietf-quic-tls-14 1871 o Update the salt used for Initial secrets (#1970) 1873 o Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 1875 o Change header protection 1877 * Sample from a fixed offset (#1575, #2030) 1879 * Cover part of the first byte, including the key phase (#1322, 1880 #2006) 1882 o TLS provides an AEAD and KDF function (#2046) 1884 * Clarify that the TLS KDF is used with TLS (#1997) 1886 * Change the labels for calculation of QUIC keys (#1845, #1971, 1887 #1991) 1889 o Initial keys are discarded once Handshake are avaialble (#1951, 1890 #2045) 1892 B.7. Since draft-ietf-quic-tls-13 1894 o Updated to TLS 1.3 final (#1660) 1896 B.8. Since draft-ietf-quic-tls-12 1898 o Changes to integration of the TLS handshake (#829, #1018, #1094, 1899 #1165, #1190, #1233, #1242, #1252, #1450) 1901 * The cryptographic handshake uses CRYPTO frames, not stream 0 1903 * QUIC packet protection is used in place of TLS record 1904 protection 1906 * Separate QUIC packet number spaces are used for the handshake 1908 * Changed Retry to be independent of the cryptographic handshake 1909 * Limit the use of HelloRetryRequest to address TLS needs (like 1910 key shares) 1912 o Changed codepoint of TLS extension (#1395, #1402) 1914 B.9. Since draft-ietf-quic-tls-11 1916 o Encrypted packet numbers. 1918 B.10. Since draft-ietf-quic-tls-10 1920 o No significant changes. 1922 B.11. Since draft-ietf-quic-tls-09 1924 o Cleaned up key schedule and updated the salt used for handshake 1925 packet protection (#1077) 1927 B.12. Since draft-ietf-quic-tls-08 1929 o Specify value for max_early_data_size to enable 0-RTT (#942) 1931 o Update key derivation function (#1003, #1004) 1933 B.13. Since draft-ietf-quic-tls-07 1935 o Handshake errors can be reported with CONNECTION_CLOSE (#608, 1936 #891) 1938 B.14. Since draft-ietf-quic-tls-05 1940 No significant changes. 1942 B.15. Since draft-ietf-quic-tls-04 1944 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 1946 B.16. Since draft-ietf-quic-tls-03 1948 No significant changes. 1950 B.17. Since draft-ietf-quic-tls-02 1952 o Updates to match changes in transport draft 1954 B.18. Since draft-ietf-quic-tls-01 1956 o Use TLS alerts to signal TLS errors (#272, #374) 1958 o Require ClientHello to fit in a single packet (#338) 1960 o The second client handshake flight is now sent in the clear (#262, 1961 #337) 1963 o The QUIC header is included as AEAD Associated Data (#226, #243, 1964 #302) 1966 o Add interface necessary for client address validation (#275) 1968 o Define peer authentication (#140) 1970 o Require at least TLS 1.3 (#138) 1972 o Define transport parameters as a TLS extension (#122) 1974 o Define handling for protected packets before the handshake 1975 completes (#39) 1977 o Decouple QUIC version and ALPN (#12) 1979 B.19. Since draft-ietf-quic-tls-00 1981 o Changed bit used to signal key phase 1983 o Updated key phase markings during the handshake 1985 o Added TLS interface requirements section 1987 o Moved to use of TLS exporters for key derivation 1989 o Moved TLS error code definitions into this document 1991 B.20. Since draft-thomson-quic-tls-01 1993 o Adopted as base for draft-ietf-quic-tls 1995 o Updated authors/editors list 1997 o Added status note 1999 Acknowledgments 2001 This document has benefited from input from Dragana Damjanovic, 2002 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 2003 Rescorla, Ian Swett, and many others. 2005 Contributors 2007 Ryan Hamilton was originally an author of this specification. 2009 Authors' Addresses 2011 Martin Thomson (editor) 2012 Mozilla 2014 Email: mt@lowentropy.net 2016 Sean Turner (editor) 2017 sn3rd 2019 Email: sean@sn3rd.com