<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.5.16 -->
<?rfc toc="yes"?>
<?rfc tocindent="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc strict="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc docmapping="yes"?>
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>
<rfc xmlns:x="http://purl.org/net/xml2rfc/ext"
     category="std"
     docName="draft-ietf-httpbis-digest-headers-07"
     ipr="trust200902"
     obsoletes="3230"
     submissionType="IETF">
   <x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22\&amp;amp;body=%3c{ref}%3e:"/>
   <front>
      <title>Digest Fields</title>
      <author fullname="Roberto Polli" initials="R." surname="Polli">
         <organization>Team Digitale, Italian Government</organization>
         <address>
            <postal>
               <country>Italy</country>
            </postal>
            <email>robipolli@gmail.com</email>
         </address>
      </author>
      <author fullname="Lucas Pardue" initials="L." surname="Pardue">
         <organization>Cloudflare</organization>
         <address>
            <email>lucaspardue.24.7@gmail.com</email>
         </address>
      </author>
      <date day="16" month="November" year="2021"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP</workgroup>
      <keyword>Digest</keyword>
      <abstract>
         <t>This document defines HTTP fields that support integrity checksums. The Digest field can be used for the integrity of HTTP representations. The Content-Digest field can be used for the integrity of HTTP message content. Want-Digest and Want-Content-Digest can be used to indicate a sender's desire to receive integrity fields respectively.</t>
         <t>This document obsoletes RFC 3230.</t>
      </abstract>
      <note title="Note to Readers">
         <t>
            <em>RFC EDITOR: please remove this section before publication</em>
         </t>
         <t>Discussion of this draft takes place on the HTTP working group mailing list (ietf-http-wg@w3.org), which is archived at <eref target="https://lists.w3.org/Archives/Public/ietf-http-wg/">https://lists.w3.org/Archives/Public/ietf-http-wg/</eref>.</t>
         <t>The source code and issues list for this draft can be found at <eref target="https://github.com/httpwg/http-extensions">https://github.com/httpwg/http-extensions</eref>.</t>
      </note>
   </front>
   <middle>
      <section anchor="introduction">
         <name>Introduction</name>
         <t>HTTP does not define a means to protect the integrity of representations. When HTTP messages are transferred between endpoints, the protocol might choose to make use of features of the lower layer in order to provide some integrity protection; for instance, TCP checksums or TLS records <xref target="RFC2818"/>.</t>
         <t>This document defines two digest integrity mechanisms for HTTP. First, representation data integrity, which acts on representation data (<xref section="3.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor representations?><?aug-title Representations?></xref>). Second, content digest integrity, which acts on conveyed content (<xref section="6.4" sectionFormat="of" target="SEMANTICS"><?aug-anchor content?><?aug-title Content?></xref>). Both mechanisms operate independent of transport integrity, offering the potential to detect programming errors and corruption of data in flight or at rest. They can be used across multiple hops in order to provide end-to-end integrity guarantees, which can aid fault diagnosis when resources are transferred across hops and system boundaries. Finally, they can be used to validate integrity when reconstructing a resource fetched using different HTTP connections.</t>
         <t>This document obsoletes <xref target="RFC3230"/>.</t>
         <section anchor="document-structure">
            <name>Document Structure</name>
            <t>This document is structured as follows:</t>
            <t>
               <list style="symbols">
                  <t>
                     <xref target="representation-digest"/> describes concepts related to representation digests,</t>
                  <t>
                     <xref target="digest"/> defines the Digest request and response header and trailer field,</t>
                  <t>
                     <xref target="content-digest"/> defines the Content-Digest request and response header and trailer field,</t>
                  <t>
                     <xref target="want-fields"/> defines the Want-Digest and Want-Content-Digest request and response header and trailer field,</t>
                  <t>
                     <xref target="algorithms"/> describes algorithms and their relation to Digest,</t>
                  <t>
                     <xref target="state-changing-requests"/> details computing representation digests,</t>
                  <t>
                     <xref target="examples-unsolicited"/> and <xref target="examples-solicited"/> provide examples of using Digest and Want-Digest.</t>
               </list>
            </t>
         </section>
         <section anchor="concept-overview">
            <name>Concept Overview</name>
            <t>This document defines the <spanx style="verb">Digest</spanx> request and response header and trailer field; see <xref target="digest"/>. At a high level, the value contains a checksum, computed over <spanx style="verb">selected representation data</spanx> (<xref section="3.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor representations?><?aug-title Representations?></xref>), that the recipient can use to validate integrity. Basing <spanx style="verb">Digest</spanx> on the selected representation makes it straightforward to apply it to use-cases where the transferred data requires some sort of manipulation to be considered a representation or conveys a partial representation of a resource, such as Range Requests (see <xref section="14.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor field.range?><?aug-title Range?></xref>).</t>
            <t>To support use-cases where a simple checksum of the content bytes is required, this document introduces the <spanx style="verb">Content-Digest</spanx> request and response header and trailer field; see <xref target="content-digest"/>.</t>
            <t>
               <spanx style="verb">Digest</spanx> and <spanx style="verb">Content-Digest</spanx> support algorithm agility. The <spanx style="verb">Want-Digest</spanx> and <spanx style="verb">Want-Content-Digest</spanx> fields allows endpoints to express interest in <spanx style="verb">Digest</spanx> and <spanx style="verb">Content-Digest</spanx> respectively, and preference of algorithms in either.</t>
            <t>Digest field calculations are tied to the <spanx style="verb">Content-Encoding</spanx> and <spanx style="verb">Content-Type</spanx> header fields. Therefore, a given resource may have multiple different checksum values when transferred with HTTP.</t>
            <t>Digest fields do not provide integrity for HTTP messages or fields. However, they can be combined with other mechanisms that protect metadata, such as digital signatures, in order to protect the phases of an HTTP exchange in whole or in part.</t>
            <t>This specification does not define means for authentication, authorization or privacy.</t>
         </section>
         <section anchor="replacing-rfc-3230">
            <name>Replacing RFC 3230</name>
            <t>Historically, the <spanx style="verb">Content-MD5</spanx> header field provided an HTTP integrity mechanism but HTTP/1.1 (<xref target="RFC7231" x:fmt="," x:sec="B"/>) obsoleted it due to inconsistent handling of partial responses. <xref target="RFC3230"/> defined the concept of "instance" digests and a more flexible integrity scheme to help address issues with <spanx style="verb">Content-MD5</spanx>. It first introduced the <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> fields. HTTP terminology has evolved since <xref target="RFC3230"/> was published. The concept of "instance" has been superseded by <spanx style="verb">selected representation</spanx>.</t>
            <t>This document replaces <xref target="RFC3230"/>. The changes described in the following paragraphs are intended to be semantically compatible with existing implementations where possible.</t>
            <t>The <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> field definitions are updated to align with the terms and notational conventions in <xref target="SEMANTICS"/>.</t>
            <t>Negotiation of <spanx style="verb">Content-MD5</spanx> is deprecated and has been replaced by <spanx style="verb">Content-Digest</spanx> negotiation via <spanx style="verb">Want-Content-Digest</spanx>.</t>
            <t>Sections <xref section="4.1.1" sectionFormat="bare" target="RFC3230"/> and <xref section="4.2" sectionFormat="bare" target="RFC3230"/> of <xref target="RFC3230"/> defined field parameters. This document obsoletes the usage of parameters with <spanx style="verb">Digest</spanx> because this feature has not been widely deployed and complicates field-value processing. <xref target="RFC3230"/> intended field parameters to provide a common way to attach additional information to a representation-data-digest. However, if parameters are used as an input to validate the checksum, an attacker could alter them to steer the validation behavior. A digest-algorithm can still be parameterized by defining its own way to encode parameters into the representation-data-digest, in such a way as to mitigate security risks related to its computation.</t>
            <t>The algorithm table has been updated to reflect the current state of the art, (see <xref target="algorithms"/>).</t>
         </section>
         <section anchor="notational-conventions">
            <name>Notational Conventions</name>
            <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/>
               <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
            <t>This document uses the Augmented BNF defined in <xref target="RFC5234"/> and updated by <xref target="RFC7405"/> along with the "#rule" extension defined in <xref section="5.6.1" sectionFormat="of" target="SEMANTICS"><?aug-anchor abnf.extension?><?aug-title Lists (#rule ABNF Extension)?></xref> and the "qvalue" rule defined in <xref section="12.4.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor quality.values?><?aug-title Quality Values?></xref>.</t>
            <t>The definitions "representation", "selected representation", "representation data", "representation metadata", and "content" in this document are to be interpreted as described in <xref target="SEMANTICS"/>.</t>
            <t>Algorithm names respect the casing used in their definition document (e.g. SHA-1, CRC32c) whereas digest-algorithm tokens are quoted (e.g. "sha", "crc32c").</t>
         </section>
      </section>
      <section anchor="representation-digest">
         <name>Representation Digest</name>
         <t>The representation digest is an integrity mechanism for HTTP resources which uses a checksum that is calculated independently of the content (see <xref section="6.4" sectionFormat="of" target="SEMANTICS"><?aug-anchor content?><?aug-title Content?></xref>). It uses the representation data (see <xref section="8.1" sectionFormat="of" target="SEMANTICS"><?aug-anchor representation.data?><?aug-title Representation Data?></xref>), that can be fully or partially contained in the content, or not contained at all.</t>
         <t>This takes into account the effect of the HTTP semantics on the messages; for example, the content can be affected by Range Requests or methods such as HEAD, while the way the content is transferred "on the wire" is dependent on other transformations (e.g. transfer codings for HTTP/1.1 - see <xref section="6.1" sectionFormat="of" target="HTTP11"/>). To help illustrate how such things affect <spanx style="verb">Digest</spanx>, several examples are provided in <xref target="resource-representation"/>.</t>
         <t>A representation digest consists of the value of a checksum computed on the entire selected <spanx style="verb">representation data</spanx> (see <xref section="8.1" sectionFormat="of" target="SEMANTICS"><?aug-anchor representation.data?><?aug-title Representation Data?></xref>) of a resource identified according to <xref section="6.4.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor identifying.content?><?aug-title Identifying Content?></xref> together with an indication of the algorithm used:</t>
         <figure>
            <sourcecode type="abnf">
   representation-data-digest = digest-algorithm "="
                                &lt;encoded digest output&gt;
</sourcecode>
         </figure>
         <t>When a message has no representation data it is still possible to assert that no representation data was sent computing the representation digest on an empty string (see <xref target="usage-in-signatures"/>).</t>
         <t>The checksum is computed using one of the digest-algorithms listed in the HTTP Digest Algorithm Values Registry (see <xref target="algorithms"/>) and then encoded in the associated format.</t>
      </section>
      <section anchor="digest">
         <name>The Digest Field</name>
         <t>The <spanx style="verb">Digest</spanx> field contains a comma-separated list of one or more representation digest values as defined in <xref target="representation-digest"/>. It can be used in both requests and responses.</t>
         <figure>
            <sourcecode type="abnf">
   Digest = 1#representation-data-digest
</sourcecode>
         </figure>
         <t>For example:</t>
         <figure>
            <sourcecode type="http-message">
Digest: sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
</sourcecode>
         </figure>
         <t>A <spanx style="verb">Digest</spanx> field MAY contain multiple representation-data-digest values. For example, a server may provide representation-data-digest values using different algorithms, allowing it to support a population of clients with different evolving capabilities; this is particularly useful in support of transitioning away from weaker algorithms should the need arise (see <xref target="algorithm-agility"/>).</t>
         <figure>
            <sourcecode type="http-message">
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
        sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
</sourcecode>
         </figure>
         <t>A recipient MAY ignore any or all of the representation-data-digests in a Digest field. This allows the recipient to choose which digest-algorithm(s) to use for validation instead of verifying every received representation-data-digest.</t>
         <t>A sender MAY send a representation-data-digest using a digest-algorithm without knowing whether the recipient supports the digest-algorithm, or even knowing that the recipient will ignore it.</t>
         <t>
            <spanx style="verb">Digest</spanx> can be sent in a trailer section. In this case, <spanx style="verb">Digest</spanx> MAY be merged into the header section; see <xref section="6.5.1" sectionFormat="of" target="SEMANTICS"><?aug-anchor trailers.limitations?><?aug-title Limitations on use of Trailers?></xref>.</t>
         <t>When an incremental digest-algorithm is used, the sender and the receiver can dynamically compute the digest value while streaming the content.</t>
         <t>A non-comprehensive set of examples showing the impacts of representation metadata, payload transformations and HTTP methods on <spanx style="verb">Digest</spanx> is provided in <xref target="examples-unsolicited"/> and <xref target="examples-solicited"/>.</t>
      </section>
      <section anchor="content-digest">
         <name>The Content-Digest Field</name>
         <t>The <spanx style="verb">Content-Digest</spanx> field contains a comma-separated list of one or more content digest values. A content digest value is computed by applying a digest-algorithm to the actual message content (see <xref section="6.4" sectionFormat="of" target="SEMANTICS"><?aug-anchor content?><?aug-title Content?></xref>). It can be used in both requests and responses.</t>
         <figure>
            <sourcecode type="abnf">
   Content-Digest = 1#content-digest
   content-digest = digest-algorithm "="
                    &lt;encoded digest output&gt;
</sourcecode>
         </figure>
         <t>For example:</t>
         <figure>
            <sourcecode type="http-message">
Content-Digest: sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                        AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
</sourcecode>
         </figure>
         <t>A <spanx style="verb">Content-Digest</spanx> field MAY contain multiple content-digest values, similarly to <spanx style="verb">Digest</spanx> (see <xref target="digest"/>)</t>
         <figure>
            <sourcecode type="http-message">
Content-Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
                sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                        AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==
</sourcecode>
         </figure>
         <t>A recipient MAY ignore any or all of the content-digests in a Content-Digest field. This allows the recipient to choose which digest-algorithm(s) to use for validation instead of verifying every received content-digest.</t>
         <t>A sender MAY send a content-digest using a digest-algorithm without knowing whether the recipient supports the digest-algorithm, or even knowing that the recipient will ignore it.</t>
         <t>
            <spanx style="verb">Content-Digest</spanx> can be sent in a trailer section. In this case, <spanx style="verb">Content-Digest</spanx> MAY be merged into the header section; see <xref section="6.5.1" sectionFormat="of" target="SEMANTICS"><?aug-anchor trailers.limitations?><?aug-title Limitations on use of Trailers?></xref>.</t>
         <t>When an incremental digest-algorithm is used, the sender and the receiver can dynamically compute the digest value while streaming the content.</t>
      </section>
      <section anchor="want-fields">
         <name>Want-Digest and Want-Content-Digest Fields</name>
         <t>Senders can indicate their integrity checksum preferences using the <spanx style="verb">Want-Digest</spanx> or <spanx style="verb">Want-Content-Digest</spanx> fields. These can be used in both requests and responses.</t>
         <t>
            <spanx style="verb">Want-Digest</spanx> indicates the sender's desire to receive a representation digest on messages associated with the request URI and representation metadata, using the <spanx style="verb">Digest</spanx> field.</t>
         <t>
            <spanx style="verb">Want-Content-Digest</spanx> indicates the sender's desire to receive a content digest on messages associated with the request URI and representation metadata, using the <spanx style="verb">Content-Digest</spanx> field.</t>
         <figure>
            <artwork>
   Want-Digest = 1#want-digest-value
   Want-Content-Digest = 1#want-digest-value
   want-digest-value = digest-algorithm [ ";" "q" "=" qvalue]
</artwork>
         </figure>
         <t>
            <spanx style="verb">qvalue</spanx> indicates the sender's digest-algorithm preferences. <xref section="12.4.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor quality.values?><?aug-title Quality Values?></xref>) describes <spanx style="verb">qvalue</spanx> usage and semantics.</t>
         <t>Senders can provide multiple digest-algorithm items with the same qvalue.</t>
         <t>Examples:</t>
         <figure>
            <sourcecode type="http-message">
Want-Digest: sha-256
Want-Digest: sha-512;q=0.3, sha-256;q=1, unixsum;q=0
Want-Content-Digest: sha-256
Want-Content-Digest: sha-512;q=0.3, sha-256;q=1, unixsum;q=0
</sourcecode>
         </figure>
      </section>
      <section anchor="algorithms">
         <name>Digest Algorithm Values</name>
         <t>Digest-algorithm values are used to indicate a specific digest computation.</t>
         <figure>
            <artwork>
   digest-algorithm = token
</artwork>
         </figure>
         <t>All digest-algorithm token values are case-insensitive but lower case is preferred; digest-algorithm token values MUST be compared in a case-insensitive fashion.</t>
         <t>Every digest-algorithm defines its computation procedure and encoding output. Unless specified otherwise, comparison of encoded output is case-sensitive.</t>
         <t>The "HTTP Digest Algorithm Values Registry", maintained by IANA at <eref target="https://www.iana.org/assignments/http-dig-alg/">https://www.iana.org/assignments/http-dig-alg/</eref> registers digest-algorithm values. Registrations MUST include the following fields:</t>
         <t>
            <list style="symbols">
               <t>Digest algorithm: the token value. The registry can be used to reserve token values</t>
               <t>Status: the status of the algorithm. Use "standard" for standardized algorithms without known problems; "experimental" or some other appropriate value <list style="symbols">
                     <t>e.g. according to the type and status of the primary document in which the algorithm is defined; "insecure" when the algorithm is insecure; "reserved" when Digest algorithm references a reserved token value</t>
                  </list>
               </t>
               <t>Description: the description of the digest-algorithm and its encoding</t>
               <t>Reference: a set of pointers to the primary documents defining the digest-algorithm</t>
            </list>
         </t>
         <t>The associated encoding for new digest-algorithms MUST either be represented as a quoted string or MUST NOT include ";" or "," in the character sets used for the encoding.</t>
         <t>Insecure digest algorithms MAY be used to preserve integrity against accidental change, but MUST NOT be used in a potentially adversarial setting; for example, when signing the digest of content for authenticity.</t>
         <t>The registry is initialized with the tokens listed below.</t>
         <dl newline="true">
            <dt>sha-512</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: sha-512</t>
                     <t>Description: The SHA-512 algorithm <xref target="RFC6234"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>.</t>
                     <t>Reference: <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
            </dd>
            <dt>sha-256</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: sha-256</t>
                     <t>Description: The SHA-256 algorithm <xref target="RFC6234"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>.</t>
                     <t>Reference: <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
            </dd>
            <dt>md5</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: md5</t>
                     <t>Description: The MD5 algorithm, as specified in <xref target="RFC1321"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>. This digest-algorithm is now vulnerable to collision attacks. See <xref target="NO-MD5"/> and <xref target="CMU-836068"/>.</t>
                     <t>Reference: <xref target="RFC1321"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: insecure</t>
                  </list>
               </t>
            </dd>
            <dt>sha</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: sha</t>
                     <t>Description: The SHA-1 algorithm <xref target="RFC3174"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>. This digest-algorithm is now vulnerable to collision attacks. See <xref target="NO-SHA1"/> and <xref target="IACR-2020-014"/>.</t>
                     <t>Reference: <xref target="RFC3174"/>, <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: insecure</t>
                  </list>
               </t>
            </dd>
            <dt>unixsum</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: unixsum</t>
                     <t>Description: The algorithm computed by the UNIX "sum" command, as defined by the Single UNIX Specification, Version 2 <xref target="UNIX"/>. The output of this algorithm is an ASCII decimal-digit string representing the 16-bit checksum, which is the first word of the output of the UNIX "sum" command.</t>
                     <t>Reference: <xref target="UNIX"/>, this document.</t>
                     <t>Status: insecure</t>
                  </list>
               </t>
            </dd>
            <dt>unixcksum</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: unixcksum</t>
                     <t>Description: The algorithm computed by the UNIX "cksum" command, as defined by the Single UNIX Specification, Version 2 <xref target="UNIX"/>. The output of this algorithm is an ASCII digit string representing the 32-bit CRC, which is the first word of the output of the UNIX "cksum" command.</t>
                     <t>Reference: <xref target="UNIX"/>, this document.</t>
                     <t>Status: insecure</t>
                  </list>
               </t>
            </dd>
            <dt>adler32</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: adler32</t>
                     <t>Description: The ADLER32 algorithm is a checksum specified in <xref target="RFC1950"/> "ZLIB Compressed Data Format". The 32-bit output is encoded in hexadecimal (using between 1 and 8 ASCII characters from 0-9, A-F, and a-f; leading 0's are allowed). For example, adler32=03da0195 and adler32=3DA0195 are both valid checksums for the 4-byte message "Wiki". This algorithm is obsoleted and SHOULD NOT be used.</t>
                     <t>Reference: <xref target="RFC1950"/>, this document.</t>
                     <t>Status: insecure</t>
                  </list>
               </t>
            </dd>
            <dt>crc32c</dt>
            <dd>
               <t>
                  <list style="symbols">
                     <t>Digest Algorithm: crc32c</t>
                     <t>Description: The CRC32c algorithm is a 32-bit cyclic redundancy check. It achieves a better hamming distance (for better error-detection performance) than many other 32-bit CRC functions. Other places it is used include iSCSI and SCTP. The 32-bit output is encoded in hexadecimal (using between 1 and 8 ASCII characters from 0-9, A-F, and a-f; leading 0's are allowed). For example, crc32c=0a72a4df and crc32c=A72A4DF are both valid checksums for the 3-byte message "dog".</t>
                     <t>Reference: <xref target="RFC4960"/> appendix B, this document.</t>
                     <t>Status: insecure</t>
                  </list>
               </t>
            </dd>
         </dl>
      </section>
      <section anchor="state-changing-requests">
         <name>Using Digest in State-Changing Requests</name>
         <t>When the representation enclosed in a state-changing request does not describe the target resource, the representation digest MUST be computed on the representation-data. This is the only possible choice because representation digest requires complete representation metadata (see <xref target="representation-digest"/>).</t>
         <t>In responses,</t>
         <t>
            <list style="symbols">
               <t>if the representation describes the status of the request, <spanx style="verb">Digest</spanx> MUST be computed on the enclosed representation (see <xref target="post-referencing-status"/> );</t>
               <t>if there is a referenced resource <spanx style="verb">Digest</spanx> MUST be computed on the selected representation of the referenced resource even if that is different from the target resource. That might or might not result in computing <spanx style="verb">Digest</spanx> on the enclosed representation.</t>
            </list>
         </t>
         <t>The latter case is done according to the HTTP semantics of the given method, for example using the <spanx style="verb">Content-Location</spanx> header field (see <xref section="8.7" sectionFormat="of" target="SEMANTICS"><?aug-anchor field.content-location?><?aug-title Content-Location?></xref>). In contrast, the <spanx style="verb">Location</spanx> header field does not affect <spanx style="verb">Digest</spanx> because it is not representation metadata.</t>
         <t>For example, in PATCH requests, the representation digest will be computed on the patch document because the representation metadata refers to the patch document and not to the target resource (see <xref section="2" sectionFormat="of" target="PATCH"/>). In responses, instead, the representation digest will be computed on the selected representation of the patched resource.</t>
         <section anchor="digest-and-content-location">
            <name>Digest and Content-Location in Responses</name>
            <t>When a state-changing method returns the <spanx style="verb">Content-Location</spanx> header field, the enclosed representation refers to the resource identified by its value and <spanx style="verb">Digest</spanx> is computed accordingly. An example is given in <xref target="post-not-request-uri"/>.</t>
         </section>
      </section>
      <section anchor="security-considerations">
         <name>Security Considerations</name>
         <section anchor="digest-does-not-protect-the-full-http-message">
            <name>Digest Does Not Protect the Full HTTP Message</name>
            <t>This document specifies a data integrity mechanism that protects HTTP <spanx style="verb">representation data</spanx> or content, but not HTTP header and trailer fields, from certain kinds of accidental corruption.</t>
            <t>Digest fields are not intended to be a general protection against malicious tampering with HTTP messages. This can be achieved by combining it with other approaches such as transport-layer security or digital signatures.</t>
         </section>
         <section anchor="digest-for-end-to-end-integrity">
            <name>Digest for End-to-End Integrity</name>
            <t>Digest fields can help detect <spanx style="verb">representation data</spanx> or content modification due to implementation errors, undesired "transforming proxies" (see <xref section="7.7" sectionFormat="of" target="SEMANTICS"><?aug-anchor message.transformations?><?aug-title Message Transformations?></xref>) or other actions as the data passes across multiple hops or system boundaries. Even a simple mechanism for end-to-end <spanx style="verb">representation data</spanx> integrity is valuable because user-agent can validate that resource retrieval succeeded before handing off to a HTML parser, video player etc. for parsing.</t>
            <t>Note that using digest fields alone does not provide end-to-end integrity of HTTP messages over multiple hops, since metadata could be manipulated at any stage. Methods to protect metadata are discussed in <xref target="usage-in-signatures"/>.</t>
         </section>
         <section anchor="usage-in-signatures">
            <name>Usage in Signatures</name>
            <t>Digital signatures are widely used together with checksums to provide the certain identification of the origin of a message <xref target="NIST800-32"/>. Such signatures can protect one or more HTTP fields and there are additional considerations when <spanx style="verb">Digest</spanx> is included in this set.</t>
            <t>Since digest fields are hashes of resource representations, they explicitly depend on the <spanx style="verb">representation metadata</spanx> (e.g. the values of <spanx style="verb">Content-Type</spanx>, <spanx style="verb">Content-Encoding</spanx> etc). A signature that protects <spanx style="verb">Digest</spanx> but not other <spanx style="verb">representation metadata</spanx> can expose the communication to tampering. For example, an actor could manipulate the <spanx style="verb">Content-Type</spanx> field-value and cause a digest validation failure at the recipient, preventing the application from accessing the representation. Such an attack consumes the resources of both endpoints. See also <xref target="digest-and-content-location"/>.</t>
            <t>Digest fields SHOULD always be used over a connection that provides integrity at the transport layer that protects HTTP fields.</t>
            <t>A <spanx style="verb">Digest</spanx> field using NOT RECOMMENDED digest-algorithms SHOULD NOT be used in signatures.</t>
            <t>Using signatures to protect the checksum of an empty representation allows receiving endpoints to detect if an eventual payload has been stripped or added.</t>
            <t>Any mangling of digest fields, including de-duplication of representation-data-digest values or combining different field values (see <xref section="5.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor field.lines?><?aug-title Field Lines and Combined Field Value?></xref>) might affect signature validation.</t>
         </section>
         <section anchor="usage-in-trailer-fields">
            <name>Usage in Trailer Fields</name>
            <t>Before sending digest fields in a trailer section, the sender should consider that intermediaries are explicitly allowed to drop any trailer (see <xref section="6.5.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor trailers.processing?><?aug-title Processing Trailer Fields?></xref>).</t>
            <t>When digest fields are used in a trailer section, the field-values are received after the content. Eager processing of content before the trailer section prevents digest validation, possibly leading to processing of invalid data.</t>
            <t>Not every digest-algorithm is suitable for use in the trailer section, some may require to pre-process the whole payload before sending a message (e.g. see <xref target="I-D.thomson-http-mice"/>).</t>
         </section>
         <section anchor="usage-with-encryption">
            <name>Usage with Encryption</name>
            <t>Digest fields may expose details of encrypted payload when the checksum is computed on the unencrypted data.</t>
            <t>The checksum of an encrypted payload can change between different messages depending on the encryption algorithm used; in those cases its value could not be used to provide a proof of integrity "at rest" unless the whole (e.g. encoded) content is persisted.</t>
         </section>
         <section anchor="algorithm-agility">
            <name>Algorithm Agility</name>
            <t>The security properties of digest-algorithms are not fixed. Algorithm Agility (see <xref target="RFC7696"/>) is achieved by providing implementations with flexibility choose digest-algorithms from the IANA Digest Algorithm Values registry in <xref target="iana-digest-algorithm-registry"/>.</t>
            <t>To help endpoints distinguish weaker algorithms from stronger ones, this document adds to the IANA Digest Algorithm Values registry a new "Status" field containing the most recent appraisal of the digest-algorithm.</t>
            <t>An endpoint might have a preference for algorithms, such as preferring "standard" algorithms over "insecure" ones. Transition from weak algorithms is supported by negotiation of digest-algorithm using <spanx style="verb">Want-Digest</spanx> or <spanx style="verb">Want-Content-Digest</spanx> (see <xref target="want-fields"/>) or by sending multiple representation-data-digest values from which the receiver chooses. Endpoints are advised that sending multiple values consumes resources, which may be wasted if the receiver ignores them (see <xref target="digest"/>).</t>
         </section>
         <section anchor="duplicate-digest-algorithm-in-field-value">
            <name>Duplicate digest-algorithm in field value</name>
            <t>An endpoint might receive multiple representation-data-digest values (see <xref target="digest"/>) that use the same digest-algorithm with different or identical digest-values. For example:</t>
            <figure>
               <sourcecode type="example">
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=,
        sha-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=
</sourcecode>
            </figure>
            <t>A receiver is permitted to ignore any representation-data-digest value, so validation of duplicates is left as an implementation decision. Endpoints might select all, some, or none of the values for checksum comparison and, based on the intersection of those results, conditionally pass or fail digest validation.</t>
         </section>
         <section anchor="resource-exhaustion">
            <name>Resource exhaustion</name>
            <t>Digest fields validation consumes computational resources. In order to avoid resource exhaustion, implementations can restrict validation of the algorithm types, number of validations, or the size of content.</t>
         </section>
      </section>
      <section anchor="iana-considerations">
         <name>IANA Considerations</name>
         <section anchor="iana-digest-algorithm-registry">
            <name>Establish the HTTP Digest Algorithm Values Registry</name>
            <t>This memo sets this specification to be the establishing document for the <eref target="https://www.iana.org/assignments/http-dig-alg/">HTTP Digest Algorithm Values</eref> registry.</t>
            <t>IANA is asked to update the "Reference" for this registry to refer this document and to inizialize the registry with the tokens defined in <xref target="algorithms"/>.</t>
            <t>This registry uses the Specification Required policy (<xref section="4.6" sectionFormat="of" target="RFC8126"/>).</t>
         </section>
         <section anchor="iana-contentMD5">
            <name>Obsolete "contentMD5" token in Digest Algorithm</name>
            <t>This memo adds the "contentMD5" token in the <eref target="https://www.iana.org/assignments/http-dig-alg/">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: contentMD5</t>
                  <t>Description: <xref section="5" sectionFormat="of" target="RFC3230"/> defined the "contentMD5" token to be used only in Want-Digest. This token is obsoleted and MUST NOT be used.</t>
                  <t>Reference: <xref target="iana-contentMD5"/> of this document, <xref section="5" sectionFormat="of" target="RFC3230"/>.</t>
                  <t>Status: obsoleted</t>
               </list>
            </t>
         </section>
         <section anchor="changes-compared-to-rfc3230">
            <name>Changes Compared to RFC3230</name>
            <t>The <spanx style="verb">contentMD5</spanx> digest-algorithm token defined in <xref section="5" sectionFormat="of" target="RFC3230"/> has been added to the HTTP Digest Algorithm Values Registry with the "obsoleted" status.</t>
            <t>All digest-algorithms defined in <xref target="RFC3230"/> are now "insecure".</t>
         </section>
         <section anchor="changes-compared-to-rfc5843">
            <name>Changes Compared to RFC5843</name>
            <t>The digest-algorithm tokens for "MD5", "SHA", "SHA-256", "SHA-512" have been updated to lowercase.</t>
            <t>The status of "MD5" and "SHA" has been updated to "insecure", and their description has been modified accordingly.</t>
         </section>
         <section anchor="want-digest-field-registration">
            <name>Want-Digest Field Registration</name>
            <t>This section registers the <spanx style="verb">Want-Digest</spanx> field in the "Hypertext Transfer Protocol (HTTP) Field Name Registry" <xref target="SEMANTICS"/>.</t>
            <t>Field name: <spanx style="verb">Want-Digest</spanx>
            </t>
            <t>Status: permanent</t>
            <t>Specification document(s): <xref target="want-fields"/> of this document</t>
         </section>
         <section anchor="digest-field-registration">
            <name>Digest Field Registration</name>
            <t>This section registers the <spanx style="verb">Digest</spanx> field in the "Hypertext Transfer Protocol (HTTP) Field Name Registry" <xref target="SEMANTICS"/>.</t>
            <t>Field name: <spanx style="verb">Digest</spanx>
            </t>
            <t>Status: permanent</t>
            <t>Specification document(s): <xref target="digest"/> of this document</t>
         </section>
         <section anchor="want-content-digest-field-registration">
            <name>Want-Content-Digest Field Registration</name>
            <t>This section registers the <spanx style="verb">Want-Content-Digest</spanx> field in the "Hypertext Transfer Protocol (HTTP) Field Name Registry" <xref target="SEMANTICS"/>.</t>
            <t>Field name: <spanx style="verb">Want-Content-Digest</spanx>
            </t>
            <t>Status: permanent</t>
            <t>Specification document(s): <xref target="want-fields"/> of this document</t>
         </section>
         <section anchor="content-digest-field-registration">
            <name>Content-Digest Field Registration</name>
            <t>This section registers the <spanx style="verb">Content-Digest</spanx> field in the "Hypertext Transfer Protocol (HTTP) Field Name Registry" <xref target="SEMANTICS"/>.</t>
            <t>Field name: <spanx style="verb">Content-Digest</spanx>
            </t>
            <t>Status: permanent</t>
            <t>Specification document(s): <xref target="content-digest"/> of this document</t>
         </section>
      </section>
   </middle>
   <back>
      <references title="Normative References">
         <reference anchor="RFC1321">
            <front>
               <title>The MD5 Message-Digest Algorithm</title>
               <author fullname="R. Rivest" initials="R." surname="Rivest"/>
               <date month="April" year="1992"/>
            </front>
            <seriesInfo name="RFC" value="1321"/>
            <seriesInfo name="DOI" value="10.17487/RFC1321"/>
         </reference>
         <reference anchor="RFC3174">
            <front>
               <title>US Secure Hash Algorithm 1 (SHA1)</title>
               <author fullname="D. Eastlake 3rd" initials="D." surname="Eastlake 3rd"/>
               <author fullname="P. Jones" initials="P." surname="Jones"/>
               <date month="September" year="2001"/>
            </front>
            <seriesInfo name="RFC" value="3174"/>
            <seriesInfo name="DOI" value="10.17487/RFC3174"/>
         </reference>
         <reference anchor="RFC1950">
            <front>
               <title>ZLIB Compressed Data Format Specification version 3.3</title>
               <author fullname="P. Deutsch" initials="P." surname="Deutsch"/>
               <author fullname="J-L. Gailly" initials="J-L." surname="Gailly"/>
               <date month="May" year="1996"/>
            </front>
            <seriesInfo name="RFC" value="1950"/>
            <seriesInfo name="DOI" value="10.17487/RFC1950"/>
         </reference>
         <reference anchor="RFC3230">
            <front>
               <title>Instance Digests in HTTP</title>
               <author fullname="J. Mogul" initials="J." surname="Mogul"/>
               <author fullname="A. Van Hoff" initials="A." surname="Van Hoff"/>
               <date month="January" year="2002"/>
            </front>
            <seriesInfo name="RFC" value="3230"/>
            <seriesInfo name="DOI" value="10.17487/RFC3230"/>
         </reference>
         <reference anchor="RFC5843">
            <front>
               <title>Additional Hash Algorithms for HTTP Instance Digests</title>
               <author fullname="A. Bryan" initials="A." surname="Bryan"/>
               <date month="April" year="2010"/>
            </front>
            <seriesInfo name="RFC" value="5843"/>
            <seriesInfo name="DOI" value="10.17487/RFC5843"/>
         </reference>
         <reference anchor="RFC4648">
            <front>
               <title>The Base16, Base32, and Base64 Data Encodings</title>
               <author fullname="S. Josefsson" initials="S." surname="Josefsson"/>
               <date month="October" year="2006"/>
            </front>
            <seriesInfo name="RFC" value="4648"/>
            <seriesInfo name="DOI" value="10.17487/RFC4648"/>
         </reference>
         <reference anchor="RFC5234">
            <front>
               <title>Augmented BNF for Syntax Specifications: ABNF</title>
               <author fullname="D. Crocker"
                       initials="D."
                       role="editor"
                       surname="Crocker"/>
               <author fullname="P. Overell" initials="P." surname="Overell"/>
               <date month="January" year="2008"/>
            </front>
            <seriesInfo name="STD" value="68"/>
            <seriesInfo name="RFC" value="5234"/>
            <seriesInfo name="DOI" value="10.17487/RFC5234"/>
         </reference>
         <reference anchor="RFC6234">
            <front>
               <title>US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)</title>
               <author fullname="D. Eastlake 3rd" initials="D." surname="Eastlake 3rd"/>
               <author fullname="T. Hansen" initials="T." surname="Hansen"/>
               <date month="May" year="2011"/>
            </front>
            <seriesInfo name="RFC" value="6234"/>
            <seriesInfo name="DOI" value="10.17487/RFC6234"/>
         </reference>
         <reference anchor="RFC7405">
            <front>
               <title>Case-Sensitive String Support in ABNF</title>
               <author fullname="P. Kyzivat" initials="P." surname="Kyzivat"/>
               <date month="December" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7405"/>
            <seriesInfo name="DOI" value="10.17487/RFC7405"/>
         </reference>
         <reference anchor="UNIX">
            <front>
               <title>The Single UNIX Specification, Version 2 - 6 Vol Set for UNIX 98</title>
               <author>
                  <organization>The Open Group</organization>
               </author>
               <date month="February" year="1997"/>
            </front>
         </reference>
         <reference anchor="NIST800-32"
                    target="https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-32.pdf">
            <front>
               <title>Introduction to Public Key Technology and the Federal PKI Infrastructure</title>
               <author>
                  <organization>National Institute of Standards and Technology, U.S. Department of Commerce</organization>
               </author>
               <date month="February" year="2001"/>
            </front>
         </reference>
         <reference anchor="CMU-836068" target="https://www.kb.cert.org/vuls/id/836068/">
            <front>
               <title>MD5 Vulnerable to collision attacks</title>
               <author>
                  <organization>Carnagie Mellon University, Software Engineering Institute</organization>
               </author>
               <date day="31" month="December" year="2008"/>
            </front>
         </reference>
         <reference anchor="IACR-2020-014" target="https://eprint.iacr.org/2020/014.pdf">
            <front>
               <title>SHA-1 is a Shambles</title>
               <author initials="G." surname="Leurent">
                  <organization>Inria, France</organization>
               </author>
               <author initials="T." surname="Peyrin">
                  <organization>Nanyang Technological University, Singapore; Temasek Laboratories, Singapore</organization>
               </author>
               <date day="05" month="January" year="2020"/>
            </front>
         </reference>
         <reference anchor="SEMANTICS">
            <front>
               <title>HTTP Semantics</title>
               <author fullname="Roy T. Fielding">
                  <organization>Adobe</organization>
               </author>
               <author fullname="Mark Nottingham">
                  <organization>Fastly</organization>
               </author>
               <author fullname="Julian Reschke">
                  <organization>greenbytes GmbH</organization>
               </author>
               <date day="12" month="September" year="2021"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-semantics-19"/>
            <x:source basename="draft-ietf-httpbis-semantics-19"
                      href="draft-ietf-httpbis-semantics-19.xml"/>
         </reference>
         <reference anchor="RFC2119">
            <front>
               <title>Key words for use in RFCs to Indicate Requirement Levels</title>
               <author fullname="S. Bradner" initials="S." surname="Bradner"/>
               <date month="March" year="1997"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="2119"/>
            <seriesInfo name="DOI" value="10.17487/RFC2119"/>
         </reference>
         <reference anchor="RFC8174">
            <front>
               <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
               <author fullname="B. Leiba" initials="B." surname="Leiba"/>
               <date month="May" year="2017"/>
            </front>
            <seriesInfo name="BCP" value="14"/>
            <seriesInfo name="RFC" value="8174"/>
            <seriesInfo name="DOI" value="10.17487/RFC8174"/>
         </reference>
         <reference anchor="RFC4960">
            <front>
               <title>Stream Control Transmission Protocol</title>
               <author fullname="R. Stewart"
                       initials="R."
                       role="editor"
                       surname="Stewart"/>
               <date month="September" year="2007"/>
            </front>
            <seriesInfo name="RFC" value="4960"/>
            <seriesInfo name="DOI" value="10.17487/RFC4960"/>
         </reference>
         <reference anchor="RFC8126">
            <front>
               <title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
               <author fullname="M. Cotton" initials="M." surname="Cotton"/>
               <author fullname="B. Leiba" initials="B." surname="Leiba"/>
               <author fullname="T. Narten" initials="T." surname="Narten"/>
               <date month="June" year="2017"/>
            </front>
            <seriesInfo name="BCP" value="26"/>
            <seriesInfo name="RFC" value="8126"/>
            <seriesInfo name="DOI" value="10.17487/RFC8126"/>
         </reference>
      </references>
      <references title="Informative References">
         <reference anchor="RFC2818">
            <front>
               <title>HTTP Over TLS</title>
               <author fullname="E. Rescorla" initials="E." surname="Rescorla"/>
               <date month="May" year="2000"/>
            </front>
            <seriesInfo name="RFC" value="2818"/>
            <seriesInfo name="DOI" value="10.17487/RFC2818"/>
         </reference>
         <reference anchor="RFC7231">
            <front>
               <title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
               <author fullname="R. Fielding"
                       initials="R."
                       role="editor"
                       surname="Fielding"/>
               <author fullname="J. Reschke"
                       initials="J."
                       role="editor"
                       surname="Reschke"/>
               <date month="June" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7231"/>
            <seriesInfo name="DOI" value="10.17487/RFC7231"/>
         </reference>
         <reference anchor="HTTP11">
            <front>
               <title>HTTP/1.1</title>
               <author fullname="Roy T. Fielding">
                  <organization>Adobe</organization>
               </author>
               <author fullname="Mark Nottingham">
                  <organization>Fastly</organization>
               </author>
               <author fullname="Julian Reschke">
                  <organization>greenbytes GmbH</organization>
               </author>
               <date day="12" month="September" year="2021"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-messaging-19"/>
         </reference>
         <reference anchor="PATCH">
            <front>
               <title>PATCH Method for HTTP</title>
               <author fullname="L. Dusseault" initials="L." surname="Dusseault"/>
               <author fullname="J. Snell" initials="J." surname="Snell"/>
               <date month="March" year="2010"/>
            </front>
            <seriesInfo name="RFC" value="5789"/>
            <seriesInfo name="DOI" value="10.17487/RFC5789"/>
         </reference>
         <reference anchor="NO-MD5">
            <front>
               <title>Updated Security Considerations for the MD5 Message-Digest and the HMAC-MD5 Algorithms</title>
               <author fullname="S. Turner" initials="S." surname="Turner"/>
               <author fullname="L. Chen" initials="L." surname="Chen"/>
               <date month="March" year="2011"/>
            </front>
            <seriesInfo name="RFC" value="6151"/>
            <seriesInfo name="DOI" value="10.17487/RFC6151"/>
         </reference>
         <reference anchor="NO-SHA1">
            <front>
               <title>Security Considerations for the SHA-0 and SHA-1 Message-Digest Algorithms</title>
               <author fullname="T. Polk" initials="T." surname="Polk"/>
               <author fullname="L. Chen" initials="L." surname="Chen"/>
               <author fullname="S. Turner" initials="S." surname="Turner"/>
               <author fullname="P. Hoffman" initials="P." surname="Hoffman"/>
               <date month="March" year="2011"/>
            </front>
            <seriesInfo name="RFC" value="6194"/>
            <seriesInfo name="DOI" value="10.17487/RFC6194"/>
         </reference>
         <reference anchor="I-D.thomson-http-mice">
            <front>
               <title>Merkle Integrity Content Encoding</title>
               <author fullname="Martin Thomson">
                  <organization>Mozilla</organization>
               </author>
               <author fullname="Jeffrey Yasskin">
                  <organization>Google</organization>
               </author>
               <date day="13" month="August" year="2018"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-thomson-http-mice-03"/>
         </reference>
         <reference anchor="RFC7696">
            <front>
               <title>Guidelines for Cryptographic Algorithm Agility and Selecting Mandatory-to-Implement Algorithms</title>
               <author fullname="R. Housley" initials="R." surname="Housley"/>
               <date month="November" year="2015"/>
            </front>
            <seriesInfo name="BCP" value="201"/>
            <seriesInfo name="RFC" value="7696"/>
            <seriesInfo name="DOI" value="10.17487/RFC7696"/>
         </reference>
         <reference anchor="RFC7396">
            <front>
               <title>JSON Merge Patch</title>
               <author fullname="P. Hoffman" initials="P." surname="Hoffman"/>
               <author fullname="J. Snell" initials="J." surname="Snell"/>
               <date month="October" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7396"/>
            <seriesInfo name="DOI" value="10.17487/RFC7396"/>
         </reference>
         <reference anchor="RFC7807">
            <front>
               <title>Problem Details for HTTP APIs</title>
               <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
               <author fullname="E. Wilde" initials="E." surname="Wilde"/>
               <date month="March" year="2016"/>
            </front>
            <seriesInfo name="RFC" value="7807"/>
            <seriesInfo name="DOI" value="10.17487/RFC7807"/>
         </reference>
         <reference anchor="I-D.ietf-httpbis-header-structure">
            <front>
               <title>Structured Field Values for HTTP</title>
               <author fullname="Mark Nottingham">
                  <organization>Fastly</organization>
               </author>
               <author fullname="Poul-Henning Kamp">
                  <organization>The Varnish Cache Project</organization>
               </author>
               <date day="3" month="June" year="2020"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-header-structure-19"/>
         </reference>
      </references>
      <section anchor="resource-representation">
         <name>Resource Representation and Representation-Data</name>
         <t>The following examples show how representation metadata, payload transformations and method impacts on the message and content. When the content contains non-printable characters (e.g. when it is compressed) it is shown as a Base64-encoded string.</t>
         <figure title="Request containing a JSON object without any content coding">
            <sourcecode type="http-message">
PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json

{"hello": "world"}
</sourcecode>
         </figure>
         <figure title="Request containing a gzip-encoded JSON object">
            <sourcecode type="http-message">
PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json
Content-Encoding: gzip

H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA=
</sourcecode>
         </figure>
         <t>Now the same content conveys a malformed JSON object, because the request does not indicate a content coding.</t>
         <figure title="Request containing malformed JSON">
            <sourcecode type="http-message">
PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json

H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA=
</sourcecode>
         </figure>
         <t>A Range-Request alters the content, conveying a partial representation.</t>
         <figure title="Request for partial content">
            <sourcecode type="http-message">
GET /entries/1234 HTTP/1.1
Host: foo.example
Range: bytes=1-7

</sourcecode>
         </figure>
         <figure title="Partial response from a gzip-encoded representation">
            <sourcecode type="http-message">
HTTP/1.1 206 Partial Content
Content-Encoding: gzip
Content-Type: application/json
Content-Range: bytes 1-7/18

iwgAla3RXA==
</sourcecode>
         </figure>
         <t>The method can also alter the content. For example, the response to a HEAD request does not carry content.</t>
         <figure title="HEAD request">
            <sourcecode type="http-message">
HEAD /entries/1234 HTTP/1.1
Host: foo.example
Accept: application/json
Accept-Encoding: gzip

</sourcecode>
         </figure>
         <figure title="Response to HEAD request (empty content)">
            <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: gzip

</sourcecode>
         </figure>
         <t>Finally, the semantics of an HTTP response might decouple the effective request URI from the enclosed representation. In the example response below, the <spanx style="verb">Content-Location</spanx> header field indicates that the enclosed representation refers to the resource available at <spanx style="verb">/authors/123</spanx>, even though the request is directed to <spanx style="verb">/authors/</spanx>.</t>
         <figure title="POST request">
            <sourcecode type="http-message">
POST /authors/ HTTP/1.1
Host: foo.example
Accept: application/json
Content-Type: application/json

{"author": "Camilleri"}
</sourcecode>
         </figure>
         <figure title="Response with Content-Location header">
            <sourcecode type="http-message">
HTTP/1.1 201 Created
Content-Type: application/json
Content-Location: /authors/123
Location: /authors/123

{"id": "123", "author": "Camilleri"}
</sourcecode>
         </figure>
      </section>
      <section anchor="examples-unsolicited">
         <name>Examples of Unsolicited Digest</name>
         <t>The following examples demonstrate interactions where a server responds with a <spanx style="verb">Digest</spanx> or <spanx style="verb">Content-Digest</spanx> fields even though the client did not solicit one using <spanx style="verb">Want-Digest</spanx> or <spanx style="verb">Want-Content-Digest</spanx>.</t>
         <t>Some examples include JSON objects in the content. For presentation purposes, objects that fit completely within the line-length limits are presented on a single line using compact notation with no leading space. Objects that would exceed line-length limits are presented across multiple lines (one line per key-value pair) with 2 spaced of leading indentation.</t>
         <t>Checksum mechanisms defined in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space. While examples can include both fields, <spanx style="verb">Digest</spanx> and <spanx style="verb">Content-Digest</spanx> can be returned independently.</t>
         <section anchor="example-full-representation">
            <name>Server Returns Full Representation Data</name>
            <t>In this example, the message content conveys complete representation data, so <spanx style="verb">Digest</spanx> and <spanx style="verb">Content-Digest</spanx> have the same value.</t>
            <figure title="GET request for an item">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example

</sourcecode>
            </figure>
            <figure title="Response with Content-Digest">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
Content-Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</sourcecode>
            </figure>
         </section>
         <section anchor="server-returns-no-representation-data">
            <name>Server Returns No Representation Data</name>
            <t>In this example, a HEAD request is used to retrieve the checksum of a resource.</t>
            <t>The response <spanx style="verb">Digest</spanx> field-value is calculated over the JSON object <spanx style="verb">{"hello": "world"}</spanx>, which is not shown because there is no payload data. <spanx style="verb">Content-Digest</spanx> is computed on empty content.</t>
            <figure title="HEAD request for an item">
               <sourcecode type="http-message">
HEAD /items/123 HTTP/1.1
Host: foo.example

</sourcecode>
            </figure>
            <figure title="Response with both Content-Digest and Digest; empty content">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
Content-Digest: sha-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=

</sourcecode>
            </figure>
         </section>
         <section anchor="server-returns-partial-representation-data">
            <name>Server Returns Partial Representation Data</name>
            <t>In this example, the client makes a range request and the server responds with partial content. The <spanx style="verb">Digest</spanx> field-value represents the entire JSON object <spanx style="verb">{"hello": "world"}</spanx>, while the <spanx style="verb">Content-Digest</spanx> field-value is computed on the message content <spanx style="verb">"hello"</spanx>.</t>
            <figure title="Request for partial content">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Range: bytes=1-7

</sourcecode>
            </figure>
            <figure title="Partial response with both Content-Digest and Digest">
               <sourcecode type="http-message">
HTTP/1.1 206 Partial Content
Content-Type: application/json
Content-Range: bytes 1-7/18
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
Content-Digest: sha-256=Wqdirjg/u3J688ejbUlApbjECpiUUtIwT8lY/z81Tno=

"hello"
</sourcecode>
            </figure>
         </section>
         <section anchor="client-and-server-provide-full-representation-data">
            <name>Client and Server Provide Full Representation Data</name>
            <t>The request contains a <spanx style="verb">Digest</spanx> field-value calculated on the enclosed representation. It also includes an <spanx style="verb">Accept-Encoding: br</spanx> header field that advertises the client supports Brotli encoding.</t>
            <t>The response includes a <spanx style="verb">Content-Encoding: br</spanx> that indicates the selected representation is Brotli-encoded. The <spanx style="verb">Digest</spanx> field-value is therefore different compared to the request.</t>
            <t>For presentation purposes, the response body is displayed as a Base64-encoded string because it contains non-printable characters.</t>
            <figure title="PUT Request with Digest">
               <sourcecode type="http-message">
PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of encoded response">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Location: /items/123
Content-Encoding: br
Content-Length: 22
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
</sourcecode>
            </figure>
         </section>
         <section anchor="client-provides-full-representation-data-server-provides-no-representation-data">
            <name>Client Provides Full Representation Data, Server Provides No Representation Data</name>
            <t>The request <spanx style="verb">Digest</spanx> field-value is calculated on the enclosed payload.</t>
            <t>The response <spanx style="verb">Digest</spanx> field-value depends on the representation metadata header fields, including <spanx style="verb">Content-Encoding: br</spanx> even when the response does not contain content.</t>
            <figure>
               <sourcecode type="http-message">
PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Content-Length: 18
Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</sourcecode>
            </figure>
            <figure title="Empty response with Digest">
               <sourcecode type="http-message">
HTTP/1.1 204 No Content
Content-Type: application/json
Content-Encoding: br
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

</sourcecode>
            </figure>
         </section>
         <section anchor="client-and-server-provide-full-representation-data-1">
            <name>Client and Server Provide Full Representation Data</name>
            <t>The response contains two digest values using different algorithms.</t>
            <t>As the response body contains non-printable characters, it is displayed as a base64-encoded string.</t>
            <figure title="PUT Request with Digest">
               <sourcecode type="http-message">
PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of Encoded Content">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: br
Content-Location: /items/123
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
        sha-512=pxo7aYzcGI88pnDnoSmAnaOEVys0MABhgvHY9+VI+ElE6
                0jBCwnMPyA/s3NF3ZO5oIWA7lf8ukk+\n5KJzm3p5og==

iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
</sourcecode>
            </figure>
         </section>
         <section anchor="post-not-request-uri">
            <name>POST Response does not Reference the Request URI</name>
            <t>The request <spanx style="verb">Digest</spanx> field-value is computed on the enclosed representation (see <xref target="state-changing-requests"/>).</t>
            <t>The representation enclosed in the response refers to the resource identified by <spanx style="verb">Content-Location</spanx> (see <xref section="6.4.2" sectionFormat="of" target="SEMANTICS"><?aug-anchor identifying.content?><?aug-title Identifying Content?></xref>). <spanx style="verb">Digest</spanx> is thus computed on the enclosed representation.</t>
            <figure title="POST Request with Digest">
               <sourcecode type="http-message">
POST /books HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=

{"title": "New Title"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of Resource">
               <sourcecode type="http-message">
HTTP/1.1 201 Created
Content-Type: application/json
Content-Location: /books/123
Location: /books/123
Digest: sha-256=yxOAqEeoj+reqygSIsLpT0LhumrNkIds5uLKtmdLyYE=

{
  "id": "123",
  "title": "New Title"
}
</sourcecode>
            </figure>
            <t>Note that a <spanx style="verb">204 No Content</spanx> response without content but with the same <spanx style="verb">Digest</spanx> field-value would have been legitimate too. In that case, <spanx style="verb">Content-Digest</spanx> would have been computed on an empty content.</t>
         </section>
         <section anchor="post-referencing-status">
            <name>POST Response Describes the Request Status</name>
            <t>The request <spanx style="verb">Digest</spanx> field-value is computed on the enclosed representation (see <xref target="state-changing-requests"/>).</t>
            <t>The representation enclosed in the response describes the status of the request, so <spanx style="verb">Digest</spanx> is computed on that enclosed representation.</t>
            <t>Response <spanx style="verb">Digest</spanx> has no explicit relation with the resource referenced by <spanx style="verb">Location</spanx>.</t>
            <figure title="POST Request with Digest">
               <sourcecode type="http-message">
POST /books HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=

{"title": "New Title"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of Representation">
               <sourcecode type="http-message">
HTTP/1.1 201 Created
Content-Type: application/json
Digest: sha-256=2LBp5RKZGpsSNf8BPXlXrX4Td4Tf5R5bZ9z7kdi5VvY=
Location: /books/123

{
  "status": "created",
  "id": "123",
  "ts": 1569327729,
  "instance": "/books/123"
}
</sourcecode>
            </figure>
         </section>
         <section anchor="digest-with-patch">
            <name>Digest with PATCH</name>
            <t>This case is analogous to a POST request where the target resource reflects the effective request URI.</t>
            <t>The PATCH request uses the <spanx style="verb">application/merge-patch+json</spanx> media type defined in <xref target="RFC7396"/>.</t>
            <t>
               <spanx style="verb">Digest</spanx> is calculated on the enclosed payload, which corresponds to the patch document.</t>
            <t>The response <spanx style="verb">Digest</spanx> field-value is computed on the complete representation of the patched resource.</t>
            <figure anchor="fig-patch" title="PATCH Request with Digest">
               <sourcecode type="http-message">
PATCH /books/123 HTTP/1.1
Host: foo.example
Content-Type: application/merge-patch+json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=

{"title": "New Title"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of Representation">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-256=yxOAqEeoj+reqygSIsLpT0LhumrNkIds5uLKtmdLyYE=

{
  "id": "123",
  "title": "New Title"
}
</sourcecode>
            </figure>
            <t>Note that a <spanx style="verb">204 No Content</spanx> response without content but with the same <spanx style="verb">Digest</spanx> field-value would have been legitimate too.</t>
         </section>
         <section anchor="error-responses">
            <name>Error responses</name>
            <t>In error responses, the representation-data does not necessarily refer to the target resource. Instead, it refers to the representation of the error.</t>
            <t>In the following example, a client sends the same request from <xref target="fig-patch"/> to patch the resource located at /books/123. However, the resource does not exist and the server generates a 404 response with a body that describes the error in accordance with <xref target="RFC7807"/>.</t>
            <t>The response <spanx style="verb">Digest</spanx> field-value is computed on this enclosed representation.</t>
            <figure title="Response with Digest of Error Representation">
               <sourcecode type="http-message">
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Digest: sha-256=KPqhVXAT25LLitV1w0O167unHmVQusu+fpxm65zAsvk=

{
  "title": "Not Found",
  "detail": "Cannot PATCH a non-existent resource",
  "status": 404
}
</sourcecode>
            </figure>
         </section>
         <section anchor="use-with-trailer-fields-and-transfer-coding">
            <name>Use with Trailer Fields and Transfer Coding</name>
            <t>An origin server sends <spanx style="verb">Digest</spanx> as trailer field, so it can calculate digest-value while streaming content and thus mitigate resource consumption. The <spanx style="verb">Digest</spanx> field-value is the same as in <xref target="example-full-representation"/> because <spanx style="verb">Digest</spanx> is designed to be independent from the use of one or more transfer codings (see <xref target="representation-digest"/>).</t>
            <figure title="GET Request">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example

</sourcecode>
            </figure>
            <figure title="Chunked Response with Digest">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Trailer: Digest

8\r\n
{"hello"\r\n
8
: "world\r\n
2\r\n
"}\r\n
0\r\n
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

</sourcecode>
            </figure>
         </section>
      </section>
      <section anchor="examples-solicited">
         <name>Examples of Want-Digest Solicited Digest</name>
         <t>The following examples demonstrate interactions where a client solicits a <spanx style="verb">Digest</spanx> using <spanx style="verb">Want-Digest</spanx>. The behavior of <spanx style="verb">Content-Digest</spanx> and <spanx style="verb">Want-Content-Digest</spanx> is identical.</t>
         <t>Some examples include JSON objects in the content. For presentation purposes, objects that fit completely within the line-length limits are presented on a single line using compact notation with no leading space. Objects that would exceed line-length limits are presented across multiple lines (one line per key-value pair) with 2 spaced of leading indentation.</t>
         <t>Checksum mechanisms described in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space.</t>
         <section anchor="server-selects-clients-least-preferred-algorithm">
            <name>Server Selects Client's Least Preferred Algorithm</name>
            <t>The client requests a digest, preferring "sha". The server is free to reply with "sha-256" anyway.</t>
            <figure title="GET Request with Want-Digest">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Want-Digest: sha-256;q=0.3, sha;q=1

</sourcecode>
            </figure>
            <figure title="Response with Different Algorithm">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</sourcecode>
            </figure>
         </section>
         <section anchor="ex-server-selects-unsupported-algorithm">
            <name>Server Selects Algorithm Unsupported by Client</name>
            <t>The client requests a only "sha" digest because that is the only algorithm it supports. The server is not obliged to produce a response containing a "sha" digest, it instead uses a different algorithm.</t>
            <figure title="GET Request with Want-Digest">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Want-Digest: sha;q=1

</sourcecode>
            </figure>
            <figure title="Response with Unsupported Algorithm">
               <sourcecode type="http-message">
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                +AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==

{"hello": "world"}
</sourcecode>
            </figure>
         </section>
         <section anchor="server-does-not-support-client-algorithm-and-returns-an-error">
            <name>Server Does Not Support Client Algorithm and Returns an Error</name>
            <t>
               <xref target="ex-server-selects-unsupported-algorithm"/> is an example where a server ignores the client's preferred digest algorithm. Alternatively a server can also reject the request and return an error.</t>
            <t>In this example, the client requests a "sha" <spanx style="verb">Digest</spanx>, and the server returns an error with problem details <xref target="RFC7807"/> contained in the content. The problem details contain a list of the digest algorithms that the server supports. This is purely an example, this specification does not define any format or requirements for such content.</t>
            <figure title="GET Request with Want-Digest">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Want-Digest: sha;q=1

</sourcecode>
            </figure>
            <figure title="Response advertising the supported algorithms">
               <sourcecode type="http-message">
HTTP/1.1 400 Bad Request
Content-Type: application/problem+json

{
  "title": "Bad Request",
  "detail": "Supported digest-algorithms: sha-256, sha-512",
  "status": 400
}
</sourcecode>
            </figure>
         </section>
      </section>
      <section anchor="acknowledgements" numbered="false">
         <name>Acknowledgements</name>
         <t>The vast majority of this document is inherited from <xref target="RFC3230"/>, so thanks to J. Mogul and A. Van Hoff for their great work. The original idea of refreshing this document arose from an interesting discussion with M. Nottingham, J. Yasskin and M. Thomson when reviewing the MICE content coding.</t>
         <t>Thanks to Julian Reschke for his valuable contributions to this document, and to the following contributors that have helped improve this specification by reporting bugs, asking smart questions, drafting or reviewing text, and evaluating open issues: Mike Bishop, Brian Campbell, Matthew Kerwin, James Manger, Tommy Pauly, Sean Turner, and Erik Wilde.</t>
      </section>
      <section anchor="faq" numbered="false">
         <name>FAQ</name>
         <t>
            <em>RFC Editor: Please remove this section before publication.</em>
         </t>
         <t>
            <list style="numbers">
               <t>Why remove all references to content-md5? <vspace blankLines="1"/> Those were unnecessary to understanding and using this specification.</t>
               <t>Why remove references to instance manipulation? <vspace blankLines="1"/> Those were unnecessary for correctly using and applying the specification. An example with Range Request is more than enough. This document uses the term "partial representation" which should group all those cases.</t>
               <t>How to use <spanx style="verb">Digest</spanx> with <spanx style="verb">PATCH</spanx> method? <vspace blankLines="1"/> See <xref target="state-changing-requests"/>.</t>
               <t>Why remove references to delta-encoding? <vspace blankLines="1"/> Unnecessary for a correct implementation of this specification. The revised specification can be nicely adapted to "delta encoding", but all the references here to delta encoding don't add anything to this RFC. Another job would be to refresh delta encoding.</t>
               <t>Why remove references to Digest Authentication? <vspace blankLines="1"/> This specification seems to me completely unrelated to Digest Authentication but for the word "Digest".</t>
               <t>What changes in <spanx style="verb">Want-Digest</spanx>? <vspace blankLines="1"/> The contentMD5 token defined in <xref section="5" sectionFormat="of" target="RFC3230"/> is deprecated by this document. <vspace blankLines="1"/> To clarify that <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> can be used in both requests and responses - <xref target="RFC3230"/> carefully uses <spanx style="verb">sender</spanx> and <spanx style="verb">receiver</spanx> in their definition - we added examples on using <spanx style="verb">Want-Digest</spanx> in responses to advertise the supported digest-algorithms and the inability to accept requests with unsupported digest-algorithms.</t>
               <t>Does this specification change supported algorithms? <vspace blankLines="1"/> Yes. This RFC updates <xref target="RFC5843"/> which is still delegated for all algorithms updates. To simplify a future transition to Structured Fields <xref target="I-D.ietf-httpbis-header-structure"/> we suggest to use lowercase for digest-algorithms.</t>
               <t>What about mid-stream trailer fields? <vspace blankLines="1"/> While <eref target="https://github.com/httpwg/http-core/issues/313#issuecomment-584389706">mid-stream trailer fields</eref> are interesting, since this specification is a rewrite of <xref target="RFC3230"/> we do not think we should face that. As a first thought, nothing in this document precludes future work that would find a use for mid-stream trailers, for example an incremental digest-algorithm. A document defining such a digest-algorithm is best positioned to describe how it is used.</t>
            </list>
         </t>
      </section>
      <section anchor="code-samples" numbered="false">
         <name>Code Samples</name>
         <t>
            <em>RFC Editor: Please remove this section before publication.</em>
         </t>
         <t>How can I generate and validate the <spanx style="verb">Digest</spanx> values shown in the examples throughout this document?</t>
         <t>The following python3 code can be used to generate digests for JSON objects using SHA algorithms for a range of encodings. Note that these are formatted as base64. This function could be adapted to other algorithms and should take into account their specific formatting rules.</t>
         <figure>
            <artwork>
import base64, json, hashlib, brotli, logging
log = logging.getLogger()

def encode_item(item, encoding=lambda x: x):
    indent = 2 if isinstance(item, dict) and len(item) &gt; 1 else None
    json_bytes = json.dumps(item, indent=indent).encode()
    return encoding(json_bytes)


def digest_bytes(bytes_, algorithm=hashlib.sha256):
    checksum_bytes = algorithm(bytes_).digest()
    log.warning("Log bytes: \n[%r]", bytes_)
    return base64.encodebytes(checksum_bytes).strip()


def digest(item, encoding=lambda x: x, algorithm=hashlib.sha256):
    content_encoded = encode_item(item, encoding)
    return digest_bytes(content_encoded, algorithm)


item = {"hello": "world"}

print("Encoding | digest-algorithm | digest-value")
print("Identity | sha256 |", digest(item))
# Encoding | digest-algorithm | digest-value
# Identity | sha256 | X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

print("Encoding | digest-algorithm | digest-value")
print("Brotli | sha256 |", digest(item, encoding=brotli.compress))
# Encoding | digest-algorithm | digest-value
# Brotli | sha256 | 4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

print("Encoding | digest-algorithm | digest-value")
print("Identity | sha512 |", digest(item, algorithm=hashlib.sha512))
print("Identity | sha512 |", digest(item, algorithm=hashlib.sha512, encoding=brotli.compress))
# Encoding | digest-algorithm | digest-value
# Identity | sha512 | b'WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm'
#                      '+AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew=='
# Brotli   | sha512 | b'pxo7aYzcGI88pnDnoSmAnaOEVys0MABhgvHY9+VI+ElE6'
#                      '0jBCwnMPyA/s3NF3ZO5oIWA7lf8ukk+\n5KJzm3p5og=='

</artwork>
         </figure>
      </section>
      <section anchor="changes" numbered="false">
         <name>Changes</name>
         <t>
            <em>RFC Editor: Please remove this section before publication.</em>
         </t>
         <section anchor="since-draft-ietf-httpbis-digest-headers-06" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-06</name>
            <t>
               <list style="symbols">
                  <t>Remove id-sha-256 and id-sha-512 from the list of supported algorithms #855</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-05" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-05</name>
            <t>
               <list style="symbols">
                  <t>Reboot digest-algorithm values registry #1567</t>
                  <t>Add Content-Digest #1542</t>
                  <t>Remove SRI section #1478</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-04" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-04</name>
            <t>
               <list style="symbols">
                  <t>Improve SRI section #1354</t>
                  <t>About duplicate digest-algorithms #1221</t>
                  <t>Improve security considerations #852</t>
                  <t>md5 and sha deprecation references #1392</t>
                  <t>Obsolete 3230 #1395</t>
                  <t>Editorial #1362</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-03" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-03</name>
            <t>
               <list style="symbols">
                  <t>Reference semantics-12</t>
                  <t>Detail encryption quirks</t>
                  <t>Details on Algorithm agility #1250</t>
                  <t>Obsolete parameters #850</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-02" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-02</name>
            <t>
               <list style="symbols">
                  <t>Deprecate SHA-1 #1154</t>
                  <t>Avoid id-* with encrypted content</t>
                  <t>Digest is independent from MESSAGING and HTTP/1.1 is not normative #1215</t>
                  <t>Identity is not a valid field value for content-encoding #1223</t>
                  <t>Mention trailers #1157</t>
                  <t>Reference httpbis-semantics #1156</t>
                  <t>Add contentMD5 as an obsoleted digest-algorithm #1249</t>
                  <t>Use lowercase digest-algorithms names in the doc and in the digest-algorithm IANA table.</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-01" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-01</name>
            <t>
               <list style="symbols">
                  <t>Digest of error responses is computed on the error representation-data #1004</t>
                  <t>Effect of HTTP semantics on payload and message body moved to appendix #1122</t>
                  <t>Editorial refactoring, moving headers sections up. #1109-#1112, #1116, #1117, #1122-#1124</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-00" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-00</name>
            <t>
               <list style="symbols">
                  <t>Align title with document name</t>
                  <t>Add id-sha-* algorithm examples #880</t>
                  <t>Reference <xref target="RFC6234"/> and <xref target="RFC3174"/> instead of FIPS-1</t>
                  <t>Deprecate MD5</t>
                  <t>Obsolete ADLER-32 but don't forbid it #828</t>
                  <t>Update CRC32C value in IANA table #828</t>
                  <t>Use when acting on resources (POST, PATCH) #853</t>
                  <t>Added Relationship with SRI, draft Use Cases #868, #971</t>
                  <t>Warn about the implications of <spanx style="verb">Content-Location</spanx>
                  </t>
               </list>
            </t>
         </section>
      </section>
   </back>
</rfc>
