<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.6.39 (Ruby 2.6.4) -->
<?rfc tocindent="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"
      consensus="true"
      docName="draft-ietf-httpbis-digest-headers-13"
      ipr="trust200902"
      obsoletes="3230"
      sortRefs="true"
      symRefs="true"
      tocInclude="true">
   <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="10" month="July" year="2023"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP</workgroup>
      <keyword>Digest</keyword>
      <abstract><?line 87?>
         <t>This document defines HTTP fields that support integrity digests. The Content-Digest field can be used for the integrity of HTTP message content. The Repr-Digest field can be used for the integrity of HTTP representations. Want-Content-Digest and Want-Repr-Digest can be used to indicate a sender's interest and preferences for receiving the respective Integrity fields.</t>
         <t>This document obsoletes RFC 3230 and the Digest and Want-Digest HTTP fields.</t>
      </abstract>
      <note removeInRFC="true" title="About This Document">
         <t>Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-ietf-httpbis-digest-headers/"/>.</t>
         <t>Discussion of this document takes place on the HTTP Working Group mailing list (<eref target="mailto:ietf-http-wg@w3.org"/>), which is archived at <eref target="https://lists.w3.org/Archives/Public/ietf-http-wg/"/>. Working Group information can be found at <eref target="https://httpwg.org/"/>.</t>
         <t>Source for this draft and an issue tracker can be found at <eref target="https://github.com/httpwg/http-extensions/labels/digest-headers"/>.</t>
      </note>
   </front>
   <middle><?line 99?>
      <section anchor="introduction">
         <name>Introduction</name>
         <t>HTTP does not define the means to protect the data integrity of content or representations. When HTTP messages are transferred between endpoints, lower layer features or properties such as TCP checksums or TLS records <xref target="TLS"/> can provide some integrity protection. However, transport-oriented integrity provides a limited utility because it is opaque to the application layer and only covers the extent of a single connection. HTTP messages often travel over a chain of separate connections. In between connections there is a possibility for data corruption. An HTTP integrity mechanism can provide the means for endpoints, or applications using HTTP, to detect data corruption and make a choice about how to act on it. An example use case is to aid fault detection and diagnosis across system boundaries.</t>
         <t>This document defines two digest integrity mechanisms for HTTP. First, content integrity, which acts on conveyed content (<xref section="6.4" sectionFormat="of" target="RFC9110"/>). Second, representation data integrity, which acts on representation data (<xref section="8.1" sectionFormat="of" target="RFC9110"/>). This supports advanced use cases such as validating the integrity of a resource that was reconstructed from parts retrieved using multiple requests or connections.</t>
         <t>This document obsoletes RFC 3230 and therefore the Digest and Want-Digest HTTP fields; see <xref target="obsolete-3230"/>.</t>
         <section anchor="document-structure">
            <name>Document Structure</name>
            <t>This document is structured as follows:</t>
            <t>
               <list style="symbols">
                  <t>New request and response header and trailer field definitions. <list style="symbols">
                        <t>
                           <xref target="content-digest"/> (Content-Digest),</t>
                        <t>
                           <xref target="representation-digest"/> (Repr-Digest), and</t>
                        <t>
                           <xref target="want-fields"/> (Want-Content-Digest and Want-Repr-Digest).</t>
                     </list>
                  </t>
                  <t>Considerations specific to representation data integrity. <list style="symbols">
                        <t>
                           <xref target="state-changing-requests"/> (State-changing requests),</t>
                        <t>
                           <xref target="digest-and-content-location"/> (Content-Location),</t>
                        <t>
                           <xref target="resource-representation"/> contains worked examples of Representation data in message exchanges, and</t>
                        <t>
                           <xref target="examples-unsolicited"/> and <xref target="examples-solicited"/> contain worked examples of Repr-Digest and Want-Repr-Digest fields in message exchanges.</t>
                     </list>
                  </t>
                  <t>
                     <xref target="algorithms"/> presents hash algorithm considerations and defines registration procedures for future entries.</t>
               </list>
            </t>
         </section>
         <section anchor="concept-overview">
            <name>Concept Overview</name>
            <t>The HTTP fields defined in this document can be used for HTTP integrity. Senders choose a hashing algorithm and calculate a digest from an input related to the HTTP message. The algorithm identifier and digest are transmitted in an HTTP field. Receivers can validate the digest for integrity purposes. Hashing algorithms are registered in the "Hash Algorithms for HTTP Digest Fields" registry (see <xref target="establish-hash-algorithm-registry"/>).</t>
            <t>Selecting the data on which digests are calculated depends on the use case of the HTTP messages. This document provides different fields for HTTP representation data and HTTP content.</t>
            <t>There are use cases where a simple digest of the HTTP content bytes is required. The <spanx style="verb">Content-Digest</spanx> request and response header and trailer field is defined to support digests of content (<xref section="6.4" sectionFormat="of" target="RFC9110"/>); see <xref target="content-digest"/>.</t>
            <t>For more advanced use cases, the <spanx style="verb">Repr-Digest</spanx> request and response header and trailer field (<xref target="representation-digest"/>) is defined. It contains a digest value computed by applying a hashing algorithm to selected representation data (<xref section="8.1" sectionFormat="of" target="RFC9110"/>). Basing <spanx style="verb">Repr-Digest</spanx> on the selected representation makes it straightforward to apply it to use cases where the message content requires some sort of manipulation to be considered as representation of the resource or content conveys a partial representation of a resource, such as Range Requests (see <xref section="14" sectionFormat="of" target="RFC9110"/>).</t>
            <t>
               <spanx style="verb">Content-Digest</spanx> and <spanx style="verb">Repr-Digest</spanx> support hashing algorithm agility. The <spanx style="verb">Want-Content-Digest</spanx> and <spanx style="verb">Want-Repr-Digest</spanx> fields allow endpoints to express interest in <spanx style="verb">Content-Digest</spanx> and <spanx style="verb">Repr-Digest</spanx> respectively, and to express algorithm preferences in either.</t>
            <t>
               <spanx style="verb">Content-Digest</spanx> and <spanx style="verb">Repr-Digest</spanx> are collectively termed Integrity fields. <spanx style="verb">Want-Content-Digest</spanx> and <spanx style="verb">Want-Repr-Digest</spanx> are collectively termed Integrity preference fields.</t>
            <t>Integrity fields 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 digest values when transferred with HTTP.</t>
            <t>Integrity fields apply to HTTP message content or HTTP representations. They do not apply to 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. For example, HTTP Message Signatures <xref target="SIGNATURES"/> could be used to sign Integrity fields, thus providing coverage for HTTP content or representation data.</t>
            <t>This specification does not define means for authentication, authorization, or privacy.</t>
         </section>
         <section anchor="obsolete-3230">
            <name>Obsoleting RFC 3230</name>
            <t>
               <xref target="RFC3230"/> defined the <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> HTTP fields for HTTP integrity. It also coined the term "instance" and "instance manipulation" in order to explain concepts that are now more universally defined, and implemented, as HTTP semantics such as selected representation data (<xref section="8.1" sectionFormat="of" target="RFC9110"/>).</t>
            <t>Experience has shown that implementations of <xref target="RFC3230"/> have interpreted the meaning of "instance" inconsistently, leading to interoperability issues. The most common issue relates to the mistake of calculating the digest using (what we now call) message content, rather than using (what we now call) representation data as was originally intended. Interestingly, time has also shown that a digest of message content can be beneficial for some use cases. So it is difficult to detect if non-conformance to <xref target="RFC3230"/> is intentional or unintentional.</t>
            <t>In order to address potential inconsistencies and ambiguity across implementations of <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx>, this document obsoletes <xref target="RFC3230"/>. The Integrity fields (Sections <xref format="counter" target="content-digest"/> and <xref format="counter" target="representation-digest"/>) and Integrity preference fields (<xref target="want-fields"/>) defined in this document are better aligned with current HTTP semantics and have names that more clearly articulate the intended usages.</t>
         </section>
         <section anchor="notational-conventions">
            <name>Notational Conventions</name>
            <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/>
               <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
            <?line -18?>
            <t>This document uses the Augmented BNF defined in <xref target="RFC5234"/> and updated by <xref target="RFC7405"/>. This includes the rules: CR (carriage return), LF (line feed), and CRLF (CR LF).</t>
            <t>This document uses the following terminology from <xref section="3" sectionFormat="of" target="STRUCTURED-FIELDS"/> to specify syntax and parsing: Boolean, Byte Sequence, Dictionary, Integer, and List.</t>
            <t>The definitions "representation", "selected representation", "representation data", "representation metadata", "user agent", and "content" in this document are to be interpreted as described in <xref target="RFC9110"/>.</t>
            <t>This document uses the line folding strategies described in <xref target="FOLDING"/>.</t>
            <t>Hashing algorithm names respect the casing used in their definition document (e.g., SHA-1, CRC32c).</t>
            <t>HTTP messages indicate hashing algorithms using an Algorithm Key (<contact fullname="algorithms"/>). Where the document refers to an Algorithm Key in prose, it is quoted (e.g., "sha", "crc32c").</t>
            <t>The term "checksum" describes the output of the application of an algorithm to a sequence of bytes, whereas "digest" is only used in relation to the value contained in the fields.</t>
            <t>Integrity fields: collective term for <spanx style="verb">Content-Digest</spanx> and <spanx style="verb">Repr-Digest</spanx>
            </t>
            <t>Integrity preference fields: collective term for <spanx style="verb">Want-Repr-Digest</spanx> and <spanx style="verb">Want-Content-Digest</spanx>
            </t>
         </section>
      </section>
      <section anchor="content-digest">
         <name>The Content-Digest Field</name>
         <t>The <spanx style="verb">Content-Digest</spanx> HTTP field can be used in requests and responses to communicate digests that are calculated using a hashing algorithm applied to the actual message content (see <xref section="6.4" sectionFormat="of" target="RFC9110"/>). It is a <spanx style="verb">Dictionary</spanx> (see <xref section="3.2" sectionFormat="of" target="STRUCTURED-FIELDS"/>) where each:</t>
         <t>
            <list style="symbols">
               <t>key conveys the hashing algorithm (see <xref target="algorithms"/>) used to compute the digest;</t>
               <t>value is a <spanx style="verb">Byte Sequence</spanx> (<xref section="3.3.5" sectionFormat="of" target="STRUCTURED-FIELDS"/>), that conveys an encoded version of the byte output produced by the digest calculation.</t>
            </list>
         </t>
         <t>For example:</t>
         <figure>
            <sourcecode type="http-message" x:line-folding="\">
Content-Digest: \
  sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP+pgk4vf2aCs\
  yRZOtw8MjkM7iw7yZ/WkppmM44T3qg==:
</sourcecode>
         </figure>
         <t>The <spanx style="verb">Dictionary</spanx> type can be used, for example, to attach multiple digests calculated using different hashing algorithms in order to support a population of endpoints with different or evolving capabilities. Such an approach could support transitions away from weaker algorithms (see <xref target="sec-agility"/>).</t>
         <figure>
            <sourcecode type="http-message" x:line-folding="\">
Content-Digest: \
  sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:,\
  sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP+pgk4vf2aCs\
  yRZOtw8MjkM7iw7yZ/WkppmM44T3qg==:
</sourcecode>
         </figure>
         <t>A recipient <bcp14>MAY</bcp14> ignore any or all digests. Application-specific behavior or local policy <bcp14>MAY</bcp14> set additional constraints on the processing and validation practices of the conveyed digests. The security considerations covers some of the issues related to ignoring digests (see <xref target="sec-agility"/>) and validating multiple digests (see <xref target="sec-exhaustion"/>).</t>
         <t>A sender <bcp14>MAY</bcp14> send a digest without knowing whether the recipient supports a given hashing 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>
            <bcp14>MAY</bcp14> be merged into the header section; see <xref section="6.5.1" sectionFormat="of" target="RFC9110"/>.</t>
      </section>
      <section anchor="representation-digest">
         <name>The Repr-Digest Field</name>
         <t>The <spanx style="verb">Repr-Digest</spanx> HTTP field can be used in requests and responses to communicate digests that are calculated using a hashing algorithm applied to the entire selected representation data (see <xref section="8.1" sectionFormat="of" target="RFC9110"/>).</t>
         <t>Representations take into account the effect of the HTTP semantics on 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="RFC9112"/>). To help illustrate HTTP representation concepts, several examples are provided in <xref target="resource-representation"/>.</t>
         <t>When a message has no representation data it is still possible to assert that no representation data was sent by computing the digest on an empty string (see <xref target="usage-in-signatures"/>).</t>
         <t>
            <spanx style="verb">Repr-Digest</spanx> is a <spanx style="verb">Dictionary</spanx> (see <xref section="3.2" sectionFormat="of" target="STRUCTURED-FIELDS"/>) where each:</t>
         <t>
            <list style="symbols">
               <t>key conveys the hashing algorithm (see <xref target="algorithms"/>) used to compute the digest;</t>
               <t>value is a <spanx style="verb">Byte Sequence</spanx>, that conveys an encoded version of the byte output produced by the digest calculation.</t>
            </list>
         </t>
         <t>For example:</t>
         <figure>
            <sourcecode type="http-message" x:line-folding="\">
Repr-Digest: \
  sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP+pgk4vf2aCs\
  yRZOtw8MjkM7iw7yZ/WkppmM44T3qg==:
</sourcecode>
         </figure>
         <t>The <spanx style="verb">Dictionary</spanx> type can be used, for example, to attach multiple digests calculated using different hashing algorithms in order to support a population of endpoints with different or evolving capabilities. Such an approach could support transitions away from weaker algorithms (see <xref target="sec-agility"/>).</t>
         <figure>
            <sourcecode type="http-message" x:line-folding="\">
Repr-Digest: \
  sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:,\
  sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP+pgk4vf2aCs\
  yRZOtw8MjkM7iw7yZ/WkppmM44T3qg==:
</sourcecode>
         </figure>
         <t>A recipient <bcp14>MAY</bcp14> ignore any or all digests. Application-specific behavior or local policy <bcp14>MAY</bcp14> set additional constraints on the processing and validation practices of the conveyed digests. The security considerations covers some of the issues related to ignoring digests (see <xref target="sec-agility"/>) and validating multiple digests (see <xref target="sec-exhaustion"/>).</t>
         <t>A sender <bcp14>MAY</bcp14> send a digest without knowing whether the recipient supports a given hashing algorithm, or even knowing that the recipient will ignore it.</t>
         <t>
            <spanx style="verb">Repr-Digest</spanx> can be sent in a trailer section. In this case, <spanx style="verb">Repr-Digest</spanx>
            <bcp14>MAY</bcp14> be merged into the header section; see <xref section="6.5.1" sectionFormat="of" target="RFC9110"/>.</t>
         <section anchor="state-changing-requests">
            <name>Using Repr-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 <bcp14>MUST</bcp14> 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">Repr-Digest</spanx>
                     <bcp14>MUST</bcp14> be computed on the enclosed representation (see <xref target="post-referencing-status"/>);</t>
                  <t>if there is a referenced resource <spanx style="verb">Repr-Digest</spanx>
                     <bcp14>MUST</bcp14> 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">Repr-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="RFC9110"/>). In contrast, the <spanx style="verb">Location</spanx> header field does not affect <spanx style="verb">Repr-Digest</spanx> because it is not representation metadata.</t>
            <t>For example, in <spanx style="verb">PATCH</spanx> 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>
         <section anchor="digest-and-content-location">
            <name>Repr-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">Repr-Digest</spanx> is computed accordingly. An example is given in <xref target="post-not-request-uri"/>.</t>
         </section>
      </section>
      <section anchor="want-fields">
         <name>Integrity preference fields</name>
         <t>Senders can indicate their interest in Integrity fields and hashing algorithm preferences using the <spanx style="verb">Want-Content-Digest</spanx> or <spanx style="verb">Want-Repr-Digest</spanx> fields. These can be used in both requests and responses.</t>
         <t>
            <spanx style="verb">Want-Content-Digest</spanx> indicates that the sender would like 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>
         <t>
            <spanx style="verb">Want-Repr-Digest</spanx> indicates that the sender would like to receive a representation digest on messages associated with the request URI and representation metadata, using the <spanx style="verb">Repr-Digest</spanx> field.</t>
         <t>If <spanx style="verb">Want-Content-Digest</spanx> or <spanx style="verb">Want-Repr-Digest</spanx> are used in a response, it indicates that the server would like the client to provide the respective Integrity field on future requests.</t>
         <t>Integrity preference fields are only a hint. The receiver of the field can ignore it and send an Integrity field using any algorithm or omit the field entirely, for example see <xref target="ex-server-selects-unsupported-algorithm"/>. It is not a protocol error if preferences are ignored. Applications that use Integrity fields and Integrity preferences can define expectations or constraints that operate in addition to this specification. Ignored preferences are an application-specific concern.</t>
         <t>
            <spanx style="verb">Want-Content-Digest</spanx> and <spanx style="verb">Want-Repr-Digest</spanx> are of type <spanx style="verb">Dictionary</spanx> where each:</t>
         <t>
            <list style="symbols">
               <t>key conveys the hashing algorithm (see <xref target="algorithms"/>);</t>
               <t>value is an <spanx style="verb">Integer</spanx> (<xref section="3.3.1" sectionFormat="of" target="STRUCTURED-FIELDS"/>) that conveys an ascending, relative, weighted preference. It must be in the range 0 to 10 inclusive. 1 is the least preferred, 10 is the most preferred, and a value of 0 means "not acceptable".</t>
            </list>
         </t>
         <t>Examples:</t>
         <figure>
            <sourcecode type="http-message">
Want-Repr-Digest: sha-256=1
Want-Repr-Digest: sha-512=3, sha-256=10, unixsum=0
Want-Content-Digest: sha-256=1
Want-Content-Digest: sha-512=3, sha-256=10, unixsum=0
</sourcecode>
         </figure>
      </section>
      <section anchor="algorithms">
         <name>Hash Algorithm Considerations and Registration</name>
         <t>There are a wide variety of hashing algorithms that can be used for the purposes of integrity. The choice of algorithm depends on several factors such as the integrity use case, implementation needs or constraints, or application design and workflows.</t>
         <t>An initial set of algorithms will be registered with IANA in the "Hash Algorithms for HTTP Digest Fields" registry; see <xref target="establish-hash-algorithm-registry"/>. Additional algorithms can be registered in accordance with the policies set out in this section.</t>
         <t>Each algorithm has a status field, which is intended to provide an aid to implementation selection.</t>
         <t>Algorithms with a status value of "Active" are suitable for many purposes and it is <bcp14>RECOMMENDED</bcp14> that applications use these algorithms. These can be used in adversarial situations where hash functions might need to provide resistance to collision, first-preimage and second-preimage attacks. For adversarial situations, selecting which of the "Active" algorithms are acceptable will depend on the level of protection the circumstances demand. More considerations are presented in <xref target="sec-agility"/>.</t>
         <t>Algorithms with a status value of "Deprecated" either provide none of these properties, or are known to be weak (see <xref target="NO-MD5"/> and <xref target="NO-SHA"/>). These algorithms <bcp14>MAY</bcp14> be used to preserve integrity against corruption, but <bcp14>MUST NOT</bcp14> be used in a potentially adversarial setting; for example, when signing Integrity fields' values for authenticity. Permitting the use of these algorithms can help some applications, for example, those that previously used <xref target="RFC3230"/>, are migrating to this specification (<xref target="migrating"/>), and have existing stored collections of computed digest values avoid undue operational overhead caused by recomputation using other more-secure algorithms. Such applications are not exempt from the requirements in this section. Furthermore, applications without such legacy or history ought to follow the guidance for using algorithms with the status value "Active".</t>
         <t>Discussion of algorithm agility is presented in <xref target="sec-agility"/>.</t>
         <t>Registration requests for the "Hash Algorithms for HTTP Digest Fields" registry use the Specification Required policy (<xref section="4.6" sectionFormat="of" target="RFC8126"/>). Requests should use the following template:</t>
         <t>
            <list style="symbols">
               <t>Algorithm Key: the Structured Fields key value used in <spanx style="verb">Content-Digest</spanx>, <spanx style="verb">Repr-Digest</spanx>, <spanx style="verb">Want-Content-Digest</spanx>, or <spanx style="verb">Want-Repr-Digest</spanx> field Dictionary member keys</t>
               <t>Status: the status of the algorithm. The options are: <list style="symbols">
                     <t>"Active" - for algorithms without known problems,</t>
                     <t>"Provisional" - for unproven algorithms,</t>
                     <t>"Deprecated" - for deprecated or insecure algorithms,</t>
                  </list>
               </t>
               <t>Description: a short description of the algorithm</t>
               <t>Reference(s): pointer(s) to the primary document(s) defining the Algorithm Key and technical details of the algorithm</t>
            </list>
         </t>
         <t>When reviewing registration requests, the designated expert(s) should pay attention to the requested status. The status value should reflect standardization status and the broad opinion of relevant interest groups such as the IETF or security-related SDOs. The "Active" status is not suitable for an algorithm that is known to be weak, broken, or experimental. If a registration request attempts to register such an algorithm as "Active", the designated expert(s) should suggest an alternative status of "Deprecated" or "Provisional".</t>
         <t>When reviewing registration requests, the designated expert(s) cannot use a status of "Deprecated" or "Provisional" as grounds for rejection.</t>
         <t>Requests to update or change the fields in an existing registration are permitted. For example, this could allow for the transition of an algorithm status from "Active" to "Deprecated" as the security environment evolves.</t>
      </section>
      <section anchor="security">
         <name>Security Considerations</name>
         <section anchor="sec-limitations">
            <name>HTTP Messages Are Not Protected In Full</name>
            <t>This document specifies a data integrity mechanism that protects HTTP representation data or content, but not HTTP header and trailer fields, from certain kinds of corruption.</t>
            <t>Integrity fields are not intended to be a general protection against malicious tampering with HTTP messages. In the absence of additional security mechanisms, an on-path, malicious actor can remove or recalculate and substitute a digest value. This attack can be mitigated by combining mechanisms described in this document with other approaches such as transport-layer security or digital signatures (for example, HTTP Message Signatures <xref target="SIGNATURES"/>).</t>
         </section>
         <section anchor="end-to-end-integrity">
            <name>End-to-End Integrity</name>
            <t>Integrity fields can help detect representation data or content modification due to implementation errors, undesired "transforming proxies" (see <xref section="7.7" sectionFormat="of" target="RFC9110"/>) or other actions as the data passes across multiple hops or system boundaries. Even a simple mechanism for end-to-end representation data integrity is valuable because a user agent can validate that resource retrieval succeeded before handing off to an HTML parser, video player, etc. for parsing.</t>
            <t>Note that using these mechanisms 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 Integrity fields are included in this set.</t>
            <t>There are no restrictions placed on the type or format of digital signature that Integrity fields can be used with. One possible approach is to combine them with HTTP Message Signatures <xref target="SIGNATURES"/>.</t>
            <t>Digests explicitly depend on the "representation metadata" (e.g., the values of <spanx style="verb">Content-Type</spanx>, <spanx style="verb">Content-Encoding</spanx> etc.). A signature that protects Integrity fields but not other "representation metadata" 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>Signatures are likely to be deemed an adversarial setting when applying Integrity fields; see <xref target="algorithms"/>. <spanx style="verb">Repr-Digest</spanx> offers an interesting possibility when combined with signatures. In the scenario where there is no content to send, the digest of an empty string can be included in the message and, if signed, can help the recipient detect if content was added either as a result of accident or purposeful manipulation. The opposite scenario is also supported; including an Integrity field for content, and signing it, can help a recipient detect where the content was removed.</t>
            <t>Any mangling of Integrity fields, including digests' de-duplication or combining different field values (see <xref section="5.2" sectionFormat="of" target="RFC9110"/>) might affect signature validation.</t>
         </section>
         <section anchor="usage-in-trailer-fields">
            <name>Usage in Trailer Fields</name>
            <t>Before sending Integrity 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="RFC9110"/>).</t>
            <t>When Integrity 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>One of the benefits of using Integrity fields in a trailer section is that it allows hashing of bytes as they are sent. However, it is possible to design a hashing algorithm that requires processing of content in such a way that would negate these benefits. For example, Merkle Integrity Content Encoding <xref target="I-D.thomson-http-mice"/> requires content to be processed in reverse order. This means the complete data needs to be available, which means there is negligible processing difference in sending an Integrity field in a header or trailer section.</t>
         </section>
         <section anchor="variations-within-content-encoding">
            <name>Variations Within Content Encoding</name>
            <t>Content coding mechanisms can support different encoding parameters, meaning that the same input content can produce different outputs. For example, GZIP supports multiple compression levels. Such encoding parameters are generally not communicated as representation metadata. For instance, different compression levels would all use the same "Content-Encoding: gzip" field. Other examples include where encoding relies on nonces or timestamps, such as the aes128gcm content coding defined in <xref target="RFC8188"/>.</t>
            <t>Since it is possible for there to be variation within content coding, the checksum conveyed by the integrity fields cannot be used to provide a proof of integrity "at rest" unless the whole content is persisted.</t>
         </section>
         <section anchor="sec-agility">
            <name>Algorithm Agility</name>
            <t>The security properties of hashing algorithms are not fixed. Algorithm Agility (see <xref target="RFC7696"/>) is achieved by providing implementations with flexibility to choose hashing algorithms from the IANA Hash Algorithms for HTTP Digest Fields registry; see <xref target="establish-hash-algorithm-registry"/>.</t>
            <t>Transition from weak algorithms is supported by negotiation of hashing algorithm using <spanx style="verb">Want-Content-Digest</spanx> or <spanx style="verb">Want-Repr-Digest</spanx> (see <xref target="want-fields"/>) or by sending multiple digests from which the receiver chooses. A receiver that depends on a digest for security will be vulnerable to attacks on the weakest algorithm it is willing to accept. Endpoints are advised that sending multiple values consumes resources, which may be wasted if the receiver ignores them (see <xref target="representation-digest"/>).</t>
            <t>While algorithm agility allows the migration to stronger algorithms it does not prevent the use of weaker algorithms. Integrity fields do not provide any mitigations for downgrade or substitution attacks (see <xref target="RFC6211" x:fmt="of" x:sec="1"/>) of the hashing algorithm. To protect against such attacks, endpoints could restrict their set of supported algorithms to stronger ones and protect the fields value by using TLS and/or digital signatures.</t>
         </section>
         <section anchor="sec-exhaustion">
            <name>Resource exhaustion</name>
            <t>Integrity 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. In these cases, skipping validation entirely or ignoring validation failure of a more-preferred algorithm leaves the possibility of a downgrade attack (see <xref target="sec-agility"/>).</t>
         </section>
      </section>
      <section anchor="iana-considerations">
         <name>IANA Considerations</name>
         <section anchor="http-field-name-registration">
            <name>HTTP Field Name Registration</name>
            <t>IANA is asked to update the "Hypertext Transfer Protocol (HTTP) Field Name Registry" registry (<xref target="RFC9110"/>) according to the table below:</t>
            <texttable>
               <ttcol align="left">Field Name</ttcol>
               <ttcol align="left">Status</ttcol>
               <ttcol align="left">Reference</ttcol>
               <c>Content-Digest</c>
               <c>permanent</c>
               <c>
                  <xref target="content-digest"/> of this document</c>
               <c>Repr-Digest</c>
               <c>permanent</c>
               <c>
                  <xref target="representation-digest"/> of this document</c>
               <c>Want-Content-Digest</c>
               <c>permanent</c>
               <c>
                  <xref target="want-fields"/> of this document</c>
               <c>Want-Repr-Digest</c>
               <c>permanent</c>
               <c>
                  <xref target="want-fields"/> of this document</c>
               <c>Digest</c>
               <c>obsoleted</c>
               <c>
                  <xref target="RFC3230"/>, <xref target="obsolete-3230"/> of this document</c>
               <c>Want-Digest</c>
               <c>obsoleted</c>
               <c>
                  <xref target="RFC3230"/>, <xref target="obsolete-3230"/> of this document</c>
            </texttable>
         </section>
         <section anchor="establish-hash-algorithm-registry">
            <name>Establish the Hash Algorithms for HTTP Digest Fields Registry</name>
            <t>IANA is requested to create the new "Hash Algorithms for HTTP Digest Fields" registry at <eref target="https://www.iana.org/assignments/http-digest-hash-alg/">https://www.iana.org/assignments/http-digest-hash-alg/</eref> and populate it with the entries in <xref target="iana-hash-algorithm-table"/>. The procedure for new registrations is provided in <xref target="algorithms"/>.</t>
            <texttable anchor="iana-hash-algorithm-table" title="Initial Hash Algorithms">
               <ttcol align="left">Algorithm Key</ttcol>
               <ttcol align="left">Status</ttcol>
               <ttcol align="left">Description</ttcol>
               <ttcol align="left">Reference(s)</ttcol>
               <c>sha-512</c>
               <c>Active</c>
               <c>The SHA-512 algorithm.</c>
               <c>
                  <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</c>
               <c>sha-256</c>
               <c>Active</c>
               <c>The SHA-256 algorithm.</c>
               <c>
                  <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</c>
               <c>md5</c>
               <c>Deprecated</c>
               <c>The MD5 algorithm. It is vulnerable to collision attacks; see <xref target="NO-MD5"/> and <xref target="CMU-836068"/>
               </c>
               <c>
                  <xref target="RFC1321"/>, <xref target="RFC4648"/>, this document.</c>
               <c>sha</c>
               <c>Deprecated</c>
               <c>The SHA-1 algorithm. It is vulnerable to collision attacks; see <xref target="NO-SHA"/> and <xref target="IACR-2020-014"/>
               </c>
               <c>
                  <xref target="RFC3174"/>, <xref target="RFC4648"/>, <xref target="RFC6234"/> this document.</c>
               <c>unixsum</c>
               <c>Deprecated</c>
               <c>The algorithm used by the UNIX "sum" command.</c>
               <c>
                  <xref target="RFC4648"/>, <xref target="RFC6234"/>, <xref target="UNIX"/>, this document.</c>
               <c>unixcksum</c>
               <c>Deprecated</c>
               <c>The algorithm used by the UNIX "cksum" command.</c>
               <c>
                  <xref target="RFC4648"/>, <xref target="RFC6234"/>, <xref target="UNIX"/>, this document.</c>
               <c>adler</c>
               <c>Deprecated</c>
               <c>The ADLER32 algorithm.</c>
               <c>
                  <xref target="RFC1950"/>, this document.</c>
               <c>crc32c</c>
               <c>Deprecated</c>
               <c>The CRC32c algorithm.</c>
               <c>
                  <xref target="RFC9260"/> appendix A, this document.</c>
            </texttable>
         </section>
         <section anchor="deprecate-the-hypertext-transfer-protocol-http-digest-algorithm-values-registry">
            <name>Deprecate the Hypertext Transfer Protocol (HTTP) Digest Algorithm Values Registry</name>
            <t>IANA is requested to deprecate the "Hypertext Transfer Protocol (HTTP) Digest Algorithm Values" registry at <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml</eref> and replace the note on this registry with the following text:</t>
            <ul empty="true">
               <li>
                  <t>"This registry is deprecated since it lists the algorithms that can be used with the Digest and Want-Digest fields defined in <xref target="RFC3230"/>
                     <eref target="https://www.iana.org/">https://www.iana.org/</eref>, which has been obsoleted by [rfc-to-be-this-document]. While registration is not closed, new registrations are encouraged to use the [Hash Algorithms for HTTP Digest Fields]<eref target="https://www.iana.org/assignments/http-digest-hash-alg/">https://www.iana.org/assignments/http-digest-hash-alg/</eref> registry instead.</t>
               </li>
            </ul>
         </section>
      </section>
   </middle>
   <back>
      <displayreference target="RFC9110" to="HTTP"/>
      <displayreference target="RFC9112" to="HTTP/1.1"/>
      <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" surname="J-L. Gailly"/>
               <date month="May" year="1996"/>
            </front>
            <seriesInfo name="RFC" value="1950"/>
            <seriesInfo name="DOI" value="10.17487/RFC1950"/>
         </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="FOLDING">
            <front>
               <title>Handling Long Lines in Content of Internet-Drafts and RFCs</title>
               <author fullname="K. Watsen" initials="K." surname="Watsen"/>
               <author fullname="E. Auerswald" initials="E." surname="Auerswald"/>
               <author fullname="A. Farrel" initials="A." surname="Farrel"/>
               <author fullname="Q. Wu" initials="Q." surname="Wu"/>
               <date month="June" year="2020"/>
            </front>
            <seriesInfo name="RFC" value="8792"/>
            <seriesInfo name="DOI" value="10.17487/RFC8792"/>
         </reference>
         <reference anchor="RFC9110">
            <front>
               <title>HTTP Semantics</title>
               <author fullname="R. Fielding"
                        initials="R."
                        role="editor"
                        surname="Fielding"/>
               <author fullname="M. Nottingham"
                        initials="M."
                        role="editor"
                        surname="Nottingham"/>
               <author fullname="J. Reschke"
                        initials="J."
                        role="editor"
                        surname="Reschke"/>
               <date month="June" year="2022"/>
            </front>
            <seriesInfo name="STD" value="97"/>
            <seriesInfo name="RFC" value="9110"/>
            <seriesInfo name="DOI" value="10.17487/RFC9110"/>
         </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="STRUCTURED-FIELDS">
            <front>
               <title>Structured Field Values for HTTP</title>
               <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
               <author fullname="P-H. Kamp" surname="P-H. Kamp"/>
               <date month="February" year="2021"/>
            </front>
            <seriesInfo name="RFC" value="8941"/>
            <seriesInfo name="DOI" value="10.17487/RFC8941"/>
         </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="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="RFC9112">
            <front>
               <title>HTTP/1.1</title>
               <author fullname="R. Fielding"
                        initials="R."
                        role="editor"
                        surname="Fielding"/>
               <author fullname="M. Nottingham"
                        initials="M."
                        role="editor"
                        surname="Nottingham"/>
               <author fullname="J. Reschke"
                        initials="J."
                        role="editor"
                        surname="Reschke"/>
               <date month="June" year="2022"/>
            </front>
            <seriesInfo name="STD" value="99"/>
            <seriesInfo name="RFC" value="9112"/>
            <seriesInfo name="DOI" value="10.17487/RFC9112"/>
         </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-SHA">
            <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="SIGNATURES">
            <front>
               <title>HTTP Message Signatures</title>
               <author fullname="Annabelle Backman" initials="A." surname="Backman">
                  <organization>Amazon</organization>
               </author>
               <author fullname="Justin Richer" initials="J." surname="Richer">
                  <organization>Bespoke Engineering</organization>
               </author>
               <author fullname="Manu Sporny" initials="M." surname="Sporny">
                  <organization>Digital Bazaar</organization>
               </author>
               <date day="2" month="May" year="2023"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-message-signatures-17"/>
         </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>Carnegie 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="TLS">
            <front>
               <title>The Transport Layer Security (TLS) Protocol Version 1.3</title>
               <author fullname="E. Rescorla" initials="E." surname="Rescorla"/>
               <date month="August" year="2018"/>
            </front>
            <seriesInfo name="RFC" value="8446"/>
            <seriesInfo name="DOI" value="10.17487/RFC8446"/>
         </reference>
         <reference anchor="I-D.thomson-http-mice">
            <front>
               <title>Merkle Integrity Content Encoding</title>
               <author fullname="Martin Thomson" initials="M." surname="Thomson">
                  <organization>Mozilla</organization>
               </author>
               <author fullname="Jeffrey Yasskin" initials="J." surname="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="RFC8188">
            <front>
               <title>Encrypted Content-Encoding for HTTP</title>
               <author fullname="M. Thomson" initials="M." surname="Thomson"/>
               <date month="June" year="2017"/>
            </front>
            <seriesInfo name="RFC" value="8188"/>
            <seriesInfo name="DOI" value="10.17487/RFC8188"/>
         </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="RFC6211">
            <front>
               <title>Cryptographic Message Syntax (CMS) Algorithm Identifier Protection Attribute</title>
               <author fullname="J. Schaad" initials="J." surname="Schaad"/>
               <date month="April" year="2011"/>
            </front>
            <seriesInfo name="RFC" value="6211"/>
            <seriesInfo name="DOI" value="10.17487/RFC6211"/>
         </reference>
         <reference anchor="RFC9260">
            <front>
               <title>Stream Control Transmission Protocol</title>
               <author fullname="R. Stewart" initials="R." surname="Stewart"/>
               <author fullname="M. Tüxen" initials="M." surname="Tüxen"/>
               <author fullname="K. Nielsen" initials="K." surname="Nielsen"/>
               <date month="June" year="2022"/>
            </front>
            <seriesInfo name="RFC" value="9260"/>
            <seriesInfo name="DOI" value="10.17487/RFC9260"/>
         </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>
      </references>
      <?line 722?>
      <section anchor="resource-representation">
         <name>Resource Representation and Representation Data</name>
         <t>This section following examples show how representation metadata, content transformations, and method impacts on the message and content. These examples a not exhaustive.</t>
         <t>Unless otherwise indicated, the examples are based on the JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF. When the content contains non-printable characters (e.g., when it is encoded) it is shown as a sequence of hex-encoded bytes.</t>
         <t>Consider a client that wishes to upload a JSON object using the PUT method. It could do this using the application/json content type without any content coding.</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
Content-Length: 19

{"hello": "world"}
</sourcecode>
         </figure>
         <t>However, the use of content coding is quite common. The client could also upload the same data with a gzip coding (<xref section="8.4.1.3" sectionFormat="of" target="RFC9110"/>). Note that in this case, the <spanx style="verb">Content-Length</spanx> contains a larger value due to the coding overheads.</t>
         <figure anchor="ex-put-gz"
                  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
Content-Length: 39

1F 8B 08 00 88 41 37 64 00 FF
AB 56 CA 48 CD C9 C9 57 B2 52
50 2A CF 2F CA 49 51 AA E5 02
00 D9 E4 31 E7 13 00 00 00
</sourcecode>
         </figure>
         <t>Sending the gzip coded data without indicating it via <spanx style="verb">Content-Encoding</spanx> means that the content is malformed. In this case, the server can reply with an error.</t>
         <figure title="Request containing malformed JSON">
            <sourcecode type="http-message">
PUT /entries/1234 HTTP/1.1
Host: foo.example
Content-Type: application/json

Content-Length: 39

1F 8B 08 00 88 41 37 64 00 FF
AB 56 CA 48 CD C9 C9 57 B2 52
50 2A CF 2F CA 49 51 AA E5 02
00 D9 E4 31 E7 13 00 00 00
</sourcecode>
         </figure>
         <figure title="An error response for a malformed content">
            <sourcecode type="http-message">
HTTP/1.1 400 Bad Request

</sourcecode>
         </figure>
         <t>A Range-Request affects the transferred message content. In this example, the client is accessing the resource at <spanx style="verb">/entries/1234</spanx>, which is the JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF. However, the client has indicated a preferred content coding and a specific byte range.</t>
         <figure title="Request for partial content">
            <sourcecode type="http-message">
GET /entries/1234 HTTP/1.1
Host: foo.example
Accept-Encoding: gzip
Range: bytes=1-7

</sourcecode>
         </figure>
         <t>The server satisfies the client request by responding with a partial representation (equivalent to the first 10 of the JSON object displayed in whole in <xref target="ex-put-gz"/>).</t>
         <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 0-9/39

1F 8B 08 00 A5 B4 BD 62 02 FF
</sourcecode>
         </figure>
         <t>Aside from content coding or range requests, the method can also affect the transferred message content. For example, the response to a HEAD request does not carry content but in this example case does include a Content-Length; see <xref section="8.6" sectionFormat="of" target="RFC9110"/>.</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
Content-Length: 39

</sourcecode>
         </figure>
         <t>Finally, the semantics of a response might decouple the target URI from the enclosed representation. In the example below, the client issues a POST request directed to <spanx style="verb">/authors/</spanx> but the response includes a <spanx style="verb">Content-Location</spanx> header field that indicates the enclosed representation refers to the resource available at <spanx style="verb">/authors/123</spanx>. Note that <spanx style="verb">Content-Length</spanx> is not sent in this example.</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">Content-Digest</spanx> or <spanx style="verb">Repr-Digest</spanx> fields even though the client did not solicit one using <spanx style="verb">Want-Content-Digest</spanx> or <spanx style="verb">Want-Repr-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 spaces 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">Content-Digest</spanx> and <spanx style="verb">Repr-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. This means that in the response, <spanx style="verb">Content-Digest</spanx> and <spanx style="verb">Repr-Digest</spanx> are both computed over the JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF, and thus 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 identical Repr-Digest and Content-Digest">
               <sourcecode type="http-message" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19
Content-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

{"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">Content-Digest</spanx> field-value is computed on empty content. <spanx style="verb">Repr-Digest</spanx> is calculated over the JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF, which is not shown because there is no 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" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Digest: \
  sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

</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.</t>
            <figure title="Request for partial content">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Range: bytes=10-18

</sourcecode>
            </figure>
            <figure title="Partial response with both Content-Digest and Repr-Digest">
               <sourcecode type="http-message" x:line-folding="\">
HTTP/1.1 206 Partial Content
Content-Type: application/json
Content-Range: bytes 10-18/19
Content-Digest: \
  sha-256=:jjcgBDWNAtbYUXI37CVG3gRuGOAjaaDRGpIUFsdyepQ=:
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

"world"}
</sourcecode>
            </figure>
            <t>In the response message above, note that the <spanx style="verb">Repr-Digest</spanx> and <spanx style="verb">Content-Digests</spanx> are different. The <spanx style="verb">Repr-Digest</spanx> field-value is calculated across the entire JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF, and the field is</t>
            <figure>
               <sourcecode type="http-message" x:line-folding="\">
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:
</sourcecode>
            </figure>
            <t>However, since the message content is constrained to bytes 10-18, the <spanx style="verb">Content-Digest</spanx> field-value is calculated over the sequence <spanx style="verb">"world"}</spanx> followed by an LF, thus resulting in</t>
            <figure>
               <sourcecode type="http-message" x:line-folding="\">
Content-Digest: \
  sha-256=:jjcgBDWNAtbYUXI37CVG3gRuGOAjaaDRGpIUFsdyepQ=:
</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">Repr-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">Repr-Digest</spanx> field-value is therefore different compared to the request.</t>
            <t>For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.</t>
            <figure title="PUT Request with Digest">
               <sourcecode type="http-message" x:line-folding="\">
PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept-Encoding: br
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

{"hello": "world"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of encoded response">
               <sourcecode type="http-message" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Location: /items/123
Content-Encoding: br
Content-Length: 23
Repr-Digest: \
  sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:

8B 08 80 7B 22 68 65 6C 6C 6F
22 3A 20 22 77 6F 72 6C 64 22
7D 0A 03
</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">Repr-Digest</spanx> field-value is calculated on the enclosed content, which is the JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF</t>
            <t>The response <spanx style="verb">Repr-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" x:line-folding="\">
PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Content-Length: 19
Accept-Encoding: br
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:

{"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
Repr-Digest: sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:

</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>For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.</t>
            <figure title="PUT Request with Digest">
               <sourcecode type="http-message" x:line-folding="\">
PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept-Encoding: br
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:

{"hello": "world"}
</sourcecode>
            </figure>
            <figure title="Response with Digest of Encoded Content">
               <sourcecode type="http-message" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: br
Content-Location: /items/123
Repr-Digest: \
  sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:,\
  sha-512=:db7fdBbgZMgX1Wb2MjA8zZj+rSNgfmDCEEXM8qLWfpfoNY0sCpHAzZbj\
  09X1/7HAb7Od5Qfto4QpuBsFbUO3dQ==:

8B 08 80 7B 22 68 65 6C 6C 6F
22 3A 20 22 77 6F 72 6C 64 22
7D 0A 03
</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">Repr-Digest</spanx> field-value is computed on the enclosed representation (see <xref target="state-changing-requests"/>), which is the JSON object <spanx style="verb">{"title": "New Title"}</spanx> followed by an LF.</t>
            <t>The representation enclosed in the response is a multiline JSON object followed by an LF. It refers to the resource identified by <spanx style="verb">Content-Location</spanx> (see <xref section="6.4.2" sectionFormat="of" target="RFC9110"/>); an application can thus use <spanx style="verb">Repr-Digest</spanx> in association with the resource referenced by <spanx style="verb">Content-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
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:

{"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
Repr-Digest: sha-256=:uVSlinTTdQUwm2On4k8TJUikGN1bf/Ds8WPX4oe0h9I=:

{
  "id": "123",
  "title": "New Title"
}
</sourcecode>
            </figure>
         </section>
         <section anchor="post-referencing-status">
            <name>POST Response Describes the Request Status</name>
            <t>The request <spanx style="verb">Repr-Digest</spanx> field-value is computed on the enclosed representation (see <xref target="state-changing-requests"/>), which is the JSON object <spanx style="verb">{"title": "New Title"}</spanx> followed by an LF.</t>
            <t>The representation enclosed in the response describes the status of the request, so <spanx style="verb">Repr-Digest</spanx> is computed on that enclosed representation. It is a multiline JSON object followed by an LF.</t>
            <t>Response <spanx style="verb">Repr-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
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:

{"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
Repr-Digest: sha-256=:yXIGDTN5VrfoyisKlXgRKUHHMs35SNtyC3szSz1dbO8=:
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 target URI.</t>
            <t>The PATCH request uses the <spanx style="verb">application/merge-patch+json</spanx> media type defined in <xref target="RFC7396"/>. <spanx style="verb">Repr-Digest</spanx> is calculated on the content, which corresponds to the patch document and is the JSON object <spanx style="verb">{"title": "New Title"}</spanx> followed by an LF.</t>
            <t>The response <spanx style="verb">Repr-Digest</spanx> field-value is computed on the complete representation of the patched resource. It is a multiline JSON object followed by an LF.</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
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:

{"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
Repr-Digest: sha-256=:uVSlinTTdQUwm2On4k8TJUikGN1bf/Ds8WPX4oe0h9I=:

{
  "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">Repr-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="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">Repr-Digest</spanx> field-value is computed on this enclosed representation. It is a multiline JSON object followed by an LF.</t>
            <figure title="Response with Digest of Error Representation">
               <sourcecode type="http-message">
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Repr-Digest: sha-256=:EXB0S2VF2H7ijkAVJkH1Sm0pBho0iDZcvVUHHXTTZSA=:

{
  "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">Repr-Digest</spanx> as trailer field, so it can calculate digest-value while streaming content and thus mitigate resource consumption. The <spanx style="verb">Repr-Digest</spanx> field-value is the same as in <xref target="example-full-representation"/> because <spanx style="verb">Repr-Digest</spanx> is designed to be independent of the use of one or more transfer codings (see <xref target="representation-digest"/>).</t>
            <t>In the response content below, the string "\r\n" represent the bytes CRLF.</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" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Trailer: Digest

8\r\n
{"hello"\r\n
8\r\n
: "world\r\n
3\r\n
"}\n\r\n
0\r\n
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:\r\n

</sourcecode>
            </figure>
         </section>
      </section>
      <section anchor="examples-solicited">
         <name>Examples of Want-Repr-Digest Solicited Digest</name>
         <t>The following examples demonstrate interactions where a client solicits a <spanx style="verb">Repr-Digest</spanx> using <spanx style="verb">Want-Repr-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 spaces 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-Repr-Digest">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha-256=3, sha=10

</sourcecode>
            </figure>
            <figure title="Response with Different Algorithm">
               <sourcecode type="http-message" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Repr-Digest: \
  sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:

{"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 "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-Repr-Digest">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10

</sourcecode>
            </figure>
            <figure title="Response with Unsupported Algorithm">
               <sourcecode type="http-message" x:line-folding="\">
HTTP/1.1 200 OK
Content-Type: application/json
Repr-Digest: \
  sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP+pgk4vf2aCs\
  yRZOtw8MjkM7iw7yZ/WkppmM44T3qg==:

{"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 a response with error status code such as 4xx or 5xx. This specification does not prescribe any requirement on status code selection; the follow example illustrates one possible option.</t>
            <t>In this example, the client requests a "sha" <spanx style="verb">Repr-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 hashing 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-Repr-Digest">
               <sourcecode type="http-message">
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10

</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 hashing algorithms: sha-256, sha-512",
  "status": 400
}
</sourcecode>
            </figure>
         </section>
      </section>
      <section anchor="sample-digest-values">
         <name>Sample Digest Values</name>
         <t>This section shows examples of digest values for different hashing algorithms. The input value is the JSON object <spanx style="verb">{"hello": "world"}</spanx>. The digest values are each produced by running the relevant hashing algorithm over the input and running the output bytes through <spanx style="verb">Byte Sequence</spanx> serialization; see <xref section="4.1.8" sectionFormat="of" target="STRUCTURED-FIELDS"/>.</t>
         <figure>
            <artwork x:line-folding="\">
sha-512 -   :WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm+\
            AbwAgBWnrIiYllu7BNNyealdVLvRwEmTHWXvJwew==:

sha-256 -   :X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:

md5 -       :Sd/dVLAcvNLSq16eXua5uQ==:

sha -       :07CavjDP4u3/TungoUHJO/Wzr4c=:

unixsum -   :GQU=:

unixcksum - :7zsHAA==:

adler -     :OZkGFw==:

crc32c -    :Q3lHIA==:
</artwork>
         </figure>
      </section>
      <section anchor="migrating">
         <name>Migrating from RFC 3230</name>
         <t>HTTP digests are computed by applying a hashing algorithm to input data. RFC 3230 defined the input data as an "instance", a term it also defined. The concept of instance has since been superseded by the HTTP semantic term "representation". It is understood that some implementations of RFC 3230 mistook "instance" to mean HTTP content. Using content for the Digest field is an error that leads to interoperability problems between peers that implement RFC 3230.</t>
         <t>RFC 3230 was only ever intended to use what HTTP now defines as selected representation data. The semantic concept of digest and representation are explained alongside the definition of <xref target="representation-digest">the Repr-Digest field</xref>.</t>
         <t>While the syntax of Digest and Repr-Digest are different, the considerations and examples this document gives for Repr-Digest apply equally to Digest because they operate on the same input data; see Sections <xref format="counter" target="state-changing-requests"/>, <xref format="counter" target="security"/> and <xref format="counter" target="usage-in-signatures"/>.</t>
         <t>RFC 3230 could never communicate the digest of HTTP message content in the Digest field; Content-Digest now provides that capability.</t>
         <t>RFC 3230 allowed algorithms to define their output encoding format for use with the Digest field. This resulted in a mix of formats such as base64, hex or decimal. By virtue of using Structured fields, Content-Digest and Repr-Digest use only a single encoding format. Further explanation and examples are provided in <xref target="sample-digest-values"/>.</t>
      </section>
      <section anchor="acknowledgements" numbered="false">
         <name>Acknowledgements</name>
         <t>This document is based on ideas from <xref target="RFC3230"/>, so thanks to Jeff Mogul and Arthur Van Hoff for their great work. The original idea of refreshing RFC3230 arose from an interesting discussion with Mark Nottingham, Jeffrey Yasskin, and Martin 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, Justin Richer, and Erik Wilde.</t>
      </section>
      <section anchor="code-samples" numbered="false" removeInRFC="true">
         <name>Code Samples</name>
         <t>How can I generate and validate the digest values, computed over the JSON object <spanx style="verb">{"hello": "world"}</spanx> followed by an LF, 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 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(bytes_, encoding=lambda x: x, algorithm=hashlib.sha256):
    content_encoded = encoding(bytes_)
    return digest_bytes(content_encoded, algorithm)


bytes_ = b'{"hello": "world"}\n'

print("Encoding | hashing algorithm | digest-value")
print("Identity | sha256 |", digest(bytes_))
# Encoding | hashing algorithm | digest-value
# Identity | sha256 | RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=

print("Encoding | hashing algorithm | digest-value")
print("Brotli | sha256 |", digest(bytes_, encoding=brotli.compress))
# Encoding | hashing algorithm | digest-value
# Brotli | sha256 | d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=

print("Encoding | hashing algorithm | digest-value")
print("Identity | sha512 |", digest(bytes_, algorithm=hashlib.sha512))
print("Brotli | sha512 |", digest(bytes_, algorithm=hashlib.sha512,
                                    encoding=brotli.compress))
# Encoding | hashing algorithm | digest-value
# Identity | sha512 |b'YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP'
#                     '+pgk4vf2aCsyRZOtw8MjkM7iw7yZ/WkppmM44T3qg=='

# Brotli | sha512 | b'db7fdBbgZMgX1Wb2MjA8zZj+rSNgfmDCEEXM8qLWfpfoNY'
#                    '0sCpHAzZbj09X1/7HAb7Od5Qfto4QpuBsFbUO3dQ=='

</artwork>
         </figure>
      </section>
      <section anchor="changes" numbered="false" removeInRFC="true">
         <name>Changes</name>
         <section anchor="since-draft-ietf-httpbis-digest-headers-12" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-12</name>
            <t>
               <list style="symbols">
                  <t>Be clearer that applications can enforce additional requirements wrt digest</t>
                  <t>Change algorithm status names: s/standard/active, s/insecure/deprecated</t>
                  <t>Remove "reserved" algorithm status</t>
                  <t>Provide clear guidance about the use of standard or deprecated algorithms</t>
                  <t>Editorial or minor changes</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-11" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-11</name>
            <t>
               <list style="symbols">
                  <t>Editorial or minor changes</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-10" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-10</name>
            <t>
               <list style="symbols">
                  <t>Editorial or minor changes</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-09" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-09</name>
            <t>
               <list style="symbols">
                  <t>Editorial or minor changes</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-08" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-08</name>
            <t>
               <list style="symbols">
                  <t>Add note about migrating from RFC 3230. #1968, #1971</t>
                  <t>Clarify what Want-* means in responses. #2097</t>
                  <t>Editorial changes to structure and to align to HTTP style guide.</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-07" numbered="false">
            <name>Since draft-ietf-httpbis-digest-headers-07</name>
            <t>
               <list style="symbols">
                  <t>Introduced Repr-Digest and Want-Repr-Digest, and deprecated Digest and Want-Digest. Use of Structured Fields. #1993, #1919</t>
                  <t>IANA refactoring. #1983</t>
                  <t>No normative text in security considerations. #1972</t>
               </list>
            </t>
         </section>
         <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 of 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>
