RFC 9001 | Using TLS to Secure QUIC | May 2021 |
Thomson & Turner | Standards Track | [Page] |
This document describes how Transport Layer Security (TLS) is used to secureQUIC.¶
This is an Internet Standards Track document.¶
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.¶
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained athttps://www.rfc-editor.org/info/rfc9001.¶
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.¶
This document describes how QUIC[QUIC-TRANSPORT] is secured using TLS[TLS13].¶
TLS 1.3 provides critical latency improvements for connection establishment overprevious versions. Absent packet loss, most new connections can be establishedand secured within a single round trip; on subsequent connections between thesame client and server, the client can often send application data immediately,that is, using a zero round-trip setup.¶
This document describes how TLS acts as a security component of QUIC.¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD","SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in thisdocument are to be interpreted as described in BCP 14[RFC2119][RFC8174]when, and only when, they appear in all capitals, as shown here.¶
This document uses the terminology established in[QUIC-TRANSPORT].¶
For brevity, the acronym TLS is used to refer to TLS 1.3, though a newer versioncould be used; seeSection 4.2.¶
TLS provides two endpoints with a way to establish a means of communication overan untrusted medium (for example, the Internet). TLS enables authentication ofpeers and provides confidentiality and integrity protection for messages thatendpoints exchange.¶
Internally, TLS is a layered protocol, with the structure shown inFigure 1.¶
+-------------+------------+--------------+---------+Content | | | Application | |Layer | Handshake | Alerts | Data | ... | | | | | | +-------------+------------+--------------+---------+Record | |Layer | Records | | | +---------------------------------------------------+
Each content-layer message (e.g., handshake, alerts, and application data) iscarried as a series of typed TLS records by the record layer. Records areindividually cryptographically protected and then transmitted over a reliabletransport (typically TCP), which provides sequencing and guaranteed delivery.¶
The TLS authenticated key exchange occurs between two endpoints: client andserver. The client initiates the exchange and the server responds. If the keyexchange completes successfully, both client and server will agree on a secret.TLS supports both pre-shared key (PSK) and Diffie-Hellman over either finitefields or elliptic curves ((EC)DHE) key exchanges. PSK is the basis for EarlyData (0-RTT); the latter provides forward secrecy (FS) when the (EC)DHEkeys are destroyed. The two modes can also be combined to provide forwardsecrecy while using the PSK for authentication.¶
After completing the TLS handshake, the client will have learned andauthenticated an identity for the server, and the server is optionally able tolearn and authenticate an identity for the client. TLS supports X.509[RFC5280] certificate-based authentication for both server and client.When PSK key exchange is used (as in resumption), knowledge of the PSKserves to authenticate the peer.¶
The TLS key exchange is resistant to tampering by attackers, and it producesshared secrets that cannot be controlled by either participating peer.¶
TLS provides two basic handshake modes of interest to QUIC:¶
A simplified TLS handshake with 0-RTT application data is shown inFigure 2.¶
Client Server ClientHello (0-RTT Application Data) --------> ServerHello {EncryptedExtensions} {Finished} <-------- [Application Data] {Finished} --------> [Application Data] <-------> [Application Data] () Indicates messages protected by Early Data (0-RTT) Keys {} Indicates messages protected using Handshake Keys [] Indicates messages protected using Application Data (1-RTT) Keys
Figure 2 omits the EndOfEarlyData message, which is not used in QUIC; seeSection 8.3. Likewise, neither ChangeCipherSpec nor KeyUpdate messages areused by QUIC. ChangeCipherSpec is redundant in TLS 1.3; seeSection 8.4.QUIC has its own key update mechanism; seeSection 6.¶
Data is protected using a number of encryption levels:¶
Application data can only appear in the early data and application datalevels. Handshake and alert messages may appear in any level.¶
The 0-RTT handshake can be used if the client and server have previouslycommunicated. In the 1-RTT handshake, the client is unable to send protectedapplication data until it has received all of the handshake messages sent by theserver.¶
QUIC[QUIC-TRANSPORT] assumes responsibility for the confidentiality andintegrity protection of packets. For this it uses keys derived from a TLShandshake[TLS13], but instead of carrying TLS records over QUIC (as withTCP), TLS handshake and alert messages are carried directly over the QUICtransport, which takes over the responsibilities of the TLS record layer, asshown inFigure 3.¶
+--------------+--------------+ +-------------+| TLS | TLS | | QUIC || Handshake | Alerts | | Applications|| | | | (h3, etc.) |+--------------+--------------+-+-------------+| || QUIC Transport || (streams, reliability, congestion, etc.) || |+---------------------------------------------+| || QUIC Packet Protection || |+---------------------------------------------+
QUIC also relies on TLS for authentication and negotiation of parameters thatare critical to security and performance.¶
Rather than a strict layering, these two protocols cooperate: QUIC uses the TLShandshake; TLS uses the reliability, ordered delivery, and record layer providedby QUIC.¶
At a high level, there are two main interactions between the TLS and QUICcomponents:¶
Figure 4 shows these interactions in more detail, with the QUIC packetprotection being called out specially.¶
+------------+ +------------+| |<---- Handshake Messages ----->| || |<- Validate 0-RTT Parameters ->| || |<--------- 0-RTT Keys ---------| || QUIC |<------- Handshake Keys -------| TLS || |<--------- 1-RTT Keys ---------| || |<------- Handshake Done -------| |+------------+ +------------+ | ^ | Protect | Protected v | Packet+------------+| QUIC || Packet || Protection |+------------+
Unlike TLS over TCP, QUIC applications that want to send data do not send itusing TLS Application Data records. Rather, they send it as QUIC STREAMframes or other frame types, which are then carried in QUIC packets.¶
QUIC carries TLS handshake data in CRYPTO frames, each of which consists of acontiguous block of handshake data identified by an offset and length. Thoseframes are packaged into QUIC packets and encrypted under the currentencryption level. As with TLS over TCP, once TLS handshake data has beendelivered to QUIC, it is QUIC's responsibility to deliver it reliably. Eachchunk of data that is produced by TLS is associated with the set of keys thatTLS is currently using. If QUIC needs to retransmit that data, itMUST use thesame keys even if TLS has already updated to newer keys.¶
Each encryption level corresponds to a packet number space. The packet numberspace that is used determines the semantics of frames. Some frames areprohibited in different packet number spaces; seeSection 12.5 of [QUIC-TRANSPORT].¶
Because packets could be reordered on the wire, QUIC uses the packet type toindicate which keys were used to protect a given packet, as shown inTable 1. When packets of different types need to be sent,endpointsSHOULD use coalesced packets to send them in the same UDP datagram.¶
Packet Type | Encryption Keys | PN Space |
---|---|---|
Initial | Initial secrets | Initial |
0-RTT Protected | 0-RTT | Application data |
Handshake | Handshake | Handshake |
Retry | Retry | N/A |
Version Negotiation | N/A | N/A |
Short Header | 1-RTT | Application data |
Section 17 of [QUIC-TRANSPORT] shows how packets at the various encryptionlevels fit into the handshake process.¶
As shown inFigure 4, the interface from QUIC to TLS consists of fourprimary functions:¶
Additional functions might be needed to configure TLS. In particular, QUIC andTLS need to agree on which is responsible for validation of peer credentials,such as certificate validation[RFC5280].¶
In this document, the TLS handshake is considered complete when the TLS stackhas reported that the handshake is complete. This happens when the TLS stackhas both sent a Finished message and verified the peer's Finished message.Verifying the peer's Finished message provides the endpoints with an assurancethat previous handshake messages have not been modified. Note that thehandshake does not complete at both endpoints simultaneously. Consequently, anyrequirement that is based on the completion of the handshake depends on theperspective of the endpoint in question.¶
In this document, the TLS handshake is considered confirmed at the server whenthe handshake completes. The serverMUST send a HANDSHAKE_DONE frame as soon asthe handshake is complete. At the client, the handshake is considered confirmedwhen a HANDSHAKE_DONE frame is received.¶
Additionally, a clientMAY consider the handshake to be confirmed when itreceives an acknowledgment for a 1-RTT packet. This can be implemented byrecording the lowest packet number sent with 1-RTT keys and comparing it to theLargest Acknowledged field in any received 1-RTT ACK frame: once the latter isgreater than or equal to the former, the handshake is confirmed.¶
In order to drive the handshake, TLS depends on being able to send and receivehandshake messages. There are two basic functions on this interface: one whereQUIC requests handshake messages and one where QUIC provides bytes that comprisehandshake messages.¶
Before starting the handshake, QUIC provides TLS with the transport parameters(seeSection 8.2) that it wishes to carry.¶
A QUIC client starts TLS by requesting TLS handshake bytes from TLS. The clientacquires handshake bytes before sending its first packet. A QUIC server startsthe process by providing TLS with the client's handshake bytes.¶
At any time, the TLS stack at an endpoint will have a current sending encryptionlevel and a receiving encryption level. TLS encryption levels determine the QUICpacket type and keys that are used for protecting data.¶
Each encryption level is associated with a different sequence of bytes, which isreliably transmitted to the peer in CRYPTO frames. When TLS provides handshakebytes to be sent, they are appended to the handshake bytes for the currentencryption level. The encryption level then determines the type of packet thatthe resulting CRYPTO frame is carried in; seeTable 1.¶
Four encryption levels are used, producing keys for Initial, 0-RTT, Handshake,and 1-RTT packets. CRYPTO frames are carried in just three of these levels,omitting the 0-RTT level. These four levels correspond to three packet numberspaces: Initial and Handshake encrypted packets use their own separate spaces;0-RTT and 1-RTT packets use the application data packet number space.¶
QUIC takes the unprotected content of TLS handshake records as the content ofCRYPTO frames. TLS record protection is not used by QUIC. QUIC assemblesCRYPTO frames into QUIC packets, which are protected using QUIC packetprotection.¶
QUIC CRYPTO frames only carry TLS handshake messages. TLSalerts are turned into QUIC CONNECTION_CLOSE error codes; seeSection 4.8.TLS application data and other content types cannot be carried by QUIC at anyencryption level; it is an error if they are received from the TLS stack.¶
When an endpoint receives a QUIC packet containing a CRYPTO frame from thenetwork, it proceeds as follows:¶
Each time that TLS is provided with new data, new handshake bytes are requestedfrom TLS. TLS might not provide any bytes if the handshake messages it hasreceived are incomplete or it has no data to send.¶
The content of CRYPTO frames might either be processed incrementally by TLS orbuffered until complete messages or flights are available. TLS is responsiblefor buffering handshake bytes that have arrived in order. QUIC is responsiblefor buffering handshake bytes that arrive out of order or for encryption levelsthat are not yet ready. QUIC does not provide any means of flow control forCRYPTO frames; seeSection 7.5 of [QUIC-TRANSPORT].¶
Once the TLS handshake is complete, this is indicated to QUIC along with anyfinal handshake bytes that TLS needs to send. At this stage, the transportparameters that the peer advertised during the handshake are authenticated;seeSection 8.2.¶
Once the handshake is complete, TLS becomes passive. TLS can still receive datafrom its peer and respond in kind, but it will not need to send more data unlessspecifically requested -- either by an application or QUIC. One reason to senddata is that the server might wish to provide additional or updated sessiontickets to a client.¶
When the handshake is complete, QUIC only needs to provide TLS with any datathat arrives in CRYPTO streams. In the same manner that is used during thehandshake, new data is requested from TLS after providing received data.¶
As keys at a given encryption level become available to TLS, TLS indicates toQUIC that reading or writing keys at that encryption level are available.¶
The availability of new keys is always a result of providing inputs to TLS. TLSonly provides new keys after being initialized (by a client) or when providedwith new handshake data.¶
However, a TLS implementation could perform some of its processingasynchronously. In particular, the process of validating a certificate can takesome time. While waiting for TLS processing to complete, an endpointSHOULDbuffer received packets if they might be processed using keys that are not yetavailable. These packets can be processed once keys are provided by TLS. AnendpointSHOULD continue to respond to packets that can be processed during thistime.¶
After processing inputs, TLS might produce handshake bytes, keys for newencryption levels, or both.¶
TLS provides QUIC with three items as a new encryption level becomes available:¶
These values are based on the values that TLS negotiates and are used by QUIC togenerate packet and header protection keys; seeSection 5 andSection 5.4.¶
If 0-RTT is possible, it is ready after the client sends a TLS ClientHellomessage or the server receives that message. After providing a QUIC client withthe first handshake bytes, the TLS stack might signal the change to 0-RTTkeys. On the server, after receiving handshake bytes that contain a ClientHellomessage, a TLS server might signal that 0-RTT keys are available.¶
Although TLS only uses one encryption level at a time, QUIC may use more thanone level. For instance, after sending its Finished message (using a CRYPTOframe at the Handshake encryption level) an endpoint can send STREAM data (in1-RTT encryption). If the Finished message is lost, the endpoint uses theHandshake encryption level to retransmit the lost message. Reordering or lossof packets can mean that QUIC will need to handle packets at multiple encryptionlevels. During the handshake, this means potentially handling packets at higherand lower encryption levels than the current encryption level used by TLS.¶
In particular, server implementations need to be able to read packets at theHandshake encryption level at the same time as the 0-RTT encryption level. Aclient could interleave ACK frames that are protected with Handshake keys with0-RTT data, and the server needs to process those acknowledgments in order todetect lost Handshake packets.¶
QUIC also needs access to keys that might not ordinarily be available to a TLSimplementation. For instance, a client might need to acknowledge Handshakepackets before it is ready to send CRYPTO frames at that encryption level. TLStherefore needs to provide keys to QUIC before it might produce them for its ownuse.¶
Figure 5 summarizes the exchange between QUIC and TLS for bothclient and server. Solid arrows indicate packets that carry handshake data;dashed arrows show where application data can be sent. Each arrow is taggedwith the encryption level used for that transmission.¶
Client Server====== ======Get Handshake Initial ------------->Install tx 0-RTT keys 0-RTT - - - - - - - -> Handshake Received Get Handshake <------------- Initial Install rx 0-RTT keys Install Handshake keys Get Handshake <----------- Handshake Install tx 1-RTT keys <- - - - - - - - 1-RTTHandshake Received (Initial)Install Handshake keysHandshake Received (Handshake)Get Handshake Handshake ----------->Handshake CompleteInstall 1-RTT keys 1-RTT - - - - - - - -> Handshake Received Handshake Complete Handshake Confirmed Install rx 1-RTT keys <--------------- 1-RTT (HANDSHAKE_DONE)Handshake Confirmed
Figure 5 shows the multiple packets that form a single "flight" ofmessages being processed individually, to show what incoming messages triggerdifferent actions. This shows multiple "Get Handshake" invocations to retrievehandshake messages at different encryption levels. New handshake messages arerequested after incoming packets have been processed.¶
Figure 5 shows one possible structure for a simple handshakeexchange. The exact process varies based on the structure of endpointimplementations and the order in which packets arrive. Implementations coulduse a different number of operations or execute them in other orders.¶
This document describes how TLS 1.3[TLS13] is used with QUIC.¶
In practice, the TLS handshake will negotiate a version of TLS to use. Thiscould result in a version of TLS newer than 1.3 being negotiated if bothendpoints support that version. This is acceptable provided that the featuresof TLS 1.3 that are used by QUIC are supported by the newer version.¶
ClientsMUST NOT offer TLS versions older than 1.3. A badly configured TLSimplementation could negotiate TLS 1.2 or another older version of TLS. AnendpointMUST terminate the connection if a version of TLS older than 1.3 isnegotiated.¶
The first Initial packet from a client contains the start or all of its firstcryptographic handshake message, which for TLS is the ClientHello. Serversmight need to parse the entire ClientHello (e.g., to access extensions such asServer Name Identification (SNI) or Application-Layer Protocol Negotiation(ALPN)) in order to decide whether to accept the new incoming QUIC connection.If the ClientHello spans multiple Initial packets, such servers would need tobuffer the first received fragments, which could consume excessive resources ifthe client's address has not yet been validated. To avoid this, serversMAYuse the Retry feature (seeSection 8.1 of [QUIC-TRANSPORT]) to only bufferpartial ClientHello messages from clients with a validated address.¶
QUIC packet and framing add at least 36 bytes of overhead to the ClientHellomessage. That overhead increases if the client chooses a Source Connection IDfield longer than zero bytes. Overheads also do not include the token or aDestination Connection ID longer than 8 bytes, both of which might be requiredif a server sends a Retry packet.¶
A typical TLS ClientHello can easily fit into a 1200-byte packet. However, inaddition to the overheads added by QUIC, there are several variables that couldcause this limit to be exceeded. Large session tickets, multiple or large keyshares, and long lists of supported ciphers, signature algorithms, versions,QUIC transport parameters, and other negotiable parameters and extensions couldcause this message to grow.¶
For servers, in addition to connection IDs and tokens, the size of TLS sessiontickets can have an effect on a client's ability to connect efficiently.Minimizing the size of these values increases the probability that clients canuse them and still fit their entire ClientHello message in their first Initialpacket.¶
The TLS implementation does not need to ensure that the ClientHello is largeenough to meet QUIC's requirements for datagrams that carry Initial packets; seeSection 14.1 of [QUIC-TRANSPORT]. QUIC implementations use PADDING frames orpacket coalescing to ensure that datagrams are large enough.¶
The requirements for authentication depend on the application protocol that isin use. TLS provides server authentication and permits the server to requestclient authentication.¶
A clientMUST authenticate the identity of the server. This typically involvesverification that the identity of the server is included in a certificate andthat the certificate is issued by a trusted entity (see for example[RFC2818]).¶
Note: Where servers provide certificates for authentication, the size of the certificate chain can consume a large number of bytes. Controlling the size of certificate chains is critical to performance in QUIC as servers are limited to sending 3 bytes for every byte received prior to validating the client address; seeSection 8.1 of [QUIC-TRANSPORT]. The size of a certificate chain can be managed by limiting the number of names or extensions; using keys with small public key representations, like ECDSA; or by using certificate compression[COMPRESS].¶
A serverMAY request that the client authenticate during the handshake. A serverMAY refuse a connection if the client is unable to authenticate when requested.The requirements for client authentication vary based on application protocoland deployment.¶
A serverMUST NOT use post-handshake client authentication (as defined inSection 4.6.2 of [TLS13]) because the multiplexing offered by QUIC preventsclients from correlating the certificate request with the application-levelevent that triggered it (see[HTTP2-TLS13]). More specifically,serversMUST NOT send post-handshake TLS CertificateRequest messages, andclientsMUST treat receipt of such messages as a connection error of typePROTOCOL_VIOLATION.¶
QUIC can use the session resumption feature of TLS 1.3. It does this bycarrying NewSessionTicket messages in CRYPTO frames after the handshake iscomplete. Session resumption can be used to provide 0-RTT and can also beused when 0-RTT is disabled.¶
Endpoints that use session resumption might need to remember some informationabout the current connection when creating a resumed connection. TLS requiresthat some information be retained; seeSection 4.6.1 of [TLS13]. QUIC itselfdoes not depend on any state being retained when resuming a connection unless0-RTT is also used; seeSection 7.4.1 of [QUIC-TRANSPORT] andSection 4.6.1. Application protocols could depend on state that is retainedbetween resumed connections.¶
Clients can store any state required for resumption along with the sessionticket. Servers can use the session ticket to help carry state.¶
Session resumption allows servers to link activity on the original connectionwith the resumed connection, which might be a privacy issue for clients.Clients can choose not to enable resumption to avoid creating this correlation.ClientsSHOULD NOT reuse tickets as that allows entities other than the serverto correlate connections; seeAppendix C.4 of [TLS13].¶
The 0-RTT feature in QUIC allows a client to send application data before thehandshake is complete. This is made possible by reusing negotiated parametersfrom a previous connection. To enable this, 0-RTT depends on the clientremembering critical parameters and providing the server with a TLS sessionticket that allows the server to recover the same information.¶
This information includes parameters that determine TLS state, as governed by[TLS13], QUIC transport parameters, the chosen application protocol, and anyinformation the application protocol might need; seeSection 4.6.3. Thisinformation determines how 0-RTT packets and their contents are formed.¶
To ensure that the same information is available to both endpoints, allinformation used to establish 0-RTT comes from the same connection. Endpointscannot selectively disregard information that might alter the sending orprocessing of 0-RTT.¶
[TLS13] sets a limit of seven days on the time between the originalconnection and any attempt to use 0-RTT. There are other constraints on 0-RTTusage, notably those caused by the potential exposure to replay attack; seeSection 9.2.¶
The TLS early_data extension in the NewSessionTicket message is defined toconvey (in the max_early_data_size parameter) the amount of TLS 0-RTT data theserver is willing to accept. QUIC does not use TLS early data. QUIC uses 0-RTTpackets to carry early data. Accordingly, the max_early_data_size parameter isrepurposed to hold a sentinel value 0xffffffff to indicate that the server iswilling to accept QUIC 0-RTT data. To indicate that the server does not accept0-RTT data, the early_data extension is omitted from the NewSessionTicket. Theamount of data that the client can send in QUIC 0-RTT is controlled by theinitial_max_data transport parameter supplied by the server.¶
ServersMUST NOT send the early_data extension with a max_early_data_size fieldset to any value other than 0xffffffff. A clientMUST treat receipt of aNewSessionTicket that contains an early_data extension with any other value asa connection error of type PROTOCOL_VIOLATION.¶
A client that wishes to send 0-RTT packets uses the early_data extension in theClientHello message of a subsequent handshake; seeSection 4.2.10 of [TLS13].It then sends application data in 0-RTT packets.¶
A client that attempts 0-RTT might also provide an address validation token ifthe server has sent a NEW_TOKEN frame; seeSection 8.1 of [QUIC-TRANSPORT].¶
A server accepts 0-RTT by sending an early_data extension in theEncryptedExtensions; seeSection 4.2.10 of [TLS13]. The server thenprocesses and acknowledges the 0-RTT packets that it receives.¶
A server rejects 0-RTT by sending the EncryptedExtensions without an early_dataextension. A server will always reject 0-RTT if it sends a TLSHelloRetryRequest. When rejecting 0-RTT, a serverMUST NOT process any 0-RTTpackets, even if it could. When 0-RTT was rejected, a clientSHOULD treatreceipt of an acknowledgment for a 0-RTT packet as a connection error of typePROTOCOL_VIOLATION, if it is able to detect the condition.¶
When 0-RTT is rejected, all connection characteristics that the client assumedmight be incorrect. This includes the choice of application protocol, transportparameters, and any application configuration. The client thereforeMUST resetthe state of all streams, including application state bound to those streams.¶
A clientMAY reattempt 0-RTT if it receives a Retry or Version Negotiationpacket. These packets do not signify rejection of 0-RTT.¶
When a server receives a ClientHello with the early_data extension, it has todecide whether to accept or reject 0-RTT data from the client. Some of thisdecision is made by the TLS stack (e.g., checking that the cipher suite beingresumed was included in the ClientHello; seeSection 4.2.10 of [TLS13]). Evenwhen the TLS stack has no reason to reject 0-RTT data, the QUIC stack or theapplication protocol using QUIC might reject 0-RTT data because theconfiguration of the transport or application associated with the resumedsession is not compatible with the server's current configuration.¶
QUIC requires additional transport state to be associated with a 0-RTT sessionticket. One common way to implement this is using stateless session tickets andstoring this state in the session ticket. Application protocols that use QUICmight have similar requirements regarding associating or storing state. Thisassociated state is used for deciding whether 0-RTT data must be rejected. Forexample, HTTP/3 settings[QUIC-HTTP] determine how 0-RTT data from theclient is interpreted. Other applications using QUIC could have differentrequirements for determining whether to accept or reject 0-RTT data.¶
The HelloRetryRequest message (seeSection 4.1.4 of [TLS13]) can be used torequest that a client provide new information, such as a key share, or tovalidate some characteristic of the client. From the perspective of QUIC,HelloRetryRequest is not differentiated from other cryptographic handshakemessages that are carried in Initial packets. Although it is in principlepossible to use this feature for address verification, QUIC implementationsSHOULD instead use the Retry feature; seeSection 8.1 of [QUIC-TRANSPORT].¶
If TLS experiences an error, it generates an appropriate alert as defined inSection 6 of [TLS13].¶
A TLS alert is converted into a QUIC connection error. The AlertDescriptionvalue isadded to 0x0100 to produce a QUIC error code from the range reserved forCRYPTO_ERROR; seeSection 20.1 of [QUIC-TRANSPORT]. The resulting value issent in a QUIC CONNECTION_CLOSE frame of type 0x1c.¶
QUIC is only able to convey an alert level of "fatal". In TLS 1.3, the onlyexisting uses for the "warning" level are to signal connection close; seeSection 6.1 of [TLS13]. As QUIC provides alternative mechanisms forconnection termination and the TLS connection is only closed if an error isencountered, a QUIC endpointMUST treat any alert from TLS as if it were at the"fatal" level.¶
QUIC permits the use of a generic code in place of a specific error code; seeSection 11 of [QUIC-TRANSPORT]. For TLS alerts, this includes replacing anyalert with a generic alert, such as handshake_failure (0x0128 in QUIC).EndpointsMAY use a generic error code to avoid possibly exposing confidentialinformation.¶
After QUIC has completed a move to a new encryption level, packet protectionkeys for previous encryption levels can be discarded. This occurs several timesduring the handshake, as well as when keys are updated; seeSection 6.¶
Packet protection keys are not discarded immediately when new keys areavailable. If packets from a lower encryption level contain CRYPTO frames,frames that retransmit that dataMUST be sent at the same encryption level.Similarly, an endpoint generates acknowledgments for packets at the sameencryption level as the packet being acknowledged. Thus, it is possible thatkeys for a lower encryption level are needed for a short time after keys for anewer encryption level are available.¶
An endpoint cannot discard keys for a given encryption level unless it hasreceived all the cryptographic handshake messages from its peer at thatencryption level and its peer has done the same. Different methods fordetermining this are provided for Initial keys (Section 4.9.1) andHandshake keys (Section 4.9.2). These methods do not prevent packetsfrom being received or sent at that encryption level because a peer might nothave received all the acknowledgments necessary.¶
Though an endpoint might retain older keys, new dataMUST be sent at the highestcurrently available encryption level. Only ACK frames and retransmissions ofdata in CRYPTO frames are sent at a previous encryption level. These packetsMAY also include PADDING frames.¶
Packets protected with Initial secrets (Section 5.2) are notauthenticated, meaning that an attacker could spoof packets with the intent todisrupt a connection. To limit these attacks, Initial packet protection keysare discarded more aggressively than other keys.¶
The successful use of Handshake packets indicates that no more Initial packetsneed to be exchanged, as these keys can only be produced after receiving allCRYPTO frames from Initial packets. Thus, a clientMUST discard Initial keyswhen it first sends a Handshake packet and a serverMUST discard Initial keyswhen it first successfully processes a Handshake packet. EndpointsMUST NOTsend Initial packets after this point.¶
This results in abandoning loss recovery state for the Initial encryption leveland ignoring any outstanding Initial packets.¶
An endpointMUST discard its Handshake keys when the TLS handshake is confirmed(Section 4.1.2).¶
0-RTT and 1-RTT packets share the same packet number space, and clients do notsend 0-RTT packets after sending a 1-RTT packet (Section 5.6).¶
Therefore, a clientSHOULD discard 0-RTT keys as soon as it installs 1-RTTkeys as they have no use after that moment.¶
Additionally, a serverMAY discard 0-RTT keys as soon as it receives a 1-RTTpacket. However, due to packet reordering, a 0-RTT packet could arrive aftera 1-RTT packet. ServersMAY temporarily retain 0-RTT keys to allow decryptingreordered packets without requiring their contents to be retransmitted with1-RTT keys. After receiving a 1-RTT packet, serversMUST discard 0-RTT keyswithin a short time; theRECOMMENDED time period is three times the ProbeTimeout (PTO, see[QUIC-RECOVERY]). A serverMAY discard 0-RTT keys earlierif it determines that it has received all 0-RTT packets, which can be done bykeeping track of missing packet numbers.¶
As with TLS over TCP, QUIC protects packets with keys derived from the TLShandshake, using the AEAD algorithm[AEAD] negotiated by TLS.¶
QUIC packets have varying protections depending on their type:¶
This section describes how packet protection is applied to Handshake packets,0-RTT packets, and 1-RTT packets. The same packet protection process is appliedto Initial packets. However, as it is trivial to determine the keys used forInitial packets, these packets are not considered to have confidentiality orintegrity protection. Retry packets use a fixed key and so similarly lackconfidentiality and integrity protection.¶
QUIC derives packet protection keys in the same way that TLS derives recordprotection keys.¶
Each encryption level has separate secret values for protection of packets sentin each direction. These traffic secrets are derived by TLS (seeSection 7.1 of [TLS13]) and are used by QUIC for all encryption levels except the Initialencryption level. The secrets for the Initial encryption level are computedbased on the client's initial Destination Connection ID, as described inSection 5.2.¶
The keys used for packet protection are computed from the TLS secrets using theKDF provided by TLS. In TLS 1.3, the HKDF-Expand-Label function described inSection 7.1 of [TLS13] is used with the hash function from the negotiatedcipher suite. All uses of HKDF-Expand-Label in QUIC use a zero-length Context.¶
Note that labels, which are described using strings, are encodedas bytes using ASCII[ASCII] without quotes or any trailing NULbyte.¶
Other versions of TLSMUST provide a similar function in order to beused with QUIC.¶
The current encryption level secret and the label "quic key" are input to theKDF to produce the AEAD key; the label "quic iv" is used to derive theInitialization Vector (IV); seeSection 5.3. The header protection key uses the"quic hp" label; seeSection 5.4. Using these labels provides keyseparation between QUIC and TLS; seeSection 9.6.¶
Both "quic key" and "quic hp" are used to produce keys, so the Length providedto HKDF-Expand-Label along with these labels is determined by the size of keysin the AEAD or header protection algorithm. The Length provided with "quic iv"is the minimum length of the AEAD nonce or 8 bytes if that is larger; see[AEAD].¶
The KDF used for initial secrets is always the HKDF-Expand-Label function fromTLS 1.3; seeSection 5.2.¶
Initial packets apply the packet protection process, but use a secret derivedfrom the Destination Connection ID field from the client's first Initialpacket.¶
This secret is determined by using HKDF-Extract (seeSection 2.2 of [HKDF])with a salt of 0x38762cf7f55934b34d179ae6a4c80cadccbb7f0a and the input keyingmaterial (IKM) of the Destination Connection ID field. This produces anintermediate pseudorandom key (PRK) that is used to derive two separate secretsfor sending and receiving.¶
The secret used by clients to construct Initial packets uses the PRK and thelabel "client in" as input to the HKDF-Expand-Label function from TLS[TLS13] to produce a 32-byte secret. Packets constructed by the server usethe same process with the label "server in". The hash function for HKDF whenderiving initial secrets and keys is SHA-256[SHA].¶
This process in pseudocode is:¶
initial_salt = 0x38762cf7f55934b34d179ae6a4c80cadccbb7f0ainitial_secret = HKDF-Extract(initial_salt, client_dst_connection_id)client_initial_secret = HKDF-Expand-Label(initial_secret, "client in", "", Hash.length)server_initial_secret = HKDF-Expand-Label(initial_secret, "server in", "", Hash.length)¶
The connection ID used with HKDF-Expand-Label is the Destination Connection IDin the Initial packet sent by the client. This will be a randomly selectedvalue unless the client creates the Initial packet after receiving a Retrypacket, where the Destination Connection ID is selected by the server.¶
Future versions of QUICSHOULD generate a new salt value, thus ensuring thatthe keys are different for each version of QUIC. This prevents a middlebox thatrecognizes only one version of QUIC from seeing or modifying the contents ofpackets from future versions.¶
The HKDF-Expand-Label function defined in TLS 1.3MUST be used for Initialpackets even where the TLS versions offered do not include TLS 1.3.¶
The secrets used for constructing subsequent Initial packets change when aserver sends a Retry packet to use the connection ID value selected by theserver. The secrets do not change when a client changes the DestinationConnection ID it uses in response to an Initial packet from the server.¶
Note: The Destination Connection ID field could be any length up to 20 bytes, including zero length if the server sends a Retry packet with a zero-length Source Connection ID field. After a Retry, the Initial keys provide the client no assurance that the server received its packet, so the client has to rely on the exchange that included the Retry packet to validate the server address; seeSection 8.1 of [QUIC-TRANSPORT].¶
Appendix A contains sample Initial packets.¶
The Authenticated Encryption with Associated Data (AEAD) function (see[AEAD]) used for QUIC packet protection is the AEAD that is negotiated foruse with the TLS connection. For example, if TLS is using theTLS_AES_128_GCM_SHA256 cipher suite, the AEAD_AES_128_GCM function is used.¶
QUIC can use any of the cipher suites defined in[TLS13] with the exceptionof TLS_AES_128_CCM_8_SHA256. A cipher suiteMUST NOT be negotiated unless aheader protection scheme is defined for the cipher suite. This document definesa header protection scheme for all cipher suites defined in[TLS13] asidefrom TLS_AES_128_CCM_8_SHA256. These cipher suites have a 16-byteauthentication tag and produce an output 16 bytes larger than their input.¶
An endpointMUST NOT reject a ClientHello that offers a cipher suite that itdoes not support, or it would be impossible to deploy a new cipher suite. Thisalso applies to TLS_AES_128_CCM_8_SHA256.¶
When constructing packets, the AEAD function is applied prior to applyingheader protection; seeSection 5.4. The unprotected packet header is partof the associated data (A). When processing packets, an endpoint firstremoves the header protection.¶
The key and IV for the packet are computed as described inSection 5.1.The nonce, N, is formed by combining the packet protection IV with the packetnumber. The 62 bits of the reconstructed QUIC packet number in network byteorder are left-padded with zeros to the size of the IV. The exclusive OR of thepadded packet number and the IV forms the AEAD nonce.¶
The associated data, A, for the AEAD is the contents of the QUIC header,starting from the first byte of either the short or long header, up to andincluding the unprotected packet number.¶
The input plaintext, P, for the AEAD is the payload of the QUIC packet, asdescribed in[QUIC-TRANSPORT].¶
The output ciphertext, C, of the AEAD is transmitted in place of P.¶
Some AEAD functions have limits for how many packets can be encrypted under thesame key and IV; seeSection 6.6. This might be lower than the packetnumber limit. An endpointMUST initiate a key update (Section 6) prior toexceeding any limit set for the AEAD that is in use.¶
Parts of QUIC packet headers, in particular the Packet Number field, areprotected using a key that is derived separately from the packet protection keyand IV. The key derived using the "quic hp" label is used to provideconfidentiality protection for those fields that are not exposed to on-pathelements.¶
This protection applies to the least significant bits of the first byte, plusthe Packet Number field. The four least significant bits of the first byte areprotected for packets with long headers; the five least significant bits of thefirst byte are protected for packets with short headers. For both header forms,this covers the reserved bits and the Packet Number Length field; the Key Phasebit is also protected for packets with a short header.¶
The same header protection key is used for the duration of the connection, withthe value not changing after a key update (seeSection 6). This allowsheader protection to be used to protect the key phase.¶
This process does not apply to Retry or Version Negotiation packets, which donot contain a protected payload or any of the fields that are protected by thisprocess.¶
Header protection is applied after packet protection is applied (seeSection 5.3).The ciphertext of the packet is sampled and used as input to an encryptionalgorithm. The algorithm used depends on the negotiated AEAD.¶
The output of this algorithm is a 5-byte mask that is applied to the protectedheader fields using exclusive OR. The least significant bits of the first byteof the packet are masked by the least significant bits of the first mask byte,and the packet number is masked with the remaining bytes. Any unused bytes ofmask that might result from a shorter packet number encoding are unused.¶
Figure 6 shows a sample algorithm for applying header protection. Removingheader protection only differs in the order in which the packet number length(pn_length) is determined (here "^" is used to represent exclusive OR).¶
mask = header_protection(hp_key, sample)pn_length = (packet[0] & 0x03) + 1if (packet[0] & 0x80) == 0x80: # Long header: 4 bits masked packet[0] ^= mask[0] & 0x0felse: # Short header: 5 bits masked packet[0] ^= mask[0] & 0x1f# pn_offset is the start of the Packet Number field.packet[pn_offset:pn_offset+pn_length] ^= mask[1:1+pn_length]
Specific header protection functions are defined based on the selected ciphersuite; seeSection 5.4.3 andSection 5.4.4.¶
Figure 7 shows an example long header packet (Initial) and a short headerpacket (1-RTT).Figure 7 shows the fields in each header that are coveredby header protection and the portion of the protected packet payload that issampled.¶
Initial Packet { Header Form (1) = 1, Fixed Bit (1) = 1, Long Packet Type (2) = 0, Reserved Bits (2), # Protected Packet Number Length (2), # Protected Version (32), DCID Len (8), Destination Connection ID (0..160), SCID Len (8), Source Connection ID (0..160), Token Length (i), Token (..), Length (i), Packet Number (8..32), # Protected Protected Payload (0..24), # Skipped Part Protected Payload (128), # Sampled Part Protected Payload (..) # Remainder}1-RTT Packet { Header Form (1) = 0, Fixed Bit (1) = 1, Spin Bit (1), Reserved Bits (2), # Protected Key Phase (1), # Protected Packet Number Length (2), # Protected Destination Connection ID (0..160), Packet Number (8..32), # Protected Protected Payload (0..24), # Skipped Part Protected Payload (128), # Sampled Part Protected Payload (..), # Remainder}
Before a TLS cipher suite can be used with QUIC, a header protection algorithmMUST be specified for the AEAD used with that cipher suite. This documentdefines algorithms for AEAD_AES_128_GCM, AEAD_AES_128_CCM, AEAD_AES_256_GCM (allthese AES AEADs are defined in[AEAD]), and AEAD_CHACHA20_POLY1305(defined in[CHACHA]). Prior to TLS selecting a cipher suite, AESheader protection is used (Section 5.4.3), matching the AEAD_AES_128_GCM packetprotection.¶
The header protection algorithm uses both the header protection key and a sampleof the ciphertext from the packet Payload field.¶
The same number of bytes are always sampled, but an allowance needs to be madefor the removal of protection by a receiving endpoint, which will not know thelength of the Packet Number field. The sample of ciphertext is taken startingfrom an offset of 4 bytes after the start of the Packet Number field. That is,in sampling packet ciphertext for header protection, the Packet Number field isassumed to be 4 bytes long (its maximum possible encoded length).¶
An endpointMUST discard packets that are not long enough to contain a completesample.¶
To ensure that sufficient data is available for sampling, packets are padded sothat the combined lengths of the encoded packet number and protected payload isat least 4 bytes longer than the sample required for header protection. Thecipher suites defined in[TLS13] -- other than TLS_AES_128_CCM_8_SHA256, forwhich a header protection scheme is not defined in this document -- have 16-byteexpansions and 16-byte header protection samples. This results in needing atleast 3 bytes of frames in the unprotected payload if the packet number isencoded on a single byte, or 2 bytes of frames for a 2-byte packet numberencoding.¶
The sampled ciphertext can be determined by the following pseudocode:¶
# pn_offset is the start of the Packet Number field.sample_offset = pn_offset + 4sample = packet[sample_offset..sample_offset+sample_length]¶
Where the packet number offset of a short header packet can be calculated as:¶
pn_offset = 1 + len(connection_id)¶
And the packet number offset of a long header packet can be calculated as:¶
pn_offset = 7 + len(destination_connection_id) + len(source_connection_id) + len(payload_length)if packet_type == Initial: pn_offset += len(token_length) + len(token)¶
For example, for a packet with a short header, an 8-byte connection ID, andprotected with AEAD_AES_128_GCM, the sample takes bytes 13 to 28 inclusive(using zero-based indexing).¶
Multiple QUIC packets might be included in the same UDP datagram. Each packetis handled separately.¶
This section defines the packet protection algorithm for AEAD_AES_128_GCM,AEAD_AES_128_CCM, and AEAD_AES_256_GCM. AEAD_AES_128_GCM and AEAD_AES_128_CCMuse 128-bit AES in Electronic Codebook (ECB) mode. AEAD_AES_256_GCM uses256-bit AES in ECB mode. AES is defined in[AES].¶
This algorithm samples 16 bytes from the packet ciphertext. This value is usedas the input to AES-ECB. In pseudocode, the header protection function isdefined as:¶
header_protection(hp_key, sample): mask = AES-ECB(hp_key, sample)¶
When AEAD_CHACHA20_POLY1305 is in use, header protection uses the raw ChaCha20function as defined inSection 2.4 of [CHACHA]. This uses a 256-bit key and16 bytes sampled from the packet protection output.¶
The first 4 bytes of the sampled ciphertext are the block counter. A ChaCha20implementation could take a 32-bit integer in place of a byte sequence, inwhich case, the byte sequence is interpreted as a little-endian value.¶
The remaining 12 bytes are used as the nonce. A ChaCha20 implementation mighttake an array of three 32-bit integers in place of a byte sequence, in whichcase, the nonce bytes are interpreted as a sequence of 32-bit little-endianintegers.¶
The encryption mask is produced by invoking ChaCha20 to protect 5 zero bytes. Inpseudocode, the header protection function is defined as:¶
header_protection(hp_key, sample): counter = sample[0..3] nonce = sample[4..15] mask = ChaCha20(hp_key, counter, nonce, {0,0,0,0,0})¶
Once an endpoint successfully receives a packet with a given packet number, itMUST discard all packets in the same packet number space with higher packetnumbers if they cannot be successfully unprotected with either the same key, or-- if there is a key update -- a subsequent packet protection key; seeSection 6. Similarly, a packet that appears to trigger a key update butcannot be unprotected successfullyMUST be discarded.¶
Failure to unprotect a packet does not necessarily indicate the existence of aprotocol error in a peer or an attack. The truncated packet number encodingused in QUIC can cause packet numbers to be decoded incorrectly if they aredelayed significantly.¶
If 0-RTT keys are available (seeSection 4.6.1), the lack of replay protectionmeans that restrictions on their use are necessary to avoid replay attacks onthe protocol.¶
Of the frames defined in[QUIC-TRANSPORT], the STREAM, RESET_STREAM,STOP_SENDING, and CONNECTION_CLOSE frames are potentially unsafe for use with0-RTT as they carry application data. Application data that is received in0-RTT could cause an application at the server to process the data multipletimes rather than just once. Additional actions taken by a server as a resultof processing replayed application data could have unwanted consequences. Aclient thereforeMUST NOT use 0-RTT for application data unless specificallyrequested by the application that is in use.¶
An application protocol that uses QUICMUST include a profile that definesacceptable use of 0-RTT; otherwise, 0-RTT can only be used to carry QUIC framesthat do not carry application data. For example, a profile for HTTP isdescribed in[HTTP-REPLAY] and used for HTTP/3; seeSection 10.9 of [QUIC-HTTP].¶
Though replaying packets might result in additional connection attempts, theeffect of processing replayed frames that do not carry application data islimited to changing the state of the affected connection. A TLS handshakecannot be successfully completed using replayed packets.¶
A clientMAY wish to apply additional restrictions on what data it sends priorto the completion of the TLS handshake.¶
A client otherwise treats 0-RTT keys as equivalent to 1-RTT keys, except thatit cannot send certain frames with 0-RTT keys; seeSection 12.5 of [QUIC-TRANSPORT].¶
A client that receives an indication that its 0-RTT data has been accepted by aserver can send 0-RTT data until it receives all of the server's handshakemessages. A clientSHOULD stop sending 0-RTT data if it receives an indicationthat 0-RTT data has been rejected.¶
A serverMUST NOT use 0-RTT keys to protect packets; it uses 1-RTT keys toprotect acknowledgments of 0-RTT packets. A clientMUST NOT attempt todecrypt 0-RTT packets it receives and insteadMUST discard them.¶
Once a client has installed 1-RTT keys, itMUST NOT send any more 0-RTTpackets.¶
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.¶
Due to reordering and loss, protected packets might be received by an endpointbefore the final TLS handshake messages are received. A client will be unableto decrypt 1-RTT packets from the server, whereas a server will be able todecrypt 1-RTT packets from the client. Endpoints in either roleMUST NOTdecrypt 1-RTT packets from their peer prior to completing the handshake.¶
Even though 1-RTT keys are available to a server after receiving the firsthandshake messages from a client, it is missing assurances on the client state:¶
Therefore, the server's use of 1-RTT keys before the handshake is complete islimited to sending data. A serverMUST NOT process incoming 1-RTT protectedpackets before the TLS handshake is complete. Because sending acknowledgmentsindicates that all frames in a packet have been processed, a server cannot sendacknowledgments for 1-RTT packets until the TLS handshake is complete. Receivedpackets protected with 1-RTT keysMAY be stored and later decrypted and usedonce the handshake is complete.¶
Note: TLS implementations might provide all 1-RTT secrets prior to handshake completion. Even where QUIC implementations have 1-RTT read keys, those keys are not to be used prior to completing the handshake.¶
The requirement for the server to wait for the client Finished message createsa dependency on that message being delivered. A client can avoid thepotential for head-of-line blocking that this implies by sending its 1-RTTpackets coalesced with a Handshake packet containing a copy of the CRYPTO framethat carries the Finished message, until one of the Handshake packets isacknowledged. This enables immediate server processing for those packets.¶
A server could receive packets protected with 0-RTT keys prior to receiving aTLS ClientHello. The serverMAY retain these packets for later decryption inanticipation of receiving a ClientHello.¶
A client generally receives 1-RTT keys at the same time as the handshakecompletes. Even if it has 1-RTT secrets, a clientMUST NOT processincoming 1-RTT protected packets before the TLS handshake is complete.¶
Retry packets (seeSection 17.2.5 of [QUIC-TRANSPORT]) carry a Retry IntegrityTag that provides two properties: it allows the discarding of packets that haveaccidentally been corrupted by the network, and only an entity that observes anInitial packet can send a valid Retry packet.¶
The Retry Integrity Tag is a 128-bit field that is computed as the output ofAEAD_AES_128_GCM[AEAD] used with the following inputs:¶
The secret key and the nonce are values derived by calling HKDF-Expand-Labelusing 0xd9c9943e6101fd200021506bcc02814c73030f25c79d71ce876eca876e6fca8e as thesecret, with labels being "quic key" and "quic iv" (Section 5.1).¶
Retry Pseudo-Packet { ODCID Length (8), Original Destination Connection ID (0..160), Header Form (1) = 1, Fixed Bit (1) = 1, Long Packet Type (2) = 3, Unused (4), Version (32), DCID Len (8), Destination Connection ID (0..160), SCID Len (8), Source Connection ID (0..160), Retry Token (..),}
The Retry Pseudo-Packet is not sent over the wire. It is computed by takingthe transmitted Retry packet, removing the Retry Integrity Tag, and prependingthe two following fields:¶
The ODCID Length field contains the length in bytes of the OriginalDestination Connection ID field that follows it, encoded as an 8-bit unsignedinteger.¶
The Original Destination Connection ID contains the value of the DestinationConnection ID from the Initial packet that this Retry is in response to. Thelength of this field is given in ODCID Length. The presence of this fieldensures that a valid Retry packet can only be sent by an entity thatobserves the Initial packet.¶
Once the handshake is confirmed (seeSection 4.1.2), an endpointMAYinitiate a key update.¶
The Key Phase bit indicates which packet protection keys are used to protect thepacket. The Key Phase bit is initially set to 0 for the first set of 1-RTTpackets and toggled to signal each subsequent key update.¶
The Key Phase bit allows a recipient to detect a change in keying materialwithout needing to receive the first packet that triggered the change. Anendpoint that notices a changed Key Phase bit updates keys and decrypts thepacket that contains the changed value.¶
Initiating a key update results in both endpoints updating keys. This differsfrom TLS where endpoints can update keys independently.¶
This mechanism replaces the key update mechanism of TLS, which relies onKeyUpdate messages sent using 1-RTT encryption keys. EndpointsMUST NOT send aTLS KeyUpdate message. EndpointsMUST treat the receipt of a TLS KeyUpdatemessage as a connection error of type 0x010a, equivalent to afatal TLS alert of unexpected_message; seeSection 4.8.¶
Figure 9 shows a key update process, where the initial set of keys used(identified with @M) are replaced by updated keys (identified with @N). Thevalue of the Key Phase bit is indicated in brackets [].¶
Initiating Peer Responding Peer@M [0] QUIC Packets... Update to @N@N [1] QUIC Packets --------> Update to @N ... QUIC Packets [1] @N <-------- QUIC Packets [1] @N containing ACK <--------... Key Update Permitted@N [1] QUIC Packets containing ACK for @N packets --------> Key Update Permitted ...
Endpoints maintain separate read and write secrets for packet protection. Anendpoint initiates a key update by updating its packet protection write secretand using that to protect new packets. The endpoint creates a new write secretfrom the existing write secret as performed inSection 7.2 of [TLS13]. Thisuses the KDF function provided by TLS with a label of "quic ku". Thecorresponding key and IV are created from that secret as defined inSection 5.1. The header protection key is not updated.¶
For example, to update write keys with TLS 1.3, HKDF-Expand-Label is used as:¶
secret_<n+1> = HKDF-Expand-Label(secret_<n>, "quic ku", "", Hash.length)¶
The endpoint toggles the value of the Key Phase bit and uses the updated key andIV to protect all subsequent packets.¶
An endpointMUST NOT initiate a key update prior to having confirmed thehandshake (Section 4.1.2). An endpointMUST NOT initiate a subsequentkey update unless it has received an acknowledgment for a packet that was sentprotected with keys from the current key phase. This ensures that keys areavailable to both peers before another key update can be initiated. This can beimplemented by tracking the lowest packet number sent with each key phase andthe highest acknowledged packet number in the 1-RTT space: once the latter ishigher than or equal to the former, another key update can be initiated.¶
Note: Keys of packets other than the 1-RTT packets are never updated; their keys are derived solely from the TLS handshake state.¶
The endpoint that initiates a key update also updates the keys that it uses forreceiving packets. These keys will be needed to process packets the peer sendsafter updating.¶
An endpointMUST retain old keys until it has successfully unprotected a packetsent using the new keys. An endpointSHOULD retain old keys for some timeafter unprotecting a packet sent using the new keys. Discarding old keys tooearly can cause delayed packets to be discarded. Discarding packets will beinterpreted as packet loss by the peer and could adversely affect performance.¶
A peer is permitted to initiate a key update after receiving an acknowledgmentof a packet in the current key phase. An endpoint detects a key update whenprocessing a packet with a key phase that differs from the value used to protectthe last packet it sent. To process this packet, the endpoint uses the nextpacket protection key and IV. SeeSection 6.3 for considerationsabout generating these keys.¶
If a packet is successfully processed using the next key and IV, then the peerhas initiated a key update. The endpointMUST update its send keys to thecorresponding key phase in response, as described inSection 6.1.Sending keysMUST be updated before sending an acknowledgment for the packetthat was received with updated keys. By acknowledging the packet that triggeredthe key update in a packet protected with the updated keys, the endpoint signalsthat the key update is complete.¶
An endpoint can defer sending the packet or acknowledgment according to itsnormal packet sending behavior; it is not necessary to immediately generate apacket in response to a key update. The next packet sent by the endpoint willuse the updated keys. The next packet that contains an acknowledgment willcause the key update to be completed. If an endpoint detects a second updatebefore it has sent any packets with updated keys containing anacknowledgment for the packet that initiated the key update, it indicates thatits peer has updated keys twice without awaiting confirmation. An endpointMAYtreat such consecutive key updates as a connection error of typeKEY_UPDATE_ERROR.¶
An endpoint that receives an acknowledgment that is carried in a packetprotected with old keys where any acknowledged packet was protected with newerkeysMAY treat that as a connection error of type KEY_UPDATE_ERROR. Thisindicates that a peer has received and acknowledged a packet that initiates akey update, but has not updated keys in response.¶
Endpoints responding to an apparent key updateMUST NOT generate a timingside-channel signal that might indicate that the Key Phase bit was invalid (seeSection 9.5). Endpoints can use randomized packet protection keys inplace of discarded keys when key updates are not yet permitted. Usingrandomized keys ensures that attempting to remove packet protection does notresult in timing variations, and results in packets with an invalid Key Phasebit being rejected.¶
The process of creating new packet protection keys for receiving packets couldreveal that a key update has occurred. An endpointMAY generate new keys aspart of packet processing, but this creates a timing signal that could be usedby an attacker to learn when key updates happen and thus leak the value of theKey Phase bit.¶
Endpoints are generally expected to have current and next receive packetprotection keys available. For a short period after a key update completes, upto the PTO, endpointsMAY defer generation of the next set ofreceive packet protection keys. This allows endpointsto retain only two sets of receive keys; seeSection 6.5.¶
Once generated, the next set of packet protection keysSHOULD be retained, evenif the packet that was received was subsequently discarded. Packets containingapparent key updates are easy to forge, and while the process of key update doesnot require significant effort, triggering this process could be used by anattacker for DoS.¶
For this reason, endpointsMUST be able to retain two sets of packet protectionkeys for receiving packets: the current and the next. Retaining the previouskeys in addition to these might improve performance, but this is not essential.¶
An endpoint never sends packets that are protected with old keys. Only thecurrent keys are used. Keys used for protecting packets can be discardedimmediately after switching to newer keys.¶
Packets with higher packet numbersMUST be protected with either the same ornewer packet protection keys than packets with lower packet numbers. Anendpoint that successfully removes protection with old keys when newer keys wereused for packets with lower packet numbersMUST treat this as a connection errorof type KEY_UPDATE_ERROR.¶
For receiving packets during a key update, packets protected with older keysmight arrive if they were delayed by the network. Retaining old packetprotection keys allows these packets to be successfully processed.¶
As packets protected with keys from the next key phase use the same Key Phasevalue as those protected with keys from the previous key phase, it is necessaryto distinguish between the two if packets protected with old keys are to beprocessed. This can be done using packet numbers. A recovered packet numberthat is lower than any packet number from the current key phase uses theprevious packet protection keys; a recovered packet number that is higher thanany packet number from the current key phase requires the use of the next packetprotection keys.¶
Some care is necessary to ensure that any process for selecting betweenprevious, current, and next packet protection keys does not expose a timing sidechannel that might reveal which keys were used to remove packet protection. SeeSection 9.5 for more information.¶
Alternatively, endpoints can retain only two sets of packet protection keys,swapping previous for next after enough time has passed to allow for reorderingin the network. In this case, the Key Phase bit alone can be used to selectkeys.¶
An endpointMAY allow a period of approximately the Probe Timeout (PTO; see[QUIC-RECOVERY]) after promoting the next set of receive keys to be currentbefore it creates the subsequent set of packet protection keys. These updatedkeysMAY replace the previous keys at that time. With the caveat that PTO is asubjective measure -- that is, a peer could have a different view of the RTT --this time is expected to be long enough that any reordered packets would bedeclared lost by a peer even if they were acknowledged and short enough to allowa peer to initiate further key updates.¶
Endpoints need to allow for the possibility that a peer might not be able todecrypt packets that initiate a key update during the period when the peerretains old keys. EndpointsSHOULD wait three times the PTO before initiating akey update after receiving an acknowledgment that confirms that the previous keyupdate was received. Failing to allow sufficient time could lead to packetsbeing discarded.¶
An endpointSHOULD retain old read keys for no more than three times the PTOafter having received a packet protected using the new keys. After this period,old read keys and their corresponding secretsSHOULD be discarded.¶
This document sets usage limits for AEAD algorithms to ensure that overuse doesnot give an adversary a disproportionate advantage in attacking theconfidentiality and integrity of communications when using QUIC.¶
The usage limits defined in TLS 1.3 exist for protection against attackson confidentiality and apply to successful applications of AEAD protection. Theintegrity protections in authenticated encryption also depend on limiting thenumber of attempts to forge packets. TLS achieves this by closing connectionsafter any record fails an authentication check. In comparison, QUIC ignores anypacket that cannot be authenticated, allowing multiple forgery attempts.¶
QUIC accounts for AEAD confidentiality and integrity limits separately. Theconfidentiality limit applies to the number of packets encrypted with a givenkey. The integrity limit applies to the number of packets decrypted within agiven connection. Details on enforcing these limits for each AEAD algorithmfollow below.¶
EndpointsMUST count the number of encrypted packets for each set of keys. Ifthe total number of encrypted packets with the same key exceeds theconfidentiality limit for the selected AEAD, the endpointMUST stop using thosekeys. EndpointsMUST initiate a key update before sending more protected packetsthan the confidentiality limit for the selected AEAD permits. If a key updateis not possible or integrity limits are reached, the endpointMUST stop usingthe connection and only send stateless resets in response to receiving packets.It isRECOMMENDED that endpoints immediately close the connection with aconnection error of type AEAD_LIMIT_REACHED before reaching a state where keyupdates are not possible.¶
For AEAD_AES_128_GCM and AEAD_AES_256_GCM, the confidentiality limit is223 encrypted packets; seeAppendix B.1. ForAEAD_CHACHA20_POLY1305, the confidentiality limit is greater than the number ofpossible packets (262) and so can be disregarded. ForAEAD_AES_128_CCM, the confidentiality limit is 221.5 encryptedpackets; seeAppendix B.2. Applying a limit reduces the probability that anattacker can distinguish the AEAD in use from a random permutation; see[AEBounds],[ROBUST], and[GCM-MU].¶
In addition to counting packets sent, endpointsMUST count the number ofreceived packets that fail authentication during the lifetime of a connection.If the total number of received packets that fail authentication within theconnection, across all keys, exceeds the integrity limit for the selected AEAD,the endpointMUST immediately close the connection with a connection error oftype AEAD_LIMIT_REACHED and not process any more packets.¶
For AEAD_AES_128_GCM and AEAD_AES_256_GCM, the integrity limit is 252invalid packets; seeAppendix B.1. For AEAD_CHACHA20_POLY1305, the integritylimit is 236 invalid packets; see[AEBounds]. For AEAD_AES_128_CCM,the integrity limit is 221.5 invalid packets; seeAppendix B.2. Applying this limit reduces the probability that an attacker cansuccessfully forge a packet; see[AEBounds],[ROBUST], and[GCM-MU].¶
Endpoints that limit the size of packetsMAY use higher confidentiality andintegrity limits; seeAppendix B for details.¶
Future analyses and specificationsMAY relax confidentiality or integrity limitsfor an AEAD.¶
Any TLS cipher suite that is specified for use with QUICMUST define limits onthe use of the associated AEAD function that preserves margins forconfidentiality and integrity. That is, limitsMUST be specified for the numberof packets that can be authenticated and for the number of packets that can failauthentication. Providing a reference to any analysis upon which values arebased -- and any assumptions used in that analysis -- allows limits to beadapted to varying usage conditions.¶
The KEY_UPDATE_ERROR error code (0x0e) is used to signal errors related to keyupdates.¶
Initial packets are not protected with a secret key, so they are subject topotential tampering by an attacker. QUIC provides protection against attackersthat cannot read packets but does not attempt to provide additional protectionagainst attacks where the attacker can observe and inject packets. Some formsof tampering -- such as modifying the TLS messages themselves -- are detectable,but some -- such as modifying ACKs -- are not.¶
For example, an attacker could inject a packet containing an ACK frame tomake it appear that a packet had not been received or to create a falseimpression 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 aduplicate. ImplementationsSHOULD use caution in relying on any data that iscontained in Initial packets that is not otherwise authenticated.¶
It is also possible for the attacker to tamper with data that is carried inHandshake packets, but because that sort of tampering requires modifying TLShandshake messages, any such tampering will cause the TLS handshake to fail.¶
Certain aspects of the TLS handshake are different when used with QUIC.¶
QUIC also requires additional features from TLS. In addition to negotiation ofcryptographic parameters, the TLS handshake carries and authenticates values forQUIC transport parameters.¶
QUIC requires that the cryptographic handshake provide authenticated protocolnegotiation. TLS uses Application-Layer Protocol Negotiation[ALPN] to select an application protocol. Unless another mechanismis used for agreeing on an application protocol, endpointsMUST use ALPN forthis purpose.¶
When using ALPN, endpointsMUST immediately close a connection (seeSection 10.2 of [QUIC-TRANSPORT]) with a no_application_protocol TLS alert (QUIC errorcode 0x0178; seeSection 4.8) if an application protocol is not negotiated.While[ALPN] only specifies that servers use this alert, QUIC clientsMUSTuse error 0x0178 to terminate a connection when ALPN negotiation fails.¶
An application protocolMAY restrict the QUIC versions that it can operate over.ServersMUST select an application protocol compatible with the QUIC versionthat the client has selected. The serverMUST treat the inability to select acompatible application protocol as a connection error of type 0x0178(no_application_protocol). Similarly, a clientMUST treat the selection of anincompatible application protocol by a server as a connection error of type0x0178.¶
QUIC transport parameters are carried in a TLS extension. Different versions ofQUIC might define a different method for negotiating transport configuration.¶
Including transport parameters in the TLS handshake provides integrityprotection for these values.¶
enum { quic_transport_parameters(0x39), (65535) } ExtensionType;¶
The extension_data field of the quic_transport_parameters extension contains avalue that is defined by the version of QUIC that is in use.¶
The quic_transport_parameters extension is carried in the ClientHello and theEncryptedExtensions messages during the handshake. EndpointsMUST send thequic_transport_parameters extension; endpoints that receive ClientHello orEncryptedExtensions messages without the quic_transport_parameters extensionMUST close the connection with an error of type 0x016d (equivalent to a fatalTLS missing_extension alert, seeSection 4.8).¶
Transport parameters become available prior to the completion of the handshake.A server might use these values earlier than handshake completion. However, thevalue of transport parameters is not authenticated until the handshakecompletes, so any use of these parameters cannot depend on their authenticity.Any tampering with transport parameters will cause the handshake to fail.¶
EndpointsMUST NOT send this extension in a TLS connection that does not useQUIC (such as the use of TLS with TCP defined in[TLS13]). A fatalunsupported_extension alertMUST be sent by an implementation that supports thisextension if the extension is received when the transport is not QUIC.¶
Negotiating the quic_transport_parameters extension causes the EndOfEarlyData tobe removed; seeSection 8.3.¶
The TLS EndOfEarlyData message is not used with QUIC. QUIC does not rely onthis message to mark the end of 0-RTT data or to signal the change to Handshakekeys.¶
ClientsMUST NOT send the EndOfEarlyData message. A serverMUST treat receiptof a CRYPTO frame in a 0-RTT packet as a connection error of typePROTOCOL_VIOLATION.¶
As a result, EndOfEarlyData does not appear in the TLS handshake transcript.¶
Appendix D.4 of[TLS13] describes an alteration to the TLS 1.3 handshake asa workaround for bugs in some middleboxes. The TLS 1.3 middlebox compatibilitymode involves setting the legacy_session_id field to a 32-byte value in theClientHello and ServerHello, then sending a change_cipher_spec record. Bothfield and record carry no semantic content and are ignored.¶
This mode has no use in QUIC as it only applies to middleboxes that interferewith TLS over TCP. QUIC also provides no means to carry a change_cipher_specrecord. A clientMUST NOT request the use of the TLS 1.3 compatibility mode. AserverSHOULD treat the receipt of a TLS ClientHello with a non-emptylegacy_session_id field as a connection error of type PROTOCOL_VIOLATION.¶
All of the security considerations that apply to TLS also apply to the use ofTLS in QUIC. Reading all of[TLS13] and its appendices is the best way togain an understanding of the security properties of QUIC.¶
This section summarizes some of the more important security aspects specific tothe TLS integration, though there are many security-relevant details in theremainder of the document.¶
Use of TLS session tickets allows servers and possibly other entities tocorrelate connections made by the same client; seeSection 4.5 for details.¶
As described inSection 8 of [TLS13], use of TLS early data comes with anexposure to replay attack. The use of 0-RTT in QUIC is similarly vulnerable toreplay attack.¶
EndpointsMUST implement and use the replay protections described in[TLS13],however it is recognized that these protections are imperfect. Therefore,additional consideration of the risk of replay is needed.¶
QUIC is not vulnerable to replay attack, except via the application protocolinformation it might carry. The management of QUIC protocol state based on theframe types defined in[QUIC-TRANSPORT] is not vulnerable to replay.Processing of QUIC frames is idempotent and cannot result in invalid connectionstates if frames are replayed, reordered, or lost. QUIC connections do notproduce effects that last beyond the lifetime of the connection, except forthose produced by the application protocol that QUIC serves.¶
TLS session tickets and address validation tokens are used to carry QUICconfiguration information between connections, specifically, to enable a serverto efficiently recover state that is used in connection establishment andaddress validation. TheseMUST NOT be used to communicate application semanticsbetween endpoints; clientsMUST treat them as opaque values. The potential forreuse of these tokens means that they require stronger protections againstreplay.¶
A server that accepts 0-RTT on a connection incurs a higher cost than acceptinga connection without 0-RTT. This includes higher processing and computationcosts. Servers need to consider the probability of replay and all associatedcosts when accepting 0-RTT.¶
Ultimately, the responsibility for managing the risks of replay attacks with0-RTT lies with an application protocol. An application protocol that uses QUICMUST describe how the protocol uses 0-RTT and the measures that are employed toprotect against replay attack. An analysis of replay risk needs to considerall QUIC protocol features that carry application semantics.¶
Disabling 0-RTT entirely is the most effective defense against replay attack.¶
QUIC extensionsMUST either describe how replay attacks affect their operationor prohibit the use of the extension in 0-RTT. Application protocolsMUSTeither prohibit the use of extensions that carry application semantics in 0-RTTor provide replay mitigation strategies.¶
A small ClientHello that results in a large block of handshake messages from aserver can be used in packet reflection attacks to amplify the traffic generatedby an attacker.¶
QUIC includes three defenses against this attack. First, the packet containinga ClientHelloMUST be padded to a minimum size. Second, if responding to anunverified source address, the server is forbidden to send more than threetimes as many bytes as the number of bytes it has received (seeSection 8.1 of [QUIC-TRANSPORT]). Finally, because acknowledgments of Handshake packets areauthenticated, a blind attacker cannot forge them. Put together, these defenseslimit the level of amplification.¶
[NAN] analyzes authenticated encryptionalgorithms that provide nonce privacy, referred to as "Hide Nonce" (HN)transforms. The general header protection construction in this document isone of those algorithms (HN1). Header protection is applied after the packetprotection AEAD, sampling a set of bytes (sample
) from the AEAD output andencrypting the header field using a pseudorandom function (PRF) as follows:¶
protected_field = field XOR PRF(hp_key, sample)¶
The header protection variants in this document use a pseudorandom permutation(PRP) in place of a generic PRF. However, since all PRPs are also PRFs[IMC],these variants do not deviate from the HN1 construction.¶
Ashp_key
is distinct from the packet protection key, it follows that headerprotection achieves AE2 security as defined in[NAN] and therefore guaranteesprivacy offield
, the protected packet header. Future header protectionvariants based on this constructionMUST use a PRF to ensure equivalentsecurity guarantees.¶
Use of the same key and ciphertext sample more than once risks compromisingheader protection. Protecting two different headers with the same key andciphertext sample reveals the exclusive OR of the protected fields. Assumingthat the AEAD acts as a PRF, if L bits are sampled, the odds of two ciphertextsamples being identical approach 2-L/2, that is, the birthday bound.For the algorithms described in this document, that probability is one in264.¶
To prevent an attacker from modifying packet headers, the header is transitivelyauthenticated using packet protection; the entire packet header is part of theauthenticated additional data. Protected fields that are falsified or modifiedcan only be detected once the packet protection is removed.¶
An attacker could guess values for packet numbers or Key Phase and have anendpoint confirm guesses through timing side channels. Similarly, guesses forthe packet number length can be tried and exposed. If the recipient of a packetdiscards packets with duplicate packet numbers without attempting to removepacket protection, they could reveal through timing side channels that thepacket number matches a received packet. For authentication to be free fromside channels, the entire process of header protection removal, packet numberrecovery, and packet protection removalMUST be applied together without timingand other side channels.¶
For the sending of packets, construction and protection of packet payloads andpacket numbersMUST be free from side channels that would reveal the packetnumber or its encoded size.¶
During a key update, the time taken to generate new keys could reveal throughtiming side channels that a key update has occurred. Alternatively, where anattacker injects packets, this side channel could reveal the value of the KeyPhase on injected packets. After receiving a key update, an endpointSHOULDgenerate and save the next set of receive packet protection keys, as describedinSection 6.3. By generating new keys before a key update isreceived, receipt of packets will not create timing signals that leak the valueof the Key Phase.¶
This depends on not doing this key generation during packet processing, and itcan require that endpoints maintain three sets of packet protection keys forreceiving: for the previous key phase, for the current key phase, and for thenext key phase. Endpoints can instead choose to defer generation of the nextreceive packet protection keys until they discard old keys so that only two setsof receive keys need to be retained at any point in time.¶
In using TLS, the central key schedule of TLS is used. As a result of the TLShandshake messages being integrated into the calculation of secrets, theinclusion of the QUIC transport parameters extension ensures that the handshakeand 1-RTT keys are not the same as those that might be produced by a serverrunning TLS over TCP. To avoid the possibility of cross-protocol keysynchronization, additional measures are provided to improve key separation.¶
The QUIC packet protection keys and IVs are derived using a different label thanthe equivalent keys in TLS.¶
To preserve this separation, a new version of QUICSHOULD define new labels forkey derivation for packet protection key and IV, plus the header protectionkeys. This version of QUIC uses the string "quic". Other versions can use aversion-specific label in place of that string.¶
The initial secrets use a key that is specific to the negotiated QUIC version.New QUIC versionsSHOULD define a new salt value used in calculating initialsecrets.¶
QUIC depends on endpoints being able to generate secure random numbers, bothdirectly for protocol values such as the connection ID, and transitively viaTLS. See[RFC4086] for guidance on secure random number generation.¶
IANA has registered a codepoint of 57 (or 0x39) for thequic_transport_parameters extension (defined inSection 8.2) in the "TLSExtensionType Values" registry[TLS-REGISTRIES].¶
The Recommended column for this extension is marked Yes. The TLS 1.3 Columnincludes CH (ClientHello) and EE (EncryptedExtensions).¶
Value | Extension Name | TLS 1.3 | Recommended | Reference |
---|---|---|---|---|
57 | quic_transport_parameters | CH, EE | Y | This document |
This section shows examples of packet protection so that implementations can beverified incrementally. Samples of Initial packets from both client and serverplus a Retry packet are defined. These packets use an 8-byte client-chosenDestination Connection ID of 0x8394c8f03e515708. Some intermediate values areincluded. All values are shown in hexadecimal.¶
The labels generated during the execution of the HKDF-Expand-Label function(that is, HkdfLabel.label) and part of the value given to the HKDF-Expandfunction in order to produce its output are:¶
00200f746c73313320636c69656e7420696e00¶
00200f746c7331332073657276657220696e00¶
00100e746c7331332071756963206b657900¶
000c0d746c733133207175696320697600¶
00100d746c733133207175696320687000¶
The initial secret is common:¶
initial_secret = HKDF-Extract(initial_salt, cid) = 7db5df06e7a69e432496adedb0085192 3595221596ae2ae9fb8115c1e9ed0a44¶
The secrets for protecting client packets are:¶
client_initial_secret = HKDF-Expand-Label(initial_secret, "client in", "", 32) = c00cf151ca5be075ed0ebfb5c80323c4 2d6b7db67881289af4008f1f6c357aeakey = HKDF-Expand-Label(client_initial_secret, "quic key", "", 16) = 1f369613dd76d5467730efcbe3b1a22div = HKDF-Expand-Label(client_initial_secret, "quic iv", "", 12) = fa044b2f42a3fd3b46fb255chp = HKDF-Expand-Label(client_initial_secret, "quic hp", "", 16) = 9f50449e04a0e810283a1e9933adedd2¶
The secrets for protecting server packets are:¶
server_initial_secret = HKDF-Expand-Label(initial_secret, "server in", "", 32) = 3c199828fd139efd216c155ad844cc81 fb82fa8d7446fa7d78be803acdda951bkey = HKDF-Expand-Label(server_initial_secret, "quic key", "", 16) = cf3a5331653c364c88f0f379b6067e37iv = HKDF-Expand-Label(server_initial_secret, "quic iv", "", 12) = 0ac1493ca1905853b0bba03ehp = HKDF-Expand-Label(server_initial_secret, "quic hp", "", 16) = c206b8d9b9f0f37644430b490eeaa314¶
The client sends an Initial packet. The unprotected payload of this packetcontains the following CRYPTO frame, plus enough PADDING frames to make a1162-byte payload:¶
060040f1010000ed0303ebf8fa56f129 39b9584a3896472ec40bb863cfd3e86804fe3a47f06a2b69484c000004130113 02010000c000000010000e00000b6578616d706c652e636f6dff01000100000a 00080006001d0017001800100007000504616c706e0005000501000000000033 00260024001d00209370b2c9caa47fbabaf4559fedba753de171fa71f50f1ce1 5d43e994ec74d748002b0003020304000d0010000e0403050306030203080408 050806002d00020101001c00024001003900320408ffffffffffffffff050480 00ffff07048000ffff0801100104800075300901100f088394c8f03e51570806 048000ffff¶
The unprotected header indicates a length of 1182 bytes: the 4-byte packetnumber, 1162 bytes of frames, and the 16-byte authentication tag. The headerincludes the connection ID and a packet number of 2:¶
c300000001088394c8f03e5157080000449e00000002¶
Protecting the payload produces output that is sampled for header protection.Because the header uses a 4-byte packet number encoding, the first 16 bytes ofthe protected payload is sampled and then applied to the header as follows:¶
sample = d1b1c98dd7689fb8ec11d242b123dc9bmask = AES-ECB(hp, sample)[0..4] = 437b9aec36header[0] ^= mask[0] & 0x0f = c0header[18..21] ^= mask[1..4] = 7b9aec34header = c000000001088394c8f03e5157080000449e7b9aec34¶
The resulting protected packet is:¶
c000000001088394c8f03e5157080000 449e7b9aec34d1b1c98dd7689fb8ec11d242b123dc9bd8bab936b47d92ec356c 0bab7df5976d27cd449f63300099f3991c260ec4c60d17b31f8429157bb35a12 82a643a8d2262cad67500cadb8e7378c8eb7539ec4d4905fed1bee1fc8aafba1 7c750e2c7ace01e6005f80fcb7df621230c83711b39343fa028cea7f7fb5ff89 eac2308249a02252155e2347b63d58c5457afd84d05dfffdb20392844ae81215 4682e9cf012f9021a6f0be17ddd0c2084dce25ff9b06cde535d0f920a2db1bf3 62c23e596d11a4f5a6cf3948838a3aec4e15daf8500a6ef69ec4e3feb6b1d98e 610ac8b7ec3faf6ad760b7bad1db4ba3485e8a94dc250ae3fdb41ed15fb6a8e5 eba0fc3dd60bc8e30c5c4287e53805db059ae0648db2f64264ed5e39be2e20d8 2df566da8dd5998ccabdae053060ae6c7b4378e846d29f37ed7b4ea9ec5d82e7 961b7f25a9323851f681d582363aa5f89937f5a67258bf63ad6f1a0b1d96dbd4 faddfcefc5266ba6611722395c906556be52afe3f565636ad1b17d508b73d874 3eeb524be22b3dcbc2c7468d54119c7468449a13d8e3b95811a198f3491de3e7 fe942b330407abf82a4ed7c1b311663ac69890f4157015853d91e923037c227a 33cdd5ec281ca3f79c44546b9d90ca00f064c99e3dd97911d39fe9c5d0b23a22 9a234cb36186c4819e8b9c5927726632291d6a418211cc2962e20fe47feb3edf 330f2c603a9d48c0fcb5699dbfe5896425c5bac4aee82e57a85aaf4e2513e4f0 5796b07ba2ee47d80506f8d2c25e50fd14de71e6c418559302f939b0e1abd576 f279c4b2e0feb85c1f28ff18f58891ffef132eef2fa09346aee33c28eb130ff2 8f5b766953334113211996d20011a198e3fc433f9f2541010ae17c1bf202580f 6047472fb36857fe843b19f5984009ddc324044e847a4f4a0ab34f719595de37 252d6235365e9b84392b061085349d73203a4a13e96f5432ec0fd4a1ee65accd d5e3904df54c1da510b0ff20dcc0c77fcb2c0e0eb605cb0504db87632cf3d8b4 dae6e705769d1de354270123cb11450efc60ac47683d7b8d0f811365565fd98c 4c8eb936bcab8d069fc33bd801b03adea2e1fbc5aa463d08ca19896d2bf59a07 1b851e6c239052172f296bfb5e72404790a2181014f3b94a4e97d117b4381303 68cc39dbb2d198065ae3986547926cd2162f40a29f0c3c8745c0f50fba3852e5 66d44575c29d39a03f0cda721984b6f440591f355e12d439ff150aab7613499d bd49adabc8676eef023b15b65bfc5ca06948109f23f350db82123535eb8a7433 bdabcb909271a6ecbcb58b936a88cd4e8f2e6ff5800175f113253d8fa9ca8885 c2f552e657dc603f252e1a8e308f76f0be79e2fb8f5d5fbbe2e30ecadd220723 c8c0aea8078cdfcb3868263ff8f0940054da48781893a7e49ad5aff4af300cd8 04a6b6279ab3ff3afb64491c85194aab760d58a606654f9f4400e8b38591356f bf6425aca26dc85244259ff2b19c41b9f96f3ca9ec1dde434da7d2d392b905dd f3d1f9af93d1af5950bd493f5aa731b4056df31bd267b6b90a079831aaf579be 0a39013137aac6d404f518cfd46840647e78bfe706ca4cf5e9c5453e9f7cfd2b 8b4c8d169a44e55c88d4a9a7f9474241e221af44860018ab0856972e194cd934¶
The server sends the following payload in response, including an ACK frame, aCRYPTO frame, and no PADDING frames:¶
02000000000600405a020000560303ee fce7f7b37ba1d1632e96677825ddf73988cfc79825df566dc5430b9a045a1200 130100002e00330024001d00209d3c940d89690b84d08a60993c144eca684d10 81287c834d5311bcf32bb9da1a002b00020304¶
The header from the server includes a new connection ID and a 2-byte packetnumber encoding for a packet number of 1:¶
c1000000010008f067a5502a4262b50040750001¶
As a result, after protection, the header protection sample is taken startingfrom the third protected byte:¶
sample = 2cd0991cd25b0aac406a5816b6394100mask = 2ec0d8356aheader = cf000000010008f067a5502a4262b5004075c0d9¶
The final protected packet is then:¶
cf000000010008f067a5502a4262b500 4075c0d95a482cd0991cd25b0aac406a5816b6394100f37a1c69797554780bb3 8cc5a99f5ede4cf73c3ec2493a1839b3dbcba3f6ea46c5b7684df3548e7ddeb9 c3bf9c73cc3f3bded74b562bfb19fb84022f8ef4cdd93795d77d06edbb7aaf2f 58891850abbdca3d20398c276456cbc42158407dd074ee¶
This shows a Retry packet that might be sent in response to the Initial packetinAppendix A.2. The integrity check includes the client-chosenconnection ID value of 0x8394c8f03e515708, but that value is notincluded in the final Retry packet:¶
ff000000010008f067a5502a4262b574 6f6b656e04a265ba2eff4d829058fb3f0f2496ba¶
This example shows some of the steps required to protect a packet witha short header. This example uses AEAD_CHACHA20_POLY1305.¶
In this example, TLS produces an application write secret from which a serveruses HKDF-Expand-Label to produce four values: a key, an IV, a headerprotection key, and the secret that will be used after keys are updated (thislast value is not used further in this example).¶
secret = 9ac312a7f877468ebe69422748ad00a1 5443f18203a07d6060f688f30f21632bkey = HKDF-Expand-Label(secret, "quic key", "", 32) = c6d98ff3441c3fe1b2182094f69caa2e d4b716b65488960a7a984979fb23e1c8iv = HKDF-Expand-Label(secret, "quic iv", "", 12) = e0459b3474bdd0e44a41c144hp = HKDF-Expand-Label(secret, "quic hp", "", 32) = 25a282b9e82f06f21f488917a4fc8f1b 73573685608597d0efcb076b0ab7a7a4ku = HKDF-Expand-Label(secret, "quic ku", "", 32) = 1223504755036d556342ee9361d25342 1a826c9ecdf3c7148684b36b714881f9¶
The following shows the steps involved in protecting a minimal packet with anempty Destination Connection ID. This packet contains a single PING frame (thatis, a payload of just 0x01) and has a packet number of 654360564. In thisexample, using a packet number of length 3 (that is, 49140 is encoded) avoidshaving to pad the payload of the packet; PADDING frames would be needed if thepacket number is encoded on fewer bytes.¶
pn = 654360564 (decimal)nonce = e0459b3474bdd0e46d417eb0unprotected header = 4200bff4payload plaintext = 01payload ciphertext = 655e5cd55c41f69080575d7999c25a5bfb¶
The resulting ciphertext is the minimum size possible. One byte is skipped toproduce the sample for header protection.¶
sample = 5e5cd55c41f69080575d7999c25a5bfbmask = aefefe7d03header = 4cfe4189¶
The protected packet is the smallest possible packet size of 21 bytes.¶
packet = 4cfe4189655e5cd55c41f69080575d7999c25a5bfb¶
This section documents analyses used in deriving AEAD algorithm limits forAEAD_AES_128_GCM, AEAD_AES_128_CCM, and AEAD_AES_256_GCM. The analyses thatfollow use symbols for multiplication (*), division (/), and exponentiation (^),plus parentheses for establishing precedence. The following symbols are alsoused:¶
The size of the authentication tag in bits. For these ciphers, t is 128.¶
The size of the block function in bits. For these ciphers, n is 128.¶
The size of the key in bits. This is 128 for AEAD_AES_128_GCM andAEAD_AES_128_CCM; 256 for AEAD_AES_256_GCM.¶
The number of blocks in each packet (see below).¶
The number of genuine packets created and protected by endpoints. This valueis the bound on the number of packets that can be protected before updatingkeys.¶
The number of forged packets that endpoints will accept. This value is thebound on the number of forged packets that an endpoint can reject beforeupdating keys.¶
The amount of offline ideal cipher queries made by an adversary.¶
The analyses that follow rely on a count of the number of block operationsinvolved in producing each message. This analysis is performed for packets ofsize up to 211 (l = 27) and 216 (l =212). A size of 211 is expected to be a limit that matchescommon deployment patterns, whereas the 216 is the maximum possiblesize of a QUIC packet. Only endpoints that strictly limit packet size can usethe larger confidentiality and integrity limits that are derived using thesmaller packet size.¶
For AEAD_AES_128_GCM and AEAD_AES_256_GCM, the message length (l) is the lengthof the associated data in blocks plus the length of the plaintext in blocks.¶
For AEAD_AES_128_CCM, the total number of block cipher operations is the sum ofthe following: the length of the associated data in blocks, the length of theciphertext in blocks, the length of the plaintext in blocks, plus 1. In thisanalysis, this is simplified to a value of twice the length of the packet inblocks (that is,2l = 28
for packets that are limited to211 bytes, or2l = 213
otherwise). Thissimplification is based on the packet containing all of the associated data andciphertext. This results in a one to three block overestimation of the number ofoperations per packet.¶
[GCM-MU] specifies concrete bounds for AEAD_AES_128_GCM and AEAD_AES_256_GCMas used in TLS 1.3 and QUIC. This section documents this analysis using severalsimplifying assumptions:¶
The bounds in[GCM-MU] are tighter and more complete than those used in[AEBounds], which allows for larger limits than those described in[TLS13].¶
For confidentiality, Theorem (4.3) in[GCM-MU] establishes that, for a singleuser that does not repeat nonces, the dominant term in determining thedistinguishing advantage between a real and random AEAD algorithm gained by anattacker is:¶
2 * (q * l)^2 / 2^n¶
For a target advantage of 2-57, this results in the relation:¶
q <= 2^35 / l¶
Thus, endpoints that do not send packets larger than 211 bytes cannotprotect more than 228 packets in a single connection without causingan attacker to gain a more significant advantage than the target of2-57. The limit for endpoints that allow for the packet size to be aslarge as 216 is instead 223.¶
For integrity, Theorem (4.3) in[GCM-MU] establishes that an attacker gainsan advantage in successfully forging a packet of no more than the following:¶
(1 / 2^(8 * n)) + ((2 * v) / 2^(2 * n)) + ((2 * o * v) / 2^(k + n)) + (n * (v + (v * l)) / 2^k)¶
The goal is to limit this advantage to 2-57. For AEAD_AES_128_GCM,the fourth term in this inequality dominates the rest, so the others can beremoved without significant effect on the result. This produces the followingapproximation:¶
v <= 2^64 / l¶
Endpoints that do not attempt to remove protection from packets larger than211 bytes can attempt to remove protection from at most257 packets. Endpoints that do not restrict the size of processedpackets can attempt to remove protection from at most 252 packets.¶
For AEAD_AES_256_GCM, the same term dominates, but the larger value of kproduces the following approximation:¶
v <= 2^192 / l¶
This is substantially larger than the limit for AEAD_AES_128_GCM. However, thisdocument recommends that the same limit be applied to both functions as eitherlimit is acceptably large.¶
TLS[TLS13] and[AEBounds] do not specify limits on usagefor AEAD_AES_128_CCM. However, any AEAD that is used with QUIC requires limitson use that ensure that both confidentiality and integrity are preserved. Thissection documents that analysis.¶
[CCM-ANALYSIS] is used as the basis of thisanalysis. The results of that analysis are used to derive usage limits that arebased on those chosen in[TLS13].¶
For confidentiality, Theorem 2 in[CCM-ANALYSIS] establishes that an attackergains a distinguishing advantage over an ideal pseudorandom permutation (PRP) ofno more than the following:¶
(2l * q)^2 / 2^n¶
The integrity limit in Theorem 1 in[CCM-ANALYSIS] provides an attacker astrictly higher advantage for the same number of messages. As the targets forthe confidentiality advantage and the integrity advantage are the same, onlyTheorem 1 needs to be considered.¶
Theorem 1 establishes that an attacker gains an advantage over anideal PRP of no more than the following:¶
v / 2^t + (2l * (v + q))^2 / 2^n¶
Ast
andn
are both 128, the first term is negligible relative to thesecond, so that term can be removed without a significant effect on the result.¶
This produces a relation that combines both encryption and decryption attemptswith the same limit as that produced by the theorem for confidentiality alone.For a target advantage of 2-57, this results in the following:¶
v + q <= 2^34.5 / l¶
By settingq = v
, values for both confidentiality and integrity limits can beproduced. Endpoints that limit packets to 211 bytes therefore haveboth confidentiality and integrity limits of 226.5 packets. Endpointsthat do not restrict packet size have a limit of 221.5.¶
The IETF QUIC Working Group received an enormous amount of support from manypeople. The following people provided substantive contributions to thisdocument:¶
Adam Langley¶
Alessandro Ghedini¶
Christian Huitema¶
Christopher Wood¶
David Schinazi¶
Dragana Damjanovic¶
Eric Rescorla¶
Felix Günther¶
Ian Swett¶
Jana Iyengar¶
奥 一穂 (Kazuho Oku)¶
Marten Seemann¶
Martin Duke¶
Mike Bishop¶
Mikkel Fahnøe Jørgensen¶
Nick Banks¶
Nick Harper¶
Roberto Peon¶
Rui Paulo¶
Ryan Hamilton¶
Victor Vasiliev¶