draft-ietf-quic-tls-12.txt   draft-ietf-quic-tls-13.txt 
QUIC M. Thomson, Ed. QUIC M. Thomson, Ed.
Internet-Draft Mozilla Internet-Draft Mozilla
Intended status: Standards Track S. Turner, Ed. Intended status: Standards Track S. Turner, Ed.
Expires: November 23, 2018 sn3rd Expires: December 30, 2018 sn3rd
May 22, 2018 June 28, 2018
Using Transport Layer Security (TLS) to Secure QUIC Using Transport Layer Security (TLS) to Secure QUIC
draft-ietf-quic-tls-12 draft-ietf-quic-tls-13
Abstract Abstract
This document describes how Transport Layer Security (TLS) is used to This document describes how Transport Layer Security (TLS) is used to
secure QUIC. secure QUIC.
Note to Readers Note to Readers
Discussion of this draft takes place on the QUIC working group Discussion of this draft takes place on the QUIC working group
mailing list (quic@ietf.org), which is archived at mailing list (quic@ietf.org), which is archived at
skipping to change at page 1, line 42 skipping to change at page 1, line 42
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on November 23, 2018. This Internet-Draft will expire on December 30, 2018.
Copyright Notice Copyright Notice
Copyright (c) 2018 IETF Trust and the persons identified as the Copyright (c) 2018 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Notational Conventions . . . . . . . . . . . . . . . . . . . 4 2. Notational Conventions . . . . . . . . . . . . . . . . . . . 3
3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 4 2.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 4
3.1. TLS Overview . . . . . . . . . . . . . . . . . . . . . . 5 3. Protocol Overview . . . . . . . . . . . . . . . . . . . . . . 6
3.2. TLS Handshake . . . . . . . . . . . . . . . . . . . . . . 6 4. Carrying TLS Messages . . . . . . . . . . . . . . . . . . . . 7
4. TLS Usage . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.1. Interface to TLS . . . . . . . . . . . . . . . . . . . . 8
4.1. Handshake and Setup Sequence . . . . . . . . . . . . . . 8 4.1.1. Sending and Receiving Handshake Messages . . . . . . 9
4.2. Interface to TLS . . . . . . . . . . . . . . . . . . . . 9 4.1.2. Encryption Level Changes . . . . . . . . . . . . . . 10
4.2.1. Handshake Interface . . . . . . . . . . . . . . . . . 10 4.1.3. TLS Interface Summary . . . . . . . . . . . . . . . . 11
4.2.2. Source Address Validation . . . . . . . . . . . . . . 11 4.2. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 12
4.2.3. Key Ready Events . . . . . . . . . . . . . . . . . . 12 4.3. ClientHello Size . . . . . . . . . . . . . . . . . . . . 12
4.2.4. Secret Export . . . . . . . . . . . . . . . . . . . . 12 4.4. Peer Authentication . . . . . . . . . . . . . . . . . . . 12
4.2.5. TLS Interface Summary . . . . . . . . . . . . . . . . 12 4.5. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 13
4.3. TLS Version . . . . . . . . . . . . . . . . . . . . . . . 13 4.6. Rejecting 0-RTT . . . . . . . . . . . . . . . . . . . . . 13
4.4. ClientHello Size . . . . . . . . . . . . . . . . . . . . 13 4.7. HelloRetryRequest . . . . . . . . . . . . . . . . . . . . 13
4.5. Peer Authentication . . . . . . . . . . . . . . . . . . . 14 4.8. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 14
4.6. Rejecting 0-RTT . . . . . . . . . . . . . . . . . . . . . 14 5. QUIC Packet Protection . . . . . . . . . . . . . . . . . . . 14
4.7. TLS Errors . . . . . . . . . . . . . . . . . . . . . . . 15 5.1. QUIC Packet Encryption Keys . . . . . . . . . . . . . . . 14
5. QUIC Packet Protection . . . . . . . . . . . . . . . . . . . 15 5.1.1. Initial Secrets . . . . . . . . . . . . . . . . . . . 14
5.1. Installing New Keys . . . . . . . . . . . . . . . . . . . 15 5.2. QUIC AEAD Usage . . . . . . . . . . . . . . . . . . . . . 15
5.2. Enabling 0-RTT . . . . . . . . . . . . . . . . . . . . . 15 5.3. Packet Number Protection . . . . . . . . . . . . . . . . 16
5.3. QUIC Key Expansion . . . . . . . . . . . . . . . . . . . 16 5.3.1. AES-Based Packet Number Protection . . . . . . . . . 17
5.3.1. QHKDF-Expand . . . . . . . . . . . . . . . . . . . . 16 5.3.2. ChaCha20-Based Packet Number Protection . . . . . . . 18
5.3.2. Handshake Secrets . . . . . . . . . . . . . . . . . . 17 5.4. Receiving Protected Packets . . . . . . . . . . . . . . . 18
5.3.3. 0-RTT Secret . . . . . . . . . . . . . . . . . . . . 17 5.5. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 18
5.3.4. 1-RTT Secrets . . . . . . . . . . . . . . . . . . . . 18 5.6. Receiving Out-of-Order Protected Frames . . . . . . . . . 19
5.3.5. Updating 1-RTT Secrets . . . . . . . . . . . . . . . 18 6. Key Update . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3.6. Packet Protection Keys . . . . . . . . . . . . . . . 18 7. Security of Initial Messages . . . . . . . . . . . . . . . . 21
5.4. QUIC AEAD Usage . . . . . . . . . . . . . . . . . . . . . 19 8. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 21
5.5. Packet Numbers . . . . . . . . . . . . . . . . . . . . . 20 8.1. Protocol and Version Negotiation . . . . . . . . . . . . 22
5.6. Packet Number Protection . . . . . . . . . . . . . . . . 21 8.2. QUIC Transport Parameters Extension . . . . . . . . . . . 22
5.6.1. AES-Based Packet Number Protection . . . . . . . . . 22 9. Security Considerations . . . . . . . . . . . . . . . . . . . 23
5.6.2. ChaCha20-Based Packet Number Protection . . . . . . . 22 9.1. Packet Reflection Attack Mitigation . . . . . . . . . . . 23
5.7. Receiving Protected Packets . . . . . . . . . . . . . . . 22 9.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 23
6. Key Phases . . . . . . . . . . . . . . . . . . . . . . . . . 23 9.3. Packet Number Protection Analysis . . . . . . . . . . . . 24
6.1. Packet Protection for the TLS Handshake . . . . . . . . . 23 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 25
6.1.1. Initial Key Transitions . . . . . . . . . . . . . . . 24 11. References . . . . . . . . . . . . . . . . . . . . . . . . . 25
6.1.2. Retransmission and Acknowledgment of Unprotected 11.1. Normative References . . . . . . . . . . . . . . . . . . 25
Packets . . . . . . . . . . . . . . . . . . . . . . . 24 11.2. Informative References . . . . . . . . . . . . . . . . . 26
6.2. Key Update . . . . . . . . . . . . . . . . . . . . . . . 25 11.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7. Client Address Validation . . . . . . . . . . . . . . . . . . 27 Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 27
7.1. HelloRetryRequest Address Validation . . . . . . . . . . 27 A.1. Since draft-ietf-quic-tls-12 . . . . . . . . . . . . . . 27
7.1.1. Stateless Address Validation . . . . . . . . . . . . 28 A.2. Since draft-ietf-quic-tls-11 . . . . . . . . . . . . . . 27
7.1.2. Sending HelloRetryRequest . . . . . . . . . . . . . . 28 A.3. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 27
7.2. NewSessionTicket Address Validation . . . . . . . . . . . 29 A.4. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 27
7.3. Address Validation Token Integrity . . . . . . . . . . . 29 A.5. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 27
8. Pre-handshake QUIC Messages . . . . . . . . . . . . . . . . . 29 A.6. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 28
8.1. Unprotected Packets Prior to Handshake Completion . . . . 30 A.7. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 28
8.1.1. STREAM Frames . . . . . . . . . . . . . . . . . . . . 31 A.8. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 28
8.1.2. ACK Frames . . . . . . . . . . . . . . . . . . . . . 31 A.9. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 28
8.1.3. Updates to Data and Stream Limits . . . . . . . . . . 31 A.10. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 28
8.1.4. Handshake Failures . . . . . . . . . . . . . . . . . 32 A.11. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 28
8.1.5. Address Verification . . . . . . . . . . . . . . . . 32 A.12. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 29
8.1.6. Denial of Service with Unprotected Packets . . . . . 32 A.13. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 29
8.2. Use of 0-RTT Keys . . . . . . . . . . . . . . . . . . . . 33 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 29
8.3. Receiving Out-of-Order Protected Frames . . . . . . . . . 33 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 29
9. QUIC-Specific Additions to the TLS Handshake . . . . . . . . 34 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 29
9.1. Protocol and Version Negotiation . . . . . . . . . . . . 34
9.2. QUIC Transport Parameters Extension . . . . . . . . . . . 34
10. Security Considerations . . . . . . . . . . . . . . . . . . . 35
10.1. Packet Reflection Attack Mitigation . . . . . . . . . . 35
10.2. Peer Denial of Service . . . . . . . . . . . . . . . . . 35
10.3. Packet Number Protection Analysis . . . . . . . . . . . 36
11. Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . 37
12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 37
13. References . . . . . . . . . . . . . . . . . . . . . . . . . 38
13.1. Normative References . . . . . . . . . . . . . . . . . . 38
13.2. Informative References . . . . . . . . . . . . . . . . . 39
13.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Appendix A. Contributors . . . . . . . . . . . . . . . . . . . . 40
Appendix B. Acknowledgments . . . . . . . . . . . . . . . . . . 40
Appendix C. Change Log . . . . . . . . . . . . . . . . . . . . . 40
C.1. Since draft-ietf-quic-tls-10 . . . . . . . . . . . . . . 41
C.2. Since draft-ietf-quic-tls-09 . . . . . . . . . . . . . . 41
C.3. Since draft-ietf-quic-tls-08 . . . . . . . . . . . . . . 41
C.4. Since draft-ietf-quic-tls-07 . . . . . . . . . . . . . . 41
C.5. Since draft-ietf-quic-tls-05 . . . . . . . . . . . . . . 41
C.6. Since draft-ietf-quic-tls-04 . . . . . . . . . . . . . . 41
C.7. Since draft-ietf-quic-tls-03 . . . . . . . . . . . . . . 41
C.8. Since draft-ietf-quic-tls-02 . . . . . . . . . . . . . . 41
C.9. Since draft-ietf-quic-tls-01 . . . . . . . . . . . . . . 41
C.10. Since draft-ietf-quic-tls-00 . . . . . . . . . . . . . . 42
C.11. Since draft-thomson-quic-tls-01 . . . . . . . . . . . . . 42
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 42
1. Introduction 1. Introduction
This document describes how QUIC [QUIC-TRANSPORT] is secured using This document describes how QUIC [QUIC-TRANSPORT] is secured using
Transport Layer Security (TLS) version 1.3 [TLS13]. TLS 1.3 provides Transport Layer Security (TLS) version 1.3 [TLS13]. TLS 1.3 provides
critical latency improvements for connection establishment over critical latency improvements for connection establishment over
previous versions. Absent packet loss, most new connections can be previous versions. Absent packet loss, most new connections can be
established and secured within a single round trip; on subsequent established and secured within a single round trip; on subsequent
connections between the same client and server, the client can often connections between the same client and server, the client can often
send application data immediately, that is, using a zero round trip send application data immediately, that is, using a zero round trip
setup. setup.
This document describes how the standardized TLS 1.3 acts a security This document describes how the standardized TLS 1.3 acts as a
component of QUIC. The same design could work for TLS 1.2, though security component of QUIC.
few of the benefits QUIC provides would be realized due to the
handshake latency in versions of TLS prior to 1.3.
2. Notational Conventions 2. Notational Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
This document uses the terminology established in [QUIC-TRANSPORT]. This document uses the terminology established in [QUIC-TRANSPORT].
For brevity, the acronym TLS is used to refer to TLS 1.3. For brevity, the acronym TLS is used to refer to TLS 1.3.
TLS terminology is used when referring to parts of TLS. Though TLS 2.1. TLS Overview
assumes a continuous stream of octets, it divides that stream into
_records_. Most relevant to QUIC are the records that contain TLS
_handshake messages_, which are discrete messages that are used for
key agreement, authentication and parameter negotiation. Ordinarily,
TLS records can also contain _application data_, though in the QUIC
usage there is no use of TLS application data.
3. Protocol Overview
QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality
and integrity protection of packets. For this it uses keys derived
from a TLS 1.3 connection [TLS13]; QUIC also relies on TLS 1.3 for
authentication and negotiation of parameters that are critical to
security and performance.
Rather than a strict layering, these two protocols are co-dependent:
QUIC uses the TLS handshake; TLS uses the reliability and ordered
delivery provided by QUIC streams.
This document defines how QUIC interacts with TLS. This includes a
description of how TLS is used, how keying material is derived from
TLS, and the application of that keying material to protect QUIC
packets. Figure 1 shows the basic interactions between TLS and QUIC,
with the QUIC packet protection being called out specially.
+------------+ +------------+
| |------ Handshake ------>| |
| |<-- Validate Address ---| |
| |-- OK/Error/Validate -->| |
| |<----- Handshake -------| |
| QUIC |------ Validate ------->| TLS |
| | | |
| |<------ 0-RTT OK -------| |
| |<------ 1-RTT OK -------| |
| |<--- Handshake Done ----| |
+------------+ +------------+
| ^ ^ |
| Protect | Protected | |
v | Packet | |
+------------+ / /
| QUIC | / /
| Packet |-------- Get Secret -------' /
| Protection |<-------- Secret -----------'
+------------+
Figure 1: QUIC and TLS Interactions
The initial state of a QUIC connection has packets exchanged without
any form of protection. In this state, QUIC is limited to using
stream 0 and associated packets. Stream 0 is reserved for a TLS
connection. This is a complete TLS connection as it would appear
when layered over TCP; the only difference is that QUIC provides the
reliability and ordering that would otherwise be provided by TCP.
At certain points during the TLS handshake, keying material is
exported from the TLS connection for use by QUIC. This keying
material is used to derive packet protection keys. Details on how
and when keys are derived and used are included in Section 5.
3.1. TLS Overview
TLS provides two endpoints with a way to establish a means of TLS provides two endpoints with a way to establish a means of
communication over an untrusted medium (that is, the Internet) that communication over an untrusted medium (that is, the Internet) that
ensures that messages they exchange cannot be observed, modified, or ensures that messages they exchange cannot be observed, modified, or
forged. forged.
TLS features can be separated into two basic functions: an Internally, TLS is a layered protocol, with the structure shown
authenticated key exchange and record protection. QUIC primarily below:
uses the authenticated key exchange provided by TLS but provides its
own packet protection. +--------------+--------------+--------------+
| Handshake | Alerts | Application |
| Layer | | Data |
| | | |
+--------------+--------------+--------------+
| |
| Record Layer |
| |
+--------------------------------------------+
Each upper layer (handshake, alerts, and application data) is carried
as a series of typed TLS records. Records are individually
cryptographically protected and then transmitted over a reliable
transport (typically TCP) which provides sequencing and guaranteed
delivery.
The TLS authenticated key exchange occurs between two entities: The TLS authenticated key exchange occurs between two entities:
client and server. The client initiates the exchange and the server client and server. The client initiates the exchange and the server
responds. If the key exchange completes successfully, both client responds. If the key exchange completes successfully, both client
and server will agree on a secret. TLS supports both pre-shared key and server will agree on a secret. TLS supports both pre-shared key
(PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for (PSK) and Diffie-Hellman (DH) key exchanges. PSK is the basis for
0-RTT; the latter provides perfect forward secrecy (PFS) when the DH 0-RTT; the latter provides perfect forward secrecy (PFS) when the DH
keys are destroyed. keys are destroyed.
After completing the TLS handshake, the client will have learned and After completing the TLS handshake, the client will have learned and
authenticated an identity for the server and the server is optionally authenticated an identity for the server and the server is optionally
able to learn and authenticate an identity for the client. TLS able to learn and authenticate an identity for the client. TLS
supports X.509 [RFC5280] certificate-based authentication for both supports X.509 [RFC5280] certificate-based authentication for both
server and client. server and client.
The TLS key exchange is resistent to tampering by attackers and it The TLS key exchange is resistent to tampering by attackers and it
produces shared secrets that cannot be controlled by either produces shared secrets that cannot be controlled by either
participating peer. participating peer.
3.2. TLS Handshake
TLS 1.3 provides two basic handshake modes of interest to QUIC: TLS 1.3 provides two basic handshake modes of interest to QUIC:
o A full 1-RTT handshake in which the client is able to send o A full 1-RTT handshake in which the client is able to send
application data after one round trip and the server immediately application data after one round trip and the server immediately
responds after receiving the first handshake message from the responds after receiving the first handshake message from the
client. client.
o A 0-RTT handshake in which the client uses information it has o A 0-RTT handshake in which the client uses information it has
previously learned about the server to send application data previously learned about the server to send application data
immediately. This application data can be replayed by an attacker immediately. This application data can be replayed by an attacker
so it MUST NOT carry a self-contained trigger for any non- so it MUST NOT carry a self-contained trigger for any non-
idempotent action. idempotent action.
A simplified TLS 1.3 handshake with 0-RTT application data is shown A simplified TLS 1.3 handshake with 0-RTT application data is shown
in Figure 2, see [TLS13] for more options and details. in Figure 1, see [TLS13] for more options and details.
Client Server Client Server
ClientHello ClientHello
(0-RTT Application Data) --------> (0-RTT Application Data) -------->
ServerHello ServerHello
{EncryptedExtensions} {EncryptedExtensions}
{Finished} {Finished}
<-------- [Application Data] <-------- [Application Data]
(EndOfEarlyData) (EndOfEarlyData)
{Finished} --------> {Finished} -------->
[Application Data] <-------> [Application Data] [Application Data] <-------> [Application Data]
Figure 2: TLS Handshake with 0-RTT () Indicates messages protected by early data (0-RTT) keys
{} Indicates messages protected using handshake keys
[] Indicates messages protected using application data
(1-RTT) keys
This 0-RTT handshake is only possible if the client and server have Figure 1: TLS Handshake with 0-RTT
Data is protected using a number of encryption levels:
o Plaintext
o Early Data (0-RTT) Keys
o Handshake Keys
o Application Data (1-RTT) Keys
Application data may appear only in the early data and application
data levels. Handshake and Alert messages may appear in any level.
The 0-RTT handshake is only possible if the client and server have
previously communicated. In the 1-RTT handshake, the client is previously communicated. In the 1-RTT handshake, the client is
unable to send protected application data until it has received all unable to send protected application data until it has received all
of the handshake messages sent by the server. of the handshake messages sent by the server.
Two additional variations on this basic handshake exchange are 3. Protocol Overview
relevant to this document:
o The server can respond to a ClientHello with a HelloRetryRequest, QUIC [QUIC-TRANSPORT] assumes responsibility for the confidentiality
which adds an additional round trip prior to the basic exchange. and integrity protection of packets. For this it uses keys derived
This is needed if the server wishes to request a different key from a TLS 1.3 handshake [TLS13], but instead of carrying TLS records
exchange key from the client. HelloRetryRequest is also used to over QUIC (as with TCP), TLS Handshake and Alert messages are carried
verify that the client is correctly able to receive packets on the directly over the QUIC transport, which takes over the
address it claims to have (see [QUIC-TRANSPORT]). responsibilities of the TLS record layer, as shown below.
o A pre-shared key mode can be used for subsequent handshakes to +--------------+--------------+ +-------------+
reduce the number of public key operations. This is the basis for | TLS | TLS | | QUIC |
0-RTT data, even if the remainder of the connection is protected | Handshake | Alerts | | Applications|
by a new Diffie-Hellman exchange. | | | | (h2q, etc.) |
+--------------+--------------+-+-------------+
| |
| QUIC Transport |
| (streams, reliability, congestion, etc.) |
| |
+---------------------------------------------+
| |
| QUIC Packet Protection |
| |
+---------------------------------------------+
4. TLS Usage QUIC also relies on TLS 1.3 for authentication and negotiation of
parameters that are critical to security and performance.
QUIC reserves stream 0 for a TLS connection. Stream 0 contains a Rather than a strict layering, these two protocols are co-dependent:
complete TLS connection, which includes the TLS record layer. Other QUIC uses the TLS handshake; TLS uses the reliability and ordered
than the definition of a QUIC-specific extension (see Section 9.2), delivery provided by QUIC streams.
TLS is unmodified for this use. This means that TLS will apply
confidentiality and integrity protection to its records. In
particular, TLS record protection is what provides confidentiality
protection for the TLS handshake messages sent by the server.
QUIC permits a client to send frames on streams starting from the At a high level, there are two main interactions between the TLS and
first packet. The initial packet from a client contains a stream QUIC components:
frame for stream 0 that contains the first TLS handshake messages
from the client. This allows the TLS handshake to start with the
first packet that a client sends.
QUIC packets are protected using a scheme that is specific to QUIC, o The TLS component sends and receives messages via the QUIC
see Section 5. Keys are exported from the TLS connection when they component, with QUIC providing a reliable stream abstraction to
become available using a TLS exporter (see Section 7.5 of [TLS13] and TLS.
Section 5.3). After keys are exported from TLS, QUIC manages its own
key schedule.
4.1. Handshake and Setup Sequence o The TLS component provides a series of updates to the QUIC
component, including (a) new packet protection keys to install (b)
state changes such as handshake completion, the server
certificate, etc.
The integration of QUIC with a TLS handshake is shown in more detail Figure 2 shows these interactions in more detail, with the QUIC
in Figure 3. QUIC "STREAM" frames on stream 0 carry the TLS packet protection being called out specially.
handshake. QUIC performs loss recovery [QUIC-RECOVERY] for this
stream and ensures that TLS handshake messages are delivered in the
correct order.
Client Server +------------+ +------------+
| |<- Handshake Messages ->| |
| |<---- 0-RTT Keys -------| |
| |<--- Handshake Keys-----| |
| QUIC |<---- 1-RTT Keys -------| TLS |
| |<--- Handshake Done ----| |
+------------+ +------------+
| ^
| Protect | Protected
v | Packet
+------------+
| QUIC |
| Packet |
| Protection |
+------------+
@H QUIC STREAM Frame(s) <0>: Figure 2: QUIC and TLS Interactions
ClientHello
+ QUIC Extension
-------->
0-RTT Key => @0
@0 QUIC STREAM Frame(s) <any stream>: Unlike TLS over TCP, QUIC applications which want to send data do not
Replayable QUIC Frames send it through TLS "application_data" records. Rather, they send it
--------> as QUIC STREAM frames which are then carried in QUIC packets.
QUIC STREAM Frame <0>: @H 4. Carrying TLS Messages
ServerHello
{TLS Handshake Messages}
<--------
1-RTT Key => @1
QUIC Frames <any> @1 QUIC carries TLS handshake data in CRYPTO frames, each of which
<-------- consists of a contiguous block of handshake data identified by an
@H QUIC STREAM Frame(s) <0>: offset and length. Those frames are packaged into QUIC packets and
(EndOfEarlyData) encrypted under the current TLS encryption level. As with TLS over
{Finished} TCP, once TLS handshake data has been delivered to QUIC, it is QUIC's
--------> responsibility to deliver it reliably. Each chunk of data that is
produced by TLS is associated with the set of keys that TLS is
currently using. If QUIC needs to retransmit that data, it MUST use
the same keys even if TLS has already updated to newer keys.
@1 QUIC Frames <any> <-------> QUIC Frames <any> @1 One important difference between TLS 1.3 records (used with TCP) and
QUIC CRYPTO frames is that in QUIC multiple frames may appear in the
same QUIC packet as long as they are associated with the same
encryption level. For instance, an implementation might bundle a
Handshake message and an ACK for some Handshake data into the same
packet.
Figure 3: QUIC over TLS Handshake Each encryption level has a specific list of frames which may appear
in it. The rules here generalize those of TLS, in that frames
associated with establishing the connection can usually appear at any
encryption level, whereas those associated with transferring data can
only appear in the 0-RTT and 1-RTT encryption levels
In Figure 3, symbols mean: o CRYPTO frames MAY appear in packets of any encryption level.
o "<" and ">" enclose stream numbers. o CONNECTION_CLOSE MAY appear in packets of any encryption level
other than 0-RTT.
o "@" indicates the keys that are used for protecting the QUIC o PADDING and PING frames MAY appear in packets of any encryption
packet (H = handshake, using keys from the well-known cleartext level.
packet secret; 0 = 0-RTT keys; 1 = 1-RTT keys).
o "(" and ")" enclose messages that are protected with TLS 0-RTT o ACK frames MAY appear in packets of any encryption level other
handshake or application keys. than 0-RTT, but can only acknowledge packets which appeared in
that encryption level.
o "{" and "}" enclose messages that are protected by the TLS o STREAM frames MUST ONLY appear in the 0-RTT and 1-RTT levels.
Handshake keys.
If 0-RTT is not attempted, then the client does not send packets o All other frame types MUST only appear at the 1-RTT levels.
protected by the 0-RTT key (@0). In that case, the only key
transition on the client is from handshake packets (@H) to 1-RTT
protection (@1), which happens after it sends its final set of TLS
handshake messages.
Note: two different types of packet are used during the handshake by Because packets could be reordered on the wire, QUIC uses the packet
both client and server. The Initial packet carries a TLS ClientHello type to indicate which level a given packet was encrypted under, as
message; the remainder of the TLS handshake is carried in Handshake shown in Table 1. When multiple packets of different encryption
packets. The Retry packet carries a TLS HelloRetryRequest, if it is levels need to be sent, endpoints SHOULD use coalesced packets to
needed, and Handshake packets carry the remainder of the server send them in the same UDP datagram.
handshake.
The server sends TLS handshake messages without protection (@H). The +-----------------+------------------+-----------+
server transitions from no protection (@H) to full 1-RTT protection | Packet Type | Encryption Level | PN Space |
(@1) after it sends the last of its handshake messages. +-----------------+------------------+-----------+
| Initial | Initial secrets | Initial |
| | | |
| 0-RTT Protected | 0-RTT | 0/1-RTT |
| | | |
| Handshake | Handshake | Handshake |
| | | |
| Retry | N/A | N/A |
| | | |
| Short Header | 1-RTT | 0/1-RTT |
+-----------------+------------------+-----------+
Some TLS handshake messages are protected by the TLS handshake record Table 1: Encryption Levels by Packet Type
protection. These keys are not exported from the TLS connection for
use in QUIC. QUIC packets from the server are sent in the clear
until the final transition to 1-RTT keys.
The client transitions from handshake (@H) to 0-RTT keys (@0) when Section 6.3 of [QUIC-TRANSPORT] shows how packets at the various
sending 0-RTT data, and subsequently to to 1-RTT keys (@1) after its encryption levels fit into the handshake process.
second flight of TLS handshake messages. This creates the potential
for unprotected packets to be received by a server in close proximity
to packets that are protected with 1-RTT keys.
More information on key transitions is included in Section 6.1. 4.1. Interface to TLS
4.2. Interface to TLS As shown in Figure 2, the interface from QUIC to TLS consists of
three primary functions:
As shown in Figure 1, the interface from QUIC to TLS consists of four o Sending and receiving handshake messages
primary functions: Handshake, Source Address Validation, Key Ready
Events, and Secret Export. o Rekeying (both transmit and receive)
o Handshake state updates
Additional functions might be needed to configure TLS. Additional functions might be needed to configure TLS.
4.2.1. Handshake Interface 4.1.1. Sending and Receiving Handshake Messages
In order to drive the handshake, TLS depends on being able to send In order to drive the handshake, TLS depends on being able to send
and receive handshake messages on stream 0. There are two basic and receive handshake messages. There are two basic functions on
functions on this interface: one where QUIC requests handshake this interface: one where QUIC requests handshake messages and one
messages and one where QUIC provides handshake packets. where QUIC provides handshake packets.
Before starting the handshake QUIC provides TLS with the transport Before starting the handshake QUIC provides TLS with the transport
parameters (see Section 9.2) that it wishes to carry. parameters (see Section 8.2) that it wishes to carry.
A QUIC client starts TLS by requesting TLS handshake octets from TLS. A QUIC client starts TLS by requesting TLS handshake octets from TLS.
The client acquires handshake octets before sending its first packet. The client acquires handshake octets before sending its first packet.
A QUIC server starts the process by providing TLS with the client's
handshake octets.
A QUIC server starts the process by providing TLS with stream 0 At any given time, the TLS stack at an endpoint will have a current
octets. sending encryption level and receiving encryption level. Each
encryption level is associated with a different flow of bytes, which
is reliably transmitted to the peer in CRYPTO frames. When TLS
provides handshake octets to be sent, they are appended to the
current flow and any packet that includes the CRYPTO frame is
protected using keys from the corresponding encryption level.
Each time that an endpoint receives data on stream 0, it delivers the When an endpoint receives a QUIC packet containing a CRYPTO frame
octets to TLS if it is able. Each time that TLS is provided with new from the network, it proceeds as follows:
data, new handshake octets are requested from TLS. TLS might not
provide any octets if the handshake messages it has received are
incomplete or it has no data to send.
At the server, when TLS provides handshake octets, it also needs to o If the packet was in the TLS receiving encryption level, sequence
indicate whether the octets contain a HelloRetryRequest. A the data into the input flow as usual. As with STREAM frames, the
HelloRetryRequest MUST always be sent in a Retry packet, so the QUIC offset is used to find the proper location in the data sequence.
server needs to know whether the octets are a HelloRetryRequest. If the result of this process is that new data is available, then
it is delivered to TLS in order.
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.
o If the packet is from a new encryption level, it is saved for
later processing by TLS. Once TLS moves to receiving from this
encryption level, saved data can be provided. When providing data
from any new encryption level to TLS, if there is data from a
previous encryption level that TLS has not consumed, this MUST be
treated as a connection error of type PROTOCOL_VIOLATION.
Each time that TLS is provided with new data, new handshake octets
are requested from TLS. TLS might not provide any octets if the
handshake messages it has received are incomplete or it has no data
to send.
Once the TLS handshake is complete, this is indicated to QUIC along Once the TLS handshake is complete, this is indicated to QUIC along
with any final handshake octets that TLS needs to send. TLS also with any final handshake octets that TLS needs to send. TLS also
provides QUIC with the transport parameters that the peer advertised provides QUIC with the transport parameters that the peer advertised
during the handshake. during the handshake.
Once the handshake is complete, TLS becomes passive. TLS can still Once the handshake is complete, TLS becomes passive. TLS can still
receive data from its peer and respond in kind, but it will not need receive data from its peer and respond in kind, but it will not need
to send more data unless specifically requested - either by an to send more data unless specifically requested - either by an
application or QUIC. One reason to send data is that the server application or QUIC. One reason to send data is that the server
might wish to provide additional or updated session tickets to a might wish to provide additional or updated session tickets to a
client. client.
When the handshake is complete, QUIC only needs to provide TLS with When the handshake is complete, QUIC only needs to provide TLS with
any data that arrives on stream 0. In the same way that is done any data that arrives in CRYPTO streams. In the same way that is
during the handshake, new data is requested from TLS after providing done during the handshake, new data is requested from TLS after
received data. providing received data.
Important: Until the handshake is reported as complete, the Important: Until the handshake is reported as complete, the
connection and key exchange are not properly authenticated at the connection and key exchange are not properly authenticated at the
server. Even though 1-RTT keys are available to a server after server. Even though 1-RTT keys are available to a server after
receiving the first handshake messages from a client, the server receiving the first handshake messages from a client, the server
cannot consider the client to be authenticated until it receives cannot consider the client to be authenticated until it receives
and validates the client's Finished message. and validates the client's Finished message.
The requirement for the server to wait for the client Finished The requirement for the server to wait for the client Finished
message creates a dependency on that message being delivered. A message creates a dependency on that message being delivered. A
client can avoid the potential for head-of-line blocking that this client can avoid the potential for head-of-line blocking that this
implies by sending a copy of the STREAM frame that carries the implies by sending a copy of the STREAM frame that carries the
Finished message in multiple packets. This enables immediate Finished message in multiple packets. This enables immediate
server processing for those packets. server processing for those packets.
4.2.2. Source Address Validation 4.1.2. Encryption Level Changes
During the processing of the TLS ClientHello, TLS requests that the
transport make a decision about whether to request source address
validation from the client.
An initial TLS ClientHello that resumes a session includes an address
validation token in the session ticket; this includes all attempts at
0-RTT. If the client does not attempt session resumption, no token
will be present. While processing the initial ClientHello, TLS
provides QUIC with any token that is present. In response, QUIC
provides one of three responses:
o proceed with the connection,
o ask for client address validation, or
o abort the connection.
If QUIC requests source address validation, it also provides a new
address validation token. TLS includes that along with any
information it requires in the cookie extension of a TLS
HelloRetryRequest message. In the other cases, the connection either
proceeds or terminates with a handshake error.
The client echoes the cookie extension in a second ClientHello. A
ClientHello that contains a valid cookie extension will always be in
response to a HelloRetryRequest. If address validation was requested
by QUIC, then this will include an address validation token. TLS
makes a second address validation request of QUIC, including the
value extracted from the cookie extension. In response to this
request, QUIC cannot ask for client address validation, it can only
abort or permit the connection attempt to proceed.
QUIC can provide a new address validation token for use in session
resumption at any time after the handshake is complete. Each time a
new token is provided TLS generates a NewSessionTicket message, with
the token included in the ticket.
See Section 7 for more details on client address validation.
4.2.3. Key Ready Events
TLS provides QUIC with signals when 0-RTT and 1-RTT keys are ready
for use. These events are not asynchronous, they always occur
immediately after TLS is provided with new handshake octets, or after
TLS produces handshake octets.
When TLS completed its handshake, 1-RTT keys can be provided to QUIC.
On both client and server, this occurs after sending the TLS Finished
message.
This ordering means that there could be frames that carry TLS At each change of encryption level in either direction, TLS signals
handshake messages ready to send at the same time that application QUIC, providing the new level and the encryption keys. These events
data is available. An implementation MUST ensure that TLS handshake are not asynchronous, they always occur immediately after TLS is
messages are always sent in packets protected with handshake keys provided with new handshake octets, or after TLS produces handshake
(see Section 5.3.2). Separate packets are required for data that octets.
needs protection from 1-RTT keys.
If 0-RTT is possible, it is ready after the client sends a TLS If 0-RTT is possible, it is ready after the client sends a TLS
ClientHello message or the server receives that message. After ClientHello message or the server receives that message. After
providing a QUIC client with the first handshake octets, the TLS providing a QUIC client with the first handshake octets, the TLS
stack might signal that 0-RTT keys are ready. On the server, after stack might signal the change to 0-RTT keys. On the server, after
receiving handshake octets that contain a ClientHello message, a TLS receiving handshake octets that contain a ClientHello message, a TLS
server might signal that 0-RTT keys are available. server might signal that 0-RTT keys are available.
1-RTT keys are used for packets in both directions. 0-RTT keys are Note that although TLS only uses one encryption level at a time, QUIC
only used to protect packets sent by the client. may use more than one level. For instance, after sending its
Finished message (using a CRYPTO frame in Handshake encryption) may
4.2.4. Secret Export send STREAM data (in 1-RTT encryption). However, if the Finished is
lost, the client would have to retransmit the Finished, in which case
Details how secrets are exported from TLS are included in it would use Handshake encryption.
Section 5.3.
4.2.5. TLS Interface Summary 4.1.3. TLS Interface Summary
Figure 4 summarizes the exchange between QUIC and TLS for both client Figure 3 summarizes the exchange between QUIC and TLS for both client
and server. and server. Each arrow is tagged with the encryption level used for
that transmission.
Client Server Client Server
Get Handshake Get Handshake
0-RTT Key Ready Initial ------------>
--- send/receive ---> Rekey tx to 0-RTT Keys
0-RTT -------------->
Handshake Received Handshake Received
0-RTT Key Ready
Get Handshake Get Handshake
1-RTT Keys Ready <------------ Initial
<--- send/receive --- Rekey rx to 0-RTT keys
Handshake Received
Rekey rx to Handshake keys
Get Handshake
<----------- Handshake
Rekey tx to 1-RTT keys
Handshake Received
Rekey rx to Handshake keys
Handshake Received Handshake Received
Get Handshake Get Handshake
Handshake Complete Handshake Complete
1-RTT Keys Ready Rekey tx to 1-RTT keys
--- send/receive ---> Handshake ---------->
Handshake Received Handshake Received
Rekey rx to 1-RTT keys
Get Handshake Get Handshake
Handshake Complete Handshake Complete
<--- send/receive --- <--------------- 1-RTT
Handshake Received Handshake Received
Get Handshake
Figure 4: Interaction Summary between QUIC and TLS Figure 3: Interaction Summary between QUIC and TLS
4.3. TLS Version 4.2. TLS Version
This document describes how TLS 1.3 [TLS13] is used with QUIC. This document describes how TLS 1.3 [TLS13] is used with QUIC.
In practice, the TLS handshake will negotiate a version of TLS to In practice, the TLS handshake will negotiate a version of TLS to
use. This could result in a newer version of TLS than 1.3 being use. This could result in a newer version of TLS than 1.3 being
negotiated if both endpoints support that version. This is negotiated if both endpoints support that version. This is
acceptable provided that the features of TLS 1.3 that are used by acceptable provided that the features of TLS 1.3 that are used by
QUIC are supported by the newer version. QUIC are supported by the newer version.
A badly configured TLS implementation could negotiate TLS 1.2 or A badly configured TLS implementation could negotiate TLS 1.2 or
another older version of TLS. An endpoint MUST terminate the another older version of TLS. An endpoint MUST terminate the
connection if a version of TLS older than 1.3 is negotiated. connection if a version of TLS older than 1.3 is negotiated.
4.4. ClientHello Size 4.3. ClientHello Size
QUIC requires that the initial handshake packet from a client fit QUIC requires that the initial handshake packet from a client fit
within the payload of a single packet. The size limits on QUIC within the payload of a single packet. The size limits on QUIC
packets mean that a record containing a ClientHello needs to fit packets mean that a record containing a ClientHello needs to fit
within 1129 octets, though endpoints can reduce the size of their within 1129 octets, though endpoints can reduce the size of their
connection ID to increase by up to 22 octets. connection ID to increase by up to 22 octets.
A TLS ClientHello can fit within this limit with ample space A TLS ClientHello can fit within this limit with ample space
remaining. However, there are several variables that could cause remaining. However, there are several variables that could cause
this limit to be exceeded. Implementations are reminded that large this limit to be exceeded. Implementations are reminded that large
skipping to change at page 14, line 19 skipping to change at page 12, line 44
For servers, the size of the session tickets and HelloRetryRequest For servers, the size of the session tickets and HelloRetryRequest
cookie extension can have an effect on a client's ability to connect. cookie extension can have an effect on a client's ability to connect.
Choosing a small value increases the probability that these values Choosing a small value increases the probability that these values
can be successfully used by a client. can be successfully used by a client.
The TLS implementation does not need to ensure that the ClientHello The TLS implementation does not need to ensure that the ClientHello
is sufficiently large. QUIC PADDING frames are added to increase the is sufficiently large. QUIC PADDING frames are added to increase the
size of the packet as necessary. size of the packet as necessary.
4.5. Peer Authentication 4.4. Peer Authentication
The requirements for authentication depend on the application The requirements for authentication depend on the application
protocol that is in use. TLS provides server authentication and protocol that is in use. TLS provides server authentication and
permits the server to request client authentication. permits the server to request client authentication.
A client MUST authenticate the identity of the server. This A client MUST authenticate the identity of the server. This
typically involves verification that the identity of the server is typically involves verification that the identity of the server is
included in a certificate and that the certificate is issued by a included in a certificate and that the certificate is issued by a
trusted entity (see for example [RFC2818]). trusted entity (see for example [RFC2818]).
A server MAY request that the client authenticate during the A server MAY request that the client authenticate during the
handshake. A server MAY refuse a connection if the client is unable handshake. A server MAY refuse a connection if the client is unable
to authenticate when requested. The requirements for client to authenticate when requested. The requirements for client
authentication vary based on application protocol and deployment. authentication vary based on application protocol and deployment.
A server MUST NOT use post-handshake client authentication (see A server MUST NOT use post-handshake client authentication (see
Section 4.6.2 of [TLS13]). Section 4.6.2 of [TLS13]).
4.6. Rejecting 0-RTT 4.5. Enabling 0-RTT
A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This
results in early exporter keys being unavailable, thereby preventing
the use of 0-RTT for QUIC.
A client that attempts 0-RTT MUST also consider 0-RTT to be rejected
if it receives a Retry or Version Negotiation packet.
When 0-RTT is rejected, all connection characteristics that the
client assumed might be incorrect. This includes the choice of
application protocol, transport parameters, and any application
configuration. The client therefore MUST reset the state of all
streams, including application state bound to those streams.
4.7. TLS Errors
Errors in the TLS connection SHOULD be signaled using TLS alerts on
stream 0. A failure in the handshake MUST be treated as a QUIC
connection error of type TLS_HANDSHAKE_FAILED. Once the handshake is
complete, an error in the TLS connection that causes a TLS alert to
be sent or received MUST be treated as a QUIC connection error of
type TLS_FATAL_ALERT_GENERATED or TLS_FATAL_ALERT_RECEIVED
respectively.
5. QUIC Packet Protection
QUIC packet protection provides authenticated encryption of packets.
This provides confidentiality and integrity protection for the
content of packets (see Section 5.4). Packet protection uses keys
that are exported from the TLS connection (see Section 5.3).
Different keys are used for QUIC packet protection and TLS record
protection. TLS handshake messages are protected solely with TLS
record protection, but post-handshake messages are redundantly
protected with both the QUIC packet protection and the TLS record
protection. These messages are limited in number, and so the
additional overhead is small.
5.1. Installing New Keys
As TLS reports the availability of keying material, the packet
protection keys and initialization vectors (IVs) are updated (see
Section 5.3). The selection of AEAD function is also updated to
match the AEAD negotiated by TLS.
For packets other than any handshake packets (see Section 6.1), once
a change of keys has been made, packets with higher packet numbers
MUST be sent with the new keying material. The KEY_PHASE bit on
these packets is inverted each time new keys are installed to signal
the use of the new keys to the recipient (see Section 6 for details).
An endpoint retransmits stream data in a new packet. New packets
have new packet numbers and use the latest packet protection keys.
This simplifies key management when there are key updates (see
Section 6.2).
5.2. Enabling 0-RTT
In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket In order to be usable for 0-RTT, TLS MUST provide a NewSessionTicket
message that contains the "max_early_data" extension with the value message that contains the "max_early_data" extension with the value
0xffffffff; the amount of data which the client can send in 0-RTT is 0xffffffff; the amount of data which the client can send in 0-RTT is
controlled by the "initial_max_data" transport parameter supplied by controlled by the "initial_max_data" transport parameter supplied by
the server. A client MUST treat receipt of a NewSessionTicket that the server. A client MUST treat receipt of a NewSessionTicket that
contains a "max_early_data" extension with any other value as a contains a "max_early_data" extension with any other value as a
connection error of type PROTOCOL_VIOLATION. connection error of type PROTOCOL_VIOLATION.
Early data within the TLS connection MUST NOT be used. As it is for Early data within the TLS connection MUST NOT be used. As it is for
other TLS application data, a server MUST treat receiving early data other TLS application data, a server MUST treat receiving early data
on the TLS connection as a connection error of type on the TLS connection as a connection error of type
PROTOCOL_VIOLATION. PROTOCOL_VIOLATION.
5.3. QUIC Key Expansion 4.6. Rejecting 0-RTT
QUIC uses a system of packet protection secrets, keys and IVs that
are modelled on the system used in TLS [TLS13]. The secrets that
QUIC uses as the basis of its key schedule are obtained using TLS
exporters (see Section 7.5 of [TLS13]).
5.3.1. QHKDF-Expand
QUIC uses the Hash-based Key Derivation Function (HKDF) [HKDF] with
the same hash function negotiated by TLS for key derivation. For
example, if TLS is using the TLS_AES_128_GCM_SHA256, the SHA-256 hash
function is used.
Most key derivations in this document use the QHKDF-Expand function,
which uses the HKDF expand function and is modelled on the HKDF-
Expand-Label function from TLS 1.3 (see Section 7.1 of [TLS13]).
QHKDF-Expand differs from HKDF-Expand-Label in that it uses a
different base label and omits the Context argument.
QHKDF-Expand(Secret, Label, Length) =
HKDF-Expand(Secret, QhkdfExpandInfo, Length)
The HKDF-Expand function used by QHKDF-Expand uses the PRF hash
function negotiated by TLS, except for handshake secrets and keys
derived from them (see Section 5.3.2).
Where the "info" parameter of HKDF-Expand is an encoded
"QhkdfExpandInfo" structure:
struct {
uint16 length = Length;
opaque label<6..255> = "QUIC " + Label;
} QhkdfExpandInfo;
For example, assuming a hash function with a 32 octet output,
derivation for a client packet protection key would use HKDF-Expand
with an "info" parameter of 0x00200851554943206b6579.
5.3.2. Handshake Secrets
Packets that carry the TLS handshake (Initial, Retry, and Handshake)
are protected with a secret derived from the Destination Connection
ID field from the client's Initial packet. Specifically:
handshake_salt = 0x9c108f98520a5c5c32968e950e8a2c5fe06d6c38
handshake_secret =
HKDF-Extract(handshake_salt, client_dst_connection_id)
client_handshake_secret =
QHKDF-Expand(handshake_secret, "client hs", Hash.length)
server_handshake_secret =
QHKDF-Expand(handshake_secret, "server hs", Hash.length)
The hash function for HKDF when deriving handshake secrets and keys
is SHA-256 [SHA]. The connection ID used with QHKDF-Expand is the
connection ID chosen by the client.
The handshake salt is a 20 octet sequence shown in the figure in
hexadecimal notation. Future versions of QUIC SHOULD generate a new
salt value, thus ensuring that the keys are different for each
version of QUIC. This prevents a middlebox that only recognizes one
version of QUIC from seeing or modifying the contents of handshake
packets from future versions.
Note: The Destination Connection ID is of arbitrary length, and it
could be zero length if the server sends a Retry packet with a
zero-length Source Connection ID field. In this case, the
handshake keys provide no assurance to the client that the server
received its packet; the client has to rely on the exchange that
included the Retry packet for that property.
5.3.3. 0-RTT Secret
0-RTT keys are those keys that are used in resumed connections prior A server rejects 0-RTT by rejecting 0-RTT at the TLS layer. This
to the completion of the TLS handshake. Data sent using 0-RTT keys also prevents QUIC from sending 0-RTT data. A client that attempts
might be replayed and so has some restrictions on its use, see 0-RTT MUST also consider 0-RTT to be rejected if it receives a
Section 8.2. 0-RTT keys are used after sending or receiving a Version Negotiation packet.
ClientHello.
The secret is exported from TLS using the exporter label "EXPORTER- When 0-RTT is rejected, all connection characteristics that the
QUIC 0rtt" and an empty context. The size of the secret MUST be the client assumed might be incorrect. This includes the choice of
size of the hash output for the PRF hash function negotiated by TLS. application protocol, transport parameters, and any application
This uses the TLS early_exporter_secret. The QUIC 0-RTT secret is configuration. The client therefore MUST reset the state of all
only used for protection of packets sent by the client. streams, including application state bound to those streams.
client_0rtt_secret = 4.7. HelloRetryRequest
TLS-Early-Exporter("EXPORTER-QUIC 0rtt", "", Hash.length)
5.3.4. 1-RTT Secrets In TLS over TCP, the HelloRetryRequest feature (see Section 4.1.4 of
[TLS13]) can be used to correct a client's incorrect KeyShare
extension as well as for a stateless round-trip check. From the
perspective of QUIC, this just looks like additional messages carried
in the Initial encryption level. Although it is in principle
possible to use this feature for address verification in QUIC, QUIC
implementations SHOULD instead use the Retry feature (see
Section 4.4.2 of [QUIC-TRANSPORT]). HelloRetryRequest is still used
to request key shares.
1-RTT keys are used by both client and server after the TLS handshake 4.8. TLS Errors
completes. There are two secrets used at any time: one is used to
derive packet protection keys for packets sent by the client, the
other for packet protection keys on packets sent by the server.
The initial client packet protection secret is exported from TLS If TLS experiences an error, it generates an appropriate alert as
using the exporter label "EXPORTER-QUIC client 1rtt"; the initial defined in Section 6 of [TLS13].
server packet protection secret uses the exporter label "EXPORTER-
QUIC server 1rtt". Both exporters use an empty context. The size of
the secret MUST be the size of the hash output for the PRF hash
function negotiated by TLS.
client_pp_secret<0> = A TLS alert is turned into a QUIC connection error by converting the
TLS-Exporter("EXPORTER-QUIC client 1rtt", "", Hash.length) one-octet alert description into a QUIC error code. The alert
server_pp_secret<0> = description is added to 0x100 to produce a QUIC error code from the
TLS-Exporter("EXPORTER-QUIC server 1rtt", "", Hash.length) range reserved for CRYPTO_ERROR. The resulting value is sent in a
QUIC CONNECTION_CLOSE frame.
These secrets are used to derive the initial client and server packet The alert level of all TLS alerts is "fatal"; a TLS stack MUST NOT
protection keys. generate alerts at the "warning" level.
5.3.5. Updating 1-RTT Secrets 5. QUIC Packet Protection
After a key update (see Section 6.2), the 1-RTT secrets are updated As with TLS over TCP, QUIC encrypts packets with keys derived from
using QHKDF-Expand. Updated secrets are derived from the existing the TLS handshake, using the AEAD algorithm negotiated by TLS.
packet protection secret. A Label parameter of "client 1rtt" is used
for the client secret and "server 1rtt" for the server. The Length
is the same as the native output of the PRF hash function.
client_pp_secret<N+1> = 5.1. QUIC Packet Encryption Keys
QHKDF-Expand(client_pp_secret<N>, "client 1rtt", Hash.length)
server_pp_secret<N+1> =
QHKDF-Expand(server_pp_secret<N>, "server 1rtt", Hash.length)
This allows for a succession of new secrets to be created as needed. QUIC derives packet encryption keys in the same way as TLS 1.3: Each
encryption level/direction pair has a secret value, which is then
used to derive the traffic keys using as described in Section 7.3 of
[TLS13]
5.3.6. Packet Protection Keys The keys for the Initial encryption level are computed based on the
client's initial Destination Connection ID, as described in
Section 5.1.1.
The complete key expansion uses a similar process for key expansion The keys for the remaining encryption level are computed in the same
to that defined in Section 7.3 of [TLS13], using QHKDF-Expand in fashion as the corresponding TLS keys (see Section 7 of [TLS13]),
place of HKDF-Expand-Label. QUIC uses the AEAD function negotiated except that the label for HKDF-Expand-Label uses the prefix "quic "
by TLS. rather than "tls13 ". A different label provides key separation
between TLS and QUIC.
The packet protection key and IV used to protect the 0-RTT packets 5.1.1. Initial Secrets
sent by a client are derived from the QUIC 0-RTT secret. The packet
protection keys and IVs for 1-RTT packets sent by the client and
server are derived from the current generation of client and server
1-RTT secrets (client_pp_secret<i> and server_pp_secret<i>)
respectively.
The length of the QHKDF-Expand output is determined by the Initial packets are protected with a secret derived from the
requirements of the AEAD function selected by TLS. The key length is Destination Connection ID field from the client's first Initial
the AEAD key size. As defined in Section 5.3 of [TLS13], the IV packet of the connection. Specifically:
length is the larger of 8 or N_MIN (see Section 4 of [AEAD]; all
ciphersuites defined in [TLS13] have N_MIN set to 12).
The size of the packet protection key is determined by the packet initial_salt = 0x9c108f98520a5c5c32968e950e8a2c5fe06d6c38
protection algorithm, see Section 5.6. initial_secret =
HKDF-Extract(initial_salt, client_dst_connection_id)
For any secret S, the AEAD key uses a label of "key", the IV uses a client_initial_secret =
label of "iv", packet number encryption uses a label of "pn": HKDF-Expand-Label(initial_secret, "client in", Hash.length)
server_initial_secret =
HKDF-Expand-Label(initial_secret, "server in", Hash.length)
key = QHKDF-Expand(S, "key", key_length) Note that if the server sends a Retry, the client's Initial will
iv = QHKDF-Expand(S, "iv", iv_length) correspond to a new connection and thus use the server provided
pn_key = QHKDF-Expand(S, "pn", pn_key_length) Destination Connection ID.
Separate keys are derived for packet protection by clients and The hash function for HKDF when deriving handshake secrets and keys
servers. Each endpoint uses the packet protection key of its peer to is SHA-256 [SHA]. The connection ID used with HKDF-Expand-Label is
remove packet protection. For example, client packet protection keys the initial Destination Connection ID.
and IVs - which are also used by the server to remove the protection
added by a client - for AEAD_AES_128_GCM are derived from 1-RTT
secrets as follows:
client_pp_key<i> = QHKDF-Expand(client_pp_secret<i>, "key", 16) The value of initial_salt is a 20 octet sequence shown in the figure
client_pp_iv<i> = QHKDF-Expand(client_pp_secret<i>, "iv", 12) in hexadecimal notation. Future versions of QUIC SHOULD generate a
client_pp_pn<i> = QHKDF-Expand(client_pp_secret<i>, "pn", 12) new salt value, thus ensuring that the keys are different for each
version of QUIC. This prevents a middlebox that only recognizes one
version of QUIC from seeing or modifying the contents of handshake
packets from future versions.
The QUIC packet protection initially starts with keying material Note: The Destination Connection ID is of arbitrary length, and it
derived from handshake keys. For a client, when the TLS state could be zero length if the server sends a Retry packet with a
machine reports that the ClientHello has been sent, 0-RTT keys can be zero-length Source Connection ID field. In this case, the Initial
generated and installed for writing, if 0-RTT is available. Finally, keys provide no assurance to the client that the server received
the TLS state machine reports completion of the handshake and 1-RTT its packet; the client has to rely on the exchange that included
keys can be generated and installed for writing. the Retry packet for that property.
5.4. QUIC AEAD Usage 5.2. QUIC AEAD Usage
The Authentication Encryption with Associated Data (AEAD) [AEAD] The Authentication Encryption with Associated Data (AEAD) [AEAD]
function used for QUIC packet protection is AEAD that is negotiated function used for QUIC packet protection is the AEAD that is
for use with the TLS connection. For example, if TLS is using the negotiated for use with the TLS connection. For example, if TLS is
TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is used. using the TLS_AES_128_GCM_SHA256, the AEAD_AES_128_GCM function is
used.
QUIC packets are protected prior to applying packet number encryption QUIC packets are protected prior to applying packet number encryption
(Section 5.6). The unprotected packet number is part of the (Section 5.3). The unprotected packet number is part of the
associated data (A). When removing packet protection, an endpoint associated data (A). When removing packet protection, an endpoint
first removes the protection from the packet number. first removes the protection from the packet number.
All QUIC packets other than Version Negotiation and Stateless Reset All QUIC packets other than Version Negotiation and Retry packets are
packets are protected with an AEAD algorithm [AEAD]. Prior to protected with an AEAD algorithm [AEAD]. Prior to establishing a
establishing a shared secret, packets are protected with shared secret, packets are protected with AEAD_AES_128_GCM and a key
AEAD_AES_128_GCM and a key derived from the client's connection ID derived from the destination connection ID in the client's first
(see Section 5.3.2). This provides protection against off-path Initial packet (see Section 5.1.1). This provides protection against
attackers and robustness against QUIC version unaware middleboxes, off-path attackers and robustness against QUIC version unaware
but not against on-path attackers. middleboxes, but not against on-path attackers.
All ciphersuites currently defined for TLS 1.3 - and therefore QUIC - All ciphersuites currently defined for TLS 1.3 - and therefore QUIC -
have a 16-byte authentication tag and produce an output 16 bytes have a 16-byte authentication tag and produce an output 16 bytes
larger than their input. larger than their input.
Once TLS has provided a key, the contents of regular QUIC packets The key and IV for the packet are computed as described in
immediately after any TLS messages have been sent are protected by Section 5.1. The nonce, N, is formed by combining the packet
the AEAD selected by TLS. protection IV with the packet number. The 64 bits of the
reconstructed QUIC packet number in network byte order are left-
The key, K, is either the client packet protection key padded with zeros to the size of the IV. The exclusive OR of the
(client_pp_key<i>) or the server packet protection key padded packet number and the IV forms the AEAD nonce.
(server_pp_key<i>), derived as defined in Section 5.3.
The nonce, N, is formed by combining the packet protection IV (either
client_pp_iv<i> or server_pp_iv<i>) with the packet number. The 64
bits of the reconstructed QUIC packet number in network byte order is
left-padded with zeros to the size of the IV. The exclusive OR of
the padded packet number and the IV forms the AEAD nonce.
The associated data, A, for the AEAD is the contents of the QUIC The associated data, A, for the AEAD is the contents of the QUIC
header, starting from the flags octet in either the short or long header, starting from the flags octet in either the short or long
header. header.
The input plaintext, P, for the AEAD is the content of the QUIC frame The input plaintext, P, for the AEAD is the content of the QUIC frame
following the header, as described in [QUIC-TRANSPORT]. following the header, as described in [QUIC-TRANSPORT].
The output ciphertext, C, of the AEAD is transmitted in place of P. The output ciphertext, C, of the AEAD is transmitted in place of P.
5.5. Packet Numbers
QUIC has a single, contiguous packet number space. In comparison,
TLS restarts its sequence number each time that record protection
keys are changed. The sequence number restart in TLS ensures that a
compromise of the current traffic keys does not allow an attacker to
truncate the data that is sent after a key update by sending
additional packets under the old key (causing new packets to be
discarded).
QUIC does not assume a reliable transport and is required to handle
attacks where packets are dropped in other ways. QUIC is therefore
not affected by this form of truncation.
The QUIC packet number is not reset and it is not permitted to go
higher than its maximum value of 2^62-1. This establishes a hard
limit on the number of packets that can be sent.
Some AEAD functions have limits for how many packets can be encrypted Some AEAD functions have limits for how many packets can be encrypted
under the same key and IV (see for example [AEBounds]). This might under the same key and IV (see for example [AEBounds]). This might
be lower than the packet number limit. An endpoint MUST initiate a be lower than the packet number limit. An endpoint MUST initiate a
key update (Section 6.2) prior to exceeding any limit set for the key update (Section 6) prior to exceeding any limit set for the AEAD
AEAD that is in use. that is in use.
TLS maintains a separate sequence number that is used for record
protection on the connection that is hosted on stream 0. This
sequence number is not visible to QUIC.
5.6. Packet Number Protection 5.3. Packet Number Protection
QUIC packets are protected using a key that is derived from the QUIC packet numbers are protected using a key that is derived from
current set of secrets. The key derived using the "pn" label is used the current set of secrets. The key derived using the "pn" label is
to protect the packet number from casual observation. The packet used to protect the packet number from casual observation. The
number protection algorithm depends on the negotiated AEAD. packet number protection algorithm depends on the negotiated AEAD.
Packet number protection is applied after packet protection is Packet number protection is applied after packet protection is
applied (see Section 5.4). The ciphertext of the packet is sampled applied (see Section 5.2). The ciphertext of the packet is sampled
and used as input to an encryption algorithm. and used as input to an encryption algorithm.
In sampling the packet ciphertext, the packet number length is In sampling the packet ciphertext, the packet number length is
assumed to be the smaller of the maximum possible packet number assumed to be 4 octets (its maximum possible encoded length), unless
encoding (4 octets), or the size of the protected packet minus the there is insufficient space in the packet for sampling. The sampled
minimum expansion for the AEAD. For example, the sampled ciphertext ciphertext starts after allowing for a 4 octet packet number unless
for a packet with a short header can be determined by: this would cause the sample to extend past the end of the packet. If
the sample would extend past the end of the packet, the end of the
packet is sampled.
"sample_offset = min(1 + connection_id_length + 4, packet_length - For example, the sampled ciphertext for a packet with a short header
aead_expansion) sample = can be determined by:
packet[sample_offset..sample_offset+sample_length] "
sample_offset = 1 + len(connection_id) + 4
if sample_offset + sample_length > packet_length then
sample_offset = packet_length - sample_length
sample = packet[sample_offset..sample_offset+sample_length]
A packet with a long header is sampled in the same way, noting that
multiple QUIC packets might be included in the same UDP datagram and
that each one is handled separately.
sample_offset = 6 + len(destination_connection_id) +
len(source_connection_id) +
len(payload_length) + 4
To ensure that this process does not sample the packet number, packet To ensure that this process does not sample the packet number, packet
number protection algorithms MUST NOT sample more ciphertext than the number protection algorithms MUST NOT sample more ciphertext than the
minimum expansion of the corresponding AEAD. minimum expansion of the corresponding AEAD.
Packet number protection is applied to the packet number encoded as Packet number protection is applied to the packet number encoded as
described in Section 4.8 of [QUIC-TRANSPORT]. Since the length of described in Section 4.8 of [QUIC-TRANSPORT]. Since the length of
the packet number is stored in the first octet of the encoded packet the packet number is stored in the first octet of the encoded packet
number, it may be necessary to progressively decrypt the packet number, it may be necessary to progressively decrypt the packet
number. number.
Before a TLS ciphersuite can be used with QUIC, a packet protection Before a TLS ciphersuite can be used with QUIC, a packet protection
algorithm MUST be specifed for the AEAD used with that ciphersuite. algorithm MUST be specifed for the AEAD used with that ciphersuite.
This document defines algorithms for AEAD_AES_128_GCM, This document defines algorithms for AEAD_AES_128_GCM,
AEAD_AES_128_CCM, AEAD_AES_256_GCM, AEAD_AES_256_CCM (all AES AEADs AEAD_AES_128_CCM, AEAD_AES_256_GCM, AEAD_AES_256_CCM (all AES AEADs
are defined in [RFC5116]), and AEAD_CHACHA20_POLY1305 ([CHACHA]). are defined in [AEAD]), and AEAD_CHACHA20_POLY1305 ([CHACHA]).
5.6.1. AES-Based Packet Number Protection 5.3.1. AES-Based Packet Number Protection
This section defines the packet protection algorithm for This section defines the packet protection algorithm for
AEAD_AES_128_GCM, AEAD_AES_128_CCM, AEAD_AES_256_GCM, and AEAD_AES_128_GCM, AEAD_AES_128_CCM, AEAD_AES_256_GCM, and
AEAD_AES_256_CCM. AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit AEAD_AES_256_CCM. AEAD_AES_128_GCM and AEAD_AES_128_CCM use 128-bit
AES [AES] in counter (CTR) mode. AEAD_AES_256_GCM, and AES [AES] in counter (CTR) mode. AEAD_AES_256_GCM, and
AEAD_AES_256_CCM use 256-bit AES in CTR mode. AEAD_AES_256_CCM use 256-bit AES in CTR mode.
This algorithm samples 16 octets from the packet ciphertext. This This algorithm samples 16 octets from the packet ciphertext. This
value is used as the counter input to AES-CTR. value is used as the counter input to AES-CTR.
encrypted_pn = AES-CTR(pn_key, sample, packet_number) encrypted_pn = AES-CTR(pn_key, sample, packet_number)
5.6.2. ChaCha20-Based Packet Number Protection 5.3.2. ChaCha20-Based Packet Number Protection
When AEAD_CHACHA20_POLY1305 is in use, packet number protection uses When AEAD_CHACHA20_POLY1305 is in use, packet number protection uses
the raw ChaCha20 function as defined in Section 2.4 of [CHACHA]. the raw ChaCha20 function as defined in Section 2.4 of [CHACHA].
This uses a 256-bit key and 16 octets sampled from the packet This uses a 256-bit key and 16 octets sampled from the packet
protection output. protection output.
The first 4 octets of the sampled ciphertext are interpreted as a The first 4 octets of the sampled ciphertext are interpreted as a
32-bit number in little-endian order and are used as the block count. 32-bit number in little-endian order and are used as the block count.
The remaining 12 octets are interpreted as three concatenated 32-bit The remaining 12 octets are interpreted as three concatenated 32-bit
numbers in little-endian order and used as the nonce. numbers in little-endian order and used as the nonce.
The encoded packet number is then encrypted with ChaCha20 directly. The encoded packet number is then encrypted with ChaCha20 directly.
In pseudocode: In pseudocode:
counter = DecodeLE(sample[0..3]) counter = DecodeLE(sample[0..3])
nonce = DecodeLE(sample[4..7], sample[8..11], sample[12..15]) nonce = DecodeLE(sample[4..7], sample[8..11], sample[12..15])
encrypted_pn = ChaCha20(pn_key, counter, nonce, packet_number) encrypted_pn = ChaCha20(pn_key, counter, nonce, packet_number)
5.7. Receiving Protected Packets 5.4. Receiving Protected Packets
Once an endpoint successfully receives a packet with a given packet Once an endpoint successfully receives a packet with a given packet
number, it MUST discard all packets with higher packet numbers if number, it MUST discard all packets in the same packet number space
they cannot be successfully unprotected with either the same key, or with higher packet numbers if they cannot be successfully unprotected
- if there is a key update - the next packet protection key (see with either the same key, or - if there is a key update - the next
Section 6.2). Similarly, a packet that appears to trigger a key packet protection key (see Section 6). Similarly, a packet that
update, but cannot be unprotected successfully MUST be discarded. appears to trigger a key update, but cannot be unprotected
successfully MUST be discarded.
Failure to unprotect a packet does not necessarily indicate the Failure to unprotect a packet does not necessarily indicate the
existence of a protocol error in a peer or an attack. The truncated existence of a protocol error in a peer or an attack. The truncated
packet number encoding used in QUIC can cause packet numbers to be packet number encoding used in QUIC can cause packet numbers to be
decoded incorrectly if they are delayed significantly. decoded incorrectly if they are delayed significantly.
6. Key Phases 5.5. Use of 0-RTT Keys
As TLS reports the availability of 0-RTT and 1-RTT keys, new keying
material can be exported from TLS and used for QUIC packet
protection. At each transition during the handshake a new secret is
exported from TLS and packet protection keys are derived from that
secret.
Every time that a new set of keys is used for protecting outbound
packets, the KEY_PHASE bit in the public flags is toggled. 0-RTT
protected packets use the QUIC long header, they do not use the
KEY_PHASE bit to select the correct keys (see Section 6.1.1).
Once the connection is fully enabled, the KEY_PHASE bit allows a
recipient to detect a change in keying material without necessarily
needing to receive the first packet that triggered the change. An
endpoint that notices a changed KEY_PHASE bit can update keys and
decrypt the packet that contains the changed bit, see Section 6.2.
The KEY_PHASE bit is included as the 0x20 bit of the QUIC short
header.
Transitions between keys during the handshake are complicated by the
need to ensure that TLS handshake messages are sent with the correct
packet protection.
6.1. Packet Protection for the TLS Handshake
The initial exchange of packets that carry the TLS handshake are
AEAD-protected using the handshake secrets generated as described in
Section 5.3.2. All TLS handshake messages up to the TLS Finished
message sent by either endpoint use packets protected with handshake
keys.
Any TLS handshake messages that are sent after completing the TLS
handshake do not need special packet protection rules. Packets
containing these messages use the packet protection keys that are
current at the time of sending (or retransmission).
Like the client, a server MUST send retransmissions of its
unprotected handshake messages or acknowledgments for unprotected
handshake messages sent by the client in packets protected with
handshake keys.
6.1.1. Initial Key Transitions
Once the TLS handshake is complete, keying material is exported from
TLS and used to protect QUIC packets.
Packets protected with 1-RTT keys initially have a KEY_PHASE bit set
to 0. This bit inverts with each subsequent key update (see
Section 6.2).
If the client sends 0-RTT data, it uses the 0-RTT packet type. The
packet that contains the TLS EndOfEarlyData and Finished messages are
sent in packets protected with handshake keys.
Using distinct packet types during the handshake for handshake If 0-RTT keys are available (see Section 4.5), the lack of replay
messages, 0-RTT data, and 1-RTT data ensures that the server is able protection means that restrictions on their use are necessary to
to distinguish between the different keys used to remove packet avoid replay attacks on the protocol.
protection. All of these packets can arrive concurrently at a
server.
A server might choose to retain 0-RTT packets that arrive before a A client MUST only use 0-RTT keys to protect data that is idempotent.
TLS ClientHello. The server can then use those packets once the A client MAY wish to apply additional restrictions on what data it
ClientHello arrives. However, the potential for denial of service sends prior to the completion of the TLS handshake. A client
from buffering 0-RTT packets is significant. These packets cannot be otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except that
authenticated and so might be employed by an attacker to exhaust it MUST NOT send ACKs with 0-RTT keys.
server resources. Limiting the number of packets that are saved
might be necessary.
The server transitions to using 1-RTT keys after sending its first A client that receives an indication that its 0-RTT data has been
flight of TLS handshake messages, ending in the Finished. From this accepted by a server can send 0-RTT data until it receives all of the
point, the server protects all packets with 1-RTT keys. Future server's handshake messages. A client SHOULD stop sending 0-RTT data
packets are therefore protected with 1-RTT keys. Initially, these if it receives an indication that 0-RTT data has been rejected.
are marked with a KEY_PHASE of 0.
6.1.2. Retransmission and Acknowledgment of Unprotected Packets A server MUST NOT use 0-RTT keys to protect packets; it uses 1-RTT
keys to protect acknowledgements of 0-RTT packets. Clients MUST NOT
attempt to decrypt 0-RTT packets it receives and instead MUST discard
them.
TLS handshake messages from both client and server are critical to Note: 0-RTT data can be acknowledged by the server as it receives
the key exchange. The contents of these messages determine the keys it, but any packets containing acknowledgments of 0-RTT data
used to protect later messages. If these handshake messages are cannot have packet protection removed by the client until the TLS
included in packets that are protected with these keys, they will be handshake is complete. The 1-RTT keys necessary to remove packet
indecipherable to the recipient. protection cannot be derived until the client receives all server
handshake messages.
Even though newer keys could be available when retransmitting, 5.6. Receiving Out-of-Order Protected Frames
retransmissions of these handshake messages MUST be sent in packets
protected with handshake keys. An endpoint MUST generate ACK frames
for these messages and send them in packets protected with handshake
keys.
A HelloRetryRequest handshake message might be used to reject an Due to reordering and loss, protected packets might be received by an
initial ClientHello. A HelloRetryRequest handshake message is sent endpoint before the final TLS handshake messages are received. A
in a Retry packet; any second ClientHello that is sent in response client will be unable to decrypt 1-RTT packets from the server,
uses a Initial packet type. These packets are only protected with a whereas a server will be able to decrypt 1-RTT packets from the
predictable key (see Section 5.3.2). This is natural, because no client.
shared secret will be available when these messages need to be sent.
Upon receipt of a HelloRetryRequest, a client SHOULD cease any
transmission of 0-RTT data; 0-RTT data will only be discarded by any
server that sends a HelloRetryRequest.
The packet type ensures that protected packets are clearly However, a server MUST NOT process data from incoming 1-RTT protected
distinguished from unprotected packets. Loss or reordering might packets before verifying either the client Finished message or - in
cause unprotected packets to arrive once 1-RTT keys are in use, the case that the server has chosen to use a pre-shared key - the
unprotected packets are easily distinguished from 1-RTT packets using pre-shared key binder (see Section 4.2.11 of [TLS13]). Verifying
the packet type. these values provides the server with an assurance that the
ClientHello has not been modified. Packets protected with 1-RTT keys
MAY be stored and later decrypted and used once the handshake is
complete.
Once 1-RTT keys are available to an endpoint, it no longer needs the A server could receive packets protected with 0-RTT keys prior to
TLS handshake messages that are carried in unprotected packets. receiving a TLS ClientHello. The server MAY retain these packets for
However, a server might need to retransmit its TLS handshake messages later decryption in anticipation of receiving a ClientHello.
in response to receiving an unprotected packet that contains ACK
frames. A server MUST process ACK frames in unprotected packets
until the TLS handshake is reported as complete, or it receives an
ACK frame in a protected packet that acknowledges all of its
handshake messages.
To limit the number of key phases that could be active, an endpoint 6. Key Update
MUST NOT initiate a key update while there are any unacknowledged
handshake messages, see Section 6.2.
6.2. Key Update Once the 1-RTT keys are established and the short header is in use,
it is possible to update the keys. The KEY_PHASE bit in the short
header is used to indicate whether key updates have occurred. The
KEY_PHASE bit is initially set to 0 and then inverted with each key
update Section 6.
Once the TLS handshake is complete, the KEY_PHASE bit allows for The KEY_PHASE bit allows a recipient to detect a change in keying
refreshes of keying material by either peer. Endpoints start using material without necessarily needing to receive the first packet that
updated keys immediately without additional signaling; the change in triggered the change. An endpoint that notices a changed KEY_PHASE
the KEY_PHASE bit indicates that a new key is in use. bit can update keys and decrypt the packet that contains the changed
bit, see Section 6.
An endpoint MUST NOT initiate more than one key update at a time. A An endpoint MUST NOT initiate more than one key update at a time. A
new key cannot be used until the endpoint has received and new key cannot be used until the endpoint has received and
successfully decrypted a packet with a matching KEY_PHASE. Note that successfully decrypted a packet with a matching KEY_PHASE.
when 0-RTT is attempted the value of the KEY_PHASE bit will be
different on packets sent by either peer.
A receiving endpoint detects an update when the KEY_PHASE bit doesn't A receiving endpoint detects an update when the KEY_PHASE bit doesn't
match what it is expecting. It creates a new secret (see match what it is expecting. It creates a new secret (see Section 7.2
Section 5.3) and the corresponding read key and IV. If the packet of [TLS13]) and the corresponding read key and IV. If the packet can
can be decrypted and authenticated using these values, then the keys be decrypted and authenticated using these values, then the keys it
it uses for packet protection are also updated. The next packet sent uses for packet protection are also updated. The next packet sent by
by the endpoint will then use the new keys. the endpoint will then use the new keys.
An endpoint doesn't need to send packets immediately when it detects An endpoint doesn't need to send packets immediately when it detects
that its peer has updated keys. The next packet that it sends will that its peer has updated keys. The next packet that it sends will
simply use the new keys. If an endpoint detects a second update simply use the new keys. If an endpoint detects a second update
before it has sent any packets with updated keys it indicates that before it has sent any packets with updated keys it indicates that
its peer has updated keys twice without awaiting a reciprocal update. its peer has updated keys twice without awaiting a reciprocal update.
An endpoint MUST treat consecutive key updates as a fatal error and An endpoint MUST treat consecutive key updates as a fatal error and
abort the connection. abort the connection.
An endpoint SHOULD retain old keys for a short period to allow it to An endpoint SHOULD retain old keys for a short period to allow it to
skipping to change at page 26, line 46 skipping to change at page 21, line 16
@M QUIC Frames @M QUIC Frames
New Keys -> @N New Keys -> @N
@N QUIC Frames @N QUIC Frames
--------> -------->
QUIC Frames @M QUIC Frames @M
New Keys -> @N New Keys -> @N
QUIC Frames @N QUIC Frames @N
<-------- <--------
Figure 5: Key Update Figure 4: Key Update
As shown in Figure 3 and Figure 5, there is never a situation where
there are more than two different sets of keying material that might
be received by a peer. Once both sending and receiving keys have
been updated, the peers immediately begin to use them.
A server cannot initiate a key update until it has received the
client's Finished message. Otherwise, packets protected by the
updated keys could be confused for retransmissions of handshake
messages. A client cannot initiate a key update until all of its
handshake messages have been acknowledged by the server.
A packet that triggers a key update could arrive after successfully A packet that triggers a key update could arrive after successfully
processing a packet with a higher packet number. This is only processing a packet with a higher packet number. This is only
possible if there is a key compromise and an attack, or if the peer possible if there is a key compromise and an attack, or if the peer
is incorrectly reverting to use of old keys. Because the latter is incorrectly reverting to use of old keys. Because the latter
cannot be differentiated from an attack, an endpoint MUST immediately cannot be differentiated from an attack, an endpoint MUST immediately
terminate the connection if it detects this condition. terminate the connection if it detects this condition.
7. Client Address Validation 7. Security of Initial Messages
Two tools are provided by TLS to enable validation of client source
addresses at a server: the cookie in the HelloRetryRequest message,
and the ticket in the NewSessionTicket message.
7.1. HelloRetryRequest Address Validation
The cookie extension in the TLS HelloRetryRequest message allows a
server to perform source address validation during the handshake.
When QUIC requests address validation during the processing of the
first ClientHello, the token it provides is included in the cookie
extension of a HelloRetryRequest. As long as the cookie cannot be
successfully guessed by a client, the server can be assured that the
client received the HelloRetryRequest if it includes the value in a
second ClientHello.
An initial ClientHello never includes a cookie extension. Thus, if a
server constructs a cookie that contains all the information
necessary to reconstruct state, it can discard local state after
sending a HelloRetryRequest. Presence of a valid cookie in a
ClientHello indicates that the ClientHello is a second attempt from
the client.
An address validation token can be extracted from a second
ClientHello and passed to the transport for further validation. If
that validation fails, the server MUST fail the TLS handshake and
send an illegal_parameter alert.
Combining address validation with the other uses of HelloRetryRequest
ensures that there are fewer ways in which an additional round-trip
can be added to the handshake. In particular, this makes it possible
to combine a request for address validation with a request for a
different client key share.
If TLS needs to send a HelloRetryRequest for other reasons, it needs
to ensure that it can correctly identify the reason that the
HelloRetryRequest was generated. During the processing of a second
ClientHello, TLS does not need to consult the transport protocol
regarding address validation if address validation was not requested
originally. In such cases, the cookie extension could either be
absent or it could indicate that an address validation token is not
present.
7.1.1. Stateless Address Validation
A server can use the cookie extension to store all state necessary to
continue the connection. This allows a server to avoid committing
state for clients that have unvalidated source addresses.
For instance, a server could use a statically-configured key to
encrypt the information that it requires and include that information
in the cookie. In addition to address validation information, a
server that uses encryption also needs to be able recover the hash of
the ClientHello and its length, plus any information it needs in
order to reconstruct the HelloRetryRequest.
7.1.2. Sending HelloRetryRequest
A server does not need to maintain state for the connection when
sending a HelloRetryRequest message. This might be necessary to
avoid creating a denial of service exposure for the server. However,
this means that information about the transport will be lost at the
server. This includes the stream offset of stream 0, the packet
number that the server selects, and any opportunity to measure round
trip time.
A server MUST send a TLS HelloRetryRequest in a Retry packet. Using
a Retry packet causes the client to reset stream offsets. It also
avoids the need for the server select an initial packet number, which
would need to be remembered so that subsequent packets could be
correctly numbered.
A HelloRetryRequest message MUST NOT be split between multiple Retry
packets. This means that HelloRetryRequest is subject to the same
size constraints as a ClientHello (see Section 4.4).
A client might send multiple Initial packets in response to loss. If
a server sends a Retry packet in response to an Initial packet, it
does not have to generate the same Retry packet each time.
Variations in Retry packet, if used by a client, could lead to
multiple connections derived from the same ClientHello. Reuse of the
client nonce is not supported by TLS and could lead to security
vulnerabilities. Clients that receive multiple Retry packets MUST
use only one and discard the remainder.
7.2. NewSessionTicket Address Validation
The ticket in the TLS NewSessionTicket message allows a server to
provide a client with a similar sort of token. When a client resumes
a TLS connection - whether or not 0-RTT is attempted - it includes
the ticket in the handshake message. As with the HelloRetryRequest
cookie, the server includes the address validation token in the
ticket. TLS provides the token it extracts from the session ticket
to the transport when it asks whether source address validation is
needed.
If both a HelloRetryRequest cookie and a session ticket are present
in the ClientHello, only the token from the cookie is passed to the
transport. The presence of a cookie indicates that this is a second
ClientHello - the token from the session ticket will have been
provided to the transport when it appeared in the first ClientHello.
A server can send a NewSessionTicket message at any time. This
allows it to update the state - and the address validation token -
that is included in the ticket. This might be done to refresh the
ticket or token, or it might be generated in response to changes in
the state of the connection. QUIC can request that a
NewSessionTicket be sent by providing a new address validation token.
A server that intends to support 0-RTT SHOULD provide an address
validation token immediately after completing the TLS handshake.
7.3. Address Validation Token Integrity
TLS MUST provide integrity protection for address validation token
unless the transport guarantees integrity protection by other means.
For a NewSessionTicket that includes confidential information - such
as the resumption secret - including the token under authenticated
encryption ensures that the token gains both confidentiality and
integrity protection without duplicating the overheads of that
protection.
8. Pre-handshake QUIC Messages
Implementations MUST NOT exchange data on any stream other than
stream 0 without packet protection. QUIC requires the use of several
types of frame for managing loss detection and recovery during this
phase. In addition, it might be useful to use the data acquired
during the exchange of unauthenticated messages for congestion
control.
This section generally only applies to TLS handshake messages from
both peers and acknowledgments of the packets carrying those
messages. In many cases, the need for servers to provide
acknowledgments is minimal, since the messages that clients send are
small and implicitly acknowledged by the server's responses.
The actions that a peer takes as a result of receiving an
unauthenticated packet needs to be limited. In particular, state
established by these packets cannot be retained once record
protection commences.
There are several approaches possible for dealing with
unauthenticated packets prior to handshake completion:
o discard and ignore them
o use them, but reset any state that is established once the
handshake completes
o use them and authenticate them afterwards; failing the handshake
if they can't be authenticated
o save them and use them when they can be properly authenticated
o treat them as a fatal error
Different strategies are appropriate for different types of data.
This document proposes that all strategies are possible depending on
the type of message.
o Transport parameters are made usable and authenticated as part of
the TLS handshake (see Section 9.2).
o Most unprotected messages are treated as fatal errors when
received except for the small number necessary to permit the
handshake to complete (see Section 8.1).
o Protected packets can either be discarded or saved and later used
(see Section 8.3).
8.1. Unprotected Packets Prior to Handshake Completion
This section describes the handling of messages that are sent and
received prior to the completion of the TLS handshake.
Sending and receiving unprotected messages is hazardous. Unless
expressly permitted, receipt of an unprotected message of any kind
MUST be treated as a fatal error.
8.1.1. STREAM Frames
"STREAM" frames for stream 0 are permitted. These carry the TLS
handshake messages. Once 1-RTT keys are available, unprotected
"STREAM" frames on stream 0 can be ignored.
Receiving unprotected "STREAM" frames for other streams MUST be
treated as a fatal error.
8.1.2. ACK Frames
"ACK" frames are permitted prior to the handshake being complete.
Information learned from "ACK" frames cannot be entirely relied upon,
since an attacker is able to inject these packets. Timing and packet
retransmission information from "ACK" frames is critical to the
functioning of the protocol, but these frames might be spoofed or
altered.
Endpoints MUST NOT use an "ACK" frame in an unprotected packet to
acknowledge packets that were protected by 0-RTT or 1-RTT keys. An
endpoint MUST treat receipt of an "ACK" frame in an unprotected
packet that claims to acknowledge protected packets as a connection
error of type OPTIMISTIC_ACK. An endpoint that can read protected
data is always able to send protected data.
Note: 0-RTT data can be acknowledged by the server as it receives
it, but any packets containing acknowledgments of 0-RTT data
cannot have packet protection removed by the client until the TLS
handshake is complete. The 1-RTT keys necessary to remove packet
protection cannot be derived until the client receives all server
handshake messages.
An endpoint SHOULD use data from "ACK" frames carried in unprotected
packets or packets protected with 0-RTT keys only during the initial
handshake. All "ACK" frames contained in unprotected packets that
are received after successful receipt of a packet protected with
1-RTT keys MUST be discarded. An endpoint SHOULD therefore include
acknowledgments for unprotected and any packets protected with 0-RTT
keys until it sees an acknowledgment for a packet that is both
protected with 1-RTT keys and contains an "ACK" frame.
8.1.3. Updates to Data and Stream Limits
"MAX_DATA", "MAX_STREAM_DATA", "BLOCKED", "STREAM_BLOCKED", and
"MAX_STREAM_ID" frames MUST NOT be sent unprotected.
Though data is exchanged on stream 0, the initial flow control window
on that stream is sufficiently large to allow the TLS handshake to
complete. This limits the maximum size of the TLS handshake and
would prevent a server or client from using an abnormally large
certificate chain.
Stream 0 is exempt from the connection-level flow control window.
Consequently, there is no need to signal being blocked on flow
control.
Similarly, there is no need to increase the number of allowed streams
until the handshake completes.
8.1.4. Handshake Failures
The "CONNECTION_CLOSE" frame MAY be sent by either endpoint in a
Handshake packet. This allows an endpoint to signal a fatal error
with connection establishment. A "STREAM" frame carrying a TLS alert
MAY be included in the same packet.
8.1.5. Address Verification
In order to perform source-address verification before the handshake
is complete, "PATH_CHALLENGE" and "PATH_RESPONSE" frames MAY be
exchanged unprotected.
8.1.6. Denial of Service with Unprotected Packets
Accepting unprotected - specifically unauthenticated - packets
presents a denial of service risk to endpoints. An attacker that is
able to inject unprotected packets can cause a recipient to drop even
protected packets with a matching packet number. The spurious packet
shadows the genuine packet, causing the genuine packet to be ignored
as redundant.
Once the TLS handshake is complete, both peers MUST ignore
unprotected packets. From that point onward, unprotected messages
can be safely dropped.
Since only TLS handshake packets and acknowledgments are sent in the
clear, an attacker is able to force implementations to rely on
retransmission for packets that are lost or shadowed. Thus, an
attacker that intends to deny service to an endpoint has to drop or
shadow protected packets in order to ensure that their victim
continues to accept unprotected packets. The ability to shadow
packets means that an attacker does not need to be on path.
In addition to causing valid packets to be dropped, an attacker can
generate packets with an intent of causing the recipient to expend
processing resources. See Section 10.2 for a discussion of these
risks.
To avoid receiving TLS packets that contain no useful data, a TLS
implementation MUST reject empty TLS handshake records and any record
that is not permitted by the TLS state machine. Any TLS application
data or alerts that are received prior to the end of the handshake
MUST be treated as a connection error of type PROTOCOL_VIOLATION.
8.2. Use of 0-RTT Keys
If 0-RTT keys are available (see Section 5.2), the lack of replay
protection means that restrictions on their use are necessary to
avoid replay attacks on the protocol.
A client MUST only use 0-RTT keys to protect data that is idempotent.
A client MAY wish to apply additional restrictions on what data it
sends prior to the completion of the TLS handshake. A client
otherwise treats 0-RTT keys as equivalent to 1-RTT keys.
A client that receives an indication that its 0-RTT data has been
accepted by a server can send 0-RTT data until it receives all of the
server's handshake messages. A client SHOULD stop sending 0-RTT data
if it receives an indication that 0-RTT data has been rejected.
A server MUST NOT use 0-RTT keys to protect packets.
If a server rejects 0-RTT, then the TLS stream will not include any
TLS records protected with 0-RTT keys.
8.3. Receiving Out-of-Order Protected Frames
Due to reordering and loss, protected packets might be received by an
endpoint before the final TLS handshake messages are received. A
client will be unable to decrypt 1-RTT packets from the server,
whereas a server will be able to decrypt 1-RTT packets from the
client.
Packets protected with 1-RTT keys MAY be stored and later decrypted Initial packets are not protected with a secret key, so they are
and used once the handshake is complete. A server MUST NOT use 1-RTT subject to potential tampering by an attacker. QUIC provides
protected packets before verifying either the client Finished message protection against attackers that cannot read packets, but does not
or - in the case that the server has chosen to use a pre-shared key - attempt to provide additional protection against attacks where the
the pre-shared key binder (see Section 4.2.8 of [TLS13]). Verifying attacker can observe and inject packets. Some forms of tampering -
these values provides the server with an assurance that the such as modifying the TLS messages themselves - are detectable, but
ClientHello has not been modified. some - such as modifying ACKs - are not.
A server could receive packets protected with 0-RTT keys prior to For example, an attacker could inject a packet containing an ACK
receiving a TLS ClientHello. The server MAY retain these packets for frame that makes it appear that a packet had not been received or to
later decryption in anticipation of receiving a ClientHello. create a false impression of the state of the connection (e.g., by
modifying the ACK Delay). Note that such a packet could cause a
legitimate packet to be dropped as a duplicate. Implementations
SHOULD use caution in relying on any data which is contained in
Initial packets that is not otherwise authenticated.
Receiving and verifying the TLS Finished message is critical in It is also possible for the attacker to tamper with data that is
ensuring the integrity of the TLS handshake. A server MUST NOT use carried in Handshake packets, but because that tampering requires
protected packets from the client prior to verifying the client modifying TLS handshake messages, that tampering will cause the TLS
Finished message if its response depends on client authentication. handshake to fail.
9. QUIC-Specific Additions to the TLS Handshake 8. QUIC-Specific Additions to the TLS Handshake
QUIC uses the TLS handshake for more than just negotiation of QUIC uses the TLS handshake for more than just negotiation of
cryptographic parameters. The TLS handshake validates protocol cryptographic parameters. The TLS handshake validates protocol
version selection, provides preliminary values for QUIC transport version selection, provides preliminary values for QUIC transport
parameters, and allows a server to perform return routeability checks parameters, and allows a server to perform return routeability checks
on clients. on clients.
9.1. Protocol and Version Negotiation 8.1. Protocol and Version Negotiation
The QUIC version negotiation mechanism is used to negotiate the The QUIC version negotiation mechanism is used to negotiate the
version of QUIC that is used prior to the completion of the version of QUIC that is used prior to the completion of the
handshake. However, this packet is not authenticated, enabling an handshake. However, this packet is not authenticated, enabling an
active attacker to force a version downgrade. active attacker to force a version downgrade.
To ensure that a QUIC version downgrade is not forced by an attacker, To ensure that a QUIC version downgrade is not forced by an attacker,
version information is copied into the TLS handshake, which provides version information is copied into the TLS handshake, which provides
integrity protection for the QUIC negotiation. This does not prevent integrity protection for the QUIC negotiation. This does not prevent
version downgrade prior to the completion of the handshake, though it version downgrade prior to the completion of the handshake, though it
skipping to change at page 34, line 46 skipping to change at page 22, line 31
select an application protocol. The application-layer protocol MAY select an application protocol. The application-layer protocol MAY
restrict the QUIC versions that it can operate over. Servers MUST restrict the QUIC versions that it can operate over. Servers MUST
select an application protocol compatible with the QUIC version that select an application protocol compatible with the QUIC version that
the client has selected. the client has selected.
If the server cannot select a compatible combination of application If the server cannot select a compatible combination of application
protocol and QUIC version, it MUST abort the connection. A client protocol and QUIC version, it MUST abort the connection. A client
MUST abort a connection if the server picks an incompatible MUST abort a connection if the server picks an incompatible
combination of QUIC version and ALPN identifier. combination of QUIC version and ALPN identifier.
9.2. QUIC Transport Parameters Extension 8.2. QUIC Transport Parameters Extension
QUIC transport parameters are carried in a TLS extension. Different QUIC transport parameters are carried in a TLS extension. Different
versions of QUIC might define a different format for this struct. versions of QUIC might define a different format for this struct.
Including transport parameters in the TLS handshake provides Including transport parameters in the TLS handshake provides
integrity protection for these values. integrity protection for these values.
enum { enum {
quic_transport_parameters(26), (65535) quic_transport_parameters(0xffa5), (65535)
} ExtensionType; } ExtensionType;
The "extension_data" field of the quic_transport_parameters extension The "extension_data" field of the quic_transport_parameters extension
contains a value that is defined by the version of QUIC that is in contains a value that is defined by the version of QUIC that is in
use. The quic_transport_parameters extension carries a use. The quic_transport_parameters extension carries a
TransportParameters when the version of QUIC defined in TransportParameters when the version of QUIC defined in
[QUIC-TRANSPORT] is used. [QUIC-TRANSPORT] is used.
The quic_transport_parameters extension is carried in the ClientHello The quic_transport_parameters extension is carried in the ClientHello
and the EncryptedExtensions messages during the handshake. and the EncryptedExtensions messages during the handshake.
10. Security Considerations While the transport parameters are technically available prior to the
completion of the handshake, they cannot be fully trusted until the
handshake completes, and reliance on them should be minimized.
However, any tampering with the parameters will cause the handshake
to fail.
9. Security Considerations
There are likely to be some real clangers here eventually, but the There are likely to be some real clangers here eventually, but the
current set of issues is well captured in the relevant sections of current set of issues is well captured in the relevant sections of
the main text. the main text.
Never assume that because it isn't in the security considerations Never assume that because it isn't in the security considerations
section it doesn't affect security. Most of this document does. section it doesn't affect security. Most of this document does.
10.1. Packet Reflection Attack Mitigation 9.1. Packet Reflection Attack Mitigation
A small ClientHello that results in a large block of handshake A small ClientHello that results in a large block of handshake
messages from a server can be used in packet reflection attacks to messages from a server can be used in packet reflection attacks to
amplify the traffic generated by an attacker. amplify the traffic generated by an attacker.
Certificate caching [RFC7924] can reduce the size of the server's QUIC includes three defenses against this attack. First, the packet
handshake messages significantly. containing a ClientHello MUST be padded to a minimum size. Second,
if responding to an unverified source address, the server is
QUIC requires that the packet containing a ClientHello be padded to a forbidden to send more than three UDP datagrams in its first flight
minimum size. A server is less likely to generate a packet (see Section 4.4.3 of [QUIC-TRANSPORT]). Finally, because
reflection attack if the data it sends is a small multiple of this acknowledgements of Handshake packets are authenticated, a blind
size. A server SHOULD use a HelloRetryRequest if the size of the attacker cannot forge them. Put together, these defenses limit the
handshake messages it sends is likely to significantly exceed the level of amplification.
size of the packet containing the ClientHello.
10.2. Peer Denial of Service 9.2. Peer Denial of Service
QUIC, TLS and HTTP/2 all contain a messages that have legitimate uses QUIC, TLS and HTTP/2 all contain a messages that have legitimate uses
in some contexts, but that can be abused to cause a peer to expend in some contexts, but that can be abused to cause a peer to expend
processing resources without having any observable impact on the processing resources without having any observable impact on the
state of the connection. If processing is disproportionately large state of the connection. If processing is disproportionately large
in comparison to the observable effects on bandwidth or state, then in comparison to the observable effects on bandwidth or state, then
this could allow a malicious peer to exhaust processing capacity this could allow a malicious peer to exhaust processing capacity
without consequence. without consequence.
QUIC prohibits the sending of empty "STREAM" frames unless they are QUIC prohibits the sending of empty "STREAM" frames unless they are
marked with the FIN bit. This prevents "STREAM" frames from being marked with the FIN bit. This prevents "STREAM" frames from being
sent that only waste effort. sent that only waste effort.
TLS records SHOULD always contain at least one octet of a handshake
messages or alert. Records containing only padding are permitted
during the handshake, but an excessive number might be used to
generate unnecessary work. Once the TLS handshake is complete,
endpoints MUST NOT send TLS application data records. Receiving TLS
application data MUST be treated as a connection error of type
PROTOCOL_VIOLATION.
While there are legitimate uses for some redundant packets, While there are legitimate uses for some redundant packets,
implementations SHOULD track redundant packets and treat excessive implementations SHOULD track redundant packets and treat excessive
volumes of any non-productive packets as indicative of an attack. volumes of any non-productive packets as indicative of an attack.
10.3. Packet Number Protection Analysis 9.3. Packet Number Protection Analysis
Packet number protection relies the packet protection AEAD being a Packet number protection relies on the packet protection AEAD being a
pseudorandom function (PRF), which is not a property that AEAD pseudorandom function (PRF), which is not a property that AEAD
algorithms guarantee. Therefore, no strong assurances about the algorithms guarantee. Therefore, no strong assurances about the
general security of this mechanism can be shown in the general case. general security of this mechanism can be shown in the general case.
The AEAD algorithms described in this document are assumed to be The AEAD algorithms described in this document are assumed to be
PRFs. PRFs.
The packet number protection algorithms defined in this document take The packet number protection algorithms defined in this document take
the form: the form:
"encrypted_pn = packet_number XOR PRF(pn_key, sample) " encrypted_pn = packet_number XOR PRF(pn_key, sample)
This construction is secure against chosen plaintext attacks (IND- This construction is secure against chosen plaintext attacks (IND-
CPA) [IMC]. CPA) [IMC].
Use of the same key and ciphertext sample more than once risks Use of the same key and ciphertext sample more than once risks
compromising packet number protection. Protecting two different compromising packet number protection. Protecting two different
packet numbers with the same key and ciphertext sample reveals the packet numbers with the same key and ciphertext sample reveals the
exclusive OR of those packet numbers. Assuming that the AEAD acts as exclusive OR of those packet numbers. Assuming that the AEAD acts as
a PRF, if L bits are sampled, the odds of two ciphertext samples a PRF, if L bits are sampled, the odds of two ciphertext samples
being identical approach 2^(-L/2), that is, the birthday bound. For being identical approach 2^(-L/2), that is, the birthday bound. For
skipping to change at page 37, line 21 skipping to change at page 25, line 5
timing side-channels that the packet number matches a received timing side-channels that the packet number matches a received
packet. For authentication to be free from side-channels, the entire packet. For authentication to be free from side-channels, the entire
process of packet number protection removal, packet number recovery, process of packet number protection removal, packet number recovery,
and packet protection removal MUST be applied together without timing and packet protection removal MUST be applied together without timing
and other side-channels. and other side-channels.
For the sending of packets, construction and protection of packet For the sending of packets, construction and protection of packet
payloads and packet numbers MUST be free from side-channels that payloads and packet numbers MUST be free from side-channels that
would reveal the packet number or its encoded size. would reveal the packet number or its encoded size.
11. Error Codes 10. IANA Considerations
This section defines error codes from the error code space used in
[QUIC-TRANSPORT].
The following error codes are defined when TLS is used for the crypto
handshake:
TLS_HANDSHAKE_FAILED (0x201): The TLS handshake failed.
TLS_FATAL_ALERT_GENERATED (0x202): A TLS fatal alert was sent,
causing the TLS connection to end prematurely.
TLS_FATAL_ALERT_RECEIVED (0x203): A TLS fatal alert was received,
causing the TLS connection to end prematurely.
12. IANA Considerations
This document does not create any new IANA registries, but it This document does not create any new IANA registries, but it
registers the values in the following registries: registers the values in the following registries:
o QUIC Transport Error Codes Registry [QUIC-TRANSPORT] - IANA is to
register the three error codes found in Section 11, these are
summarized in Table 1.
o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register o TLS ExtensionsType Registry [TLS-REGISTRIES] - IANA is to register
the quic_transport_parameters extension found in Section 9.2. the quic_transport_parameters extension found in Section 8.2. The
Assigning 26 to the extension would be greatly appreciated. The
Recommended column is to be marked Yes. The TLS 1.3 Column is to Recommended column is to be marked Yes. The TLS 1.3 Column is to
include CH and EE. include CH and EE.
o TLS Exporter Label Registry [TLS-REGISTRIES] - IANA is requested 11. References
to register "EXPORTER-QUIC 0rtt" from Section 5.3.3; "EXPORTER-
QUIC client 1rtt" and "EXPORTER-QUIC server 1-RTT" from
Section 5.3.4. The DTLS column is to be marked No. The
Recommended column is to be marked Yes.
+-------+---------------------------+---------------+---------------+
| Value | Error | Description | Specification |
+-------+---------------------------+---------------+---------------+
| 0x201 | TLS_HANDSHAKE_FAILED | TLS handshake | Section 11 |
| | | failure | |
| | | | |
| 0x202 | TLS_FATAL_ALERT_GENERATED | Sent TLS | Section 11 |
| | | alert | |
| | | | |
| 0x203 | TLS_FATAL_ALERT_RECEIVED | Receives TLS | Section 11 |
| | | alert | |
+-------+---------------------------+---------------+---------------+
Table 1: QUIC Transport Error Codes for TLS
13. References
13.1. Normative References 11.1. Normative References
[AEAD] McGrew, D., "An Interface and Algorithms for Authenticated [AEAD] McGrew, D., "An Interface and Algorithms for Authenticated
Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008, Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008,
<https://www.rfc-editor.org/info/rfc5116>. <https://www.rfc-editor.org/info/rfc5116>.
[AES] "Advanced encryption standard (AES)", National Institute [AES] "Advanced encryption standard (AES)", National Institute
of Standards and Technology report, of Standards and Technology report,
DOI 10.6028/nist.fips.197, November 2001. DOI 10.6028/nist.fips.197, November 2001.
[CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF [CHACHA] Nir, Y. and A. Langley, "ChaCha20 and Poly1305 for IETF
Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015, Protocols", RFC 7539, DOI 10.17487/RFC7539, May 2015,
<https://www.rfc-editor.org/info/rfc7539>. <https://www.rfc-editor.org/info/rfc7539>.
[HKDF] Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand
Key Derivation Function (HKDF)", RFC 5869,
DOI 10.17487/RFC5869, May 2010,
<https://www.rfc-editor.org/info/rfc5869>.
[QUIC-TRANSPORT] [QUIC-TRANSPORT]
Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based
Multiplexed and Secure Transport", draft-ietf-quic- Multiplexed and Secure Transport", draft-ietf-quic-
transport-12 (work in progress), May 2018. transport-13 (work in progress), June 2018.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC5116] McGrew, D., "An Interface and Algorithms for Authenticated
Encryption", RFC 5116, DOI 10.17487/RFC5116, January 2008,
<https://www.rfc-editor.org/info/rfc5116>.
[RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan, [RFC7301] Friedl, S., Popov, A., Langley, A., and E. Stephan,
"Transport Layer Security (TLS) Application-Layer Protocol "Transport Layer Security (TLS) Application-Layer Protocol
Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301, Negotiation Extension", RFC 7301, DOI 10.17487/RFC7301,
July 2014, <https://www.rfc-editor.org/info/rfc7301>. July 2014, <https://www.rfc-editor.org/info/rfc7301>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[SHA] Dang, Q., "Secure Hash Standard", National Institute of [SHA] Dang, Q., "Secure Hash Standard", National Institute of
Standards and Technology report, Standards and Technology report,
DOI 10.6028/nist.fips.180-4, July 2015. DOI 10.6028/nist.fips.180-4, July 2015.
[TLS-REGISTRIES] [TLS-REGISTRIES]
Salowey, J. and S. Turner, "IANA Registry Updates for TLS Salowey, J. and S. Turner, "IANA Registry Updates for
and DTLS", draft-ietf-tls-iana-registry-updates-04 (work Transport Layer Security (TLS) and Datagram Transport
in progress), February 2018. Layer Security (DTLS)", draft-ietf-tls-iana-registry-
updates-05 (work in progress), May 2018.
[TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol [TLS13] Rescorla, E., "The Transport Layer Security (TLS) Protocol
Version 1.3", draft-ietf-tls-tls13-21 (work in progress), Version 1.3", draft-ietf-tls-tls13-21 (work in progress),
July 2017. July 2017.
13.2. Informative References 11.2. Informative References
[AEBounds] [AEBounds]
Luykx, A. and K. Paterson, "Limits on Authenticated Luykx, A. and K. Paterson, "Limits on Authenticated
Encryption Use in TLS", March 2016, Encryption Use in TLS", March 2016,
<http://www.isg.rhul.ac.uk/~kp/TLS-AEbounds.pdf>. <http://www.isg.rhul.ac.uk/~kp/TLS-AEbounds.pdf>.
[IMC] Katz, J. and Y. Lindell, "Introduction to Modern [IMC] Katz, J. and Y. Lindell, "Introduction to Modern
Cryptography, Second Edition", ISBN 978-1466570269, Cryptography, Second Edition", ISBN 978-1466570269,
November 2014. November 2014.
[QUIC-HTTP] [QUIC-HTTP]
Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over
QUIC", draft-ietf-quic-http-12 (work in progress), May QUIC", draft-ietf-quic-http-13 (work in progress), June
2018. 2018.
[QUIC-RECOVERY] [QUIC-RECOVERY]
Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection Iyengar, J., Ed. and I. Swett, Ed., "QUIC Loss Detection
and Congestion Control", draft-ietf-quic-recovery-11 (work and Congestion Control", draft-ietf-quic-recovery-13 (work
in progress), May 2018. in progress), June 2018.
[RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818,
DOI 10.17487/RFC2818, May 2000, DOI 10.17487/RFC2818, May 2000,
<https://www.rfc-editor.org/info/rfc2818>. <https://www.rfc-editor.org/info/rfc2818>.
[RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
Housley, R., and W. Polk, "Internet X.509 Public Key Housley, R., and W. Polk, "Internet X.509 Public Key
Infrastructure Certificate and Certificate Revocation List Infrastructure Certificate and Certificate Revocation List
(CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008,
<https://www.rfc-editor.org/info/rfc5280>. <https://www.rfc-editor.org/info/rfc5280>.
[RFC7924] Santesson, S. and H. Tschofenig, "Transport Layer Security 11.3. URIs
(TLS) Cached Information Extension", RFC 7924,
DOI 10.17487/RFC7924, July 2016,
<https://www.rfc-editor.org/info/rfc7924>.
13.3. URIs
[1] https://mailarchive.ietf.org/arch/search/?email_list=quic [1] https://mailarchive.ietf.org/arch/search/?email_list=quic
[2] https://github.com/quicwg [2] https://github.com/quicwg
[3] https://github.com/quicwg/base-drafts/labels/-tls [3] https://github.com/quicwg/base-drafts/labels/-tls
Appendix A. Contributors Appendix A. Change Log
Ryan Hamilton was originally an author of this specification. *RFC Editor's Note:* Please remove this section prior to
publication of a final version of this document.
Appendix B. Acknowledgments Issue and pull request numbers are listed with a leading octothorp.
This document has benefited from input from Dragana Damjanovic, A.1. Since draft-ietf-quic-tls-12
Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric
Rescorla, Ian Swett, and many others.
Appendix C. Change Log o Changes to integration of the TLS handshake (#829, #1018, #1094,
#1165, #1190, #1233, #1242, #1252, #1450)
*RFC Editor's Note:* Please remove this section prior to * The cryptographic handshake uses CRYPTO frames, not stream 0
publication of a final version of this document.
Issue and pull request numbers are listed with a leading octothorp. * QUIC packet protection is used in place of TLS record
protection
C.1. Since draft-ietf-quic-tls-10 * Separate QUIC packet number spaces are used for the handshake
* Changed Retry to be independent of the cryptographic handshake
* Limit the use of HelloRetryRequest to address TLS needs (like
key shares)
o Changed codepoint of TLS extension (#1395, #1402)
A.2. Since draft-ietf-quic-tls-11
o Encrypted packet numbers.
A.3. Since draft-ietf-quic-tls-10
o No significant changes. o No significant changes.
C.2. Since draft-ietf-quic-tls-09 A.4. Since draft-ietf-quic-tls-09
o Cleaned up key schedule and updated the salt used for handshake o Cleaned up key schedule and updated the salt used for handshake
packet protection (#1077) packet protection (#1077)
C.3. Since draft-ietf-quic-tls-08 A.5. Since draft-ietf-quic-tls-08
o Specify value for max_early_data_size to enable 0-RTT (#942) o Specify value for max_early_data_size to enable 0-RTT (#942)
o Update key derivation function (#1003, #1004) o Update key derivation function (#1003, #1004)
C.4. Since draft-ietf-quic-tls-07 A.6. Since draft-ietf-quic-tls-07
o Handshake errors can be reported with CONNECTION_CLOSE (#608, o Handshake errors can be reported with CONNECTION_CLOSE (#608,
#891) #891)
C.5. Since draft-ietf-quic-tls-05 A.7. Since draft-ietf-quic-tls-05
No significant changes. No significant changes.
C.6. Since draft-ietf-quic-tls-04 A.8. Since draft-ietf-quic-tls-04
o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642) o Update labels used in HKDF-Expand-Label to match TLS 1.3 (#642)
C.7. Since draft-ietf-quic-tls-03 A.9. Since draft-ietf-quic-tls-03
No significant changes. No significant changes.
C.8. Since draft-ietf-quic-tls-02 A.10. Since draft-ietf-quic-tls-02
o Updates to match changes in transport draft o Updates to match changes in transport draft
C.9. Since draft-ietf-quic-tls-01 A.11. Since draft-ietf-quic-tls-01
o Use TLS alerts to signal TLS errors (#272, #374) o Use TLS alerts to signal TLS errors (#272, #374)
o Require ClientHello to fit in a single packet (#338) o Require ClientHello to fit in a single packet (#338)
o The second client handshake flight is now sent in the clear (#262, o The second client handshake flight is now sent in the clear (#262,
#337) #337)
o The QUIC header is included as AEAD Associated Data (#226, #243, o The QUIC header is included as AEAD Associated Data (#226, #243,
#302) #302)
skipping to change at page 42, line 18 skipping to change at page 29, line 5
o Require at least TLS 1.3 (#138) o Require at least TLS 1.3 (#138)
o Define transport parameters as a TLS extension (#122) o Define transport parameters as a TLS extension (#122)
o Define handling for protected packets before the handshake o Define handling for protected packets before the handshake
completes (#39) completes (#39)
o Decouple QUIC version and ALPN (#12) o Decouple QUIC version and ALPN (#12)
C.10. Since draft-ietf-quic-tls-00 A.12. Since draft-ietf-quic-tls-00
o Changed bit used to signal key phase o Changed bit used to signal key phase
o Updated key phase markings during the handshake o Updated key phase markings during the handshake
o Added TLS interface requirements section o Added TLS interface requirements section
o Moved to use of TLS exporters for key derivation o Moved to use of TLS exporters for key derivation
o Moved TLS error code definitions into this document o Moved TLS error code definitions into this document
C.11. Since draft-thomson-quic-tls-01 A.13. Since draft-thomson-quic-tls-01
o Adopted as base for draft-ietf-quic-tls o Adopted as base for draft-ietf-quic-tls
o Updated authors/editors list o Updated authors/editors list
o Added status note o Added status note
Acknowledgments
This document has benefited from input from Dragana Damjanovic,
Christian Huitema, Jana Iyengar, Adam Langley, Roberto Peon, Eric
Rescorla, Ian Swett, and many others.
Contributors
Ryan Hamilton was originally an author of this specification.
Authors' Addresses Authors' Addresses
Martin Thomson (editor) Martin Thomson (editor)
Mozilla Mozilla
Email: martin.thomson@gmail.com Email: martin.thomson@gmail.com
Sean Turner (editor) Sean Turner (editor)
sn3rd sn3rd
 End of changes. 170 change blocks. 
1217 lines changed or deleted 591 lines changed or added

This html diff was produced by rfcdiff 1.45. The latest version is available from http://tools.ietf.org/tools/rfcdiff/