<?xml version="1.0" encoding="UTF-8"?>

<!-- updated by Chris 05/07/20 -->

<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902"
     docName="draft-ietf-tls-certificate-compression-10" number="8879"
     obsoletes="" updates="" submissionType="IETF" category="std"
     consensus="true" xml:lang="en" tocInclude="true" sortRefs="true"
     symRefs="true" version="3">

  <!-- xml2rfc v2v3 conversion 2.44.0 -->
  <front>
    <title abbrev="TLS Certificate Compression">TLS Certificate Compression</title>
    <seriesInfo name="RFC" value="8879"/>
    <author initials="A." surname="Ghedini" fullname="Alessandro Ghedini">
      <organization>Cloudflare, Inc.</organization>
      <address>
        <email>alessandro@cloudflare.com</email>
      </address>
    </author>
    <author initials="V." surname="Vasiliev" fullname="Victor Vasiliev">
      <organization>Google</organization>
      <address>
        <email>vasilvv@google.com</email>
      </address>
    </author>
    <date year="2020" month="December"/>
    <area>Security</area>
    <workgroup>TLS</workgroup>
    

    <abstract>
      <t>In TLS handshakes, certificate chains often take up
the majority of the bytes transmitted.</t>
      <t>This document describes how certificate chains can be compressed to reduce the
amount of data transmitted and avoid some round trips.</t>
    </abstract>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
      <t>In order to reduce latency and improve performance, it can be useful to reduce
the amount of data exchanged during a TLS handshake.</t>
      <t><xref target="RFC7924" format="default"/> describes a mechanism that allows a client and a server to avoid
transmitting certificates already shared in an earlier handshake, but it
doesn't help when the client connects to a server for the first time and
doesn't already have knowledge of the server's certificate chain.</t>
      <t>This document describes a mechanism that would allow certificates to be
compressed during all handshakes.</t>
    </section>
    <section anchor="notational-conventions" numbered="true" toc="default">
      <name>Notational Conventions</name>
        <t>
    The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
    NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
    "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
    described in BCP&nbsp;14 <xref target="RFC2119"/> <xref target="RFC8174"/> 
    when, and only when, they appear in all capitals, as shown here.
        </t>

    </section>
    <section anchor="negotiating-certificate-compression" numbered="true" toc="default">
      <name>Negotiating Certificate Compression</name>
      <t>This extension is only supported with TLS 1.3 <xref target="RFC8446" format="default"/> and newer; if TLS 1.2
<xref target="RFC5246" format="default"/> or earlier is negotiated, the peers <bcp14>MUST</bcp14> ignore this extension.</t>
      <t>This document defines a new extension type (compress_certificate(27)), which
can be used to signal the supported compression formats for the Certificate
message to the peer.  Whenever it is sent by the client as a ClientHello message
extension (<xref target="RFC8446" sectionFormat="comma" section="4.1.2"/>), it indicates support for
compressed server certificates.  Whenever it is sent by the server as a
CertificateRequest extension (<xref target="RFC8446" sectionFormat="comma"
section="4.3.2"/>), it indicates support for compressed client certificates.</t>
      <t>By sending a compress_certificate extension, the sender indicates to the peer
the certificate-compression algorithms it is willing to use for decompression.
The "extension_data" field of this extension <bcp14>SHALL</bcp14> contain a
      CertificateCompressionAlgorithms value:</t>

<sourcecode type="tls-presentation">
    enum {
        zlib(1),
        brotli(2),
        zstd(3),
        (65535)
    } CertificateCompressionAlgorithm;

    struct {
        CertificateCompressionAlgorithm algorithms&lt;2..2^8-2&gt;;
    } CertificateCompressionAlgorithms;
</sourcecode>

      <t>The compress_certificate extension is a unidirectional indication; no
corresponding response extension is needed.</t>
    </section>
    <section anchor="compressed-certificate-message" numbered="true" toc="default">
      <name>Compressed Certificate Message</name>
      <t>If the peer has indicated that it supports compression, server and
      client <bcp14>MAY</bcp14>
compress their corresponding Certificate messages (<xref
target="RFC8446" sectionFormat="of" section="4.4.2"/>)
and send them in the form of the CompressedCertificate message (replacing the
Certificate message).</t>
      <t>The CompressedCertificate message is formed as follows:</t>
<sourcecode>
    struct {
         CertificateCompressionAlgorithm algorithm;
         uint24 uncompressed_length;
         opaque compressed_certificate_message&lt;1..2^24-1&gt;;
    } CompressedCertificate;
</sourcecode>
      <dl newline="false" spacing="normal">
        <dt>algorithm:</dt>
        <dd>The algorithm used to compress the certificate.  The algorithm
	<bcp14>MUST</bcp14> be one of
	the algorithms listed in the peer's compress_certificate extension.</dd>
        <dt>uncompressed_length:</dt>
        <dd>
  The length of the Certificate message once it is uncompressed.  If, after
decompression, the specified length does not match the actual length, the
party receiving the invalid message <bcp14>MUST</bcp14> abort the connection with the
"bad_certificate" alert.  The presence of this field allows the receiver to
preallocate the buffer for the uncompressed Certificate message and enforce
	limits on the message size before performing decompression.</dd>
        <dt>compressed_certificate_message:</dt>
        <dd>
  The result of applying the indicated compression algorithm to the encoded
Certificate message that would have been sent if certificate compression was not
in use. The compression algorithm defines how the
bytes in the compressed_certificate_message field are converted into the
Certificate message.</dd>
      </dl>
      <t>If the specified compression algorithm is zlib, then the Certificate message
<bcp14>MUST</bcp14> be compressed with the ZLIB compression algorithm, as defined in <xref target="RFC1950" format="default"/>.
If the specified compression algorithm is brotli, the Certificate message <bcp14>MUST</bcp14>
be compressed with the Brotli compression algorithm, as defined in <xref target="RFC7932" format="default"/>.  If
the specified compression algorithm is zstd, the Certificate message <bcp14>MUST</bcp14> be
compressed with the Zstandard compression algorithm, as defined in <xref target="RFC8478" format="default"/>.</t>
      <t>It is possible to define a certificate compression algorithm that uses a
preshared dictionary to achieve a higher compression ratio.  This document does
not define any such algorithms, but additional codepoints may be allocated for
such use per the policy in <xref target="registry" format="default"/>.</t>
      <t>If the received CompressedCertificate message cannot be decompressed, the
connection <bcp14>MUST</bcp14> be terminated with the "bad_certificate" alert.</t>
      <t>If the format of the Certificate message is altered using the
server_certificate_type or client_certificate_type extensions <xref target="RFC7250" format="default"/>, the
resulting altered message is compressed instead.</t>
    </section>
    <section anchor="security-considerations" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>After decompression, the Certificate message <bcp14>MUST</bcp14> be processed as if it were
encoded without being compressed.  This way, the parsing and the verification
have the same security properties as they would have in TLS normally.</t>
      <t>In order for certificate compression to function correctly, the underlying
compression algorithm <bcp14>MUST</bcp14> output the same data
that was provided as input by the peer.</t>
      <t>Since certificate chains are typically presented on a per-server-name or
per-user basis, a malicious application does not have control over any individual fragments
in the Certificate message, meaning that they cannot leak information about the
certificate by modifying the plaintext.</t>
      <t>Implementations <bcp14>SHOULD</bcp14> bound the memory usage when decompressing the
CompressedCertificate message.</t>
      <t>Implementations <bcp14>MUST</bcp14> limit the size of the resulting decompressed chain to
the specified uncompressed length, and they <bcp14>MUST</bcp14> abort the connection if the
size of the output of the decompression function exceeds that limit.  TLS framing
imposes a 16777216-byte limit on the certificate message size, and implementations
<bcp14>MAY</bcp14> impose a limit that is lower than that; in both cases, they <bcp14>MUST</bcp14> apply the same
limit as if no compression were used.</t>
      <t>While the Certificate message in TLS 1.3 is encrypted, third parties can draw
inferences from the message length observed on the wire.  TLS 1.3 provides a padding
mechanism (discussed in Sections <xref target="RFC8446"
sectionFormat="bare" section="5.4"/> and <xref target="RFC8446"
sectionFormat="bare" section="E.3"/> of <xref target="RFC8446"/>) to counteract such
analysis.  Certificate compression alters the length of the Certificate message,
and the change in length is dependent on the actual contents of the certificate.
Any padding scheme covering the Certificate message has to address compression
within its design or disable it altogether.</t>
    </section>
    <section anchor="middlebox-compatibility" numbered="true" toc="default">
      <name>Middlebox Compatibility</name>
      <t>It's been observed that a significant number of middleboxes intercept and try
to validate the Certificate message exchanged during a TLS handshake. This
means that middleboxes that don't understand the CompressedCertificate message
might misbehave and drop connections that adopt certificate compression.
Because of that, the extension is only supported in the versions of TLS where
the certificate message is encrypted in a way that prevents middleboxes from
intercepting it -- that is, TLS version 1.3 <xref target="RFC8446" format="default"/> and higher.</t>
    </section>
    <section anchor="iana-considerations" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <section anchor="update-of-the-tls-extensiontype-registry" numbered="true" toc="default">
        <name>TLS ExtensionType Values</name>
        <t>IANA has created an entry, compress_certificate(27), in the
	"TLS ExtensionType Values" registry (defined in <xref
	target="RFC8446" format="default"/>) with the values in the "TLS 1.3" column 
set to "CH, CR" and the "Recommended" column entry set to "Yes".</t>
      </section>
      <section anchor="update-of-the-tls-handshaketype-registry" numbered="true" toc="default">
        <name>TLS HandshakeType</name>
        <t>IANA has created an entry, compressed_certificate(25), in
	the "TLS Handshake Type" registry (defined in <xref
	target="RFC8446" format="default"/>), with the "DTLS-OK" column value set to
"Yes".</t>
      </section>
      <section anchor="registry" numbered="true" toc="default">
        <name>Compression Algorithms</name>
        <t>This document establishes a registry of compression algorithms supported for
compressing the Certificate message, titled "TLS Certificate Compression Algorithm
IDs", under the existing "Transport Layer Security (TLS) Extensions" registry.</t>
        <t>The entries in the registry are:</t>
        <table align="center">
	  <name>TLS Certificate Compression Algorithm IDs</name>
          <thead>
            <tr>
              <th align="left">Algorithm Number</th>
              <th align="left">Description</th>
              <th align="left">Reference</th>
            </tr>
          </thead>
	  
          <tbody>
            <tr>
              <td align="left">0</td>
              <td align="left">Reserved</td>
              <td align="left">RFC 8879</td>
            </tr>
            <tr>
              <td align="left">1</td>
              <td align="left">zlib</td>
              <td align="left">RFC 8879</td>
            </tr>
            <tr>
              <td align="left">2</td>
              <td align="left">brotli</td>
              <td align="left">RFC 8879</td>
            </tr>
            <tr>
              <td align="left">3</td>
              <td align="left">zstd</td>
              <td align="left">RFC 8879</td>
            </tr>
            <tr>
              <td align="left">16384 to 65535</td>
              <td align="left">Reserved for Experimental Use</td>
              <td align="left">&nbsp;</td>
            </tr>
          </tbody>
        </table>
        <t>The values in this registry shall be allocated under "IETF Review" policy for
values strictly smaller than 256, under "Specification Required" policy for
values 256-16383, and under "Experimental Use" otherwise (see <xref target="RFC8126" format="default"/> for the
definition of relevant policies).  Experimental Use extensions can be used both
on private networks and over the open Internet.</t>
        <t>The procedures for requesting values in the Specification Required space are
specified in <xref target="RFC8447" sectionFormat="of" section="17"/>.</t>
      </section>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1950.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7250.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7932.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7924.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8126.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8447.xml"/>

<!--Note: [I-D.kucherawy-rfc8478bis] (or 8878) was replaced with 8478 per AD approval.-->

        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8478.xml"/>

      </references>
      <references>
        <name>Informative References</name>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5246.xml"/>
      </references>
    </references>
    <section anchor="acknowledgements" numbered="false" toc="default">
      <name>Acknowledgements</name>
      <t>Certificate compression was originally introduced in the QUIC Crypto protocol,
designed by <contact fullname="Adam Langley"/> and <contact fullname="Wan-Teh
Chang" />.</t>
      <t>This document has benefited from contributions and suggestions from <contact fullname="David
Benjamin"/>, <contact fullname="Ryan Hamilton"/>, <contact fullname="Christian
Huitema"/>, <contact fullname="Benjamin Kaduk"/>, <contact fullname="Ilari
Liusvaara"/>, <contact fullname="Piotr Sikora"/>, <contact fullname="Ian Swett"/>, <contact fullname="Martin Thomson"/>, <contact fullname="Sean Turner"/>, and many others.</t>
    </section>
  </back>

</rfc>
