idnits 2.17.00 (12 Aug 2021) /tmp/idnits28771/draft-ietf-quic-tls-21.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 08, 2019) is 1047 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 1638 -- Looks like a reference, but probably isn't: '2' on line 1640 -- Looks like a reference, but probably isn't: '3' on line 1642 -- Looks like a reference, but probably isn't: '0' on line 1732 == Unused Reference: 'QUIC-HTTP' is defined on line 1621, 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-21 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 9, 2020 sn3rd 6 July 08, 2019 8 Using TLS to Secure QUIC 9 draft-ietf-quic-tls-21 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 9, 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-20 . . . . . . . . . . . . . . 40 117 B.2. Since draft-ietf-quic-tls-18 . . . . . . . . . . . . . . 40 118 B.3. Since draft-ietf-quic-tls-17 . . . . . . . . . . . . . . 40 119 B.4. Since draft-ietf-quic-tls-14 . . . . . . . . . . . . . . 41 120 B.5. Since draft-ietf-quic-tls-13 . . . . . . . . . . . . . . 41 121 B.6. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 41 122 B.7. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 42 123 B.8. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 42 124 B.9. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 42 125 B.10. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 42 126 B.11. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 42 127 B.12. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 42 128 B.13. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 42 129 B.14. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 42 130 B.15. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 42 131 B.16. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 42 132 B.17. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 43 133 B.18. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 43 134 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 43 135 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 43 136 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 44 138 1. Introduction 140 This document describes how QUIC [QUIC-TRANSPORT] is secured using 141 TLS [TLS13]. 143 TLS 1.3 provides critical latency improvements for connection 144 establishment over previous versions. Absent packet loss, most new 145 connections can be established and secured within a single round 146 trip; on subsequent connections between the same client and server, 147 the client can often send application data immediately, that is, 148 using a zero round trip setup. 150 This document describes how TLS acts as a security component of QUIC. 152 2. Notational Conventions 154 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 155 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 156 "OPTIONAL" in this document are to be interpreted as described in BCP 157 14 [RFC2119] [RFC8174] when, and only when, they appear in all 158 capitals, as shown here. 160 This document uses the terminology established in [QUIC-TRANSPORT]. 162 For brevity, the acronym TLS is used to refer to TLS 1.3, though a 163 newer version could be used (see Section 4.2). 165 2.1. TLS Overview 167 TLS provides two endpoints with a way to establish a means of 168 communication over an untrusted medium (that is, the Internet) that 169 ensures that messages they exchange cannot be observed, modified, or 170 forged. 172 Internally, TLS is a layered protocol, with the structure shown 173 below: 175 +--------------+--------------+--------------+ 176 | Handshake | Alerts | Application | 177 | Layer | | Data | 178 | | | | 179 +--------------+--------------+--------------+ 180 | | 181 | Record Layer | 182 | | 183 +--------------------------------------------+ 185 Each upper layer (handshake, alerts, and application data) is carried 186 as a series of typed TLS records. Records are individually 187 cryptographically protected and then transmitted over a reliable 188 transport (typically TCP) which provides sequencing and guaranteed 189 delivery. 191 Change Cipher Spec records cannot be sent in QUIC. 193 The TLS authenticated key exchange occurs between two entities: 194 client and server. The client initiates the exchange and the server 195 responds. If the key exchange completes successfully, both client 196 and server will agree on a secret. TLS supports both pre-shared key 197 (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for 198 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 199 keys are destroyed. 201 After completing the TLS handshake, the client will have learned and 202 authenticated an identity for the server and the server is optionally 203 able to learn and authenticate an identity for the client. TLS 204 supports X.509 [RFC5280] certificate-based authentication for both 205 server and client. 207 The TLS key exchange is resistant to tampering by attackers and it 208 produces shared secrets that cannot be controlled by either 209 participating peer. 211 TLS provides two basic handshake modes of interest to QUIC: 213 o A full 1-RTT handshake in which the client is able to send 214 application data after one round trip and the server immediately 215 responds after receiving the first handshake message from the 216 client. 218 o A 0-RTT handshake in which the client uses information it has 219 previously learned about the server to send application data 220 immediately. This application data can be replayed by an attacker 221 so it MUST NOT carry a self-contained trigger for any non- 222 idempotent action. 224 A simplified TLS handshake with 0-RTT application data is shown in 225 Figure 1. Note that this omits the EndOfEarlyData message, which is 226 not used in QUIC (see Section 8.3). 228 Client Server 230 ClientHello 231 (0-RTT Application Data) --------> 232 ServerHello 233 {EncryptedExtensions} 234 {Finished} 235 <-------- [Application Data] 236 {Finished} --------> 238 [Application Data] <-------> [Application Data] 240 () Indicates messages protected by early data (0-RTT) keys 241 {} Indicates messages protected using handshake keys 242 [] Indicates messages protected using application data 243 (1-RTT) keys 245 Figure 1: TLS Handshake with 0-RTT 247 Data is protected using a number of encryption levels: 249 o Initial Keys 251 o Early Data (0-RTT) Keys 253 o Handshake Keys 255 o Application Data (1-RTT) Keys 257 Application data may appear only in the early data and application 258 data levels. Handshake and Alert messages may appear in any level. 260 The 0-RTT handshake is only possible if the client and server have 261 previously communicated. In the 1-RTT handshake, the client is 262 unable to send protected application data until it has received all 263 of the handshake messages sent by the server. 265 3. Protocol Overview 267 QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality 268 and integrity protection of packets. For this it uses keys derived 269 from a TLS handshake [TLS13], but instead of carrying TLS records 270 over QUIC (as with TCP), TLS Handshake and Alert messages are carried 271 directly over the QUIC transport, which takes over the 272 responsibilities of the TLS record layer, as shown below. 274 +--------------+--------------+ +-------------+ 275 | TLS | TLS | | QUIC | 276 | Handshake | Alerts | | Applications| 277 | | | | (h3, etc.) | 278 +--------------+--------------+-+-------------+ 279 | | 280 | QUIC Transport | 281 | (streams, reliability, congestion, etc.) | 282 | | 283 +---------------------------------------------+ 284 | | 285 | QUIC Packet Protection | 286 | | 287 +---------------------------------------------+ 289 QUIC also relies on TLS for authentication and negotiation of 290 parameters that are critical to security and performance. 292 Rather than a strict layering, these two protocols are co-dependent: 293 QUIC uses the TLS handshake; TLS uses the reliability, ordered 294 delivery, and record layer provided by QUIC. 296 At a high level, there are two main interactions between the TLS and 297 QUIC components: 299 o The TLS component sends and receives messages via the QUIC 300 component, with QUIC providing a reliable stream abstraction to 301 TLS. 303 o The TLS component provides a series of updates to the QUIC 304 component, including (a) new packet protection keys to install (b) 305 state changes such as handshake completion, the server 306 certificate, etc. 308 Figure 2 shows these interactions in more detail, with the QUIC 309 packet protection being called out specially. 311 +------------+ +------------+ 312 | |<- Handshake Messages ->| | 313 | |<---- 0-RTT Keys -------| | 314 | |<--- Handshake Keys-----| | 315 | QUIC |<---- 1-RTT Keys -------| TLS | 316 | |<--- Handshake Done ----| | 317 +------------+ +------------+ 318 | ^ 319 | Protect | Protected 320 v | Packet 321 +------------+ 322 | QUIC | 323 | Packet | 324 | Protection | 325 +------------+ 327 Figure 2: QUIC and TLS Interactions 329 Unlike TLS over TCP, QUIC applications which want to send data do not 330 send it through TLS "application_data" records. Rather, they send it 331 as QUIC STREAM frames which are then carried in QUIC packets. 333 4. Carrying TLS Messages 335 QUIC carries TLS handshake data in CRYPTO frames, each of which 336 consists of a contiguous block of handshake data identified by an 337 offset and length. Those frames are packaged into QUIC packets and 338 encrypted under the current TLS encryption level. As with TLS over 339 TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's 340 responsibility to deliver it reliably. Each chunk of data that is 341 produced by TLS is associated with the set of keys that TLS is 342 currently using. If QUIC needs to retransmit that data, it MUST use 343 the same keys even if TLS has already updated to newer keys. 345 One important difference between TLS records (used with TCP) and QUIC 346 CRYPTO frames is that in QUIC multiple frames may appear in the same 347 QUIC packet as long as they are associated with the same encryption 348 level. For instance, an implementation might bundle a Handshake 349 message and an ACK for some Handshake data into the same packet. 351 Some frames are prohibited in different encryption levels, others 352 cannot be sent. The rules here generalize those of TLS, in that 353 frames associated with establishing the connection can usually appear 354 at any encryption level, whereas those associated with transferring 355 data can only appear in the 0-RTT and 1-RTT encryption levels: 357 o PADDING frames MAY appear in packets of any encryption level. 359 o CRYPTO and CONNECTION_CLOSE frames MAY appear in packets of any 360 encryption level except 0-RTT. 362 o ACK frames MAY appear in packets of any encryption level other 363 than 0-RTT, but can only acknowledge packets which appeared in 364 that packet number space. 366 o All other frame types MUST only be sent in the 0-RTT and 1-RTT 367 levels. 369 Note that it is not possible to send the following frames in 0-RTT 370 for various reasons: ACK, CRYPTO, NEW_TOKEN, PATH_RESPONSE, and 371 RETIRE_CONNECTION_ID. 373 Because packets could be reordered on the wire, QUIC uses the packet 374 type to indicate which level a given packet was encrypted under, as 375 shown in Table 1. When multiple packets of different encryption 376 levels need to be sent, endpoints SHOULD use coalesced packets to 377 send them in the same UDP datagram. 379 +---------------------+------------------+-----------+ 380 | Packet Type | Encryption Level | PN Space | 381 +---------------------+------------------+-----------+ 382 | Initial | Initial secrets | Initial | 383 | | | | 384 | 0-RTT Protected | 0-RTT | 0/1-RTT | 385 | | | | 386 | Handshake | Handshake | Handshake | 387 | | | | 388 | Retry | N/A | N/A | 389 | | | | 390 | Version Negotiation | N/A | N/A | 391 | | | | 392 | Short Header | 1-RTT | 0/1-RTT | 393 +---------------------+------------------+-----------+ 395 Table 1: Encryption Levels by Packet Type 397 Section 17 of [QUIC-TRANSPORT] shows how packets at the various 398 encryption levels fit into the handshake process. 400 4.1. Interface to TLS 402 As shown in Figure 2, the interface from QUIC to TLS consists of 403 three primary functions: 405 o Sending and receiving handshake messages 406 o Rekeying (both transmit and receive) 408 o Handshake state updates 410 Additional functions might be needed to configure TLS. 412 4.1.1. Handshake Complete 414 In this document, the TLS handshake is considered complete when the 415 TLS stack has reported that the handshake is complete. This happens 416 when the TLS stack has both sent a Finished message and verified the 417 peer's Finished message. Verifying the peer's Finished provides the 418 endpoints with an assurance that previous handshake messages have not 419 been modified. Note that the handshake does not complete at both 420 endpoints simultaneously. Consequently, any requirement that is 421 based on the completion of the handshake depends on the perspective 422 of the endpoint in question. 424 4.1.2. Handshake Confirmed 426 In this document, the TLS handshake is considered confirmed at an 427 endpoint when the following two conditions are met: the handshake is 428 complete, and the endpoint has received an acknowledgment for a 429 packet sent with 1-RTT keys. This second condition can be 430 implemented by recording the lowest packet number sent with 1-RTT 431 keys, and the highest value of the Largest Acknowledged field in any 432 received 1-RTT ACK frame: once the latter is higher than or equal to 433 the former, the handshake is confirmed. 435 4.1.3. Sending and Receiving Handshake Messages 437 In order to drive the handshake, TLS depends on being able to send 438 and receive handshake messages. There are two basic functions on 439 this interface: one where QUIC requests handshake messages and one 440 where QUIC provides handshake packets. 442 Before starting the handshake QUIC provides TLS with the transport 443 parameters (see Section 8.2) that it wishes to carry. 445 A QUIC client starts TLS by requesting TLS handshake bytes from TLS. 446 The client acquires handshake bytes before sending its first packet. 447 A QUIC server starts the process by providing TLS with the client's 448 handshake bytes. 450 At any given time, the TLS stack at an endpoint will have a current 451 sending encryption level and receiving encryption level. Each 452 encryption level is associated with a different flow of bytes, which 453 is reliably transmitted to the peer in CRYPTO frames. When TLS 454 provides handshake bytes to be sent, they are appended to the current 455 flow and any packet that includes the CRYPTO frame is protected using 456 keys from the corresponding encryption level. 458 QUIC takes the unprotected content of TLS handshake records as the 459 content of CRYPTO frames. TLS record protection is not used by QUIC. 460 QUIC assembles CRYPTO frames into QUIC packets, which are protected 461 using QUIC packet protection. 463 When an endpoint receives a QUIC packet containing a CRYPTO frame 464 from the network, it proceeds as follows: 466 o If the packet was in the TLS receiving encryption level, sequence 467 the data into the input flow as usual. As with STREAM frames, the 468 offset is used to find the proper location in the data sequence. 469 If the result of this process is that new data is available, then 470 it is delivered to TLS in order. 472 o If the packet is from a previously installed encryption level, it 473 MUST not contain data which extends past the end of previously 474 received data in that flow. Implementations MUST treat any 475 violations of this requirement as a connection error of type 476 PROTOCOL_VIOLATION. 478 o If the packet is from a new encryption level, it is saved for 479 later processing by TLS. Once TLS moves to receiving from this 480 encryption level, saved data can be provided. When providing data 481 from any new encryption level to TLS, if there is data from a 482 previous encryption level that TLS has not consumed, this MUST be 483 treated as a connection error of type PROTOCOL_VIOLATION. 485 Each time that TLS is provided with new data, new handshake bytes are 486 requested from TLS. TLS might not provide any bytes if the handshake 487 messages it has received are incomplete or it has no data to send. 489 Once the TLS handshake is complete, this is indicated to QUIC along 490 with any final handshake bytes that TLS needs to send. TLS also 491 provides QUIC with the transport parameters that the peer advertised 492 during the handshake. 494 Once the handshake is complete, TLS becomes passive. TLS can still 495 receive data from its peer and respond in kind, but it will not need 496 to send more data unless specifically requested - either by an 497 application or QUIC. One reason to send data is that the server 498 might wish to provide additional or updated session tickets to a 499 client. 501 When the handshake is complete, QUIC only needs to provide TLS with 502 any data that arrives in CRYPTO streams. In the same way that is 503 done during the handshake, new data is requested from TLS after 504 providing received data. 506 4.1.4. Encryption Level Changes 508 As keys for new encryption levels become available, TLS provides QUIC 509 with those keys. Separately, as TLS starts using keys at a given 510 encryption level, TLS indicates to QUIC that it is now reading or 511 writing with keys at that encryption level. These events are not 512 asynchronous; they always occur immediately after TLS is provided 513 with new handshake bytes, or after TLS produces handshake bytes. 515 TLS provides QUIC with three items as a new encryption level becomes 516 available: 518 o A secret 520 o An Authenticated Encryption with Associated Data (AEAD) function 522 o A Key Derivation Function (KDF) 524 These values are based on the values that TLS negotiates and are used 525 by QUIC to generate packet and header protection keys (see Section 5 526 and Section 5.4). 528 If 0-RTT is possible, it is ready after the client sends a TLS 529 ClientHello message or the server receives that message. After 530 providing a QUIC client with the first handshake bytes, the TLS stack 531 might signal the change to 0-RTT keys. On the server, after 532 receiving handshake bytes that contain a ClientHello message, a TLS 533 server might signal that 0-RTT keys are available. 535 Although TLS only uses one encryption level at a time, QUIC may use 536 more than one level. For instance, after sending its Finished 537 message (using a CRYPTO frame at the Handshake encryption level) an 538 endpoint can send STREAM data (in 1-RTT encryption). If the Finished 539 message is lost, the endpoint uses the Handshake encryption level to 540 retransmit the lost message. Reordering or loss of packets can mean 541 that QUIC will need to handle packets at multiple encryption levels. 542 During the handshake, this means potentially handling packets at 543 higher and lower encryption levels than the current encryption level 544 used by TLS. 546 In particular, server implementations need to be able to read packets 547 at the Handshake encryption level at the same time as the 0-RTT 548 encryption level. A client could interleave ACK frames that are 549 protected with Handshake keys with 0-RTT data and the server needs to 550 process those acknowledgments in order to detect lost Handshake 551 packets. 553 4.1.5. TLS Interface Summary 555 Figure 3 summarizes the exchange between QUIC and TLS for both client 556 and server. Each arrow is tagged with the encryption level used for 557 that transmission. 559 Client Server 561 Get Handshake 562 Initial -------------> 563 Install tx 0-RTT Keys 564 0-RTT ---------------> 565 Handshake Received 566 Get Handshake 567 <------------- Initial 568 Install rx 0-RTT keys 569 Install Handshake keys 570 Get Handshake 571 <----------- Handshake 572 Install tx 1-RTT keys 573 <--------------- 1-RTT 574 Handshake Received 575 Install tx Handshake keys 576 Handshake Received 577 Get Handshake 578 Handshake Complete 579 Handshake -----------> 580 Install 1-RTT keys 581 1-RTT ---------------> 582 Handshake Received 583 Install rx 1-RTT keys 584 Handshake Complete 585 Get Handshake 586 <--------------- 1-RTT 587 Handshake Received 589 Figure 3: Interaction Summary between QUIC and TLS 591 4.2. TLS Version 593 This document describes how TLS 1.3 [TLS13] is used with QUIC. 595 In practice, the TLS handshake will negotiate a version of TLS to 596 use. This could result in a newer version of TLS than 1.3 being 597 negotiated if both endpoints support that version. This is 598 acceptable provided that the features of TLS 1.3 that are used by 599 QUIC are supported by the newer version. 601 A badly configured TLS implementation could negotiate TLS 1.2 or 602 another older version of TLS. An endpoint MUST terminate the 603 connection if a version of TLS older than 1.3 is negotiated. 605 4.3. ClientHello Size 607 QUIC requires that the first Initial packet from a client contain an 608 entire cryptographic handshake message, which for TLS is the 609 ClientHello. Though a packet larger than 1200 bytes might be 610 supported by the path, a client improves the likelihood that a packet 611 is accepted if it ensures that the first ClientHello message is small 612 enough to stay within this limit. 614 QUIC packet and framing add at least 36 bytes of overhead to the 615 ClientHello message. That overhead increases if the client chooses a 616 connection ID without zero length. Overheads also do not include the 617 token or a connection ID longer than 8 bytes, both of which might be 618 required if a server sends a Retry packet. 620 A typical TLS ClientHello can easily fit into a 1200 byte packet. 621 However, in addition to the overheads added by QUIC, there are 622 several variables that could cause this limit to be exceeded. Large 623 session tickets, multiple or large key shares, and long lists of 624 supported ciphers, signature algorithms, versions, QUIC transport 625 parameters, and other negotiable parameters and extensions could 626 cause this message to grow. 628 For servers, in addition to connection IDs and tokens, the size of 629 TLS session tickets can have an effect on a client's ability to 630 connect. Minimizing the size of these values increases the 631 probability that they can be successfully used by a client. 633 A client is not required to fit the ClientHello that it sends in 634 response to a HelloRetryRequest message into a single UDP datagram. 636 The TLS implementation does not need to ensure that the ClientHello 637 is sufficiently large. QUIC PADDING frames are added to increase the 638 size of the packet as necessary. 640 4.4. Peer Authentication 642 The requirements for authentication depend on the application 643 protocol that is in use. TLS provides server authentication and 644 permits the server to request client authentication. 646 A client MUST authenticate the identity of the server. This 647 typically involves verification that the identity of the server is 648 included in a certificate and that the certificate is issued by a 649 trusted entity (see for example [RFC2818]). 651 A server MAY request that the client authenticate during the 652 handshake. A server MAY refuse a connection if the client is unable 653 to authenticate when requested. The requirements for client 654 authentication vary based on application protocol and deployment. 656 A server MUST NOT use post-handshake client authentication (see 657 Section 4.6.2 of [TLS13]). 659 4.5. Enabling 0-RTT 661 In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket 662 message that contains the "early_data" extension with a 663 max_early_data_size of 0xffffffff; the amount of data which the 664 client can send in 0-RTT is controlled by the "initial_max_data" 665 transport parameter supplied by the server. A client MUST treat 666 receipt of a NewSessionTicket that contains an "early_data" extension 667 with any other value as a connection error of type 668 PROTOCOL_VIOLATION. 670 4.6. Rejecting 0-RTT 672 A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This 673 also prevents QUIC from sending 0-RTT data. A server will always 674 reject 0-RTT if it sends a TLS HelloRetryRequest. 676 When 0-RTT is rejected, all connection characteristics that the 677 client assumed might be incorrect. This includes the choice of 678 application protocol, transport parameters, and any application 679 configuration. The client therefore MUST reset the state of all 680 streams, including application state bound to those streams. 682 A client MAY attempt to send 0-RTT again if it receives a Retry or 683 Version Negotiation packet. These packets do not signify rejection 684 of 0-RTT. 686 4.7. HelloRetryRequest 688 In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of 689 [TLS13]) can be used to correct a client's incorrect KeyShare 690 extension as well as for a stateless round-trip check. From the 691 perspective of QUIC, this just looks like additional messages carried 692 in the Initial encryption level. Although it is in principle 693 possible to use this feature for address verification in QUIC, QUIC 694 implementations SHOULD instead use the Retry feature (see Section 8.1 695 of [QUIC-TRANSPORT]). HelloRetryRequest is still used to request key 696 shares. 698 4.8. TLS Errors 700 If TLS experiences an error, it generates an appropriate alert as 701 defined in Section 6 of [TLS13]. 703 A TLS alert is turned into a QUIC connection error by converting the 704 one-byte alert description into a QUIC error code. The alert 705 description is added to 0x100 to produce a QUIC error code from the 706 range reserved for CRYPTO_ERROR. The resulting value is sent in a 707 QUIC CONNECTION_CLOSE frame. 709 The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT 710 generate alerts at the "warning" level. 712 4.9. Discarding Unused Keys 714 After QUIC moves to a new encryption level, packet protection keys 715 for previous encryption levels can be discarded. This occurs several 716 times during the handshake, as well as when keys are updated; see 717 Section 6. 719 Packet protection keys are not discarded immediately when new keys 720 are available. If packets from a lower encryption level contain 721 CRYPTO frames, frames that retransmit that data MUST be sent at the 722 same encryption level. Similarly, an endpoint generates 723 acknowledgements for packets at the same encryption level as the 724 packet being acknowledged. Thus, it is possible that keys for a 725 lower encryption level are needed for a short time after keys for a 726 newer encryption level are available. 728 An endpoint cannot discard keys for a given encryption level unless 729 it has both received and acknowledged all CRYPTO frames for that 730 encryption level and when all CRYPTO frames for that encryption level 731 have been acknowledged by its peer. However, this does not guarantee 732 that no further packets will need to be received or sent at that 733 encryption level because a peer might not have received all the 734 acknowledgements necessary to reach the same state. 736 Though an endpoint might retain older keys, new data MUST be sent at 737 the highest currently-available encryption level. Only ACK frames 738 and retransmissions of data in CRYPTO frames are sent at a previous 739 encryption level. These packets MAY also include PADDING frames. 741 4.9.1. Discarding Initial Keys 743 Packets protected with Initial secrets (Section 5.2) are not 744 authenticated, meaning that an attacker could spoof packets with the 745 intent to disrupt a connection. To limit these attacks, Initial 746 packet protection keys can be discarded more aggressively than other 747 keys. 749 The successful use of Handshake packets indicates that no more 750 Initial packets need to be exchanged, as these keys can only be 751 produced after receiving all CRYPTO frames from Initial packets. 752 Thus, a client MUST discard Initial keys when it first sends a 753 Handshake packet and a server MUST discard Initial keys when it first 754 successfully processes a Handshake packet. Endpoints MUST NOT send 755 Initial packets after this point. 757 This results in abandoning loss recovery state for the Initial 758 encryption level and ignoring any outstanding Initial packets. 760 4.9.2. Discarding Handshake Keys 762 An endpoint MUST NOT discard its handshake keys until the TLS 763 handshake is confirmed (Section 4.1.2). An endpoint SHOULD discard 764 its handshake keys as soon as it has confirmed the handshake. Most 765 application protocols will send data after the handshake, resulting 766 in acknowledgements that allow both endpoints to discard their 767 handshake keys promptly. Endpoints that do not have reason to send 768 immediately after completing the handshake MAY send ack-eliciting 769 frames, such as PING, which will cause the handshake to be confirmed 770 when they are acknowledged. 772 4.9.3. Discarding 0-RTT Keys 774 0-RTT and 1-RTT packets share the same packet number space, and 775 clients do not send 0-RTT packets after sending a 1-RTT packet 776 (Section 5.6). 778 Therefore, a client SHOULD discard 0-RTT keys as soon as it installs 779 1-RTT keys, since they have no use after that moment. 781 Additionally, a server MAY discard 0-RTT keys as soon as it receives 782 a 1-RTT packet. However, due to packet reordering, a 0-RTT packet 783 could arrive after a 1-RTT packet. Servers MAY temporarily retain 784 0-RTT keys to allow decrypting reordered packets without requiring 785 their contents to be retransmitted with 1-RTT keys. After receiving 786 a 1-RTT packet, servers MUST discard 0-RTT keys within a short time; 787 the RECOMMENDED time period is three times the Probe Timeout (PTO, 788 see [QUIC-RECOVERY]). A server MAY discard 0-RTT keys earlier if it 789 determines that it has received all 0-RTT packets, which can be done 790 by keeping track of missing packet numbers. 792 5. Packet Protection 794 As with TLS over TCP, QUIC protects packets with keys derived from 795 the TLS handshake, using the AEAD algorithm negotiated by TLS. 797 5.1. Packet Protection Keys 799 QUIC derives packet protection keys in the same way that TLS derives 800 record protection keys. 802 Each encryption level has separate secret values for protection of 803 packets sent in each direction. These traffic secrets are derived by 804 TLS (see Section 7.1 of [TLS13]) and are used by QUIC for all 805 encryption levels except the Initial encryption level. The secrets 806 for the Initial encryption level are computed based on the client's 807 initial Destination Connection ID, as described in Section 5.2. 809 The keys used for packet protection are computed from the TLS secrets 810 using the KDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label 811 function described in Section 7.1 of [TLS13] is used, using the hash 812 function from the negotiated cipher suite. Other versions of TLS 813 MUST provide a similar function in order to be used with QUIC. 815 The current encryption level secret and the label "quic key" are 816 input to the KDF to produce the AEAD key; the label "quic iv" is used 817 to derive the IV; see Section 5.3. The header protection key uses 818 the "quic hp" label; see Section 5.4. Using these labels provides 819 key separation between QUIC and TLS; see Section 9.5. 821 The KDF used for initial secrets is always the HKDF-Expand-Label 822 function from TLS 1.3 (see Section 5.2). 824 5.2. Initial Secrets 826 Initial packets are protected with a secret derived from the 827 Destination Connection ID field from the client's first Initial 828 packet of the connection. Specifically: 830 initial_salt = 0x7fbcdb0e7c66bbe9193a96cd21519ebd7a02644a 831 initial_secret = HKDF-Extract(initial_salt, 832 client_dst_connection_id) 834 client_initial_secret = HKDF-Expand-Label(initial_secret, 835 "client in", "", 836 Hash.length) 837 server_initial_secret = HKDF-Expand-Label(initial_secret, 838 "server in", "", 839 Hash.length) 841 The hash function for HKDF when deriving initial secrets and keys is 842 SHA-256 [SHA]. 844 The connection ID used with HKDF-Expand-Label is the Destination 845 Connection ID in the Initial packet sent by the client. This will be 846 a randomly-selected value unless the client creates the Initial 847 packet after receiving a Retry packet, where the Destination 848 Connection ID is selected by the server. 850 The value of initial_salt is a 20 byte sequence shown in the figure 851 in hexadecimal notation. Future versions of QUIC SHOULD generate a 852 new salt value, thus ensuring that the keys are different for each 853 version of QUIC. This prevents a middlebox that only recognizes one 854 version of QUIC from seeing or modifying the contents of packets from 855 future versions. 857 The HKDF-Expand-Label function defined in TLS 1.3 MUST be used for 858 Initial packets even where the TLS versions offered do not include 859 TLS 1.3. 861 Appendix A contains test vectors for the initial packet encryption. 863 Note: The Destination Connection ID is of arbitrary length, and it 864 could be zero length if the server sends a Retry packet with a 865 zero-length Source Connection ID field. In this case, the Initial 866 keys provide no assurance to the client that the server received 867 its packet; the client has to rely on the exchange that included 868 the Retry packet for that property. 870 5.3. AEAD Usage 872 The Authentication Encryption with Associated Data (AEAD) [AEAD] 873 function used for QUIC packet protection is the AEAD that is 874 negotiated for use with the TLS connection. For example, if TLS is 875 using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is 876 used. 878 Packets are protected prior to applying header protection 879 (Section 5.4). The unprotected packet header is part of the 880 associated data (A). When removing packet protection, an endpoint 881 first removes the header protection. 883 All QUIC packets other than Version Negotiation and Retry packets are 884 protected with an AEAD algorithm [AEAD]. Prior to establishing a 885 shared secret, packets are protected with AEAD_AES_128_GCM and a key 886 derived from the Destination Connection ID in the client's first 887 Initial packet (see Section 5.2). This provides protection against 888 off-path attackers and robustness against QUIC version unaware 889 middleboxes, but not against on-path attackers. 891 QUIC can use any of the ciphersuites defined in [TLS13] with the 892 exception of TLS_AES_128_CCM_8_SHA256. A ciphersuite MUST NOT be 893 negotiated unless a header protection scheme is defined for the 894 ciphersuite. This document defines a header protection scheme for 895 all ciphersuites defined in [TLS13] aside from 896 TLS_AES_128_CCM_8_SHA256. These ciphersuites have a 16-byte 897 authentication tag and produce an output 16 bytes larger than their 898 input. 900 Note: An endpoint MUST NOT reject a ClientHello that offers a 901 ciphersuite that it does not support, or it would be impossible to 902 deploy a new ciphersuite. This also applies to 903 TLS_AES_128_CCM_8_SHA256. 905 The key and IV for the packet are computed as described in 906 Section 5.1. The nonce, N, is formed by combining the packet 907 protection IV with the packet number. The 62 bits of the 908 reconstructed QUIC packet number in network byte order are left- 909 padded with zeros to the size of the IV. The exclusive OR of the 910 padded packet number and the IV forms the AEAD nonce. 912 The associated data, A, for the AEAD is the contents of the QUIC 913 header, starting from the flags byte in either the short or long 914 header, up to and including the unprotected packet number. 916 The input plaintext, P, for the AEAD is the payload of the QUIC 917 packet, as described in [QUIC-TRANSPORT]. 919 The output ciphertext, C, of the AEAD is transmitted in place of P. 921 Some AEAD functions have limits for how many packets can be encrypted 922 under the same key and IV (see for example [AEBounds]). This might 923 be lower than the packet number limit. An endpoint MUST initiate a 924 key update (Section 6) prior to exceeding any limit set for the AEAD 925 that is in use. 927 5.4. Header Protection 929 Parts of QUIC packet headers, in particular the Packet Number field, 930 are protected using a key that is derived separate to the packet 931 protection key and IV. The key derived using the "quic hp" label is 932 used to provide confidentiality protection for those fields that are 933 not exposed to on-path elements. 935 This protection applies to the least-significant bits of the first 936 byte, plus the Packet Number field. The four least-significant bits 937 of the first byte are protected for packets with long headers; the 938 five least significant bits of the first byte are protected for 939 packets with short headers. For both header forms, this covers the 940 reserved bits and the Packet Number Length field; the Key Phase bit 941 is also protected for packets with a short header. 943 The same header protection key is used for the duration of the 944 connection, with the value not changing after a key update (see 945 Section 6). This allows header protection to be used to protect the 946 key phase. 948 This process does not apply to Retry or Version Negotiation packets, 949 which do not contain a protected payload or any of the fields that 950 are protected by this process. 952 5.4.1. Header Protection Application 954 Header protection is applied after packet protection is applied (see 955 Section 5.3). The ciphertext of the packet is sampled and used as 956 input to an encryption algorithm. The algorithm used depends on the 957 negotiated AEAD. 959 The output of this algorithm is a 5 byte mask which is applied to the 960 protected header fields using exclusive OR. The least significant 961 bits of the first byte of the packet are masked by the least 962 significant bits of the first mask byte, and the packet number is 963 masked with the remaining bytes. Any unused bytes of mask that might 964 result from a shorter packet number encoding are unused. 966 Figure 4 shows a sample algorithm for applying header protection. 967 Removing header protection only differs in the order in which the 968 packet number length (pn_length) is determined. 970 mask = header_protection(hp_key, sample) 972 pn_length = (packet[0] & 0x03) + 1 973 if (packet[0] & 0x80) == 0x80: 974 # Long header: 4 bits masked 975 packet[0] ^= mask[0] & 0x0f 976 else: 977 # Short header: 5 bits masked 978 packet[0] ^= mask[0] & 0x1f 980 # pn_offset is the start of the Packet Number field. 981 packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length] 983 Figure 4: Header Protection Pseudocode 985 Figure 5 shows the protected fields of long and short headers marked 986 with an E. Figure 5 also shows the sampled fields. 988 Long Header: 989 +-+-+-+-+-+-+-+-+ 990 |1|1|T T|E E E E| 991 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 992 | Version -> Length Fields ... 993 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 995 Short Header: 996 +-+-+-+-+-+-+-+-+ 997 |0|1|S|E E E E E| 998 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 999 | Destination Connection ID (0/32..144) ... 1000 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1002 Common Fields: 1003 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1004 |E E E E E E E E E Packet Number (8/16/24/32) E E E E E E E E... 1005 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1006 | [Protected Payload (8/16/24)] ... 1007 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1008 | Sampled part of Protected Payload (128) ... 1009 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1010 | Protected Payload Remainder (*) ... 1011 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1013 Figure 5: Header Protection and Ciphertext Sample 1015 Before a TLS ciphersuite can be used with QUIC, a header protection 1016 algorithm MUST be specified for the AEAD used with that ciphersuite. 1017 This document defines algorithms for AEAD_AES_128_GCM, 1018 AEAD_AES_128_CCM, AEAD_AES_256_GCM (all AES AEADs are defined in 1019 [AEAD]), and AEAD_CHACHA20_POLY1305 [CHACHA]. Prior to TLS selecting 1020 a ciphersuite, AES header protection is used (Section 5.4.3), 1021 matching the AEAD_AES_128_GCM packet protection. 1023 5.4.2. Header Protection Sample 1025 The header protection algorithm uses both the header protection key 1026 and a sample of the ciphertext from the packet Payload field. 1028 The same number of bytes are always sampled, but an allowance needs 1029 to be made for the endpoint removing protection, which will not know 1030 the length of the Packet Number field. In sampling the packet 1031 ciphertext, the Packet Number field is assumed to be 4 bytes long 1032 (its maximum possible encoded length). 1034 An endpoint MUST discard packets that are not long enough to contain 1035 a complete sample. 1037 To ensure that sufficient data is available for sampling, packets are 1038 padded so that the combined lengths of the encoded packet number and 1039 protected payload is at least 4 bytes longer than the sample required 1040 for header protection. The ciphersuites defined in [TLS13] - other 1041 than TLS_AES_128_CCM_8_SHA256, for which a header protection scheme 1042 is not defined in this document - have 16-byte expansions and 16-byte 1043 header protection samples. This results in needing at least 3 bytes 1044 of frames in the unprotected payload if the packet number is encoded 1045 on a single byte, or 2 bytes of frames for a 2-byte packet number 1046 encoding. 1048 The sampled ciphertext for a packet with a short header can be 1049 determined by the following pseudocode: 1051 sample_offset = 1 + len(connection_id) + 4 1053 sample = packet[sample_offset..sample_offset+sample_length] 1055 For example, for a packet with a short header, an 8 byte connection 1056 ID, and protected with AEAD_AES_128_GCM, the sample takes bytes 13 to 1057 28 inclusive (using zero-based indexing). 1059 A packet with a long header is sampled in the same way, noting that 1060 multiple QUIC packets might be included in the same UDP datagram and 1061 that each one is handled separately. 1063 sample_offset = 6 + len(destination_connection_id) + 1064 len(source_connection_id) + 1065 len(payload_length) + 4 1066 if packet_type == Initial: 1067 sample_offset += len(token_length) + 1068 len(token) 1070 sample = packet[sample_offset..sample_offset+sample_length] 1072 5.4.3. AES-Based Header Protection 1074 This section defines the packet protection algorithm for 1075 AEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. 1076 AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AES [AES] in 1077 electronic code-book (ECB) mode. AEAD_AES_256_GCM uses 256-bit AES 1078 in ECB mode. 1080 This algorithm samples 16 bytes from the packet ciphertext. This 1081 value is used as the input to AES-ECB. In pseudocode: 1083 mask = AES-ECB(hp_key, sample) 1085 5.4.4. ChaCha20-Based Header Protection 1087 When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw 1088 ChaCha20 function as defined in Section 2.4 of [CHACHA]. This uses a 1089 256-bit key and 16 bytes sampled from the packet protection output. 1091 The first 4 bytes of the sampled ciphertext are interpreted as a 1092 32-bit number in little-endian order and are used as the block count. 1093 The remaining 12 bytes are interpreted as three concatenated 32-bit 1094 numbers in little-endian order and used as the nonce. 1096 The encryption mask is produced by invoking ChaCha20 to protect 5 1097 zero bytes. In pseudocode: 1099 counter = DecodeLE(sample[0..3]) 1100 nonce = DecodeLE(sample[4..7], sample[8..11], sample[12..15]) 1101 mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0}) 1103 5.5. Receiving Protected Packets 1105 Once an endpoint successfully receives a packet with a given packet 1106 number, it MUST discard all packets in the same packet number space 1107 with higher packet numbers if they cannot be successfully unprotected 1108 with either the same key, or - if there is a key update - the next 1109 packet protection key (see Section 6). Similarly, a packet that 1110 appears to trigger a key update, but cannot be unprotected 1111 successfully MUST be discarded. 1113 Failure to unprotect a packet does not necessarily indicate the 1114 existence of a protocol error in a peer or an attack. The truncated 1115 packet number encoding used in QUIC can cause packet numbers to be 1116 decoded incorrectly if they are delayed significantly. 1118 5.6. Use of 0-RTT Keys 1120 If 0-RTT keys are available (see Section 4.5), the lack of replay 1121 protection means that restrictions on their use are necessary to 1122 avoid replay attacks on the protocol. 1124 A client MUST only use 0-RTT keys to protect data that is idempotent. 1125 A client MAY wish to apply additional restrictions on what data it 1126 sends prior to the completion of the TLS handshake. A client 1127 otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that 1128 it MUST NOT send ACKs with 0-RTT keys. 1130 A client that receives an indication that its 0-RTT data has been 1131 accepted by a server can send 0-RTT data until it receives all of the 1132 server's handshake messages. A client SHOULD stop sending 0-RTT data 1133 if it receives an indication that 0-RTT data has been rejected. 1135 A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT 1136 keys to protect acknowledgements of 0-RTT packets. A client MUST NOT 1137 attempt to decrypt 0-RTT packets it receives and instead MUST discard 1138 them. 1140 Once a client has installed 1-RTT keys, it MUST NOT send any more 1141 0-RTT packets. 1143 Note: 0-RTT data can be acknowledged by the server as it receives 1144 it, but any packets containing acknowledgments of 0-RTT data 1145 cannot have packet protection removed by the client until the TLS 1146 handshake is complete. The 1-RTT keys necessary to remove packet 1147 protection cannot be derived until the client receives all server 1148 handshake messages. 1150 5.7. Receiving Out-of-Order Protected Frames 1152 Due to reordering and loss, protected packets might be received by an 1153 endpoint before the final TLS handshake messages are received. A 1154 client will be unable to decrypt 1-RTT packets from the server, 1155 whereas a server will be able to decrypt 1-RTT packets from the 1156 client. 1158 Even though 1-RTT keys are available to a server after receiving the 1159 first handshake messages from a client, it is missing assurances on 1160 the client state: 1162 o The client is not authenticated, unless the server has chosen to 1163 use a pre-shared key and validated the client's pre-shared key 1164 binder; see Section 4.2.11 of [TLS13]. 1166 o The client has not demonstrated liveness, unless a RETRY packet 1167 was used. 1169 o Any received 0-RTT data that the server responds to might be due 1170 to a replay attack. 1172 Therefore, the server's use of 1-RTT keys is limited before the 1173 handshake is complete. A server MUST NOT process data from incoming 1174 1-RTT protected packets before the TLS handshake is complete. 1175 Because sending acknowledgments indicates that all frames in a packet 1176 have been processed, a server cannot send acknowledgments for 1-RTT 1177 packets until the TLS handshake is complete. Received packets 1178 protected with 1-RTT keys MAY be stored and later decrypted and used 1179 once the handshake is complete. 1181 The requirement for the server to wait for the client Finished 1182 message creates a dependency on that message being delivered. A 1183 client can avoid the potential for head-of-line blocking that this 1184 implies by sending its 1-RTT packets coalesced with a handshake 1185 packet containing a copy of the CRYPTO frame that carries the 1186 Finished message, until one of the handshake packets is acknowledged. 1187 This enables immediate server processing for those packets. 1189 A server could receive packets protected with 0-RTT keys prior to 1190 receiving a TLS ClientHello. The server MAY retain these packets for 1191 later decryption in anticipation of receiving a ClientHello. 1193 6. Key Update 1195 Once the handshake is confirmed, it is possible to update the keys. 1196 The KEY_PHASE bit in the short header is used to indicate whether key 1197 updates have occurred. The KEY_PHASE bit is initially set to 0 and 1198 then inverted with each key update. 1200 The KEY_PHASE bit allows a recipient to detect a change in keying 1201 material without necessarily needing to receive the first packet that 1202 triggered the change. An endpoint that notices a changed KEY_PHASE 1203 bit can update keys and decrypt the packet that contains the changed 1204 bit. 1206 This mechanism replaces the TLS KeyUpdate message. Endpoints MUST 1207 NOT send a TLS KeyUpdate message. Endpoints MUST treat the receipt 1208 of a TLS KeyUpdate message as a connection error of type 0x10a, 1209 equivalent to a fatal TLS alert of unexpected_message (see 1210 Section 4.8). 1212 An endpoint MUST NOT initiate the first key update until the 1213 handshake is confirmed (Section 4.1.2). An endpoint MUST NOT 1214 initiate a subsequent key update until it has received an 1215 acknowledgment for a packet sent at the current KEY_PHASE. This can 1216 be implemented by tracking the lowest packet number sent with each 1217 KEY_PHASE, and the highest acknowledged packet number in the 1-RTT 1218 space: once the latter is higher than or equal to the former, another 1219 key update can be initiated. 1221 Endpoints MAY limit the number of keys they retain to two sets for 1222 removing packet protection and one set for protecting packets. Older 1223 keys can be discarded. Updating keys multiple times rapidly can 1224 cause packets to be effectively lost if packets are significantly 1225 reordered. Therefore, an endpoint SHOULD NOT initiate a key update 1226 for some time after it has last updated keys; the RECOMMENDED time 1227 period is three times the PTO. This avoids valid reordered packets 1228 being dropped by the peer as a result of the peer discarding older 1229 keys. 1231 A receiving endpoint detects an update when the KEY_PHASE bit does 1232 not match what it is expecting. It creates a new secret (see 1233 Section 7.2 of [TLS13]) and the corresponding read key and IV using 1234 the KDF function provided by TLS. The header protection key is not 1235 updated. 1237 If the packet can be decrypted and authenticated using the updated 1238 key and IV, then the keys the endpoint uses for packet protection are 1239 also updated. The next packet sent by the endpoint MUST then use the 1240 new keys. Once an endpoint has sent a packet encrypted with a given 1241 key phase, it MUST NOT send a packet encrypted with an older key 1242 phase. 1244 An endpoint does not always need to send packets when it detects that 1245 its peer has updated keys. The next packet that it sends will simply 1246 use the new keys. If an endpoint detects a second update before it 1247 has sent any packets with updated keys, it indicates that its peer 1248 has updated keys twice without awaiting a reciprocal update. An 1249 endpoint MUST treat consecutive key updates as a fatal error and 1250 abort the connection. 1252 An endpoint SHOULD retain old keys for a period of no more than three 1253 times the PTO. After this period, old keys and their corresponding 1254 secrets SHOULD be discarded. Retaining keys allow endpoints to 1255 process packets that were sent with old keys and delayed in the 1256 network. Packets with higher packet numbers always use the updated 1257 keys and MUST NOT be decrypted with old keys. 1259 This ensures that once the handshake is complete, packets with the 1260 same KEY_PHASE will have the same packet protection keys, unless 1261 there are multiple key updates in a short time frame succession and 1262 significant packet reordering. 1264 Initiating Peer Responding Peer 1266 @M QUIC Frames 1267 New Keys -> @N 1268 @N QUIC Frames 1269 --------> 1270 QUIC Frames @M 1271 New Keys -> @N 1272 QUIC Frames @N 1273 <-------- 1275 Figure 6: Key Update 1277 A packet that triggers a key update could arrive after the receiving 1278 endpoint successfully processed a packet with a higher packet number. 1279 This is only possible if there is a key compromise and an attack, or 1280 if the peer is incorrectly reverting to use of old keys. Because the 1281 latter cannot be differentiated from an attack, an endpoint MUST 1282 immediately terminate the connection if it detects this condition. 1284 In deciding when to update keys, endpoints MUST NOT exceed the limits 1285 for use of specific keys, as described in Section 5.5 of [TLS13]. 1287 7. Security of Initial Messages 1289 Initial packets are not protected with a secret key, so they are 1290 subject to potential tampering by an attacker. QUIC provides 1291 protection against attackers that cannot read packets, but does not 1292 attempt to provide additional protection against attacks where the 1293 attacker can observe and inject packets. Some forms of tampering - 1294 such as modifying the TLS messages themselves - are detectable, but 1295 some - such as modifying ACKs - are not. 1297 For example, an attacker could inject a packet containing an ACK 1298 frame that makes it appear that a packet had not been received or to 1299 create a false impression of the state of the connection (e.g., by 1300 modifying the ACK Delay). Note that such a packet could cause a 1301 legitimate packet to be dropped as a duplicate. Implementations 1302 SHOULD use caution in relying on any data which is contained in 1303 Initial packets that is not otherwise authenticated. 1305 It is also possible for the attacker to tamper with data that is 1306 carried in Handshake packets, but because that tampering requires 1307 modifying TLS handshake messages, that tampering will cause the TLS 1308 handshake to fail. 1310 8. QUIC-Specific Additions to the TLS Handshake 1312 QUIC uses the TLS handshake for more than just negotiation of 1313 cryptographic parameters. The TLS handshake validates protocol 1314 version selection, provides preliminary values for QUIC transport 1315 parameters, and allows a server to perform return routeability checks 1316 on clients. 1318 8.1. Protocol Negotiation 1320 QUIC requires that the cryptographic handshake provide authenticated 1321 protocol negotiation. TLS uses Application Layer Protocol 1322 Negotiation (ALPN) [RFC7301] to select an application protocol. 1323 Unless another mechanism is used for agreeing on an application 1324 protocol, endpoints MUST use ALPN for this purpose. When using ALPN, 1325 endpoints MUST immediately close a connection (see Section 10.3 in 1326 [QUIC-TRANSPORT]) if an application protocol is not negotiated with a 1327 no_application_protocol TLS alert (QUIC error code 0x178, see 1328 Section 4.8). While [RFC7301] only specifies that servers use this 1329 alert, QUIC clients MUST also use it to terminate a connection when 1330 ALPN negotiation fails. 1332 An application-layer protocol MAY restrict the QUIC versions that it 1333 can operate over. Servers MUST select an application protocol 1334 compatible with the QUIC version that the client has selected. If 1335 the server cannot select a compatible combination of application 1336 protocol and QUIC version, it MUST abort the connection. A client 1337 MUST abort a connection if the server picks an incompatible 1338 combination of QUIC version and ALPN identifier. 1340 8.2. QUIC Transport Parameters Extension 1342 QUIC transport parameters are carried in a TLS extension. Different 1343 versions of QUIC might define a different format for this struct. 1345 Including transport parameters in the TLS handshake provides 1346 integrity protection for these values. 1348 enum { 1349 quic_transport_parameters(0xffa5), (65535) 1350 } ExtensionType; 1352 The "extension_data" field of the quic_transport_parameters extension 1353 contains a value that is defined by the version of QUIC that is in 1354 use. The quic_transport_parameters extension carries a 1355 TransportParameters struct when the version of QUIC defined in 1356 [QUIC-TRANSPORT] is used. 1358 The quic_transport_parameters extension is carried in the ClientHello 1359 and the EncryptedExtensions messages during the handshake. Endpoints 1360 MUST send the quic_transport_parameters extension; endpoints that 1361 receive ClientHello or EncryptedExtensions messages without the 1362 quic_transport_parameters extension MUST close the connection with an 1363 error of type 0x16d (equivalent to a fatal TLS missing_extension 1364 alert, see Section 4.8). 1366 While the transport parameters are technically available prior to the 1367 completion of the handshake, they cannot be fully trusted until the 1368 handshake completes, and reliance on them should be minimized. 1369 However, any tampering with the parameters will cause the handshake 1370 to fail. 1372 Endpoints MUST NOT send this extension in a TLS connection that does 1373 not use QUIC (such as the use of TLS with TCP defined in [TLS13]). A 1374 fatal unsupported_extension alert MUST be sent by an implementation 1375 that supports this extension if the extension is received when the 1376 transport is not QUIC. 1378 8.3. Removing the EndOfEarlyData Message 1380 The TLS EndOfEarlyData message is not used with QUIC. QUIC does not 1381 rely on this message to mark the end of 0-RTT data or to signal the 1382 change to Handshake keys. 1384 Clients MUST NOT send the EndOfEarlyData message. A server MUST 1385 treat receipt of a CRYPTO frame in a 0-RTT packet as a connection 1386 error of type PROTOCOL_VIOLATION. 1388 As a result, EndOfEarlyData does not appear in the TLS handshake 1389 transcript. 1391 9. Security Considerations 1393 There are likely to be some real clangers here eventually, but the 1394 current set of issues is well captured in the relevant sections of 1395 the main text. 1397 Never assume that because it isn't in the security considerations 1398 section it doesn't affect security. Most of this document does. 1400 9.1. Replay Attacks with 0-RTT 1402 As described in Section 8 of [TLS13], use of TLS early data comes 1403 with an exposure to replay attack. The use of 0-RTT in QUIC is 1404 similarly vulnerable to replay attack. 1406 Endpoints MUST implement and use the replay protections described in 1407 [TLS13], however it is recognized that these protections are 1408 imperfect. Therefore, additional consideration of the risk of replay 1409 is needed. 1411 QUIC is not vulnerable to replay attack, except via the application 1412 protocol information it might carry. The management of QUIC protocol 1413 state based on the frame types defined in [QUIC-TRANSPORT] is not 1414 vulnerable to replay. Processing of QUIC frames is idempotent and 1415 cannot result in invalid connection states if frames are replayed, 1416 reordered or lost. QUIC connections do not produce effects that last 1417 beyond the lifetime of the connection, except for those produced by 1418 the application protocol that QUIC serves. 1420 Note: TLS session tickets and address validation tokens are used to 1421 carry QUIC configuration information between connections. These 1422 MUST NOT be used to carry application semantics. The potential 1423 for reuse of these tokens means that they require stronger 1424 protections against replay. 1426 A server that accepts 0-RTT on a connection incurs a higher cost than 1427 accepting a connection without 0-RTT. This includes higher 1428 processing and computation costs. Servers need to consider the 1429 probability of replay and all associated costs when accepting 0-RTT. 1431 Ultimately, the responsibility for managing the risks of replay 1432 attacks with 0-RTT lies with an application protocol. An application 1433 protocol that uses QUIC MUST describe how the protocol uses 0-RTT and 1434 the measures that are employed to protect against replay attack. An 1435 analysis of replay risk needs to consider all QUIC protocol features 1436 that carry application semantics. 1438 Disabling 0-RTT entirely is the most effective defense against replay 1439 attack. 1441 QUIC extensions MUST describe how replay attacks affect their 1442 operation, or prohibit their use in 0-RTT. Application protocols 1443 MUST either prohibit the use of extensions that carry application 1444 semantics in 0-RTT or provide replay mitigation strategies. 1446 9.2. Packet Reflection Attack Mitigation 1448 A small ClientHello that results in a large block of handshake 1449 messages from a server can be used in packet reflection attacks to 1450 amplify the traffic generated by an attacker. 1452 QUIC includes three defenses against this attack. First, the packet 1453 containing a ClientHello MUST be padded to a minimum size. Second, 1454 if responding to an unverified source address, the server is 1455 forbidden to send more than three UDP datagrams in its first flight 1456 (see Section 8.1 of [QUIC-TRANSPORT]). Finally, because 1457 acknowledgements of Handshake packets are authenticated, a blind 1458 attacker cannot forge them. Put together, these defenses limit the 1459 level of amplification. 1461 9.3. Peer Denial of Service 1463 QUIC, TLS, and HTTP/2 all contain messages that have legitimate uses 1464 in some contexts, but that can be abused to cause a peer to expend 1465 processing resources without having any observable impact on the 1466 state of the connection. If processing is disproportionately large 1467 in comparison to the observable effects on bandwidth or state, then 1468 this could allow a malicious peer to exhaust processing capacity 1469 without consequence. 1471 While there are legitimate uses for some redundant packets, 1472 implementations SHOULD track redundant packets and treat excessive 1473 volumes of any non-productive packets as indicative of an attack. 1475 9.4. Header Protection Analysis 1477 Header protection relies on the packet protection AEAD being a 1478 pseudorandom function (PRF), which is not a property that AEAD 1479 algorithms guarantee. Therefore, no strong assurances about the 1480 general security of this mechanism can be shown in the general case. 1481 The AEAD algorithms described in this document are assumed to be 1482 PRFs. 1484 The header protection algorithms defined in this document take the 1485 form: 1487 protected_field = field XOR PRF(hp_key, sample) 1489 This construction is secure against chosen plaintext attacks (IND- 1490 CPA) [IMC]. 1492 Use of the same key and ciphertext sample more than once risks 1493 compromising header protection. Protecting two different headers 1494 with the same key and ciphertext sample reveals the exclusive OR of 1495 the protected fields. Assuming that the AEAD acts as a PRF, if L 1496 bits are sampled, the odds of two ciphertext samples being identical 1497 approach 2^(-L/2), that is, the birthday bound. For the algorithms 1498 described in this document, that probability is one in 2^64. 1500 Note: In some cases, inputs shorter than the full size required by 1501 the packet protection algorithm might be used. 1503 To prevent an attacker from modifying packet headers, the header is 1504 transitively authenticated using packet protection; the entire packet 1505 header is part of the authenticated additional data. Protected 1506 fields that are falsified or modified can only be detected once the 1507 packet protection is removed. 1509 An attacker could guess values for packet numbers and have an 1510 endpoint confirm guesses through timing side channels. Similarly, 1511 guesses for the packet number length can be trialed and exposed. If 1512 the recipient of a packet discards packets with duplicate packet 1513 numbers without attempting to remove packet protection they could 1514 reveal through timing side-channels that the packet number matches a 1515 received packet. For authentication to be free from side-channels, 1516 the entire process of header protection removal, packet number 1517 recovery, and packet protection removal MUST be applied together 1518 without timing and other side-channels. 1520 For the sending of packets, construction and protection of packet 1521 payloads and packet numbers MUST be free from side-channels that 1522 would reveal the packet number or its encoded size. 1524 9.5. Key Diversity 1526 In using TLS, the central key schedule of TLS is used. As a result 1527 of the TLS handshake messages being integrated into the calculation 1528 of secrets, the inclusion of the QUIC transport parameters extension 1529 ensures that handshake and 1-RTT keys are not the same as those that 1530 might be produced by a server running TLS over TCP. To avoid the 1531 possibility of cross-protocol key synchronization, additional 1532 measures are provided to improve key separation. 1534 The QUIC packet protection keys and IVs are derived using a different 1535 label than the equivalent keys in TLS. 1537 To preserve this separation, a new version of QUIC SHOULD define new 1538 labels for key derivation for packet protection key and IV, plus the 1539 header protection keys. This version of QUIC uses the string "quic". 1540 Other versions can use a version-specific label in place of that 1541 string. 1543 The initial secrets use a key that is specific to the negotiated QUIC 1544 version. New QUIC versions SHOULD define a new salt value used in 1545 calculating initial secrets. 1547 10. IANA Considerations 1549 This document does not create any new IANA registries, but it 1550 registers the values in the following registries: 1552 o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register 1553 the quic_transport_parameters extension found in Section 8.2. The 1554 Recommended column is to be marked Yes. The TLS 1.3 Column is to 1555 include CH and EE. 1557 11. References 1559 11.1. Normative References 1561 [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated 1562 Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, 1563 . 1565 [AES] "Advanced encryption standard (AES)", National Institute 1566 of Standards and Technology report, 1567 DOI 10.6028/nist.fips.197, November 2001. 1569 [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF 1570 Protocols", RFC 8439, DOI 10.17487/RFC8439, June 2018, 1571 . 1573 [QUIC-RECOVERY] 1574 Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection 1575 and Congestion Control", draft-ietf-quic-recovery-21 (work 1576 in progress), July 2019. 1578 [QUIC-TRANSPORT] 1579 Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based 1580 Multiplexed and Secure Transport", draft-ietf-quic- 1581 transport-21 (work in progress), July 2019. 1583 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1584 Requirement Levels", BCP 14, RFC 2119, 1585 DOI 10.17487/RFC2119, March 1997, 1586 . 1588 [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, 1589 "Transport Layer Security (TLS) Application-Layer Protocol 1590 Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, 1591 July 2014, . 1593 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1594 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1595 May 2017, . 1597 [SHA] Dang, Q., "Secure Hash Standard", National Institute of 1598 Standards and Technology report, 1599 DOI 10.6028/nist.fips.180-4, July 2015. 1601 [TLS-REGISTRIES] 1602 Salowey, J. and S. Turner, "IANA Registry Updates for TLS 1603 and DTLS", RFC 8447, DOI 10.17487/RFC8447, August 2018, 1604 . 1606 [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol 1607 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 1608 . 1610 11.2. Informative References 1612 [AEBounds] 1613 Luykx, A. and K. Paterson, "Limits on Authenticated 1614 Encryption Use in TLS", March 2016, 1615 . 1617 [IMC] Katz, J. and Y. Lindell, "Introduction to Modern 1618 Cryptography, Second Edition", ISBN 978-1466570269, 1619 November 2014. 1621 [QUIC-HTTP] 1622 Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over 1623 QUIC", draft-ietf-quic-http-21 (work in progress), July 1624 2019. 1626 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 1627 DOI 10.17487/RFC2818, May 2000, 1628 . 1630 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 1631 Housley, R., and W. Polk, "Internet X.509 Public Key 1632 Infrastructure Certificate and Certificate Revocation List 1633 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 1634 . 1636 11.3. URIs 1638 [1] https://mailarchive.ietf.org/arch/search/?email_list=quic 1640 [2] https://github.com/quicwg 1642 [3] https://github.com/quicwg/base-drafts/labels/-tls 1644 Appendix A. Sample Initial Packet Protection 1646 This section shows examples of packet protection for Initial packets 1647 so that implementations can be verified incrementally. These packets 1648 use an 8-byte client-chosen Destination Connection ID of 1649 0x8394c8f03e515708. Values for both server and client packet 1650 protection are shown together with values in hexadecimal. 1652 A.1. Keys 1654 The labels generated by the HKDF-Expand-Label function are: 1656 client in: 00200f746c73313320636c69656e7420696e00 1658 server in: 00200f746c7331332073657276657220696e00 1660 quic key: 00100e746c7331332071756963206b657900 1662 quic iv: 000c0d746c733133207175696320697600 1664 quic hp: 00100d746c733133207175696320687000 1666 The initial secret is common: 1668 initial_secret = HKDF-Extract(initial_salt, cid) 1669 = 4496d3903d3f97cc5e45ac5790ddc686 1670 683c7c0067012bb09d900cc21832d596 1672 The secrets for protecting client packets are: 1674 client_initial_secret 1675 = HKDF-Expand-Label(initial_secret, "client in", _, 32) 1676 = 8a3515a14ae3c31b9c2d6d5bc58538ca 1677 5cd2baa119087143e60887428dcb52f6 1679 key = HKDF-Expand-Label(client_initial_secret, "quic key", _, 16) 1680 = 98b0d7e5e7a402c67c33f350fa65ea54 1682 iv = HKDF-Expand-Label(client_initial_secret, "quic iv", _, 12) 1683 = 19e94387805eb0b46c03a788 1685 hp = HKDF-Expand-Label(client_initial_secret, "quic hp", _, 16) 1686 = 0edd982a6ac527f2eddcbb7348dea5d7 1688 The secrets for protecting server packets are: 1690 server_initial_secret 1691 = HKDF-Expand-Label(initial_secret, "server in", _, 32) 1692 = 47b2eaea6c266e32c0697a9e2a898bdf 1693 5c4fb3e5ac34f0e549bf2c58581a3811 1695 key = HKDF-Expand-Label(server_initial_secret, "quic key", _, 16) 1696 = 9a8be902a9bdd91d16064ca118045fb4 1698 iv = HKDF-Expand-Label(server_initial_secret, "quic iv", _, 12) 1699 = 0a82086d32205ba22241d8dc 1701 hp = HKDF-Expand-Label(server_initial_secret, "quic hp", _, 16) 1702 = 94b9452d2b3c7c7f6da7fdd8593537fd 1704 A.2. Client Initial 1706 The client sends an Initial packet. The unprotected payload of this 1707 packet contains the following CRYPTO frame, plus enough PADDING 1708 frames to make an 1163 byte payload: 1710 060040c4010000c003036660261ff947 cea49cce6cfad687f457cf1b14531ba1 1711 4131a0e8f309a1d0b9c4000006130113 031302010000910000000b0009000006 1712 736572766572ff01000100000a001400 12001d00170018001901000101010201 1713 03010400230000003300260024001d00 204cfdfcd178b784bf328cae793b136f 1714 2aedce005ff183d7bb14952072366470 37002b0003020304000d0020001e0403 1715 05030603020308040805080604010501 060102010402050206020202002d0002 1716 0101001c00024001 1718 The unprotected header includes the connection ID and a 4 byte packet 1719 number encoding for a packet number of 2: 1721 c3ff000015508394c8f03e51570800449f00000002 1722 Protecting the payload produces output that is sampled for header 1723 protection. Because the header uses a 4 byte packet number encoding, 1724 the first 16 bytes of the protected payload is sampled, then applied 1725 to the header: 1727 sample = 65f354ebb400418b614f73765009c016 1729 mask = AES-ECB(hp, sample)[0..4] 1730 = 519bd343ff 1732 header[0] ^= mask[0] & 0x0f 1733 = c2 1734 header[17..20] ^= mask[1..4] 1735 = 9bd343fd 1736 header = c2ff000015508394c8f03e51570800449f9bd343fd 1738 The resulting protected packet is: 1740 c2ff000015508394c8f03e5157080044 9f9bd343fd65f354ebb400418b614f73 1741 765009c0162d594777f9e6ddeb32fba3 865cffd7e26e3724d4997cdde8df34f8 1742 868772fed2412d43046f44dc7c6adf5e e10da456d56c892c8f69594594e8dcab 1743 edb10d591130ca464588f2834eab931b 10feb963c1947a05f57062692c242248 1744 ad0133b31f6dcc585ba344ca5beb382f b619272e65dfccae59c08eb00b7d2a5b 1745 bccd888582df1d1aee040aea76ab4dfd cae126791e71561b1f58312edb31c164 1746 ff1341fd2820e2399946bad901e425da e58a9859ef1825e7d757a6291d9ba6ee 1747 1a8c836dc0027cd705bd2bc67f56bad0 024efaa3819cbb5d46cefdb7e0df3ad9 1748 2b0689650e2b49ac29e6398bedc75554 1a3f3865bc4759bec74d721a28a0452c 1749 1260189e8e92f844c91b27a00fc5ed6d 14d8fceb5a848bea0a3208162c7a9578 1750 2fcf9a045b20b76710a2565372f25411 81030e4350e199e62fa4e2e0bba19ff6 1751 6662ab8cc6815eeaa20b80d5f31c41e5 51f558d2c836a215ccff4e8afd2fec4b 1752 fcb9ea9d051d12162f1b14842489b69d 72a307d9144fced64fc4aa21ebd310f8 1753 97cf00062e90dad5dbf04186622e6c12 96d388176585fdb395358ecfec4d95db 1754 4429f4473a76210866fd180eaeb60da4 33500c74c00aef24d77eae81755faa03 1755 e71a8879937b32d31be2ba51d41b5d7a 1fbb4d952b10dd2d6ec171a3187cf3f6 1756 4d520afad796e4188bc32d153241c083 f225b6e6b845ce9911bd3fe1eb4737b7 1757 1c8d55e3962871b73657b1e2cce368c7 400658d47cfd9290ed16cdc2a6e3e7dc 1758 ea77fb5c6459303a32d58f62969d8f46 70ce27f591c7a59cc3e7556eda4c58a3 1759 2e9f53fd7f9d60a9c05cd6238c71e3c8 2d2efabd3b5177670b8d595151d7eb44 1760 aa401fe3b5b87bdb88dffb2bfb6d1d0d 8868a41ba96265ca7a68d06fc0b74bcc 1761 ac55b038f8362b84d47f52744323d08b 46bfec8c421f991e1394938a546a7482 1762 a17c72be109ea4b0c71abc7d9c0ac096 0327754e1043f18a32b9fb402fc33fdc 1763 b6a0b4fdbbddbdf0d85779879e98ef21 1d104a5271f22823f16942cfa8ace68d 1764 0c9e5b52297da9702d8f1de24bcd0628 4ac8aa1068fa21a82abbca7e7454b848 1765 d7de8c3d43560541a362ff4f6be06c01 15e3a733bff44417da11ae668857bba2 1766 c53ba17db8c100f1b5c7c9ea960d3f3d 3b9e77c16c31a222b498a7384e286b9b 1767 7c45167d5703de715f9b06708403562d cff77fdf2793f94e294888cebe8da4ee 1768 88a53e38f2430addc161e8b2e2f2d405 41d10cda9a7aa518ac14d0195d8c2012 1769 0b4f1d47d6d0909e69c4a0e641b83c1a d4fff85af4751035bc5698b6141ecc3f 1770 bffcf2f55036880071ba118927400796 7f64468172854d140d229320d689f576 1771 60f6c445e629d15ff2dcdff4b71a41ec 0c24bd2fd8f5ad13b2c3688e0fdb8dbc 1772 ce42e6cf49cf60d022ccd5b19b4fd5d9 8dc10d9ce3a626851b1fdd23e1fa3a96 1773 1f9b0333ab8d632e48c944b82bdd9e80 0fa2b2b9e31e96aee54b40edaf6b79ec 1774 211fdc95d95ef552aa532583d76a539e 988e416a0a10df2550cdeacafc3d61b0 1775 b0a79337960a0be8cf6169e4d55fa6e7 a9c2e8efabab3da008f5bcc38c1bbabd 1776 b6c10368723da0ae83c4b1819ff54946 e7806458d80d7be2c867d46fe1f029c5 1777 e952eb19ded16fabb19980480eb0fbcd 1779 A.3. Server Initial 1781 The server sends the following payload in response, including an ACK 1782 frame, a CRYPTO frame, and no PADDING frames: 1784 0d0000000018410a020000560303eefc e7f7b37ba1d1632e96677825ddf73988 1785 cfc79825df566dc5430b9a045a120013 0100002e00330024001d00209d3c940d 1786 89690b84d08a60993c144eca684d1081 287c834d5311bcf32bb9da1a002b0002 1787 0304 1788 The header from the server includes a new connection ID and a 2-byte 1789 packet number encoding for a packet number of 1: 1791 c1ff00001505f067a5502a4262b50040740001 1793 As a result, after protection, the header protection sample is taken 1794 starting from the third protected octet: 1796 sample = 6176fa3b713f272a9bf03ee28d3c8add 1797 mask = 5bd74a846c 1798 header = caff00001505f067a5502a4262b5004074d74b 1800 The final protected packet is then: 1802 caff00001505f067a5502a4262b50040 74d74b7e486176fa3b713f272a9bf03e 1803 e28d3c8addb4e805b3a110b663122a75 eee93c9177ac6b7a6b548e15a7b8f884 1804 65e9eab253a760779b2e6a2c574882b4 8d3a3eed696e50d04d5ec59af85261e4 1805 cdbe264bd65f2b076760c69beef23aa7 14c9a174d69034c09a2863e1e1863508 1806 8d4afdeab9 1808 Appendix B. Change Log 1810 *RFC Editor's Note:* Please remove this section prior to 1811 publication of a final version of this document. 1813 Issue and pull request numbers are listed with a leading octothorp. 1815 B.1. Since draft-ietf-quic-tls-20 1817 o Mandate the use of the QUIC transport parameters extension (#2528, 1818 #2560) 1820 o Define handshake completion and confirmation; define clearer rules 1821 when it encryption keys should be discarded (#2214, #2267, #2673) 1823 B.2. Since draft-ietf-quic-tls-18 1825 o Increased the set of permissible frames in 0-RTT (#2344, #2355) 1827 o Transport parameter extension is mandatory (#2528, #2560) 1829 B.3. Since draft-ietf-quic-tls-17 1831 o Endpoints discard initial keys as soon as handshake keys are 1832 available (#1951, #2045) 1834 o Use of ALPN or equivalent is mandatory (#2263, #2284) 1836 B.4. Since draft-ietf-quic-tls-14 1838 o Update the salt used for Initial secrets (#1970) 1840 o Clarify that TLS_AES_128_CCM_8_SHA256 isn't supported (#2019) 1842 o Change header protection 1844 * Sample from a fixed offset (#1575, #2030) 1846 * Cover part of the first byte, including the key phase (#1322, 1847 #2006) 1849 o TLS provides an AEAD and KDF function (#2046) 1851 * Clarify that the TLS KDF is used with TLS (#1997) 1853 * Change the labels for calculation of QUIC keys (#1845, #1971, 1854 #1991) 1856 o Initial keys are discarded once Handshake are avaialble (#1951, 1857 #2045) 1859 B.5. Since draft-ietf-quic-tls-13 1861 o Updated to TLS 1.3 final (#1660) 1863 B.6. Since draft-ietf-quic-tls-12 1865 o Changes to integration of the TLS handshake (#829, #1018, #1094, 1866 #1165, #1190, #1233, #1242, #1252, #1450) 1868 * The cryptographic handshake uses CRYPTO frames, not stream 0 1870 * QUIC packet protection is used in place of TLS record 1871 protection 1873 * Separate QUIC packet number spaces are used for the handshake 1875 * Changed Retry to be independent of the cryptographic handshake 1877 * Limit the use of HelloRetryRequest to address TLS needs (like 1878 key shares) 1880 o Changed codepoint of TLS extension (#1395, #1402) 1882 B.7. Since draft-ietf-quic-tls-11 1884 o Encrypted packet numbers. 1886 B.8. Since draft-ietf-quic-tls-10 1888 o No significant changes. 1890 B.9. Since draft-ietf-quic-tls-09 1892 o Cleaned up key schedule and updated the salt used for handshake 1893 packet protection (#1077) 1895 B.10. Since draft-ietf-quic-tls-08 1897 o Specify value for max_early_data_size to enable 0-RTT (#942) 1899 o Update key derivation function (#1003, #1004) 1901 B.11. Since draft-ietf-quic-tls-07 1903 o Handshake errors can be reported with CONNECTION_CLOSE (#608, 1904 #891) 1906 B.12. Since draft-ietf-quic-tls-05 1908 No significant changes. 1910 B.13. Since draft-ietf-quic-tls-04 1912 o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) 1914 B.14. Since draft-ietf-quic-tls-03 1916 No significant changes. 1918 B.15. Since draft-ietf-quic-tls-02 1920 o Updates to match changes in transport draft 1922 B.16. Since draft-ietf-quic-tls-01 1924 o Use TLS alerts to signal TLS errors (#272, #374) 1926 o Require ClientHello to fit in a single packet (#338) 1928 o The second client handshake flight is now sent in the clear (#262, 1929 #337) 1931 o The QUIC header is included as AEAD Associated Data (#226, #243, 1932 #302) 1934 o Add interface necessary for client address validation (#275) 1936 o Define peer authentication (#140) 1938 o Require at least TLS 1.3 (#138) 1940 o Define transport parameters as a TLS extension (#122) 1942 o Define handling for protected packets before the handshake 1943 completes (#39) 1945 o Decouple QUIC version and ALPN (#12) 1947 B.17. Since draft-ietf-quic-tls-00 1949 o Changed bit used to signal key phase 1951 o Updated key phase markings during the handshake 1953 o Added TLS interface requirements section 1955 o Moved to use of TLS exporters for key derivation 1957 o Moved TLS error code definitions into this document 1959 B.18. Since draft-thomson-quic-tls-01 1961 o Adopted as base for draft-ietf-quic-tls 1963 o Updated authors/editors list 1965 o Added status note 1967 Acknowledgments 1969 This document has benefited from input from Dragana Damjanovic, 1970 Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric 1971 Rescorla, Ian Swett, and many others. 1973 Contributors 1975 Ryan Hamilton was originally an author of this specification. 1977 Authors' Addresses 1979 Martin Thomson (editor) 1980 Mozilla 1982 Email: mt@lowentropy.net 1984 Sean Turner (editor) 1985 sn3rd 1987 Email: sean@sn3rd.com