idnits 2.17.00 (12 Aug 2021) /tmp/idnits62605/draft-ietf-quic-tls-22.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 (July 09, 2019) is 1046 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 1639 -- Looks like a reference, but probably isn't: '2' on line 1641 -- Looks like a reference, but probably isn't: '3' on line 1643 -- Looks like a reference, but probably isn't: '0' on line 1733 == Unused Reference: 'QUIC-HTTP' is defined on line 1622, 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-22 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: January 10, 2020 sn3rd 6 July 09, 2019 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-22 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 January 10, 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 . . . . . . . . . . . . . . . . . . . . . . . 13 72 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 14 73 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 14 74 4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 15 75 4.6. Rejecting 0-RTT . . . . . . . . . . . . . . . . . . . . . 15 76 4.7. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 15 77 4.8. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 16 78 4.9. Discarding Unused Keys . . . . . . . . . . . . . . . . . 16 79 4.9.1. Discarding Initial Keys . . . . . . . . . . . . . . . 17 80 4.9.2. Discarding Handshake Keys . . . . . . . . . . . . . . 17 81 4.9.3. Discarding 0-RTT Keys . . . . . . . . . . . . . . . . 17 82 5. Packet Protection . . . . . . . . . . . . . . . . . . . . . . 18 83 5.1. Packet Protection Keys . . . . . . . . . . . . . . . . . 18 84 5.2. Initial Secrets . . . . . . . . . . . . . . . . . . . . . 18 85 5.3. AEAD Usage . . . . . . . . . . . . . . . . . . . . . . . 19 86 5.4. Header Protection . . . . . . . . . . . . . . . . . . . . 21 87 5.4.1. Header Protection Application . . . . . . . . . . . . 21 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 . . . . . . . . . . 24 91 5.5. Receiving Protected Packets . . . . . . . . . . . . . . . 24 92 5.6. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 25 93 5.7. Receiving Out-of-Order Protected Frames . . . . . . . . . 25 94 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 26 95 7. Security of Initial Messages . . . . . . . . . . . . . . . . 28 96 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 29 97 8.1. Protocol Negotiation . . . . . . . . . . . . . . . . . . 29 98 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 29 99 8.3. Removing the EndOfEarlyData Message . . . . . . . . . . . 30 100 9. Security Considerations . . . . . . . . . . . . . . . . . . . 30 101 9.1. Replay Attacks with 0-RTT . . . . . . . . . . . . . . . . 31 102 9.2. Packet Reflection Attack Mitigation . . . . . . . . . . . 32 103 9.3. Peer Denial of Service . . . . . . . . . . . . . . . . . 32 104 9.4. Header Protection Analysis . . . . . . . . . . . . . . . 32 105 9.5. Key Diversity . . . . . . . . . . . . . . . . . . . . . . 33 106 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 34 107 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 34 108 11.1. Normative References . . . . . . . . . . . . . . . . . . 34 109 11.2. Informative References . . . . . . . . . . . . . . . . . 35 110 11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 36 111 Appendix A. Sample Initial Packet Protection . . . . . . . . . . 36 112 A.1. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . 36 113 A.2. Client Initial . . . . . . . . . . . . . . . . . . . . . 37 114 A.3. Server Initial . . . . . . . . . . . . . . . . . . . . . 39 115 Appendix B. Change Log . . . . . . . . . . . . . . . . . . . . . 40 116 B.1. Since draft-ietf-quic-tls-21 . . . . . . . . . . . . . . 40 117 B.2. Since draft-ietf-quic-tls-20 . . . . . . . . . . . . . . 40 118 B.3. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 40 119 B.4. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 41 120 B.5. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 41 121 B.6. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 41 122 B.7. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 41 123 B.8. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 42 124 B.9. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 42 125 B.10. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 42 126 B.11. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 42 127 B.12. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 42 128 B.13. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 42 129 B.14. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 42 130 B.15. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 42 131 B.16. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 42 132 B.17. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 43 133 B.18. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 43 134 B.19. 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 which are then carried in QUIC packets. 334 4. Carrying TLS Messages 336 QUIC carries TLS handshake data in CRYPTO frames, each of which 337 consists of a contiguous block of handshake data identified by an 338 offset and length. Those frames are packaged into QUIC packets and 339 encrypted under the current TLS encryption level. As with TLS over 340 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 341 responsibility to deliver it reliably. Each chunk of data that is 342 produced by TLS is associated with the set of keys that TLS is 343 currently using. If QUIC needs to retransmit that data, it MUST use 344 the same keys even if TLS has already updated to newer keys. 346 One important difference between TLS records (used with TCP) and QUIC 347 CRYPTO frames is that in QUIC multiple frames may appear in the same 348 QUIC packet as long as they are associated with the same encryption 349 level. For instance, an implementation might bundle a Handshake 350 message and an ACK for some Handshake data into the same packet. 352 Some frames are prohibited in different encryption levels, others 353 cannot be sent. The rules here generalize those of TLS, in that 354 frames associated with establishing the connection can usually appear 355 at any encryption level, whereas those associated with transferring 356 data can only appear in the 0-RTT and 1-RTT encryption levels: 358 o PADDING frames MAY appear in packets of any encryption level. 360 o CRYPTO and CONNECTION_CLOSE frames MAY appear in packets of any 361 encryption level except 0-RTT. 363 o ACK frames MAY appear in packets of any encryption level other 364 than 0-RTT, but can only acknowledge packets which appeared in 365 that packet number space. 367 o All other frame types MUST only be sent in the 0-RTT and 1-RTT 368 levels. 370 Note that it is not possible to send the following frames in 0-RTT 371 for various reasons: ACK, CRYPTO, NEW_TOKEN, PATH_RESPONSE, and 372 RETIRE_CONNECTION_ID. 374 Because packets could be reordered on the wire, QUIC uses the packet 375 type to indicate which level a given packet was encrypted under, as 376 shown in Table 1. When multiple packets of different encryption 377 levels need to be sent, endpoints SHOULD use coalesced packets to 378 send them in the same UDP datagram. 380 +---------------------+------------------+-----------+ 381 | Packet Type | Encryption Level | PN Space | 382 +---------------------+------------------+-----------+ 383 | Initial | Initial secrets | Initial | 384 | | | | 385 | 0-RTT Protected | 0-RTT | 0/1-RTT | 386 | | | | 387 | Handshake | Handshake | Handshake | 388 | | | | 389 | Retry | N/A | N/A | 390 | | | | 391 | Version Negotiation | N/A | N/A | 392 | | | | 393 | Short Header | 1-RTT | 0/1-RTT | 394 +---------------------+------------------+-----------+ 396 Table 1: Encryption Levels by Packet Type 398 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 399 encryption levels fit into the handshake process. 401 4.1. Interface to TLS 403 As shown in Figure 2, the interface from QUIC to TLS consists of 404 three primary functions: 406 o Sending and receiving handshake messages 407 o Rekeying (both transmit and receive) 409 o Handshake state updates 411 Additional functions might be needed to configure TLS. 413 4.1.1. Handshake Complete 415 In this document, the TLS handshake is considered complete when the 416 TLS stack has reported that the handshake is complete. This happens 417 when the TLS stack has both sent a Finished message and verified the 418 peer's Finished message. Verifying the peer's Finished provides the 419 endpoints with an assurance that previous handshake messages have not 420 been modified. Note that the handshake does not complete at both 421 endpoints simultaneously. Consequently, any requirement that is 422 based on the completion of the handshake depends on the perspective 423 of the endpoint in question. 425 4.1.2. Handshake Confirmed 427 In this document, the TLS handshake is considered confirmed at an 428 endpoint when the following two conditions are met: the handshake is 429 complete, and the endpoint has received an acknowledgment for a 430 packet sent with 1-RTT keys. This second condition can be 431 implemented by recording the lowest packet number sent with 1-RTT 432 keys, and the highest value of the Largest Acknowledged field in any 433 received 1-RTT ACK frame: once the latter is higher than or equal to 434 the former, the handshake is confirmed. 436 4.1.3. Sending and Receiving Handshake Messages 438 In order to drive the handshake, TLS depends on being able to send 439 and receive handshake messages. There are two basic functions on 440 this interface: one where QUIC requests handshake messages and one 441 where QUIC provides handshake packets. 443 Before starting the handshake QUIC provides TLS with the transport 444 parameters (see Section 8.2) that it wishes to carry. 446 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 447 The client acquires handshake bytes before sending its first packet. 448 A QUIC server starts the process by providing TLS with the client's 449 handshake bytes. 451 At any given time, the TLS stack at an endpoint will have a current 452 sending encryption level and receiving encryption level. Each 453 encryption level is associated with a different flow of bytes, which 454 is reliably transmitted to the peer in CRYPTO frames. When TLS 455 provides handshake bytes to be sent, they are appended to the current 456 flow and any packet that includes the CRYPTO frame is protected using 457 keys from the corresponding encryption level. 459 QUIC takes the unprotected content of TLS handshake records as the 460 content of CRYPTO frames. TLS record protection is not used by QUIC. 461 QUIC assembles CRYPTO frames into QUIC packets, which are protected 462 using QUIC packet protection. 464 When an endpoint receives a QUIC packet containing a CRYPTO frame 465 from the network, it proceeds as follows: 467 o If the packet was in the TLS receiving encryption level, sequence 468 the data into the input flow as usual. As with STREAM frames, the 469 offset is used to find the proper location in the data sequence. 470 If the result of this process is that new data is available, then 471 it is delivered to TLS in order. 473 o If the packet is from a previously installed encryption level, it 474 MUST not contain data which extends past the end of previously 475 received data in that flow. Implementations MUST treat any 476 violations of this requirement as a connection error of type 477 PROTOCOL_VIOLATION. 479 o If the packet is from a new encryption level, it is saved for 480 later processing by TLS. Once TLS moves to receiving from this 481 encryption level, saved data can be provided. When providing data 482 from any new encryption level to TLS, if there is data from a 483 previous encryption level that TLS has not consumed, this MUST be 484 treated as a connection error of type PROTOCOL_VIOLATION. 486 Each time that TLS is provided with new data, new handshake bytes are 487 requested from TLS. TLS might not provide any bytes if the handshake 488 messages it has received are incomplete or it has no data to send. 490 Once the TLS handshake is complete, this is indicated to QUIC along 491 with any final handshake bytes that TLS needs to send. TLS also 492 provides QUIC with the transport parameters that the peer advertised 493 during the handshake. 495 Once the handshake is complete, TLS becomes passive. TLS can still 496 receive data from its peer and respond in kind, but it will not need 497 to send more data unless specifically requested - either by an 498 application or QUIC. One reason to send data is that the server 499 might wish to provide additional or updated session tickets to a 500 client. 502 When the handshake is complete, QUIC only needs to provide TLS with 503 any data that arrives in CRYPTO streams. In the same way that is 504 done during the handshake, new data is requested from TLS after 505 providing received data. 507 4.1.4. Encryption Level Changes 509 As keys for new encryption levels become available, TLS provides QUIC 510 with those keys. Separately, as TLS starts using keys at a given 511 encryption level, TLS indicates to QUIC that it is now reading or 512 writing with keys at that encryption level. These events are not 513 asynchronous; they always occur immediately after TLS is provided 514 with new handshake bytes, or after TLS produces handshake bytes. 516 TLS provides QUIC with three items as a new encryption level becomes 517 available: 519 o A secret 521 o An Authenticated Encryption with Associated Data (AEAD) function 523 o A Key Derivation Function (KDF) 525 These values are based on the values that TLS negotiates and are used 526 by QUIC to generate packet and header protection keys (see Section 5 527 and Section 5.4). 529 If 0-RTT is possible, it is ready after the client sends a TLS 530 ClientHello message or the server receives that message. After 531 providing a QUIC client with the first handshake bytes, the TLS stack 532 might signal the change to 0-RTT keys. On the server, after 533 receiving handshake bytes that contain a ClientHello message, a TLS 534 server might signal that 0-RTT keys are available. 536 Although TLS only uses one encryption level at a time, QUIC may use 537 more than one level. For instance, after sending its Finished 538 message (using a CRYPTO frame at the Handshake encryption level) an 539 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 540 message is lost, the endpoint uses the Handshake encryption level to 541 retransmit the lost message. Reordering or loss of packets can mean 542 that QUIC will need to handle packets at multiple encryption levels. 543 During the handshake, this means potentially handling packets at 544 higher and lower encryption levels than the current encryption level 545 used by TLS. 547 In particular, server implementations need to be able to read packets 548 at the Handshake encryption level at the same time as the 0-RTT 549 encryption level. A client could interleave ACK frames that are 550 protected with Handshake keys with 0-RTT data and the server needs to 551 process those acknowledgments in order to detect lost Handshake 552 packets. 554 4.1.5. TLS Interface Summary 556 Figure 3 summarizes the exchange between QUIC and TLS for both client 557 and server. Each arrow is tagged with the encryption level used for 558 that transmission. 560 Client Server 562 Get Handshake 563 Initial -------------> 564 Install tx 0-RTT Keys 565 0-RTT ---------------> 566 Handshake Received 567 Get Handshake 568 <------------- Initial 569 Install rx 0-RTT keys 570 Install Handshake keys 571 Get Handshake 572 <----------- Handshake 573 Install tx 1-RTT keys 574 <--------------- 1-RTT 575 Handshake Received 576 Install tx Handshake keys 577 Handshake Received 578 Get Handshake 579 Handshake Complete 580 Handshake -----------> 581 Install 1-RTT keys 582 1-RTT ---------------> 583 Handshake Received 584 Install rx 1-RTT keys 585 Handshake Complete 586 Get Handshake 587 <--------------- 1-RTT 588 Handshake Received 590 Figure 3: Interaction Summary between QUIC and TLS 592 4.2. TLS Version 594 This document describes how TLS 1.3 [TLS13] is used with QUIC. 596 In practice, the TLS handshake will negotiate a version of TLS to 597 use. This could result in a newer version of TLS than 1.3 being 598 negotiated if both endpoints support that version. This is 599 acceptable provided that the features of TLS 1.3 that are used by 600 QUIC are supported by the newer version. 602 A badly configured TLS implementation could negotiate TLS 1.2 or 603 another older version of TLS. An endpoint MUST terminate the 604 connection if a version of TLS older than 1.3 is negotiated. 606 4.3. ClientHello Size 608 QUIC requires that the first Initial packet from a client contain an 609 entire cryptographic handshake message, which for TLS is the 610 ClientHello. Though a packet larger than 1200 bytes might be 611 supported by the path, a client improves the likelihood that a packet 612 is accepted if it ensures that the first ClientHello message is small 613 enough to stay within this limit. 615 QUIC packet and framing add at least 36 bytes of overhead to the 616 ClientHello message. That overhead increases if the client chooses a 617 connection ID without zero length. Overheads also do not include the 618 token or a connection ID longer than 8 bytes, both of which might be 619 required if a server sends a Retry packet. 621 A typical TLS ClientHello can easily fit into a 1200 byte packet. 622 However, in addition to the overheads added by QUIC, there are 623 several variables that could cause this limit to be exceeded. Large 624 session tickets, multiple or large key shares, and long lists of 625 supported ciphers, signature algorithms, versions, QUIC transport 626 parameters, and other negotiable parameters and extensions could 627 cause this message to grow. 629 For servers, in addition to connection IDs and tokens, the size of 630 TLS session tickets can have an effect on a client's ability to 631 connect. Minimizing the size of these values increases the 632 probability that they can be successfully used by a client. 634 A client is not required to fit the ClientHello that it sends in 635 response to a HelloRetryRequest message into a single UDP datagram. 637 The TLS implementation does not need to ensure that the ClientHello 638 is sufficiently large. QUIC PADDING frames are added to increase the 639 size of the packet as necessary. 641 4.4. Peer Authentication 643 The requirements for authentication depend on the application 644 protocol that is in use. TLS provides server authentication and 645 permits the server to request client authentication. 647 A client MUST authenticate the identity of the server. This 648 typically involves verification that the identity of the server is 649 included in a certificate and that the certificate is issued by a 650 trusted entity (see for example [RFC2818]). 652 A server MAY request that the client authenticate during the 653 handshake. A server MAY refuse a connection if the client is unable 654 to authenticate when requested. The requirements for client 655 authentication vary based on application protocol and deployment. 657 A server MUST NOT use post-handshake client authentication (see 658 Section 4.6.2 of [TLS13]). 660 4.5. Enabling 0-RTT 662 In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket 663 message that contains the "early_data" extension with a 664 max_early_data_size of 0xffffffff; the amount of data which the 665 client can send in 0-RTT is controlled by the "initial_max_data" 666 transport parameter supplied by the server. A client MUST treat 667 receipt of a NewSessionTicket that contains an "early_data" extension 668 with any other value as a connection error of type 669 PROTOCOL_VIOLATION. 671 4.6. Rejecting 0-RTT 673 A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This 674 also prevents QUIC from sending 0-RTT data. A server will always 675 reject 0-RTT if it sends a TLS HelloRetryRequest. 677 When 0-RTT is rejected, all connection characteristics that the 678 client assumed might be incorrect. This includes the choice of 679 application protocol, transport parameters, and any application 680 configuration. The client therefore MUST reset the state of all 681 streams, including application state bound to those streams. 683 A client MAY attempt to send 0-RTT again if it receives a Retry or 684 Version Negotiation packet. These packets do not signify rejection 685 of 0-RTT. 687 4.7. HelloRetryRequest 689 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 690 [TLS13]) can be used to correct a client's incorrect KeyShare 691 extension as well as for a stateless round-trip check. From the 692 perspective of QUIC, this just looks like additional messages carried 693 in the Initial encryption level. Although it is in principle 694 possible to use this feature for address verification in QUIC, QUIC 695 implementations SHOULD instead use the Retry feature (see Section 8.1 696 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 697 shares. 699 4.8. TLS Errors 701 If TLS experiences an error, it generates an appropriate alert as 702 defined in Section 6 of [TLS13]. 704 A TLS alert is turned into a QUIC connection error by converting the 705 one-byte alert description into a QUIC error code. The alert 706 description is added to 0x100 to produce a QUIC error code from the 707 range reserved for CRYPTO_ERROR. The resulting value is sent in a 708 QUIC CONNECTION_CLOSE frame. 710 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 711 generate alerts at the "warning" level. 713 4.9. Discarding Unused Keys 715 After QUIC moves to a new encryption level, packet protection keys 716 for previous encryption levels can be discarded. This occurs several 717 times during the handshake, as well as when keys are updated; see 718 Section 6. 720 Packet protection keys are not discarded immediately when new keys 721 are available. If packets from a lower encryption level contain 722 CRYPTO frames, frames that retransmit that data MUST be sent at the 723 same encryption level. Similarly, an endpoint generates 724 acknowledgements for packets at the same encryption level as the 725 packet being acknowledged. Thus, it is possible that keys for a 726 lower encryption level are needed for a short time after keys for a 727 newer encryption level are available. 729 An endpoint cannot discard keys for a given encryption level unless 730 it has both received and acknowledged all CRYPTO frames for that 731 encryption level and when all CRYPTO frames for that encryption level 732 have been acknowledged by its peer. However, this does not guarantee 733 that no further packets will need to be received or sent at that 734 encryption level because a peer might not have received all the 735 acknowledgements necessary to reach the same state. 737 Though an endpoint might retain older keys, new data MUST be sent at 738 the highest currently-available encryption level. Only ACK frames 739 and retransmissions of data in CRYPTO frames are sent at a previous 740 encryption level. These packets MAY also include PADDING frames. 742 4.9.1. Discarding Initial Keys 744 Packets protected with Initial secrets (Section 5.2) are not 745 authenticated, meaning that an attacker could spoof packets with the 746 intent to disrupt a connection. To limit these attacks, Initial 747 packet protection keys can be discarded more aggressively than other 748 keys. 750 The successful use of Handshake packets indicates that no more 751 Initial packets need to be exchanged, as these keys can only be 752 produced after receiving all CRYPTO frames from Initial packets. 753 Thus, a client MUST discard Initial keys when it first sends a 754 Handshake packet and a server MUST discard Initial keys when it first 755 successfully processes a Handshake packet. Endpoints MUST NOT send 756 Initial packets after this point. 758 This results in abandoning loss recovery state for the Initial 759 encryption level and ignoring any outstanding Initial packets. 761 4.9.2. Discarding Handshake Keys 763 An endpoint MUST NOT discard its handshake keys until the TLS 764 handshake is confirmed (Section 4.1.2). An endpoint SHOULD discard 765 its handshake keys as soon as it has confirmed the handshake. Most 766 application protocols will send data after the handshake, resulting 767 in acknowledgements that allow both endpoints to discard their 768 handshake keys promptly. Endpoints that do not have reason to send 769 immediately after completing the handshake MAY send ack-eliciting 770 frames, such as PING, which will cause the handshake to be confirmed 771 when they are acknowledged. 773 4.9.3. Discarding 0-RTT Keys 775 0-RTT and 1-RTT packets share the same packet number space, and 776 clients do not send 0-RTT packets after sending a 1-RTT packet 777 (Section 5.6). 779 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 780 1-RTT keys, since they have no use after that moment. 782 Additionally, a server MAY discard 0-RTT keys as soon as it receives 783 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 784 could arrive after a 1-RTT packet. Servers MAY temporarily retain 785 0-RTT keys to allow decrypting reordered packets without requiring 786 their contents to be retransmitted with 1-RTT keys. After receiving 787 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 788 the RECOMMENDED time period is three times the Probe Timeout (PTO, 789 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 790 determines that it has received all 0-RTT packets, which can be done 791 by keeping track of missing packet numbers. 793 5. Packet Protection 795 As with TLS over TCP, QUIC protects packets with keys derived from 796 the TLS handshake, using the AEAD algorithm negotiated by TLS. 798 5.1. Packet Protection Keys 800 QUIC derives packet protection keys in the same way that TLS derives 801 record protection keys. 803 Each encryption level has separate secret values for protection of 804 packets sent in each direction. These traffic secrets are derived by 805 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 806 encryption levels except the Initial encryption level. The secrets 807 for the Initial encryption level are computed based on the client's 808 initial Destination Connection ID, as described in Section 5.2. 810 The keys used for packet protection are computed from the TLS secrets 811 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 812 function described in Section 7.1 of [TLS13] is used, using the hash 813 function from the negotiated cipher suite. Other versions of TLS 814 MUST provide a similar function in order to be used with QUIC. 816 The current encryption level secret and the label "quic key" are 817 input to the KDF to produce the AEAD key; the label "quic iv" is used 818 to derive the IV; see Section 5.3. The header protection key uses 819 the "quic hp" label; see Section 5.4. Using these labels provides 820 key separation between QUIC and TLS; see Section 9.5. 822 The KDF used for initial secrets is always the HKDF-Expand-Label 823 function from TLS 1.3 (see Section 5.2). 825 5.2. Initial Secrets 827 Initial packets are protected with a secret derived from the 828 Destination Connection ID field from the client's first Initial 829 packet of the connection. Specifically: 831 initial_salt = 0x7fbcdb0e7c66bbe9193a96cd21519ebd7a02644a 832 initial_secret = HKDF-Extract(initial_salt, 833 client_dst_connection_id) 835 client_initial_secret = HKDF-Expand-Label(initial_secret, 836 "client in", "", 837 Hash.length) 838 server_initial_secret = HKDF-Expand-Label(initial_secret, 839 "server in", "", 840 Hash.length) 842 The hash function for HKDF when deriving initial secrets and keys is 843 SHA-256 [SHA]. 845 The connection ID used with HKDF-Expand-Label is the Destination 846 Connection ID in the Initial packet sent by the client. This will be 847 a randomly-selected value unless the client creates the Initial 848 packet after receiving a Retry packet, where the Destination 849 Connection ID is selected by the server. 851 The value of initial_salt is a 20 byte sequence shown in the figure 852 in hexadecimal notation. Future versions of QUIC SHOULD generate a 853 new salt value, thus ensuring that the keys are different for each 854 version of QUIC. This prevents a middlebox that only recognizes one 855 version of QUIC from seeing or modifying the contents of packets from 856 future versions. 858 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 859 Initial packets even where the TLS versions offered do not include 860 TLS 1.3. 862 Appendix A contains test vectors for the initial packet encryption. 864 Note: The Destination Connection ID is of arbitrary length, and it 865 could be zero length if the server sends a Retry packet with a 866 zero-length Source Connection ID field. In this case, the Initial 867 keys provide no assurance to the client that the server received 868 its packet; the client has to rely on the exchange that included 869 the Retry packet for that property. 871 5.3. AEAD Usage 873 The Authentication Encryption with Associated Data (AEAD) [AEAD] 874 function used for QUIC packet protection is the AEAD that is 875 negotiated for use with the TLS connection. For example, if TLS is 876 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 877 used. 879 Packets are protected prior to applying header protection 880 (Section 5.4). The unprotected packet header is part of the 881 associated data (A). When removing packet protection, an endpoint 882 first removes the header protection. 884 All QUIC packets other than Version Negotiation and Retry packets are 885 protected with an AEAD algorithm [AEAD]. Prior to establishing a 886 shared secret, packets are protected with AEAD_AES_128_GCM and a key 887 derived from the Destination Connection ID in the client's first 888 Initial packet (see Section 5.2). This provides protection against 889 off-path attackers and robustness against QUIC version unaware 890 middleboxes, but not against on-path attackers. 892 QUIC can use any of the ciphersuites defined in [TLS13] with the 893 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 894 negotiated unless a header protection scheme is defined for the 895 ciphersuite. This document defines a header protection scheme for 896 all ciphersuites defined in [TLS13] aside from 897 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 898 authentication tag and produce an output 16 bytes larger than their 899 input. 901 Note: An endpoint MUST NOT reject a ClientHello that offers a 902 ciphersuite that it does not support, or it would be impossible to 903 deploy a new ciphersuite. This also applies to 904 TLS_AES_128_CCM_8_SHA256. 906 The key and IV for the packet are computed as described in 907 Section 5.1. The nonce, N, is formed by combining the packet 908 protection IV with the packet number. The 62 bits of the 909 reconstructed QUIC packet number in network byte order are left- 910 padded with zeros to the size of the IV. The exclusive OR of the 911 padded packet number and the IV forms the AEAD nonce. 913 The associated data, A, for the AEAD is the contents of the QUIC 914 header, starting from the flags byte in either the short or long 915 header, up to and including the unprotected packet number. 917 The input plaintext, P, for the AEAD is the payload of the QUIC 918 packet, as described in [QUIC-TRANSPORT]. 920 The output ciphertext, C, of the AEAD is transmitted in place of P. 922 Some AEAD functions have limits for how many packets can be encrypted 923 under the same key and IV (see for example [AEBounds]). This might 924 be lower than the packet number limit. An endpoint MUST initiate a 925 key update (Section 6) prior to exceeding any limit set for the AEAD 926 that is in use. 928 5.4. Header Protection 930 Parts of QUIC packet headers, in particular the Packet Number field, 931 are protected using a key that is derived separate to the packet 932 protection key and IV. The key derived using the "quic hp" label is 933 used to provide confidentiality protection for those fields that are 934 not exposed to on-path elements. 936 This protection applies to the least-significant bits of the first 937 byte, plus the Packet Number field. The four least-significant bits 938 of the first byte are protected for packets with long headers; the 939 five least significant bits of the first byte are protected for 940 packets with short headers. For both header forms, this covers the 941 reserved bits and the Packet Number Length field; the Key Phase bit 942 is also protected for packets with a short header. 944 The same header protection key is used for the duration of the 945 connection, with the value not changing after a key update (see 946 Section 6). This allows header protection to be used to protect the 947 key phase. 949 This process does not apply to Retry or Version Negotiation packets, 950 which do not contain a protected payload or any of the fields that 951 are protected by this process. 953 5.4.1. Header Protection Application 955 Header protection is applied after packet protection is applied (see 956 Section 5.3). The ciphertext of the packet is sampled and used as 957 input to an encryption algorithm. The algorithm used depends on the 958 negotiated AEAD. 960 The output of this algorithm is a 5 byte mask which is applied to the 961 protected header fields using exclusive OR. The least significant 962 bits of the first byte of the packet are masked by the least 963 significant bits of the first mask byte, and the packet number is 964 masked with the remaining bytes. Any unused bytes of mask that might 965 result from a shorter packet number encoding are unused. 967 Figure 4 shows a sample algorithm for applying header protection. 968 Removing header protection only differs in the order in which the 969 packet number length (pn_length) is determined. 971 mask = header_protection(hp_key, sample) 973 pn_length = (packet[0] & 0x03) + 1 974 if (packet[0] & 0x80) == 0x80: 975 # Long header: 4 bits masked 976 packet[0] ^= mask[0] & 0x0f 977 else: 978 # Short header: 5 bits masked 979 packet[0] ^= mask[0] & 0x1f 981 # pn_offset is the start of the Packet Number field. 982 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 984 Figure 4: Header Protection Pseudocode 986 Figure 5 shows the protected fields of long and short headers marked 987 with an E. Figure 5 also shows the sampled fields. 989 Long Header: 990 +-+-+-+-+-+-+-+-+ 991 |1|1|T T|E E E E| 992 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 993 | Version -> Length Fields ... 994 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 996 Short Header: 997 +-+-+-+-+-+-+-+-+ 998 |0|1|S|E E E E E| 999 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1000 | Destination Connection ID (0/32..144) ... 1001 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1003 Common Fields: 1004 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1005 |E E E E E E E E E Packet Number (8/16/24/32) E E E E E E E E... 1006 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1007 | [Protected Payload (8/16/24)] ... 1008 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1009 | Sampled part of Protected Payload (128) ... 1010 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1011 | Protected Payload Remainder (*) ... 1012 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1014 Figure 5: Header Protection and Ciphertext Sample 1016 Before a TLS ciphersuite can be used with QUIC, a header protection 1017 algorithm MUST be specified for the AEAD used with that ciphersuite. 1018 This document defines algorithms for AEAD_AES_128_GCM, 1019 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1020 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1021 a ciphersuite, AES header protection is used (Section 5.4.3), 1022 matching the AEAD_AES_128_GCM packet protection. 1024 5.4.2. Header Protection Sample 1026 The header protection algorithm uses both the header protection key 1027 and a sample of the ciphertext from the packet Payload field. 1029 The same number of bytes are always sampled, but an allowance needs 1030 to be made for the endpoint removing protection, which will not know 1031 the length of the Packet Number field. In sampling the packet 1032 ciphertext, the Packet Number field is assumed to be 4 bytes long 1033 (its maximum possible encoded length). 1035 An endpoint MUST discard packets that are not long enough to contain 1036 a complete sample. 1038 To ensure that sufficient data is available for sampling, packets are 1039 padded so that the combined lengths of the encoded packet number and 1040 protected payload is at least 4 bytes longer than the sample required 1041 for header protection. The ciphersuites defined in [TLS13] - other 1042 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1043 is not defined in this document - have 16-byte expansions and 16-byte 1044 header protection samples. This results in needing at least 3 bytes 1045 of frames in the unprotected payload if the packet number is encoded 1046 on a single byte, or 2 bytes of frames for a 2-byte packet number 1047 encoding. 1049 The sampled ciphertext for a packet with a short header can be 1050 determined by the following pseudocode: 1052 sample_offset = 1 + len(connection_id) + 4 1054 sample = packet[sample_offset..sample_offset+sample_length] 1056 For example, for a packet with a short header, an 8 byte connection 1057 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1058 28 inclusive (using zero-based indexing). 1060 A packet with a long header is sampled in the same way, noting that 1061 multiple QUIC packets might be included in the same UDP datagram and 1062 that each one is handled separately. 1064 sample_offset = 6 + len(destination_connection_id) + 1065 len(source_connection_id) + 1066 len(payload_length) + 4 1067 if packet_type == Initial: 1068 sample_offset += len(token_length) + 1069 len(token) 1071 sample = packet[sample_offset..sample_offset+sample_length] 1073 5.4.3. AES-Based Header Protection 1075 This section defines the packet protection algorithm for 1076 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1077 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1078 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1079 in ECB mode. 1081 This algorithm samples 16 bytes from the packet ciphertext. This 1082 value is used as the input to AES-ECB. In pseudocode: 1084 mask = AES-ECB(hp_key, sample) 1086 5.4.4. ChaCha20-Based Header Protection 1088 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1089 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1090 256-bit key and 16 bytes sampled from the packet protection output. 1092 The first 4 bytes of the sampled ciphertext are interpreted as a 1093 32-bit number in little-endian order and are used as the block count. 1094 The remaining 12 bytes are interpreted as three concatenated 32-bit 1095 numbers in little-endian order and used as the nonce. 1097 The encryption mask is produced by invoking ChaCha20 to protect 5 1098 zero bytes. In pseudocode: 1100 counter = DecodeLE(sample[0..3]) 1101 nonce = DecodeLE(sample[4..7], sample[8..11], sample[12..15]) 1102 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1104 5.5. Receiving Protected Packets 1106 Once an endpoint successfully receives a packet with a given packet 1107 number, it MUST discard all packets in the same packet number space 1108 with higher packet numbers if they cannot be successfully unprotected 1109 with either the same key, or - if there is a key update - the next 1110 packet protection key (see Section 6). Similarly, a packet that 1111 appears to trigger a key update, but cannot be unprotected 1112 successfully MUST be discarded. 1114 Failure to unprotect a packet does not necessarily indicate the 1115 existence of a protocol error in a peer or an attack. The truncated 1116 packet number encoding used in QUIC can cause packet numbers to be 1117 decoded incorrectly if they are delayed significantly. 1119 5.6. Use of 0-RTT Keys 1121 If 0-RTT keys are available (see Section 4.5), the lack of replay 1122 protection means that restrictions on their use are necessary to 1123 avoid replay attacks on the protocol. 1125 A client MUST only use 0-RTT keys to protect data that is idempotent. 1126 A client MAY wish to apply additional restrictions on what data it 1127 sends prior to the completion of the TLS handshake. A client 1128 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1129 it MUST NOT send ACKs with 0-RTT keys. 1131 A client that receives an indication that its 0-RTT data has been 1132 accepted by a server can send 0-RTT data until it receives all of the 1133 server's handshake messages. A client SHOULD stop sending 0-RTT data 1134 if it receives an indication that 0-RTT data has been rejected. 1136 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1137 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1138 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1139 them. 1141 Once a client has installed 1-RTT keys, it MUST NOT send any more 1142 0-RTT packets. 1144 Note: 0-RTT data can be acknowledged by the server as it receives 1145 it, but any packets containing acknowledgments of 0-RTT data 1146 cannot have packet protection removed by the client until the TLS 1147 handshake is complete. The 1-RTT keys necessary to remove packet 1148 protection cannot be derived until the client receives all server 1149 handshake messages. 1151 5.7. Receiving Out-of-Order Protected Frames 1153 Due to reordering and loss, protected packets might be received by an 1154 endpoint before the final TLS handshake messages are received. A 1155 client will be unable to decrypt 1-RTT packets from the server, 1156 whereas a server will be able to decrypt 1-RTT packets from the 1157 client. 1159 Even though 1-RTT keys are available to a server after receiving the 1160 first handshake messages from a client, it is missing assurances on 1161 the client state: 1163 o The client is not authenticated, unless the server has chosen to 1164 use a pre-shared key and validated the client's pre-shared key 1165 binder; see Section 4.2.11 of [TLS13]. 1167 o The client has not demonstrated liveness, unless a RETRY packet 1168 was used. 1170 o Any received 0-RTT data that the server responds to might be due 1171 to a replay attack. 1173 Therefore, the server's use of 1-RTT keys is limited before the 1174 handshake is complete. A server MUST NOT process data from incoming 1175 1-RTT protected packets before the TLS handshake is complete. 1176 Because sending acknowledgments indicates that all frames in a packet 1177 have been processed, a server cannot send acknowledgments for 1-RTT 1178 packets until the TLS handshake is complete. Received packets 1179 protected with 1-RTT keys MAY be stored and later decrypted and used 1180 once the handshake is complete. 1182 The requirement for the server to wait for the client Finished 1183 message creates a dependency on that message being delivered. A 1184 client can avoid the potential for head-of-line blocking that this 1185 implies by sending its 1-RTT packets coalesced with a handshake 1186 packet containing a copy of the CRYPTO frame that carries the 1187 Finished message, until one of the handshake packets is acknowledged. 1188 This enables immediate server processing for those packets. 1190 A server could receive packets protected with 0-RTT keys prior to 1191 receiving a TLS ClientHello. The server MAY retain these packets for 1192 later decryption in anticipation of receiving a ClientHello. 1194 6. Key Update 1196 Once the handshake is confirmed, it is possible to update the keys. 1197 The KEY_PHASE bit in the short header is used to indicate whether key 1198 updates have occurred. The KEY_PHASE bit is initially set to 0 and 1199 then inverted with each key update. 1201 The KEY_PHASE bit allows a recipient to detect a change in keying 1202 material without necessarily needing to receive the first packet that 1203 triggered the change. An endpoint that notices a changed KEY_PHASE 1204 bit can update keys and decrypt the packet that contains the changed 1205 bit. 1207 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1208 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1209 of a TLS KeyUpdate message as a connection error of type 0x10a, 1210 equivalent to a fatal TLS alert of unexpected_message (see 1211 Section 4.8). 1213 An endpoint MUST NOT initiate the first key update until the 1214 handshake is confirmed (Section 4.1.2). An endpoint MUST NOT 1215 initiate a subsequent key update until it has received an 1216 acknowledgment for a packet sent at the current KEY_PHASE. This can 1217 be implemented by tracking the lowest packet number sent with each 1218 KEY_PHASE, and the highest acknowledged packet number in the 1-RTT 1219 space: once the latter is higher than or equal to the former, another 1220 key update can be initiated. 1222 Endpoints MAY limit the number of keys they retain to two sets for 1223 removing packet protection and one set for protecting packets. Older 1224 keys can be discarded. Updating keys multiple times rapidly can 1225 cause packets to be effectively lost if packets are significantly 1226 reordered. Therefore, an endpoint SHOULD NOT initiate a key update 1227 for some time after it has last updated keys; the RECOMMENDED time 1228 period is three times the PTO. This avoids valid reordered packets 1229 being dropped by the peer as a result of the peer discarding older 1230 keys. 1232 A receiving endpoint detects an update when the KEY_PHASE bit does 1233 not match what it is expecting. It creates a new secret (see 1234 Section 7.2 of [TLS13]) and the corresponding read key and IV using 1235 the KDF function provided by TLS. The header protection key is not 1236 updated. 1238 If the packet can be decrypted and authenticated using the updated 1239 key and IV, then the keys the endpoint uses for packet protection are 1240 also updated. The next packet sent by the endpoint MUST then use the 1241 new keys. Once an endpoint has sent a packet encrypted with a given 1242 key phase, it MUST NOT send a packet encrypted with an older key 1243 phase. 1245 An endpoint does not always need to send packets when it detects that 1246 its peer has updated keys. The next packet that it sends will simply 1247 use the new keys. If an endpoint detects a second update before it 1248 has sent any packets with updated keys, it indicates that its peer 1249 has updated keys twice without awaiting a reciprocal update. An 1250 endpoint MUST treat consecutive key updates as a fatal error and 1251 abort the connection. 1253 An endpoint SHOULD retain old keys for a period of no more than three 1254 times the PTO. After this period, old keys and their corresponding 1255 secrets SHOULD be discarded. Retaining keys allow endpoints to 1256 process packets that were sent with old keys and delayed in the 1257 network. Packets with higher packet numbers always use the updated 1258 keys and MUST NOT be decrypted with old keys. 1260 This ensures that once the handshake is complete, packets with the 1261 same KEY_PHASE will have the same packet protection keys, unless 1262 there are multiple key updates in a short time frame succession and 1263 significant packet reordering. 1265 Initiating Peer Responding Peer 1267 @M QUIC Frames 1268 New Keys -> @N 1269 @N QUIC Frames 1270 --------> 1271 QUIC Frames @M 1272 New Keys -> @N 1273 QUIC Frames @N 1274 <-------- 1276 Figure 6: Key Update 1278 A packet that triggers a key update could arrive after the receiving 1279 endpoint successfully processed a packet with a higher packet number. 1280 This is only possible if there is a key compromise and an attack, or 1281 if the peer is incorrectly reverting to use of old keys. Because the 1282 latter cannot be differentiated from an attack, an endpoint MUST 1283 immediately terminate the connection if it detects this condition. 1285 In deciding when to update keys, endpoints MUST NOT exceed the limits 1286 for use of specific keys, as described in Section 5.5 of [TLS13]. 1288 7. Security of Initial Messages 1290 Initial packets are not protected with a secret key, so they are 1291 subject to potential tampering by an attacker. QUIC provides 1292 protection against attackers that cannot read packets, but does not 1293 attempt to provide additional protection against attacks where the 1294 attacker can observe and inject packets. Some forms of tampering - 1295 such as modifying the TLS messages themselves - are detectable, but 1296 some - such as modifying ACKs - are not. 1298 For example, an attacker could inject a packet containing an ACK 1299 frame that makes it appear that a packet had not been received or to 1300 create a false impression of the state of the connection (e.g., by 1301 modifying the ACK Delay). Note that such a packet could cause a 1302 legitimate packet to be dropped as a duplicate. Implementations 1303 SHOULD use caution in relying on any data which is contained in 1304 Initial packets that is not otherwise authenticated. 1306 It is also possible for the attacker to tamper with data that is 1307 carried in Handshake packets, but because that tampering requires 1308 modifying TLS handshake messages, that tampering will cause the TLS 1309 handshake to fail. 1311 8. QUIC-Specific Additions to the TLS Handshake 1313 QUIC uses the TLS handshake for more than just negotiation of 1314 cryptographic parameters. The TLS handshake validates protocol 1315 version selection, provides preliminary values for QUIC transport 1316 parameters, and allows a server to perform return routeability checks 1317 on clients. 1319 8.1. Protocol Negotiation 1321 QUIC requires that the cryptographic handshake provide authenticated 1322 protocol negotiation. TLS uses Application Layer Protocol 1323 Negotiation (ALPN) [RFC7301] to select an application protocol. 1324 Unless another mechanism is used for agreeing on an application 1325 protocol, endpoints MUST use ALPN for this purpose. When using ALPN, 1326 endpoints MUST immediately close a connection (see Section 10.3 in 1327 [QUIC-TRANSPORT]) if an application protocol is not negotiated with a 1328 no_application_protocol TLS alert (QUIC error code 0x178, see 1329 Section 4.8). While [RFC7301] only specifies that servers use this 1330 alert, QUIC clients MUST also use it to terminate a connection when 1331 ALPN negotiation fails. 1333 An application-layer protocol MAY restrict the QUIC versions that it 1334 can operate over. Servers MUST select an application protocol 1335 compatible with the QUIC version that the client has selected. If 1336 the server cannot select a compatible combination of application 1337 protocol and QUIC version, it MUST abort the connection. A client 1338 MUST abort a connection if the server picks an incompatible 1339 combination of QUIC version and ALPN identifier. 1341 8.2. QUIC Transport Parameters Extension 1343 QUIC transport parameters are carried in a TLS extension. Different 1344 versions of QUIC might define a different format for this struct. 1346 Including transport parameters in the TLS handshake provides 1347 integrity protection for these values. 1349 enum { 1350 quic_transport_parameters(0xffa5), (65535) 1351 } ExtensionType; 1353 The "extension_data" field of the quic_transport_parameters extension 1354 contains a value that is defined by the version of QUIC that is in 1355 use. The quic_transport_parameters extension carries a 1356 TransportParameters struct when the version of QUIC defined in 1357 [QUIC-TRANSPORT] is used. 1359 The quic_transport_parameters extension is carried in the ClientHello 1360 and the EncryptedExtensions messages during the handshake. Endpoints 1361 MUST send the quic_transport_parameters extension; endpoints that 1362 receive ClientHello or EncryptedExtensions messages without the 1363 quic_transport_parameters extension MUST close the connection with an 1364 error of type 0x16d (equivalent to a fatal TLS missing_extension 1365 alert, see Section 4.8). 1367 While the transport parameters are technically available prior to the 1368 completion of the handshake, they cannot be fully trusted until the 1369 handshake completes, and reliance on them should be minimized. 1370 However, any tampering with the parameters will cause the handshake 1371 to fail. 1373 Endpoints MUST NOT send this extension in a TLS connection that does 1374 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1375 fatal unsupported_extension alert MUST be sent by an implementation 1376 that supports this extension if the extension is received when the 1377 transport is not QUIC. 1379 8.3. Removing the EndOfEarlyData Message 1381 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1382 rely on this message to mark the end of 0-RTT data or to signal the 1383 change to Handshake keys. 1385 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1386 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1387 error of type PROTOCOL_VIOLATION. 1389 As a result, EndOfEarlyData does not appear in the TLS handshake 1390 transcript. 1392 9. Security Considerations 1394 There are likely to be some real clangers here eventually, but the 1395 current set of issues is well captured in the relevant sections of 1396 the main text. 1398 Never assume that because it isn't in the security considerations 1399 section it doesn't affect security. Most of this document does. 1401 9.1. Replay Attacks with 0-RTT 1403 As described in Section 8 of [TLS13], use of TLS early data comes 1404 with an exposure to replay attack. The use of 0-RTT in QUIC is 1405 similarly vulnerable to replay attack. 1407 Endpoints MUST implement and use the replay protections described in 1408 [TLS13], however it is recognized that these protections are 1409 imperfect. Therefore, additional consideration of the risk of replay 1410 is needed. 1412 QUIC is not vulnerable to replay attack, except via the application 1413 protocol information it might carry. The management of QUIC protocol 1414 state based on the frame types defined in [QUIC-TRANSPORT] is not 1415 vulnerable to replay. Processing of QUIC frames is idempotent and 1416 cannot result in invalid connection states if frames are replayed, 1417 reordered or lost. QUIC connections do not produce effects that last 1418 beyond the lifetime of the connection, except for those produced by 1419 the application protocol that QUIC serves. 1421 Note: TLS session tickets and address validation tokens are used to 1422 carry QUIC configuration information between connections. These 1423 MUST NOT be used to carry application semantics. The potential 1424 for reuse of these tokens means that they require stronger 1425 protections against replay. 1427 A server that accepts 0-RTT on a connection incurs a higher cost than 1428 accepting a connection without 0-RTT. This includes higher 1429 processing and computation costs. Servers need to consider the 1430 probability of replay and all associated costs when accepting 0-RTT. 1432 Ultimately, the responsibility for managing the risks of replay 1433 attacks with 0-RTT lies with an application protocol. An application 1434 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1435 the measures that are employed to protect against replay attack. An 1436 analysis of replay risk needs to consider all QUIC protocol features 1437 that carry application semantics. 1439 Disabling 0-RTT entirely is the most effective defense against replay 1440 attack. 1442 QUIC extensions MUST describe how replay attacks affect their 1443 operation, or prohibit their use in 0-RTT. Application protocols 1444 MUST either prohibit the use of extensions that carry application 1445 semantics in 0-RTT or provide replay mitigation strategies. 1447 9.2. Packet Reflection Attack Mitigation 1449 A small ClientHello that results in a large block of handshake 1450 messages from a server can be used in packet reflection attacks to 1451 amplify the traffic generated by an attacker. 1453 QUIC includes three defenses against this attack. First, the packet 1454 containing a ClientHello MUST be padded to a minimum size. Second, 1455 if responding to an unverified source address, the server is 1456 forbidden to send more than three UDP datagrams in its first flight 1457 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1458 acknowledgements of Handshake packets are authenticated, a blind 1459 attacker cannot forge them. Put together, these defenses limit the 1460 level of amplification. 1462 9.3. Peer Denial of Service 1464 QUIC, TLS, and HTTP/2 all contain messages that have legitimate uses 1465 in some contexts, but that can be abused to cause a peer to expend 1466 processing resources without having any observable impact on the 1467 state of the connection. If processing is disproportionately large 1468 in comparison to the observable effects on bandwidth or state, then 1469 this could allow a malicious peer to exhaust processing capacity 1470 without consequence. 1472 While there are legitimate uses for some redundant packets, 1473 implementations SHOULD track redundant packets and treat excessive 1474 volumes of any non-productive packets as indicative of an attack. 1476 9.4. Header Protection Analysis 1478 Header protection relies on the packet protection AEAD being a 1479 pseudorandom function (PRF), which is not a property that AEAD 1480 algorithms guarantee. Therefore, no strong assurances about the 1481 general security of this mechanism can be shown in the general case. 1482 The AEAD algorithms described in this document are assumed to be 1483 PRFs. 1485 The header protection algorithms defined in this document take the 1486 form: 1488 protected_field = field XOR PRF(hp_key, sample) 1490 This construction is secure against chosen plaintext attacks (IND- 1491 CPA) [IMC]. 1493 Use of the same key and ciphertext sample more than once risks 1494 compromising header protection. Protecting two different headers 1495 with the same key and ciphertext sample reveals the exclusive OR of 1496 the protected fields. Assuming that the AEAD acts as a PRF, if L 1497 bits are sampled, the odds of two ciphertext samples being identical 1498 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1499 described in this document, that probability is one in 2^64. 1501 Note: In some cases, inputs shorter than the full size required by 1502 the packet protection algorithm might be used. 1504 To prevent an attacker from modifying packet headers, the header is 1505 transitively authenticated using packet protection; the entire packet 1506 header is part of the authenticated additional data. Protected 1507 fields that are falsified or modified can only be detected once the 1508 packet protection is removed. 1510 An attacker could guess values for packet numbers and have an 1511 endpoint confirm guesses through timing side channels. Similarly, 1512 guesses for the packet number length can be trialed and exposed. If 1513 the recipient of a packet discards packets with duplicate packet 1514 numbers without attempting to remove packet protection they could 1515 reveal through timing side-channels that the packet number matches a 1516 received packet. For authentication to be free from side-channels, 1517 the entire process of header protection removal, packet number 1518 recovery, and packet protection removal MUST be applied together 1519 without timing and other side-channels. 1521 For the sending of packets, construction and protection of packet 1522 payloads and packet numbers MUST be free from side-channels that 1523 would reveal the packet number or its encoded size. 1525 9.5. Key Diversity 1527 In using TLS, the central key schedule of TLS is used. As a result 1528 of the TLS handshake messages being integrated into the calculation 1529 of secrets, the inclusion of the QUIC transport parameters extension 1530 ensures that handshake and 1-RTT keys are not the same as those that 1531 might be produced by a server running TLS over TCP. To avoid the 1532 possibility of cross-protocol key synchronization, additional 1533 measures are provided to improve key separation. 1535 The QUIC packet protection keys and IVs are derived using a different 1536 label than the equivalent keys in TLS. 1538 To preserve this separation, a new version of QUIC SHOULD define new 1539 labels for key derivation for packet protection key and IV, plus the 1540 header protection keys. This version of QUIC uses the string "quic". 1541 Other versions can use a version-specific label in place of that 1542 string. 1544 The initial secrets use a key that is specific to the negotiated QUIC 1545 version. New QUIC versions SHOULD define a new salt value used in 1546 calculating initial secrets. 1548 10. IANA Considerations 1550 This document does not create any new IANA registries, but it 1551 registers the values in the following registries: 1553 o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register 1554 the quic_transport_parameters extension found in Section 8.2. The 1555 Recommended column is to be marked Yes. The TLS 1.3 Column is to 1556 include CH and EE. 1558 11. References 1560 11.1. Normative References 1562 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1563 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1564 . 1566 [AES] "Advanced encryption standard (AES)", National Institute 1567 of Standards and Technology report, 1568 DOI 10.6028/nist.fips.197, November 2001. 1570 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1571 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1572 . 1574 [QUIC-RECOVERY] 1575 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1576 and Congestion Control", draft-ietf-quic-recovery-22 (work 1577 in progress), July 2019. 1579 [QUIC-TRANSPORT] 1580 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1581 Multiplexed and Secure Transport", draft-ietf-quic- 1582 transport-22 (work in progress), July 2019. 1584 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1585 Requirement Levels", BCP 14, RFC 2119, 1586 DOI 10.17487/RFC2119, March 1997, 1587 . 1589 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1590 "Transport Layer Security (TLS) Application-Layer Protocol 1591 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1592 July 2014, . 1594 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1595 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1596 May 2017, . 1598 [SHA] Dang, Q., "Secure Hash Standard", National Institute of 1599 Standards and Technology report, 1600 DOI 10.6028/nist.fips.180-4, July 2015. 1602 [TLS-REGISTRIES] 1603 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 1604 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 1605 . 1607 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1608 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1609 . 1611 11.2. Informative References 1613 [AEBounds] 1614 Luykx, A. and K. Paterson, "Limits on Authenticated 1615 Encryption Use in TLS", March 2016, 1616 . 1618 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1619 Cryptography, Second Edition", ISBN 978-1466570269, 1620 November 2014. 1622 [QUIC-HTTP] 1623 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1624 QUIC", draft-ietf-quic-http-22 (work in progress), July 1625 2019. 1627 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1628 DOI 10.17487/RFC2818, May 2000, 1629 . 1631 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1632 Housley, R., and W. Polk, "Internet X.509 Public Key 1633 Infrastructure Certificate and Certificate Revocation List 1634 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1635 . 1637 11.3. URIs 1639 [1] https://mailarchive.ietf.org/arch/search/?email_list=quic 1641 [2] https://github.com/quicwg 1643 [3] https://github.com/quicwg/base-drafts/labels/-tls 1645 Appendix A. Sample Initial Packet Protection 1647 This section shows examples of packet protection for Initial packets 1648 so that implementations can be verified incrementally. These packets 1649 use an 8-byte client-chosen Destination Connection ID of 1650 0x8394c8f03e515708. Values for both server and client packet 1651 protection are shown together with values in hexadecimal. 1653 A.1. Keys 1655 The labels generated by the HKDF-Expand-Label function are: 1657 client in: 00200f746c73313320636c69656e7420696e00 1659 server in: 00200f746c7331332073657276657220696e00 1661 quic key: 00100e746c7331332071756963206b657900 1663 quic iv: 000c0d746c733133207175696320697600 1665 quic hp: 00100d746c733133207175696320687000 1667 The initial secret is common: 1669 initial_secret = HKDF-Extract(initial_salt, cid) 1670 = 4496d3903d3f97cc5e45ac5790ddc686 1671 683c7c0067012bb09d900cc21832d596 1673 The secrets for protecting client packets are: 1675 client_initial_secret 1676 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 1677 = 8a3515a14ae3c31b9c2d6d5bc58538ca 1678 5cd2baa119087143e60887428dcb52f6 1680 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 1681 = 98b0d7e5e7a402c67c33f350fa65ea54 1683 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 1684 = 19e94387805eb0b46c03a788 1686 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 1687 = 0edd982a6ac527f2eddcbb7348dea5d7 1689 The secrets for protecting server packets are: 1691 server_initial_secret 1692 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 1693 = 47b2eaea6c266e32c0697a9e2a898bdf 1694 5c4fb3e5ac34f0e549bf2c58581a3811 1696 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 1697 = 9a8be902a9bdd91d16064ca118045fb4 1699 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 1700 = 0a82086d32205ba22241d8dc 1702 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 1703 = 94b9452d2b3c7c7f6da7fdd8593537fd 1705 A.2. Client Initial 1707 The client sends an Initial packet. The unprotected payload of this 1708 packet contains the following CRYPTO frame, plus enough PADDING 1709 frames to make an 1163 byte payload: 1711 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 1712 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 1713 736572766572ff01000100000a001400 12001d00170018001901000101010201 1714 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 1715 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 1716 05030603020308040805080604010501 060102010402050206020202002d0002 1717 0101001c00024001 1719 The unprotected header includes the connection ID and a 4 byte packet 1720 number encoding for a packet number of 2: 1722 c3ff000015508394c8f03e51570800449f00000002 1723 Protecting the payload produces output that is sampled for header 1724 protection. Because the header uses a 4 byte packet number encoding, 1725 the first 16 bytes of the protected payload is sampled, then applied 1726 to the header: 1728 sample = 65f354ebb400418b614f73765009c016 1730 mask = AES-ECB(hp, sample)[0..4] 1731 = 519bd343ff 1733 header[0] ^= mask[0] & 0x0f 1734 = c2 1735 header[17..20] ^= mask[1..4] 1736 = 9bd343fd 1737 header = c2ff000015508394c8f03e51570800449f9bd343fd 1739 The resulting protected packet is: 1741 c2ff000015508394c8f03e5157080044 9f9bd343fd65f354ebb400418b614f73 1742 765009c0162d594777f9e6ddeb32fba3 865cffd7e26e3724d4997cdde8df34f8 1743 868772fed2412d43046f44dc7c6adf5e e10da456d56c892c8f69594594e8dcab 1744 edb10d591130ca464588f2834eab931b 10feb963c1947a05f57062692c242248 1745 ad0133b31f6dcc585ba344ca5beb382f b619272e65dfccae59c08eb00b7d2a5b 1746 bccd888582df1d1aee040aea76ab4dfd cae126791e71561b1f58312edb31c164 1747 ff1341fd2820e2399946bad901e425da e58a9859ef1825e7d757a6291d9ba6ee 1748 1a8c836dc0027cd705bd2bc67f56bad0 024efaa3819cbb5d46cefdb7e0df3ad9 1749 2b0689650e2b49ac29e6398bedc75554 1a3f3865bc4759bec74d721a28a0452c 1750 1260189e8e92f844c91b27a00fc5ed6d 14d8fceb5a848bea0a3208162c7a9578 1751 2fcf9a045b20b76710a2565372f25411 81030e4350e199e62fa4e2e0bba19ff6 1752 6662ab8cc6815eeaa20b80d5f31c41e5 51f558d2c836a215ccff4e8afd2fec4b 1753 fcb9ea9d051d12162f1b14842489b69d 72a307d9144fced64fc4aa21ebd310f8 1754 97cf00062e90dad5dbf04186622e6c12 96d388176585fdb395358ecfec4d95db 1755 4429f4473a76210866fd180eaeb60da4 33500c74c00aef24d77eae81755faa03 1756 e71a8879937b32d31be2ba51d41b5d7a 1fbb4d952b10dd2d6ec171a3187cf3f6 1757 4d520afad796e4188bc32d153241c083 f225b6e6b845ce9911bd3fe1eb4737b7 1758 1c8d55e3962871b73657b1e2cce368c7 400658d47cfd9290ed16cdc2a6e3e7dc 1759 ea77fb5c6459303a32d58f62969d8f46 70ce27f591c7a59cc3e7556eda4c58a3 1760 2e9f53fd7f9d60a9c05cd6238c71e3c8 2d2efabd3b5177670b8d595151d7eb44 1761 aa401fe3b5b87bdb88dffb2bfb6d1d0d 8868a41ba96265ca7a68d06fc0b74bcc 1762 ac55b038f8362b84d47f52744323d08b 46bfec8c421f991e1394938a546a7482 1763 a17c72be109ea4b0c71abc7d9c0ac096 0327754e1043f18a32b9fb402fc33fdc 1764 b6a0b4fdbbddbdf0d85779879e98ef21 1d104a5271f22823f16942cfa8ace68d 1765 0c9e5b52297da9702d8f1de24bcd0628 4ac8aa1068fa21a82abbca7e7454b848 1766 d7de8c3d43560541a362ff4f6be06c01 15e3a733bff44417da11ae668857bba2 1767 c53ba17db8c100f1b5c7c9ea960d3f3d 3b9e77c16c31a222b498a7384e286b9b 1768 7c45167d5703de715f9b06708403562d cff77fdf2793f94e294888cebe8da4ee 1769 88a53e38f2430addc161e8b2e2f2d405 41d10cda9a7aa518ac14d0195d8c2012 1770 0b4f1d47d6d0909e69c4a0e641b83c1a d4fff85af4751035bc5698b6141ecc3f 1771 bffcf2f55036880071ba118927400796 7f64468172854d140d229320d689f576 1772 60f6c445e629d15ff2dcdff4b71a41ec 0c24bd2fd8f5ad13b2c3688e0fdb8dbc 1773 ce42e6cf49cf60d022ccd5b19b4fd5d9 8dc10d9ce3a626851b1fdd23e1fa3a96 1774 1f9b0333ab8d632e48c944b82bdd9e80 0fa2b2b9e31e96aee54b40edaf6b79ec 1775 211fdc95d95ef552aa532583d76a539e 988e416a0a10df2550cdeacafc3d61b0 1776 b0a79337960a0be8cf6169e4d55fa6e7 a9c2e8efabab3da008f5bcc38c1bbabd 1777 b6c10368723da0ae83c4b1819ff54946 e7806458d80d7be2c867d46fe1f029c5 1778 e952eb19ded16fabb19980480eb0fbcd 1780 A.3. Server Initial 1782 The server sends the following payload in response, including an ACK 1783 frame, a CRYPTO frame, and no PADDING frames: 1785 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 1786 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 1787 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 1788 0304 1789 The header from the server includes a new connection ID and a 2-byte 1790 packet number encoding for a packet number of 1: 1792 c1ff00001505f067a5502a4262b50040740001 1794 As a result, after protection, the header protection sample is taken 1795 starting from the third protected octet: 1797 sample = 6176fa3b713f272a9bf03ee28d3c8add 1798 mask = 5bd74a846c 1799 header = caff00001505f067a5502a4262b5004074d74b 1801 The final protected packet is then: 1803 caff00001505f067a5502a4262b50040 74d74b7e486176fa3b713f272a9bf03e 1804 e28d3c8addb4e805b3a110b663122a75 eee93c9177ac6b7a6b548e15a7b8f884 1805 65e9eab253a760779b2e6a2c574882b4 8d3a3eed696e50d04d5ec59af85261e4 1806 cdbe264bd65f2b076760c69beef23aa7 14c9a174d69034c09a2863e1e1863508 1807 8d4afdeab9 1809 Appendix B. Change Log 1811 *RFC Editor's Note:* Please remove this section prior to 1812 publication of a final version of this document. 1814 Issue and pull request numbers are listed with a leading octothorp. 1816 B.1. Since draft-ietf-quic-tls-21 1818 o No changes 1820 B.2. Since draft-ietf-quic-tls-20 1822 o Mandate the use of the QUIC transport parameters extension (#2528, 1823 #2560) 1825 o Define handshake completion and confirmation; define clearer rules 1826 when it encryption keys should be discarded (#2214, #2267, #2673) 1828 B.3. Since draft-ietf-quic-tls-18 1830 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 1832 o Transport parameter extension is mandatory (#2528, #2560) 1834 B.4. Since draft-ietf-quic-tls-17 1836 o Endpoints discard initial keys as soon as handshake keys are 1837 available (#1951, #2045) 1839 o Use of ALPN or equivalent is mandatory (#2263, #2284) 1841 B.5. Since draft-ietf-quic-tls-14 1843 o Update the salt used for Initial secrets (#1970) 1845 o Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 1847 o Change header protection 1849 * Sample from a fixed offset (#1575, #2030) 1851 * Cover part of the first byte, including the key phase (#1322, 1852 #2006) 1854 o TLS provides an AEAD and KDF function (#2046) 1856 * Clarify that the TLS KDF is used with TLS (#1997) 1858 * Change the labels for calculation of QUIC keys (#1845, #1971, 1859 #1991) 1861 o Initial keys are discarded once Handshake are avaialble (#1951, 1862 #2045) 1864 B.6. Since draft-ietf-quic-tls-13 1866 o Updated to TLS 1.3 final (#1660) 1868 B.7. Since draft-ietf-quic-tls-12 1870 o Changes to integration of the TLS handshake (#829, #1018, #1094, 1871 #1165, #1190, #1233, #1242, #1252, #1450) 1873 * The cryptographic handshake uses CRYPTO frames, not stream 0 1875 * QUIC packet protection is used in place of TLS record 1876 protection 1878 * Separate QUIC packet number spaces are used for the handshake 1880 * Changed Retry to be independent of the cryptographic handshake 1881 * Limit the use of HelloRetryRequest to address TLS needs (like 1882 key shares) 1884 o Changed codepoint of TLS extension (#1395, #1402) 1886 B.8. Since draft-ietf-quic-tls-11 1888 o Encrypted packet numbers. 1890 B.9. Since draft-ietf-quic-tls-10 1892 o No significant changes. 1894 B.10. Since draft-ietf-quic-tls-09 1896 o Cleaned up key schedule and updated the salt used for handshake 1897 packet protection (#1077) 1899 B.11. Since draft-ietf-quic-tls-08 1901 o Specify value for max_early_data_size to enable 0-RTT (#942) 1903 o Update key derivation function (#1003, #1004) 1905 B.12. Since draft-ietf-quic-tls-07 1907 o Handshake errors can be reported with CONNECTION_CLOSE (#608, 1908 #891) 1910 B.13. Since draft-ietf-quic-tls-05 1912 No significant changes. 1914 B.14. Since draft-ietf-quic-tls-04 1916 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 1918 B.15. Since draft-ietf-quic-tls-03 1920 No significant changes. 1922 B.16. Since draft-ietf-quic-tls-02 1924 o Updates to match changes in transport draft 1926 B.17. Since draft-ietf-quic-tls-01 1928 o Use TLS alerts to signal TLS errors (#272, #374) 1930 o Require ClientHello to fit in a single packet (#338) 1932 o The second client handshake flight is now sent in the clear (#262, 1933 #337) 1935 o The QUIC header is included as AEAD Associated Data (#226, #243, 1936 #302) 1938 o Add interface necessary for client address validation (#275) 1940 o Define peer authentication (#140) 1942 o Require at least TLS 1.3 (#138) 1944 o Define transport parameters as a TLS extension (#122) 1946 o Define handling for protected packets before the handshake 1947 completes (#39) 1949 o Decouple QUIC version and ALPN (#12) 1951 B.18. Since draft-ietf-quic-tls-00 1953 o Changed bit used to signal key phase 1955 o Updated key phase markings during the handshake 1957 o Added TLS interface requirements section 1959 o Moved to use of TLS exporters for key derivation 1961 o Moved TLS error code definitions into this document 1963 B.19. Since draft-thomson-quic-tls-01 1965 o Adopted as base for draft-ietf-quic-tls 1967 o Updated authors/editors list 1969 o Added status note 1971 Acknowledgments 1973 This document has benefited from input from Dragana Damjanovic, 1974 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1975 Rescorla, Ian Swett, and many others. 1977 Contributors 1979 Ryan Hamilton was originally an author of this specification. 1981 Authors' Addresses 1983 Martin Thomson (editor) 1984 Mozilla 1986 Email: mt@lowentropy.net 1988 Sean Turner (editor) 1989 sn3rd 1991 Email: sean@sn3rd.com