<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.3.14 -->
<?rfc toc="yes"?>
<?rfc tocindent="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>
<?rfc strict="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc docmapping="yes"?>
<?rfc-ext html-pretty-print="prettyprint https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"?>
<rfc xmlns:x="http://purl.org/net/xml2rfc/ext"
     category="std"
     docName="draft-ietf-httpbis-digest-headers-04"
     ipr="trust200902"
     submissionType="IETF">
   <x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22\&amp;amp;body=%3c{ref}%3e:"/>
   <front>
      <title>Digest Headers</title>
      <author fullname="Roberto Polli" initials="R." surname="Polli">
         <organization>Team Digitale, Italian Government</organization>
         <address>
            <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="17" month="October" year="2020"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP</workgroup>
      <keyword>Digest</keyword>
      <abstract>
         <t>This document defines the HTTP Digest and Want-Digest fields, thus allowing client and server to negotiate an integrity checksum of the exchanged resource representation data.</t>
         <t>This document obsoletes RFC 3230. It replaces the term "instance" with "representation", which makes it consistent with the HTTP Semantic and Context defined in draft-ietf-httpbis-semantics.</t>
      </abstract>
      <note title="Note to Readers">
         <t>
            <spanx>RFC EDITOR: please remove this section before publication</spanx>
         </t>
         <t>Discussion of this draft takes place on the HTTP working group mailing list (ietf-http-wg@w3.org), which is archived at <eref target="https://lists.w3.org/Archives/Public/ietf-http-wg/">https://lists.w3.org/Archives/Public/ietf-http-wg/</eref>.</t>
         <t>The source code and issues list for this draft can be found at <eref target="https://github.com/httpwg/http-extensions">https://github.com/httpwg/http-extensions</eref>.</t>
      </note>
   </front>
   <middle>
      <section anchor="introduction" title="Introduction">
         <t>The core specification of HTTP does not define a means to protect the integrity of resources. When HTTP messages are transferred between endpoints, the protocol might choose to make use of features of the lower layer in order to provide some integrity protection; for instance TCP checksums or TLS records <xref target="RFC2818"/>.</t>
         <t>However, there are cases where relying on this alone is insufficient. An HTTP-level integrity mechanism that operates independent of transfer can be used to detect programming errors and/or corruption of data at rest, be used across multiple hops in order to provide end-to-end integrity guarantees, aid fault diagnosis across hops and system boundaries, and can be used to validate integrity when reconstructing a resource fetched using different HTTP connections.</t>
         <t>This document defines a mechanism that acts on HTTP representation-data. It can be combined with other mechanisms that protect representation-metadata, such as digital signatures, in order to protect the desired parts of an HTTP exchange in whole or in part.</t>
         <section anchor="history" title="A Brief History of HTTP Integrity Fields">
            <t>The Content-MD5 header field was originally introduced to provide integrity, but HTTP/1.1 (<xref target="RFC7231" x:fmt="," x:sec="B"/>) obsoleted it:</t>
            <t>
               <list style="empty">
                  <t>The Content-MD5 header field has been removed because it was inconsistently implemented with respect to partial responses.</t>
               </list>
            </t>
            <t>
               <xref target="RFC3230"/> provided a more flexible solution introducing the concept of "instance", and the fields <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx>.</t>
         </section>
         <section anchor="this-proposal" title="This Proposal">
            <t>The concept of <spanx style="verb">selected representation</spanx> defined in <xref target="SEMANTICS" x:fmt="of" x:sec="7"><?aug-anchor representations?><?aug-title Representations?></xref> makes <xref target="RFC3230"/> definitions inconsistent with current HTTP semantics. This document updates the <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> field definitions to align with <xref target="SEMANTICS"/> concepts.</t>
            <t>Basing <spanx style="verb">Digest</spanx> on the selected representation makes it straightforward to apply it to use-cases where the transferred data does require some sort of manipulation to be considered a representation, or conveys a partial representation of a resource eg. Range Requests (see <xref target="SEMANTICS" x:fmt="of" x:sec="13.2"><?aug-anchor field.range?><?aug-title Range?></xref>).</t>
            <t>Changes are semantically compatible with existing implementations and better cover both the request and response cases.</t>
            <t>The value of <spanx style="verb">Digest</spanx> is calculated on selected representation, which is tied to the value contained in any <spanx style="verb">Content-Encoding</spanx> or <spanx style="verb">Content-Type</spanx> header fields. Therefore, a given resource may have multiple different digest values.</t>
            <t>To allow both parties to exchange a Digest of a representation with no content codings (see <xref target="SEMANTICS" x:fmt="of" x:sec="7.5.1"><?aug-anchor content.codings?><?aug-title Content Codings?></xref>) two more digest-algorithms are added ("id-sha-256" and "id-sha-512").</t>
         </section>
         <section anchor="goals" title="Goals">
            <t>The goals of this proposal are:</t>
            <t>
               <list style="numbers">
                  <t>Digest coverage for either the resource's <spanx style="verb">representation data</spanx> or <spanx style="verb">selected representation data</spanx> communicated via HTTP.</t>
                  <t>Support for multiple digest-algorithms.</t>
                  <t>Negotiation of the use of digests.</t>
               </list>
            </t>
            <t>The goals do not include:</t>
            <t>
               <list style="hanging">
                  <t hangText="HTTP message integrity:">The digest mechanism described here does not cover the full HTTP message nor its semantic, as representation metadata are not included in the checksum.</t>
                  <t hangText="HTTP field integrity:">The digest mechanisms described here cover only representation and selected representation data, and do not protect the integrity of associated representation metadata or other message fields.</t>
                  <t hangText="Authentication:">The digest mechanisms described here are not meant to support authentication of the source of a digest or of a message or anything else. These mechanisms, therefore, are not a sufficient defense against many kinds of malicious attacks.</t>
                  <t hangText="Privacy:">Digest mechanisms do not provide message privacy.</t>
                  <t hangText="Authorization:">The digest mechanisms described here are not meant to support authorization or other kinds of access controls.</t>
               </list>
            </t>
         </section>
         <section anchor="notational-conventions" title="Notational Conventions">
            <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 (<xref target="RFC2119"/> and <xref target="RFC8174"/>) when, and only when, they appear in all capitals, as shown here.</t>
            <t>This document uses the Augmented BNF defined in <xref target="RFC5234"/> and updated by <xref target="RFC7405"/> along with the "#rule" extension defined in <xref target="SEMANTICS" x:fmt="of" x:sec="5.7.1"><?aug-anchor abnf.extension?><?aug-title Lists (#rule ABNF Extension)?></xref>.</t>
            <t>The definitions "representation", "selected representation", "representation data", "representation metadata", and "payload body" in this document are to be interpreted as described in <xref target="SEMANTICS"/>.</t>
            <t>Algorithm names respect the casing used in their definition document (eg. SHA-1, CRC32c) whereas digest-algorithm tokens are quoted (eg. "sha", "crc32c").</t>
         </section>
      </section>
      <section anchor="representation-digest" title="Representation Digest">
         <t>The representation digest is an integrity mechanism for HTTP resources which uses a checksum that is calculated independently of the payload body (see <xref target="SEMANTICS" x:fmt="of" x:sec="5.5.4"><?aug-anchor payload.body?><?aug-title Payload Body?></xref>). It uses the representation data (see <xref target="SEMANTICS" x:fmt="of" x:sec="7.2"><?aug-anchor representation.data?><?aug-title Data?></xref>), that can be fully or partially contained in the payload body, or not contained at all:</t>
         <figure>
            <artwork>
   representation-data := Content-Encoding( Content-Type( bits ) )
</artwork>
         </figure>
         <t>This takes into account the effect of the HTTP semantics on the messages; for example the payload body can be affected by Range Requests or methods such as HEAD, while the way the payload body is transferred "on the wire" is dependent on other transformations (eg. transfer codings for HTTP/1.1 see 6.1 of <xref target="HTTP11"/>): <xref target="resource-representation"/> contains several examples to help illustrate those effects.</t>
         <t>A representation digest consists of the value of a checksum computed on the entire selected <spanx style="verb">representation data</spanx> (see <xref target="SEMANTICS" x:fmt="of" x:sec="7"><?aug-anchor representations?><?aug-title Representations?></xref>) of a resource identified according to <xref target="SEMANTICS" x:fmt="of" x:sec="5.5.2"><?aug-anchor identifying.payload?><?aug-title Identification?></xref> together with an indication of the algorithm used</t>
         <figure>
            <artwork type="abnf">
   representation-data-digest = digest-algorithm "="
                                &lt;encoded digest output&gt;
</artwork>
         </figure>
         <t>The checksum is computed using one of the digest-algorithms listed in <xref target="algorithms"/> and then encoded in the associated format.</t>
         <t>The example below shows the "sha-256" digest-algorithm which uses base64 encoding.</t>
         <figure>
            <artwork type="example">
   sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
</artwork>
         </figure>
      </section>
      <section anchor="digest" title="The Digest Field">
         <t>The <spanx style="verb">Digest</spanx> field contains a list of one or more representation digest values as defined in <xref target="representation-digest"/>. It can be used in both request and response.</t>
         <figure>
            <artwork type="abnf">
   Digest = "Digest" ":" OWS 1#representation-data-digest
</artwork>
         </figure>
         <t>The relationship between <spanx style="verb">Content-Location</spanx> (see <xref target="SEMANTICS" x:fmt="of" x:sec="7.8"><?aug-anchor field.content-location?><?aug-title Content-Location?></xref>) and <spanx style="verb">Digest</spanx> is demonstrated in <xref target="post-not-request-uri"/>. A comprehensive set of examples showing the impacts of representation metadata, payload transformations and HTTP methods on Digest is provided in <xref target="examples-unsolicited"/> and <xref target="examples-solicited"/>.</t>
         <t>A <spanx style="verb">Digest</spanx> field MAY contain multiple representation-data-digest values. For example, a server may provide representation-data-digest values using different algorithms, allowing it to support a population of clients with different evolving capabilities; this is particularly useful in support of transitioning away from weaker algorithms should the need arise (see <xref target="algorithm-agility"/>).</t>
         <t>A recipient MAY ignore any or all of the representation-data-digests in a Digest field. This allows the recipient to choose which digest-algorithm(s) to use for validation instead of verifying every received representation-data-digest.</t>
         <t>A sender MAY send a representation-data-digest using a digest-algorithm without knowing whether the recipient supports the digest-algorithm, or even knowing that the recipient will ignore it.</t>
         <t>
            <spanx style="verb">Digest</spanx> can be sent in a trailer section. When using incremental digest-algorithms this allows the sender and the receiver to dynamically compute the digest value while streaming the content.</t>
         <t>Two examples of its use are</t>
         <figure>
            <artwork type="example">
   Digest: id-sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                      AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==

   Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
           id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
</artwork>
         </figure>
      </section>
      <section anchor="want-digest" title="The Want-Digest Field">
         <t>The <spanx style="verb">Want-Digest</spanx> field indicates the sender's desire to receive a representation digest on messages associated with the request URI and representation metadata.</t>
         <figure>
            <artwork>
   Want-Digest = "Want-Digest" ":" OWS 1#want-digest-value
   want-digest-value = digest-algorithm [ ";" "q" "=" qvalue]
   qvalue = ( "0"  [ "."  0*1DIGIT ] ) /
            ( "1"  [ "."  0*1( "0" ) ] )
</artwork>
         </figure>
         <t>If a digest-algorithm is not accompanied by a "qvalue", it is treated as if its associated "qvalue" were 1.0.</t>
         <t>The sender is willing to accept a digest-algorithm if and only if it is listed in a <spanx style="verb">Want-Digest</spanx> field of a message, and its "qvalue" is non-zero.</t>
         <t>If multiple acceptable digest-algorithm values are given, the sender's preferred digest-algorithm is the one (or ones) with the highest "qvalue".</t>
         <t>Two examples of its use are</t>
         <figure>
            <artwork>
   Want-Digest: sha-256
   Want-Digest: sha-512;q=0.3, sha-256;q=1, unixsum;q=0
</artwork>
         </figure>
      </section>
      <section anchor="algorithms" title="Digest Algorithm Values">
         <t>Digest-algorithm values are used to indicate a specific digest computation.</t>
         <figure>
            <artwork>
   digest-algorithm = token
</artwork>
         </figure>
         <t>All digest-algorithm values are case-insensitive but the lower case is preferred.</t>
         <t>The Internet Assigned Numbers Authority (IANA) acts as a registry for digest-algorithm values. The registry contains the tokens listed below.</t>
         <t>Some digest-algorithms, although registered, rely on vulnerable algorithms: the "md5" digest-algorithm MUST NOT be used due to collision attacks <xref target="CMU-836068"/> and the "sha" digest-algorithm MUST NOT be used due to collision attacks <xref target="IACR-2020-014"/>.</t>
         <t>
            <list style="hanging">
               <t hangText="sha-256">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The SHA-256 algorithm <xref target="RFC6234"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>.</t>
                     <t>Reference: <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="sha-512">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The SHA-512 algorithm <xref target="RFC6234"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>.</t>
                     <t>Reference: <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="md5">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The MD5 algorithm, as specified in <xref target="RFC1321"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>. This digest-algorithm MUST NOT be used as it's now vulnerable to collision attacks <xref target="CMU-836068"/>.</t>
                     <t>Reference: <xref target="RFC1321"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: deprecated</t>
                  </list>
               </t>
               <t hangText="sha">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The SHA-1 algorithm <xref target="RFC3174"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>. This digest-algorithm MUST NOT be used as it's now vulnerable to collision attacks <xref target="IACR-2020-014"/>.</t>
                     <t>Reference: <xref target="RFC3174"/>, <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: deprecated</t>
                  </list>
               </t>
               <t hangText="unixsum">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The algorithm computed by the UNIX "sum" command, as defined by the Single UNIX Specification, Version 2 <xref target="UNIX"/>. The output of this algorithm is an ASCII decimal-digit string representing the 16-bit checksum, which is the first word of the output of the UNIX "sum" command.</t>
                     <t>Reference: <xref target="UNIX"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="unixcksum">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The algorithm computed by the UNIX "cksum" command, as defined by the Single UNIX Specification, Version 2 <xref target="UNIX"/>. The output of this algorithm is an ASCII digit string representing the 32-bit CRC, which is the first word of the output of the UNIX "cksum" command.</t>
                     <t>Reference: <xref target="UNIX"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
            </list>
         </t>
         <t>To allow sender and recipient to provide a checksum which is independent from <spanx style="verb">Content-Encoding</spanx>, the following additional digest-algorithms are defined:</t>
         <t>
            <list style="hanging">
               <t hangText="id-sha-512">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The sha-512 digest of the representation-data of the resource when no content coding is applied</t>
                     <t>Reference: <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="id-sha-256">
                  <vspace blankLines="0"/>
                  <list style="symbols">
                     <t>Description: The sha-256 digest of the representation-data of the resource when no content coding is applied</t>
                     <t>Reference: <xref target="RFC6234"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
            </list>
         </t>
         <t>If other digest-algorithm values are defined, the associated encoding MUST either be represented as a quoted string, or MUST NOT include ";" or "," in the character sets used for the encoding.</t>
      </section>
      <section anchor="acting-on-resources"
               title="Use of Digest when acting on resources">
         <t>POST and PATCH requests can appear to convey partial representations but are semantically acting on resources. The enclosed representation, including its metadata refers to that action.</t>
         <t>In these requests the representation digest MUST be computed on the representation-data of that action. This is the only possible choice because representation digest requires complete representation metadata (see <xref target="representation-digest"/>).</t>
         <t>In responses,</t>
         <t>
            <list style="symbols">
               <t>if the representation describes the status of the request, <spanx style="verb">Digest</spanx> MUST be computed on the enclosed representation (see <xref target="post-referencing-action"/> );</t>
               <t>if there is a referenced resource <spanx style="verb">Digest</spanx> MUST be computed on the selected representation of the referenced resource even if that is different from the target resource. That might or might not result in computing <spanx style="verb">Digest</spanx> on the enclosed representation.</t>
            </list>
         </t>
         <t>The latter case might be done according to the HTTP semantics of the given method, for example using the <spanx style="verb">Content-Location</spanx> header field. In contrast, the <spanx style="verb">Location</spanx> header field does not affect <spanx style="verb">Digest</spanx> because it is not representation metadata.</t>
         <section anchor="digest-and-patch" title="Digest and PATCH">
            <t>In PATCH requests the representation digest MUST be computed on the patch document because the representation metadata refers to the patch document and not to the target resource (see <xref target="RFC5789" x:fmt="of" x:sec="2"/>).</t>
            <t>In PATCH responses the representation digest MUST be computed on the selected representation of the patched resource.</t>
            <t>
               <spanx style="verb">Digest</spanx> usage with PATCH is thus very similar to the POST one, but with the resource's own semantic partly implied by the method and by the patch document.</t>
         </section>
      </section>
      <section anchor="deprecate-contentMD5"
               title="Deprecate Negotiation of Content-MD5">
         <t>This RFC deprecates the negotiation of Content-MD5 as it has been obsoleted by <xref target="RFC7231"/>. The <spanx style="verb">contentMD5</spanx> token defined in <xref target="RFC3230" x:fmt="of" x:sec="5"/> MUST NOT be used as a digest-algorithm.</t>
      </section>
      <section anchor="obsolete-parameters"
               title="Obsolete Digest Header Field Parameters">
         <t>This document obsoletes the usage of parameters with <spanx style="verb">Digest</spanx> introduced in Section <xref target="RFC3230" x:fmt="number" x:sec="4.1.1"/> and <xref target="RFC3230" x:fmt="number" x:sec="4.2"/> of <xref target="RFC3230"/> because this feature has not been widely deployed and complicates field-value processing.</t>
         <t>Field parameters provided a common way to attach additional information to a representation-data-digest, but if they are used as an input to validate the checksum, an attacker could alter them to steer the validation behavior.</t>
         <t>A digest-algorithm can still be parameterized defining its own way to encode parameters into the representation-data-digest in such a way as to mitigate security risks related to its computation.</t>
      </section>
      <section anchor="relationship-to-subresource-integrity-sri"
               title="Relationship to Subresource Integrity (SRI)">
         <t>Subresource Integrity <xref target="SRI"/> is an integrity mechanism that shares some similarities to the present document's mechanism. However, there are differences in motivating factors, threat model and specification of integrity digest generation, signalling and validation.</t>
         <t>SRI allows a first-party authority to declare an integrity assertion on a resource served by a first or third party authority. This is done via the <spanx style="verb">integrity</spanx> attribute that can be added to <spanx style="verb">script</spanx> or <spanx style="verb">link</spanx> HTML elements. Therefore, the integrity assertion is always made out-of-band to the resource fetch. In contrast, the <spanx style="verb">Digest</spanx> field is supplied in-band alongside the selected representation, meaning that an authority can only declare an integrity assertion for itself. Methods to improve the security properties of representation digests are presented in <xref target="security-considerations"/>. This contrast is interesting because on one hand self-assertion is less likely to be affected by coordination problems such as the first-party holding stale information about the third party, but on the other hand the self-assertion is only as trustworthy as the authority that provided it.</t>
         <t>The SRI <spanx style="verb">integrity</spanx> attribute contains a cryptographic hash algorithm and digest value which is similar to <spanx style="verb">representation-data-digest</spanx> (see <xref target="representation-digest"/>). The major differences are in serialization format.</t>
         <t>The SRI digest value is calculated over the identity encoding of the resource, not the selected representation (as specified for <spanx style="verb">representation-data-digest</spanx> in this document). Section 3.4.5 of <xref target="SRI"/> describes the benefit of the identity approach - the SRI <spanx style="verb">integrity</spanx> attribute can contain multiple algorithm-value pairs where each applies to a different identity encoded payload. This allows for protection of distinct resources sharing a URL. However, this is a contrast to the design of representation digests, where multiple <spanx style="verb">Digest</spanx> field-values all protect the same representation.</t>
         <t>SRI does not specify handling of partial representation data (e.g. Range requests). In contrast, this document specifies handling in terms that are fully compatible with core HTTP concepts (an example is provided in <xref target="server-returns-partial-representation-data"/>).</t>
         <t>SRI specifies strong requirements on the selection of algorithm for generation and validation of digests. In contrast, the requirements in this document are weaker.</t>
         <t>SRI defines no method for a client to declare an integrity assertion on resources it transfers to a server. In contrast, the <spanx style="verb">Digest</spanx> field can appear on requests.</t>
         <section anchor="supporting-both-sri-and-representation-digest"
                  title="Supporting Both SRI and Representation Digest">
            <t>The SRI and Representation Digest mechanisms are different and complementary but one is not capable of replacing the other because they have different threat, security and implementation properties.</t>
            <t>A user agent that supports both mechanisms is expected to apply the rules specified for each but since the two mechanisms are independent, the ordering is not important. However, a user agent supporting both could benefit from performing representation digest validation first because it does not always require a conversion into identity encoding.</t>
            <t>There is a chance that a user agent supporting both mechanisms may find one validates successfully while the other fails. This document specifies no requirements or guidance for user agents that experience such cases.</t>
         </section>
      </section>
      <section anchor="examples-unsolicited" title="Examples of Unsolicited Digest">
         <t>The following examples demonstrate interactions where a server responds with a <spanx style="verb">Digest</spanx> field even though the client did not solicit one using <spanx style="verb">Want-Digest</spanx>.</t>
         <section anchor="example-full-representation"
                  title="Server Returns Full Representation Data">
            <t>Request:</t>
            <figure>
               <artwork>
GET /items/123

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</artwork>
            </figure>
         </section>
         <section anchor="server-returns-no-representation-data"
                  title="Server Returns No Representation Data">
            <t>Requests without a payload body can still send a <spanx style="verb">Digest</spanx> field applying the digest-algorithm to an empty representation.</t>
            <t>As there is no content coding applied, the "sha-256" and the "id-sha-256" digest-values in the response are the same.</t>
            <t>Request:</t>
            <figure>
               <artwork>
HEAD /items/123 HTTP/1.1
Digest: sha-256=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Digest: id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

</artwork>
            </figure>
         </section>
         <section anchor="server-returns-partial-representation-data"
                  title="Server Returns Partial Representation Data">
            <t>Request:</t>
            <figure>
               <artwork>
GET /items/123
Range: bytes=1-7

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 206 Partial Content
Content-Type: application/json
Content-Range: bytes 1-7/18
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

"hello"
</artwork>
            </figure>
         </section>
         <section anchor="client-and-server-provide-full-representation-data"
                  title="Client and Server Provide Full Representation Data">
            <t>The request contains a <spanx style="verb">Digest</spanx> field calculated on the enclosed representation.</t>
            <t>It also includes an <spanx style="verb">Accept-Encoding: br</spanx> header field that advertises the client supports brotli encoding.</t>
            <t>The response includes a <spanx style="verb">Content-Encoding: br</spanx> that indicates the selected representation is brotli encoded. The <spanx style="verb">Digest</spanx> field-value is therefore different compared to the request.</t>
            <t>The response body is displayed as a base64-encoded string because it contains non-printable characters.</t>
            <t>Request:</t>
            <figure>
               <artwork>
PUT /items/123
Content-Type: application/json
Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
Content-Type: application/json
Content-Encoding: br
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
</artwork>
            </figure>
         </section>
         <section anchor="client-provides-full-representation-data-server-provides-no-representation-data"
                  title="Client Provides Full Representation Data, Server Provides No Representation Data">
            <t>Request <spanx style="verb">Digest</spanx> value is calculated on the enclosed payload. Response <spanx style="verb">Digest</spanx> value depends on the representation metadata header fields, including <spanx style="verb">Content-Encoding: br</spanx> even when the response does not contain a payload body.</t>
            <t>Request:</t>
            <figure>
               <artwork>
PUT /items/123
Content-Type: application/json
Content-Length: 18
Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 204 No Content
Content-Type: application/json
Content-Encoding: br
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

</artwork>
            </figure>
         </section>
         <section anchor="client-and-server-provide-full-representation-data-client-uses-id-sha-256"
                  title="Client and Server Provide Full Representation Data, Client Uses id-sha-256.">
            <t>The response contains two digest values:</t>
            <t>
               <list style="symbols">
                  <t>one with no content coding applied, which in this case accidentally matches the unencoded digest-value sent in the request;</t>
                  <t>one taking into account the <spanx style="verb">Content-Encoding</spanx>.</t>
               </list>
            </t>
            <t>As the response body contains non-printable characters, it is displayed as a base64-encoded string.</t>
            <t>Request:</t>
            <figure>
               <artwork>
PUT /items/123 HTTP/1.1
Content-Type: application/json
Accept-Encoding: br
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: br
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
        id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
</artwork>
            </figure>
         </section>
         <section anchor="post-not-request-uri"
                  title="POST Response does not Reference the Request URI">
            <t>Request <spanx style="verb">Digest</spanx> value is computed on the enclosed representation (see <xref target="acting-on-resources"/>).</t>
            <t>The representation enclosed in the response refers to the resource identified by <spanx style="verb">Content-Location</spanx> (see <xref target="SEMANTICS" x:fmt="," x:sec="5.5.2"><?aug-anchor identifying.payload?><?aug-title Identification?></xref>).</t>
            <t>
               <spanx style="verb">Digest</spanx> is thus computed on the enclosed representation.</t>
            <t>Request:</t>
            <figure>
               <artwork>
POST /books HTTP/1.1
Content-Type: application/json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=

{"title": "New Title"}
</artwork>
            </figure>
            <t>Response</t>
            <figure>
               <artwork>
HTTP/1.1 201 Created
Content-Type: application/json
Digest: id-sha-256=BZlF2v0IzjuxN01RQ97EUXriaNNLhtI8Chx8Eq+XYSc=
Content-Location: /books/123

{"id": "123", "title": "New Title"}
</artwork>
            </figure>
            <t>Note that a <spanx style="verb">204 No Content</spanx> response without a payload body but with the same <spanx style="verb">Digest</spanx> field-value would have been legitimate too.</t>
         </section>
         <section anchor="post-referencing-action"
                  title="POST Response Describes the Request Status">
            <t>Request <spanx style="verb">Digest</spanx> value is computed on the enclosed representation (see <xref target="acting-on-resources"/>).</t>
            <t>The representation enclosed in the response describes the status of the request, so <spanx style="verb">Digest</spanx> is computed on that enclosed representation.</t>
            <t>Response <spanx style="verb">Digest</spanx> has no explicit relation with the resource referenced by <spanx style="verb">Location</spanx>.</t>
            <t>Request:</t>
            <figure>
               <artwork>
POST /books HTTP/1.1
Content-Type: application/json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=
Location: /books/123

{"title": "New Title"}
</artwork>
            </figure>
            <t>Response</t>
            <figure>
               <artwork>
HTTP/1.1 201 Created
Content-Type: application/json
Digest: id-sha-256=0o/WKwSfnmIoSlop2LV/ISaBDth05IeW27zzNMUh5l8=
Location: /books/123

{
  "status": "created",
  "id": "123",
  "ts": 1569327729,
  "instance": "/books/123"
}
</artwork>
            </figure>
         </section>
         <section anchor="digest-with-patch" title="Digest with PATCH">
            <t>This case is analogous to a POST request where the target resource reflects the effective request URI.</t>
            <t>The PATCH request uses the <spanx style="verb">application/merge-patch+json</spanx> media type defined in <xref target="RFC7396"/>.</t>
            <t>
               <spanx style="verb">Digest</spanx> is calculated on the enclosed payload, which corresponds to the patch document.</t>
            <t>The response <spanx style="verb">Digest</spanx> is computed on the complete representation of the patched resource.</t>
            <t>Request:</t>
            <figure>
               <artwork>
PATCH /books/123 HTTP/1.1
Content-Type: application/merge-patch+json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=

{"title": "New Title"}
</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Digest: id-sha-256=BZlF2v0IzjuxN01RQ97EUXriaNNLhtI8Chx8Eq+XYSc=

{"id": "123", "title": "New Title"}
</artwork>
            </figure>
            <t>Note that a <spanx style="verb">204 No Content</spanx> response without a payload body but with the same <spanx style="verb">Digest</spanx> field-value would have been legitimate too.</t>
         </section>
         <section anchor="error-responses" title="Error responses">
            <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 attempts 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 digest of the response is computed on this enclosed representation.</t>
            <t>Request:</t>
            <figure>
               <artwork>
PATCH /books/123 HTTP/1.1
Content-Type: application/merge-patch+json
Accept: application/json
Accept-Encoding: identity
Digest: sha-256=bWopGGNiZtbVgHsG+I4knzfEJpmmmQHf7RHDXA3o1hQ=

{"title": "New Title"}
</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Digest: sha-256=UJSojgEzqUe4UoHzmNl5d2xkmrW3BOdmvsvWu1uFeu0=

{
  "title": "Not Found",
  "detail": "Cannot PATCH a non-existent resource",
  "status": 404
}
</artwork>
            </figure>
         </section>
         <section anchor="use-with-trailers-and-transfer-coding"
                  title="Use with trailers and transfer coding">
            <t>An origin server sends <spanx style="verb">Digest</spanx> in the HTTP trailer, so it can calculate digest-value while streaming content and thus mitigate resource consumption. The field value is the same as in <xref target="example-full-representation"/> because <spanx style="verb">Digest</spanx> is designed to be independent from the use of one or more transfer codings (see <xref target="representation-digest"/>).</t>
            <t>Request:</t>
            <figure>
               <artwork>
GET /items/123

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Trailer: Digest

8\r\n
{"hello"\r\n
8
: "world\r\n
2\r\n
"}\r\n
0\r\n
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

</artwork>
            </figure>
         </section>
      </section>
      <section anchor="examples-solicited"
               title="Examples of Want-Digest Solicited Digest">
         <t>The following examples demonstrate interactions where a client solicits a <spanx style="verb">Digest</spanx> using <spanx style="verb">Want-Digest</spanx>.</t>
         <section anchor="server-selects-clients-least-preferred-algorithm"
                  title="Server Selects Client's Least Preferred Algorithm">
            <t>The client requests a digest, preferring "sha". The server is free to reply with "sha-256" anyway.</t>
            <t>Request:</t>
            <figure>
               <artwork>
GET /items/123 HTTP/1.1
Want-Digest: sha-256;q=0.3, sha;q=1

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

{"hello": "world"}
</artwork>
            </figure>
         </section>
         <section anchor="server-selects-algorithm-unsupported-by-client"
                  title="Server Selects Algorithm Unsupported by Client">
            <t>The client requests a sha digest only. The server is currently free to reply with a Digest containing an unsupported algorithm.</t>
            <t>Request:</t>
            <figure>
               <artwork>
GET /items/123
Want-Digest: sha;q=1

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Digest: id-sha-512=WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2svX+TaPm
                   +AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==

{"hello": "world"}
</artwork>
            </figure>
         </section>
         <section anchor="server-does-not-support-client-algorithm-and-returns-an-error"
                  title="Server Does Not Support Client Algorithm and Returns an Error">
            <t>The client requests a sha Digest, the server advises for sha-256 and sha-512</t>
            <t>Request:</t>
            <figure>
               <artwork>
GET /items/123
Want-Digest: sha;q=1

</artwork>
            </figure>
            <t>Response:</t>
            <figure>
               <artwork>
HTTP/1.1 400 Bad Request
Want-Digest: sha-256, sha-512

</artwork>
            </figure>
         </section>
      </section>
      <section anchor="security-considerations" title="Security Considerations">
         <section anchor="digest-does-not-protect-the-full-http-message"
                  title="Digest Does Not Protect the Full HTTP Message">
            <t>This document specifies a data integrity mechanism that protects HTTP <spanx style="verb">representation data</spanx>, but not HTTP <spanx style="verb">representation metadata</spanx> fields, from certain kinds of accidental corruption.</t>
            <t>
               <spanx style="verb">Digest</spanx> is not intended as general protection against malicious tampering with HTTP messages, this can be achieved by combining it with other approaches such as transport-layer security or digital signatures.</t>
         </section>
         <section anchor="broken-cryptographic-algorithms"
                  title="Broken Cryptographic Algorithms">
            <t>Cryptographic algorithms are intended to provide a proof of integrity suited towards cryptographic constructions such as signatures.</t>
            <t>However, these rely on collision-resistance for their security proofs <xref target="CMU-836068"/>. The "md5" and "sha" digest-algorithms are vulnerable to collisions attacks, so they MUST NOT be used with <spanx style="verb">Digest</spanx>.</t>
         </section>
         <section anchor="other-deprecated-algorithms"
                  title="Other Deprecated Algorithms">
            <t>The ADLER32 algorithm defined in <xref target="RFC1950"/> has been deprecated by <xref target="RFC3309"/> because under certain conditions it provides weak detection of errors and is now NOT RECOMMENDED for use with <spanx style="verb">Digest</spanx>.</t>
         </section>
         <section anchor="digest-for-end-to-end-integrity"
                  title="Digest for End-to-End Integrity">
            <t>
               <spanx style="verb">Digest</spanx> alone does not provide end-to-end integrity of HTTP messages over multiple hops, as it just covers the <spanx style="verb">representation data</spanx> and not the <spanx style="verb">representation metadata</spanx>.</t>
            <t>Besides, it allows to protect <spanx style="verb">representation data</spanx> from buggy manipulation, buggy compression, etc.</t>
            <t>Moreover identity digest-algorithms (eg. "id-sha-256" and "id-sha-512") allow piecing together a resource from different sources (e.g. different servers that perhaps apply different content codings) enabling the user-agent to detect that the application-layer tasks completed properly, before handing off to say the HTML parser, video player etc.</t>
            <t>Even a simple mechanism for end-to-end validation is thus valuable.</t>
         </section>
         <section anchor="digest-and-content-location"
                  title="Digest and Content-Location in responses">
            <t>When a state-changing method returns the <spanx style="verb">Content-Location</spanx> header field, the enclosed representation refers to the resource identified by its value and <spanx style="verb">Digest</spanx> is computed accordingly.</t>
         </section>
         <section anchor="usage-in-signatures" title="Usage in signatures">
            <t>Digital signatures are widely used together with checksums to provide the certain identification of the origin of a message <xref target="NIST800-32"/>. Such signatures can protect one or more HTTP fields and there are additional considerations when <spanx style="verb">Digest</spanx> is included in this set.</t>
            <t>Since the <spanx style="verb">Digest</spanx> field is a hash of a resource representation, it explicitly depends on the <spanx style="verb">representation metadata</spanx> (eg. the values of <spanx style="verb">Content-Type</spanx>, <spanx style="verb">Content-Encoding</spanx> etc). A signature that protects <spanx style="verb">Digest</spanx> but not other <spanx style="verb">representation metadata</spanx> can expose the communication to tampering. For example, an actor could manipulate the <spanx style="verb">Content-Type</spanx> field-value and cause a digest validation failure at the recipient, preventing the application from accessing the representation. Such an attack consumes the resources of both endpoints. See also <xref target="digest-and-content-location"/>.</t>
            <t>
               <spanx style="verb">Digest</spanx> SHOULD always be used over a connection which provides integrity at the transport layer that protects HTTP fields.</t>
            <t>A <spanx style="verb">Digest</spanx> field using NOT RECOMMENDED digest-algorithms SHOULD NOT be used in signatures.</t>
            <t>Using signatures to protect the <spanx style="verb">Digest</spanx> of an empty representation allows receiving endpoints to detect if an eventual payload has been stripped or added.</t>
         </section>
         <section anchor="usage-in-trailers" title="Usage in trailers">
            <t>When used in trailers, the receiver gets the digest value after the payload body and may thus be tempted to process the data before validating the digest value. Instead, data should only be processed after validating the Digest.</t>
            <t>If received in trailers, <spanx style="verb">Digest</spanx> MUST NOT be discarded; instead it MAY be merged in the header section (See <xref target="SEMANTICS" x:fmt="of" x:sec="5.6.2"><?aug-anchor trailers.limitations?><?aug-title Limitations?></xref>).</t>
            <t>Not every digest-algorithm is suitable for trailers, as they may require to pre-process the whole payload before sending a message (eg. see <xref target="I-D.thomson-http-mice"/>).</t>
         </section>
         <section anchor="usage-with-encryption" title="Usage with encryption">
            <t>
               <spanx style="verb">Digest</spanx> may expose information details of encrypted payload when the checksum is computed on the unencrypted data. An example of that is the use of the "id-sha-256" digest-algorithm in conjunction with the encrypted content-coding <xref target="RFC8188"/>.</t>
            <t>The representation-data-digest of an encrypted payload can change between different messages depending on the encryption algorithm used; in those cases its value could not be used to provide a proof of integrity "at rest" unless the whole (e.g. encoded) payload body is persisted.</t>
         </section>
         <section anchor="algorithm-agility" title="Algorithm Agility">
            <t>The security properties of digest-algorithms are not fixed. Algorithm Agility (see <xref target="RFC7696"/>) is achieved by providing implementations flexibility in their choice of digest-algorithm from the IANA Digest Algorithm Values registry in <xref target="iana-digest-algorithm-registry"/>.</t>
            <t>To help endpoints understand weaker algorithms from stronger ones, this document adds to the IANA Digest Algorithm Values registry a new "Status" field containing the most-recent appraisal of the digest-algorithm; the allowed values are specified in <xref target="iana-digest-algorithm-status"/>.</t>
            <t>An endpoint might have a preference for algorithms, such as preferring "standard" algorithms over "deprecated" ones. Transition from weak algorithms is supported by negotiation of digest-algorithm using <spanx style="verb">Want-Digest</spanx> (see <xref target="want-digest"/>) or by sending multiple representation-data-digest values from which the receiver chooses. Endpoints are advised that sending multiple values consumes resources, which may be wasted if the receiver ignores them (see <xref target="digest"/>).</t>
         </section>
      </section>
      <section anchor="iana-considerations" title="IANA Considerations">
         <section anchor="iana-digest-algorithm-registry"
                  title="Establish the HTTP Digest Algorithm Values">
            <t>This memo sets this spec to be the establishing document for the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref>
            </t>
         </section>
         <section anchor="iana-digest-algorithm-status"
                  title="The &#34;status&#34; Field in the HTTP Digest Algorithm Values">
            <t>This memo adds the field "Status" to the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry. The allowed values for the "Status" fields are described below.</t>
            <t>
               <list style="hanging">
                  <t hangText="Status">
                     <vspace blankLines="0"/>
                     <list style="symbols">
                        <t>"standard" for standardized algorithms without known problems;</t>
                        <t>"experimental", "obsoleted" or some other appropriate value - e.g. according to the type and status of the primary document in which the algorithm is defined;</t>
                        <t>"deprecated" when the algorithm is insecure or otherwise undesirable.</t>
                     </list>
                  </t>
               </list>
            </t>
         </section>
         <section anchor="iana-md5" title="Deprecate &#34;MD5&#34; Digest Algorithm">
            <t>This memo updates the "MD5" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: md5</t>
                  <t>Description: As specified in <xref target="algorithms"/>.</t>
                  <t>Status: As specified in <xref target="algorithms"/>.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-unixsum" title="Update &#34;UNIXsum&#34; Digest Algorithm">
            <t>This memo updates the "UNIXsum" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: As specified in <xref target="algorithms"/>.</t>
                  <t>Description: As specified in <xref target="algorithms"/>.</t>
                  <t>Status: As specified in <xref target="algorithms"/>.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-unixcksum" title="Update &#34;UNIXcksum&#34; Digest Algorithm">
            <t>This memo updates the "UNIXcksum" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: As specified in <xref target="algorithms"/>.</t>
                  <t>Description: As specified in <xref target="algorithms"/>.</t>
                  <t>Status: As specified in <xref target="algorithms"/>.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-crc32c" title="Update &#34;CRC32c&#34; Digest Algorithm">
            <t>This memo updates the "CRC32c" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: crc32c</t>
                  <t>Description: The CRC32c algorithm is a 32-bit cyclic redundancy check. It achieves a better hamming distance (for better error-detection performance) than many other 32-bit CRC functions. Other places it is used include iSCSI and SCTP. The 32-bit output is encoded in hexadecimal (using between 1 and 8 ASCII characters from 0-9, A-F, and a-f; leading 0's are allowed). For example, crc32c=0a72a4df and crc32c=A72A4DF are both valid checksums for the 3-byte message "dog".</t>
                  <t>Reference: <xref target="RFC4960"/> appendix B, this document.</t>
                  <t>Status: standard.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-sha" title="Deprecate &#34;SHA&#34; Digest Algorithm">
            <t>This memo updates the "SHA" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: sha</t>
                  <t>Description: As specified in <xref target="algorithms"/>.</t>
                  <t>Status: As specified in <xref target="algorithms"/>.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-adler-32" title="Obsolete &#34;ADLER32&#34; Digest Algorithm">
            <t>This memo updates the "ADLER32" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: adler32</t>
                  <t>Description: The ADLER32 algorithm is a checksum specified in <xref target="RFC1950"/> "ZLIB Compressed Data Format". The 32-bit output is encoded in hexadecimal (using between 1 and 8 ASCII characters from 0-9, A-F, and a-f; leading 0's are allowed). For example, adler32=03da0195 and adler32=3DA0195 are both valid checksums for the 4-byte message "Wiki". This algorithm is obsoleted and SHOULD NOT be used.</t>
                  <t>Status: obsoleted</t>
               </list>
            </t>
         </section>
         <section anchor="iana-contentMD5"
                  title="Obsolete &#34;contentMD5&#34; token in Digest Algorithm">
            <t>This memo adds the "contentMD5" token in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: contentMD5</t>
                  <t>Description: <xref target="RFC3230" x:fmt="of" x:sec="5"/> defined the "contentMD5" token to be used only in Want-Digest. This token is obsoleted and MUST NOT be used.</t>
                  <t>Reference: <xref target="iana-contentMD5"/> of this document, <xref target="RFC3230" x:fmt="of" x:sec="5"/>.</t>
                  <t>Status: obsoleted</t>
               </list>
            </t>
         </section>
         <section anchor="iana-id-sha-256" title="The &#34;id-sha-256&#34; Digest Algorithm">
            <t>This memo registers the "id-sha-256" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: id-sha-256</t>
                  <t>Description: As specified in <xref target="algorithms"/>.</t>
                  <t>Status: As specified in <xref target="algorithms"/>.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-id-sha-512" title="The &#34;id-sha-512&#34; Digest Algorithm">
            <t>This memo registers the "id-sha-512" digest-algorithm in the <eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref> registry:</t>
            <t>
               <list style="symbols">
                  <t>Digest Algorithm: id-sha-512</t>
                  <t>Description: As specified in <xref target="algorithms"/>.</t>
                  <t>Status: As specified in <xref target="algorithms"/>.</t>
               </list>
            </t>
         </section>
         <section anchor="changes-compared-to-rfc5843"
                  title="Changes compared to RFC5843">
            <t>The digest-algorithm values for "MD5", "SHA", "SHA-256", "SHA-512", "UNIXcksum", "UNIXsum", "ADLER32" and "CRC32c" have been updated to lowercase.</t>
            <t>The status of "MD5" has been updated to "deprecated", and its description states that this algorithm MUST NOT be used.</t>
            <t>The status of "SHA" has been updated to "deprecated", and its description states that this algorithm MUST NOT be used.</t>
            <t>The status for "CRC2c", "UNIXsum" and "UNIXcksum" has been updated to "standard".</t>
            <t>The "id-sha-256" and "id-sha-512" algorithms have been added to the registry.</t>
         </section>
         <section anchor="want-digest-field-registration"
                  title="Want-Digest Field Registration">
            <t>This section registers the <spanx style="verb">Want-Digest</spanx> field in the "Hypertext Transfer Protocol (HTTP) Field Name Registry" <xref target="SEMANTICS"/>.</t>
            <t>Field name: <spanx style="verb">Want-Digest</spanx>
            </t>
            <t>Status: permanent</t>
            <t>Specification document(s): <xref target="want-digest"/> of this document</t>
         </section>
         <section anchor="digest-header-field-registration"
                  title="Digest Header Field Registration">
            <t>This section registers the <spanx style="verb">Digest</spanx> field in the "Hypertext Transfer Protocol (HTTP) Field Name Registry" <xref target="SEMANTICS"/>.</t>
            <t>Field name: <spanx style="verb">Digest</spanx>
            </t>
            <t>Status: permanent</t>
            <t>Specification document(s): <xref target="digest"/> of this document</t>
         </section>
      </section>
   </middle>
   <back>
      <references title="Normative References">
         <reference anchor="RFC1321">
            <front>
               <title>The MD5 Message-Digest Algorithm</title>
               <author fullname="R. Rivest" initials="R." surname="Rivest"/>
               <date month="April" year="1992"/>
            </front>
            <seriesInfo name="RFC" value="1321"/>
            <seriesInfo name="DOI" value="10.17487/RFC1321"/>
         </reference>
         <reference anchor="RFC3174">
            <front>
               <title>US Secure Hash Algorithm 1 (SHA1)</title>
               <author fullname="D. Eastlake 3rd" initials="D." surname="Eastlake 3rd"/>
               <author fullname="P. Jones" initials="P." surname="Jones"/>
               <date month="September" year="2001"/>
            </front>
            <seriesInfo name="RFC" value="3174"/>
            <seriesInfo name="DOI" value="10.17487/RFC3174"/>
         </reference>
         <reference anchor="RFC1950">
            <front>
               <title>ZLIB Compressed Data Format Specification version 3.3</title>
               <author fullname="P. Deutsch" initials="P." surname="Deutsch"/>
               <author fullname="J-L. Gailly" initials="J-L." surname="Gailly"/>
               <date month="May" year="1996"/>
            </front>
            <seriesInfo name="RFC" value="1950"/>
            <seriesInfo name="DOI" value="10.17487/RFC1950"/>
         </reference>
         <reference anchor="RFC3230">
            <front>
               <title>Instance Digests in HTTP</title>
               <author fullname="J. Mogul" initials="J." surname="Mogul"/>
               <author fullname="A. Van Hoff" initials="A." surname="Van Hoff"/>
               <date month="January" year="2002"/>
            </front>
            <seriesInfo name="RFC" value="3230"/>
            <seriesInfo name="DOI" value="10.17487/RFC3230"/>
         </reference>
         <reference anchor="RFC3309">
            <front>
               <title>Stream Control Transmission Protocol (SCTP) Checksum Change</title>
               <author fullname="J. Stone" initials="J." surname="Stone"/>
               <author fullname="R. Stewart" initials="R." surname="Stewart"/>
               <author fullname="D. Otis" initials="D." surname="Otis"/>
               <date month="September" year="2002"/>
            </front>
            <seriesInfo name="RFC" value="3309"/>
            <seriesInfo name="DOI" value="10.17487/RFC3309"/>
         </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="RFC5843">
            <front>
               <title>Additional Hash Algorithms for HTTP Instance Digests</title>
               <author fullname="A. Bryan" initials="A." surname="Bryan"/>
               <date month="April" year="2010"/>
            </front>
            <seriesInfo name="RFC" value="5843"/>
            <seriesInfo name="DOI" value="10.17487/RFC5843"/>
         </reference>
         <reference anchor="RFC4648">
            <front>
               <title>The Base16, Base32, and Base64 Data Encodings</title>
               <author fullname="S. Josefsson" initials="S." surname="Josefsson"/>
               <date month="October" year="2006"/>
            </front>
            <seriesInfo name="RFC" value="4648"/>
            <seriesInfo name="DOI" value="10.17487/RFC4648"/>
         </reference>
         <reference anchor="RFC5234">
            <front>
               <title>Augmented BNF for Syntax Specifications: ABNF</title>
               <author fullname="D. Crocker"
                       initials="D."
                       role="editor"
                       surname="Crocker"/>
               <author fullname="P. Overell" initials="P." surname="Overell"/>
               <date month="January" year="2008"/>
            </front>
            <seriesInfo name="STD" value="68"/>
            <seriesInfo name="RFC" value="5234"/>
            <seriesInfo name="DOI" value="10.17487/RFC5234"/>
         </reference>
         <reference anchor="RFC6234">
            <front>
               <title>US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)</title>
               <author fullname="D. Eastlake 3rd" initials="D." surname="Eastlake 3rd"/>
               <author fullname="T. Hansen" initials="T." surname="Hansen"/>
               <date month="May" year="2011"/>
            </front>
            <seriesInfo name="RFC" value="6234"/>
            <seriesInfo name="DOI" value="10.17487/RFC6234"/>
         </reference>
         <reference anchor="RFC7405">
            <front>
               <title>Case-Sensitive String Support in ABNF</title>
               <author fullname="P. Kyzivat" initials="P." surname="Kyzivat"/>
               <date month="December" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7405"/>
            <seriesInfo name="DOI" value="10.17487/RFC7405"/>
         </reference>
         <reference anchor="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="UNIX">
            <front>
               <title>The Single UNIX Specification, Version 2 - 6 Vol Set for UNIX 98</title>
               <author>
                  <organization>The Open Group</organization>
               </author>
               <date month="February" year="1997"/>
            </front>
         </reference>
         <reference anchor="NIST800-32"
                    target="https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-32.pdf">
            <front>
               <title>Introduction to Public Key Technology and the Federal PKI Infrastructure</title>
               <author>
                  <organization>National Institute of Standards and Technology, U.S. Department of Commerce</organization>
               </author>
               <date month="February" year="2001"/>
            </front>
         </reference>
         <reference anchor="CMU-836068" target="https://www.kb.cert.org/vuls/id/836068/">
            <front>
               <title>MD5 Vulnerable to collision attacks</title>
               <author>
                  <organization>Carnagie Mellon University, Software Engineering Institute</organization>
               </author>
               <date day="31" month="December" year="2008"/>
            </front>
         </reference>
         <reference anchor="IACR-2020-014" target="https://eprint.iacr.org/2020/014.pdf">
            <front>
               <title>SHA-1 is a Shambles</title>
               <author initials="G." surname="Leurent">
                  <organization>Inria, France</organization>
               </author>
               <author initials="T." surname="Peyrin">
                  <organization>Nanyang Technological University, Singapore; Temasek Laboratories, Singapore</organization>
               </author>
               <date day="05" month="January" year="2020"/>
            </front>
         </reference>
         <reference anchor="SEMANTICS">
            <front>
               <title>HTTP Semantics</title>
               <author fullname="Roy Fielding" initials="R" surname="Fielding"/>
               <author fullname="Mark Nottingham" initials="M" surname="Nottingham"/>
               <author fullname="Julian Reschke" initials="J" surname="Reschke"/>
               <date day="2" month="October" year="2020"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-semantics-12"/>
            <x:source basename="draft-ietf-httpbis-semantics-12"
                      href="draft-ietf-httpbis-semantics-12.xml"/>
         </reference>
         <reference anchor="RFC4960">
            <front>
               <title>Stream Control Transmission Protocol</title>
               <author fullname="R. Stewart"
                       initials="R."
                       role="editor"
                       surname="Stewart"/>
               <date month="September" year="2007"/>
            </front>
            <seriesInfo name="RFC" value="4960"/>
            <seriesInfo name="DOI" value="10.17487/RFC4960"/>
         </reference>
      </references>
      <references title="Informative References">
         <reference anchor="RFC2818">
            <front>
               <title>HTTP Over TLS</title>
               <author fullname="E. Rescorla" initials="E." surname="Rescorla"/>
               <date month="May" year="2000"/>
            </front>
            <seriesInfo name="RFC" value="2818"/>
            <seriesInfo name="DOI" value="10.17487/RFC2818"/>
         </reference>
         <reference anchor="RFC7231">
            <front>
               <title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
               <author fullname="R. Fielding"
                       initials="R."
                       role="editor"
                       surname="Fielding"/>
               <author fullname="J. Reschke"
                       initials="J."
                       role="editor"
                       surname="Reschke"/>
               <date month="June" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7231"/>
            <seriesInfo name="DOI" value="10.17487/RFC7231"/>
         </reference>
         <reference anchor="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="SRI" target="https://www.w3.org/TR/2016/REC-SRI-20160623/">
            <front>
               <title>Subresource Integrity</title>
               <author initials="D." surname="Akhawe"/>
               <author initials="F." surname="Braun"/>
               <author initials="F." surname="Marier"/>
               <author initials="J." surname="Weinberger"/>
               <date day="23" month="June" year="2016"/>
            </front>
            <seriesInfo name="W3C Recommendation" value="REC-SRI-20160623"/>
         </reference>
         <reference anchor="HTTP11">
            <front>
               <title>HTTP/1.1 Messaging</title>
               <author fullname="Roy Fielding" initials="R" surname="Fielding"/>
               <author fullname="Mark Nottingham" initials="M" surname="Nottingham"/>
               <author fullname="Julian Reschke" initials="J" surname="Reschke"/>
               <date day="2" month="October" year="2020"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-messaging-12"/>
         </reference>
         <reference anchor="RFC5789">
            <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="RFC7807">
            <front>
               <title>Problem Details for HTTP APIs</title>
               <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
               <author fullname="E. Wilde" initials="E." surname="Wilde"/>
               <date month="March" year="2016"/>
            </front>
            <seriesInfo name="RFC" value="7807"/>
            <seriesInfo name="DOI" value="10.17487/RFC7807"/>
         </reference>
         <reference anchor="I-D.thomson-http-mice">
            <front>
               <title>Merkle Integrity Content Encoding</title>
               <author fullname="Martin Thomson" initials="M" surname="Thomson"/>
               <author fullname="Jeffrey Yasskin" initials="J" surname="Yasskin"/>
               <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="I-D.ietf-httpbis-header-structure">
            <front>
               <title>Structured Field Values for HTTP</title>
               <author fullname="Mark Nottingham" initials="M" surname="Nottingham"/>
               <author fullname="Poul-Henning Kamp" initials="P" surname="Kamp"/>
               <date day="3" month="June" year="2020"/>
            </front>
            <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-header-structure-19"/>
         </reference>
      </references>
      <section anchor="resource-representation"
               title="Resource Representation and Representation-Data">
         <t>The following examples show how representation metadata, payload transformations and method impacts on the message and payload body. When the payload body contains non-printable characters (eg. when it is compressed) it is shown as base64-encoded string.</t>
         <t>A request with a json object without any content coding.</t>
         <t>Request:</t>
         <figure>
            <artwork>
PUT /entries/1234 HTTP/1.1
Content-Type: application/json

{"hello": "world"}
</artwork>
         </figure>
         <t>Here is a gzip-compressed json object using a content coding.</t>
         <t>Request:</t>
         <figure>
            <artwork>
PUT /entries/1234 HTTP/1.1
Content-Type: application/json
Content-Encoding: gzip

H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA=
</artwork>
         </figure>
         <t>Now the same payload body conveys a malformed json object.</t>
         <t>Request:</t>
         <figure>
            <artwork>
PUT /entries/1234 HTTP/1.1
Content-Type: application/json

H4sIAItWyFwC/6tWSlSyUlAypANQqgUAREcqfG0AAAA=
</artwork>
         </figure>
         <t>A Range-Request alters the payload body, conveying a partial representation.</t>
         <t>Request:</t>
         <figure>
            <artwork>
GET /entries/1234 HTTP/1.1
Range: bytes=1-7

</artwork>
         </figure>
         <t>Response:</t>
         <figure>
            <artwork>
HTTP/1.1 206 Partial Content
Content-Encoding: gzip
Content-Type: application/json
Content-Range: bytes 1-7/18

iwgAla3RXA==
</artwork>
         </figure>
         <t>Now the method too alters the payload body.</t>
         <t>Request:</t>
         <figure>
            <artwork>
HEAD /entries/1234 HTTP/1.1
Accept: application/json
Accept-Encoding: gzip

</artwork>
         </figure>
         <t>Response:</t>
         <figure>
            <artwork>
HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: gzip

</artwork>
         </figure>
         <t>Finally the semantics of an HTTP response might decouple the effective request URI from the enclosed representation. In the example response below, the <spanx style="verb">Content-Location</spanx> header field indicates that the enclosed representation refers to the resource available at <spanx style="verb">/authors/123</spanx>.</t>
         <t>Request:</t>
         <figure>
            <artwork>
POST /authors/ HTTP/1.1
Accept: application/json
Content-Type: application/json

{"author": "Camilleri"}
</artwork>
         </figure>
         <t>Response:</t>
         <figure>
            <artwork>
HTTP/1.1 201 Created
Content-Type: application/json
Content-Location: /authors/123
Location: /authors/123

{"id": "123", "author": "Camilleri"}
</artwork>
         </figure>
      </section>
      <section anchor="faq" title="FAQ">
         <t>
            <list style="numbers">
               <t>Why remove all references to content-md5? <vspace blankLines="1"/> Those were unnecessary to understanding and using this spec.</t>
               <t>Why remove references to instance manipulation? <vspace blankLines="1"/> Those were unnecessary for correctly using and applying the spec. An example with Range Request is more than enough. This doc uses the term "partial representation" which should group all those cases.</t>
               <t>How to use <spanx style="verb">Digest</spanx> with <spanx style="verb">PATCH</spanx> method? <vspace blankLines="1"/> See <xref target="acting-on-resources"/>.</t>
               <t>Why remove references to delta-encoding? <vspace blankLines="1"/> Unnecessary for a correct implementation of this spec. The revised spec can be nicely adapted to "delta encoding", but all the references here to delta encoding don't add anything to this RFC. Another job would be to refresh delta encoding.</t>
               <t>Why remove references to Digest Authentication? <vspace blankLines="1"/> This RFC seems to me completely unrelated to Digest Authentication but for the word "Digest".</t>
               <t>What changes in <spanx style="verb">Want-Digest</spanx>? <vspace blankLines="1"/> The contentMD5 token defined in <xref target="RFC3230" x:fmt="of" x:sec="5"/> is deprecated by <xref target="deprecate-contentMD5"/>. <vspace blankLines="1"/> To clarify that <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> can be used in both requests and responses - <xref target="RFC3230"/> carefully uses <spanx style="verb">sender</spanx> and <spanx style="verb">receiver</spanx> in their definition - we added examples on using <spanx style="verb">Want-Digest</spanx> in responses to advertise the supported digest-algorithms and the inability to accept requests with unsupported digest-algorithms.</t>
               <t>Does this spec changes supported algorithms? <vspace blankLines="1"/> This RFC updates <xref target="RFC5843"/> which is still delegated for all algorithms updates, and adds two more algorithms: "id-sha-256" and "id-sha-512" which allows to send a checksum of a resource representation with no content codings applied. To simplify a future transition to Structured Fields <xref target="I-D.ietf-httpbis-header-structure"/> we suggest to use lowercase for digest-algorithms.</t>
               <t>What about mid-stream trailers? <vspace blankLines="1"/> While <eref target="https://github.com/httpwg/http-core/issues/313#issuecomment-584389706">mid-stream trailers</eref> are interesting, since this specification is a rewrite of <xref target="RFC3230"/> we do not think we should face that. As a first thought, nothing in this document precludes future work that would find a use for mid-stream trailers, for example an incremental digest-algorithm. A document defining such a digest-algorithm is best positioned to describe how it is used.</t>
            </list>
         </t>
      </section>
      <section anchor="acknowledgements" numbered="false" title="Acknowledgements">
         <t>The vast majority of this document is inherited from <xref target="RFC3230"/>, so thanks to J. Mogul and A. Van Hoff for their great work. The original idea of refreshing this document arose from an interesting discussion with M. Nottingham, J. Yasskin and M. Thomson when reviewing the MICE content coding.</t>
      </section>
      <section anchor="code-samples" numbered="false" title="Code Samples">
         <t>
            <spanx>RFC Editor: Please remove this section before publication.</spanx>
         </t>
         <t>How can I generate and validate the <spanx style="verb">Digest</spanx> values shown in the examples throughout this document?</t>
         <t>The following python3 code can be used to generate digests for json objects using SHA algorithms for a range of encodings. Note that these are formatted as base64. This function could be adapted to other algorithms and should take into account their specific formatting rules.</t>
         <figure>
            <artwork>
import base64, json, hashlib, brotli


def digest(item, encoding=lambda x: x, algorithm=hashlib.sha256):
    json_bytes = json.dumps(item).encode()
    content_encoded = encoding(json_bytes)
    checksum_bytes = algorithm(content_encoded).digest()
    return base64.encodebytes(checksum_bytes).strip()


item = {"hello": "world"}

print("Encoding | digest-algorithm | digest-value")
print("Identity | sha256 |", digest(item))
# Encoding | digest-algorithm | digest-value
# Identity | sha256 | 4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

print("Encoding | digest-algorithm | digest-value")
print("Brotli | sha256 |", digest(item, encoding=brotli.compress))
# Encoding | digest-algorithm | digest-value
# Brotli , sha256 4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=


print("Encoding | digest-algorithm | digest-value")
print("Identity | sha512 |", digest(item, algorithm=hashlib.sha512))
# Encoding | digest-algorithm | digest-value
# Identity | sha512 | b'WZDPaVn/7XgHaAy8pmojAkGWoRx2UFChF41A2s
vX+TaPm+AbwAgBWnrIiYllu7BNNyealdVLvRwE\nmTHWXvJwew==\n'
</artwork>
         </figure>
      </section>
      <section anchor="changes" numbered="false" title="Changes">
         <t>
            <spanx>RFC Editor: Please remove this section before publication.</spanx>
         </t>
         <section anchor="since-draft-ietf-httpbis-digest-headers-03"
                  numbered="false"
                  title="Since draft-ietf-httpbis-digest-headers-03">
            <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"
                  title="Since draft-ietf-httpbis-digest-headers-02">
            <t>
               <list style="symbols">
                  <t>Deprecate SHA-1 #1154</t>
                  <t>Avoid id-* with encrypted content</t>
                  <t>Digest is independent from MESSAGING and HTTP/1.1 is not normative #1215</t>
                  <t>Identity is not a valid field value for content-encoding #1223</t>
                  <t>Mention trailers #1157</t>
                  <t>Reference httpbis-semantics #1156</t>
                  <t>Add contentMD5 as an obsoleted digest-algorithm #1249</t>
                  <t>Use lowercase digest-algorithms names in the doc and in the digest-algorithm IANA table.</t>
               </list>
            </t>
         </section>
         <section anchor="since-draft-ietf-httpbis-digest-headers-01"
                  numbered="false"
                  title="Since draft-ietf-httpbis-digest-headers-01">
            <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"
                  title="Since draft-ietf-httpbis-digest-headers-00">
            <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>
