<?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.2.9 -->
<?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-00"
     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>Resource Digests for HTTP</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="04" month="July" year="2019"/>
      <area>Applications and Real-Time</area>
      <workgroup>HTTP</workgroup>
      <keyword>Digest</keyword>
      <abstract>
         <t>This document defines the Digest and Want-Digest header fields for HTTP, 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 RFC 7231.</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>Integrity protection for HTTP content is multi layered and is usually achieved across the protocol stack: TCP checksums and TLS <xref target="RFC2818"/> record to name but some.</t>
         <t>The HTTP protocol does not provide means to protect the various message parts. Besides, it might be desirable to add additional guarantees to the ones provided by the transport layer (eg. HTTPS). This may be in order to:</t>
         <t>
            <list style="symbols">
               <t>detect programming errors and corruption of stored data;</t>
               <t>address the need for the representation-data to remain unmodified throughout multiple hops;</t>
               <t>implement signature mechanisms that cover the desired parts of an HTTP exchange;</t>
               <t>provide additional protection against failures or attack (see <xref target="SRI"/>).</t>
            </list>
         </t>
         <section anchor="brief-history-of-integrity-headers"
                  title="Brief history of integrity headers">
            <t>The Content-MD5 header field was originally introduced to provide integrity, but HTTP/1.1 <xref target="RFC7231"/> in appendix-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 headers <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="RFC7231"/> made <xref target="RFC3230"/> definitions inconsistent with the current standard. A refresh was then required.</t>
            <t>This document updates the <spanx style="verb">Digest</spanx> and <spanx style="verb">Want-Digest</spanx> header field definitions to align with <xref target="RFC7231"/> concepts.</t>
            <t>This approach can be easily adapted 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 <xref target="RFC7233"/>).</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 <eref target="https://tools.ietf.org/html/rfc7231#section-3.1.2.1">no content codings</eref> two more algorithms are added (<spanx style="verb">ID-SHA-256</spanx> and <spanx style="verb">ID-SHA-512</spanx>).</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="Header integrity:">The digest mechanisms described here cover only representation and selected representation data, and do not protect the integrity of associated representation metadata headers or other message headers.</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="RFC7230" x:fmt="of" x:sec="7"/>.</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="RFC7230"/> and <xref target="RFC7231"/>.</t>
         </section>
      </section>
      <section anchor="resource-representation"
               title="Resource representation and representation-data">
         <t>To avoid inconsistencies, an integrity mechanism for HTTP messages should decouple the checksum calculation:</t>
         <t>
            <list style="symbols">
               <t>from the payload body - which may be altered by mechanism like Range Requests <xref target="RFC7233"/> or the method (eg. HEAD);</t>
               <t>and from the message body - which depends on <spanx style="verb">Transfer-Encoding</spanx> and whatever tranformations the intermediaries may apply.</t>
            </list>
         </t>
         <t>The following examples show how representation metadata, payload tranformations and method impacts on the message and payload body.</t>
         <t>Here is a gzip-compressed json object</t>
         <figure>
            <artwork>
Request:

    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>
         <figure>
            <artwork>
Request:

    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>
         <figure>
            <artwork>
Request:

    GET /entries/1234 HTTP/1.1
    Range: bytes=1-7

Response:

    HTTP/1.1 206 Partial Content
    Content-Encoding: gzip
    Content-Type: application/json
    Content-Range: bytes=1-7

    iwgAla3RXA==
</artwork>
         </figure>
         <t>Now the method too alters the payload body.</t>
         <figure>
            <artwork>
Request:

    HEAD /entries/1234 HTTP/1.1
    Accept: application/json
    Accept-Encoding: gzip

Response:

    HTTP/1.1 200 OK
    Content-Type: application/json
    Content-Encoding: gzip

</artwork>
         </figure>
      </section>
      <section anchor="algorithms" title="Digest Algorithm values">
         <t>Digest algorithm values are used to indicate a specific digest computation. For some algorithms, one or more parameters may be supplied.</t>
         <figure>
            <artwork>
      digest-algorithm = token
</artwork>
         </figure>
         <t>The BNF for “parameter” is as is used in <xref target="RFC7230"/>. All digest-algorithm values are case-insensitive.</t>
         <t>The Internet Assigned Numbers Authority (IANA) acts as a registry for digest-algorithm values. The registry contains the following tokens.</t>
         <t>
            <list style="hanging">
               <t hangText="SHA-256:">
                  <list style="symbols">
                     <t>Description: The SHA-256 algorithm <xref target="FIPS180-3"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>.</t>
                     <t>Reference: <xref target="FIPS180-3"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="SHA-512:">
                  <list style="symbols">
                     <t>Description: The SHA-512 algorithm <xref target="FIPS180-3"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>.</t>
                     <t>Reference: <xref target="FIPS180-3"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="MD5:">
                  <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"/>. The MD5 algorithm is NOT RECOMMENDED 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: obsoleted</t>
                  </list>
               </t>
               <t hangText="SHA:">
                  <list style="symbols">
                     <t>Description: The SHA-1 algorithm <xref target="FIPS180-1"/>. The output of this algorithm is encoded using the base64 encoding <xref target="RFC4648"/>. The SHA algorithm is NOT RECOMMENDED as it’s now vulnerable to collision attacks <xref target="IACR-2019-459"/>.</t>
                     <t>Reference: <xref target="FIPS180-3"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: obsoleted</t>
                  </list>
               </t>
               <t hangText="UNIXsum:">
                  <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:">
                  <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 algorithms are defined:</t>
         <t>
            <list style="hanging">
               <t hangText="ID-SHA-512:">
                  <list style="symbols">
                     <t>Description: The sha-512 digest of the representation-data of the resource when no content coding is applied (eg. <spanx style="verb">Content-Encoding: identity</spanx>)</t>
                     <t>Reference: <xref target="FIPS180-3"/>, <xref target="RFC4648"/>, this document.</t>
                     <t>Status: standard</t>
                  </list>
               </t>
               <t hangText="ID-SHA-256:">
                  <list style="symbols">
                     <t>Description: The sha-256 digest of the representation-data of the resource when no content coding is applied (eg. <spanx style="verb">Content-Encoding: identity</spanx>)</t>
                     <t>Reference: <xref target="FIPS180-3"/>, <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 anchor="representation-digest" title="Representation digest">
            <t>A representation digest is the value of the output of a digest algorithm, together with an indication of the algorithm used (and any parameters).</t>
            <figure>
               <artwork>
    representation-data-digest = digest-algorithm "="
                            &lt;encoded digest output&gt;
</artwork>
            </figure>
            <t>As explained in <xref target="resource-representation"/> the digest is computed on the entire selected <spanx style="verb">representation data</spanx> of the resource defined in <xref target="RFC7231"/>:</t>
            <figure>
               <artwork>
  representation-data := Content-Encoding( Content-Type( bits ) )
</artwork>
            </figure>
            <t>The encoded digest output uses the encoding format defined for the specific digest-algorithm.</t>
            <section anchor="digest-algorithm-encoding-examples"
                     title="digest-algorithm encoding examples">
               <t>The <spanx style="verb">sha-256</spanx> digest-algorithm uses base64 encoding. Note that digest-algoritm values are case insensitive.</t>
               <figure>
                  <artwork>
sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
</artwork>
               </figure>
               <t>The “UNIXsum” digest-algorithm uses ASCII string of decimal digits.</t>
               <figure>
                  <artwork>
UNIXsum=30637
</artwork>
               </figure>
            </section>
         </section>
      </section>
      <section anchor="header-specifications" title="Header Specifications">
         <t>The following headers are defined</t>
         <section anchor="want-digest-header" title="Want-Digest">
            <t>The Want-Digest message header 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 Want-Digest header 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>Examples:</t>
            <figure>
               <artwork>
   Want-Digest: sha-256
   Want-Digest: SHA-512;q=0.3, sha-256;q=1, md5;q=0
</artwork>
            </figure>
         </section>
         <section anchor="digest-header" title="Digest">
            <t>The Digest header field provides a digest of the representation data</t>
            <figure>
               <artwork>
      Digest = "Digest" ":" OWS 1#representation-data-digest
</artwork>
            </figure>
            <t>
               <spanx style="verb">Representation data</spanx> might be:</t>
            <t>
               <list style="symbols">
                  <t>fully contained in the message body,</t>
                  <t>partially-contained in the message body,</t>
                  <t>or not at all contained in the message body.</t>
               </list>
            </t>
            <t>The resource is specified by the effective Request-URI and any cache-validator contained in the message.</t>
            <t>For example, in a response to a HEAD request, the digest is calculated using the representation data that would have been enclosed in the payload body if the same request had been a GET.</t>
            <t>Digest can be used in requests too. Returned value depends on the representation metadata headers.</t>
            <t>A Digest header field MAY contain multiple representation-data-digest values. This could be useful for responses expected to reside in caches shared by users with different browsers, for example.</t>
            <t>A recipient MAY ignore any or all of the representation-data-digests in a Digest header field. This allows the recipient to chose 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>…</t>
         </section>
      </section>
      <section anchor="deprecate-negotiation-of-content-md5"
               title="Deprecate Negotiation of Content-MD5">
         <t>This RFC deprecates the negotiation of Content-MD5 as this header has been obsoleted by <xref target="RFC7231"/>
         </t>
      </section>
      <section anchor="broken-cryptographic-algorithms-are-not-recommended"
               title="Broken cryptographic algorithms are NOT RECOMMENDED">
         <t>The MD5 algorithm is NOT RECOMMENDED as it’s now vulnerable to collision attacks <xref target="CMU-836068"/>.</t>
         <t>The SHA algorithm is NOT RECOMMENDED as it’s now vulnerable to collision attacks <xref target="IACR-2019-459"/>.</t>
      </section>
      <section anchor="examples" title="Examples">
         <section anchor="unsolicited-digest-response"
                  title="Unsolicited Digest response">
            <section anchor="representation-data-is-fully-contained-in-the-payload"
                     title="Representation data is fully contained in the payload">
               <figure>
                  <artwork>
Request:

  GET /items/123

Response:

  HTTP/1.1 200 Ok
  Content-Type: application/json
  Content-Encoding: identity
  Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

  {"hello": "world"}
</artwork>
               </figure>
            </section>
            <section anchor="representation-data-is-not-contained-in-the-payload"
                     title="Representation data is not contained in the payload">
               <figure>
                  <artwork>
Request:

  HEAD /items/123

Response:

  HTTP/1.1 200 Ok
  Content-Type: application/json
  Content-Encoding: identity
  Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

</artwork>
               </figure>
            </section>
            <section anchor="representation-data-is-partially-contained-in-the-payload-ie-range-request"
                     title="Representation data is partially contained in the payload i.e. range request">
               <figure>
                  <artwork>
Request:

  GET /items/123
  Range: bytes=1-7

Response:

  HTTP/1.1 206 Partial Content
  Content-Type: application/json
  Content-Encoding: identity
  Content-Range: bytes 1-7/18
  Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

  "hello"

</artwork>
               </figure>
            </section>
            <section anchor="digest-in-both-request-and-response-returned-value-depends-on-representation-metadata"
                     title="Digest in both Request and Response. Returned value depends on representation metadata">
               <t>Digest can be used in requests too. Returned value depends on the representation metadata headers.</t>
               <figure>
                  <artwork>
Request:

  PUT /items/123
  Content-Type: application/json
  Content-Encoding: identity
  Accept-Encoding: br
  Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=

  {"hello": "world"}

Response:

  Content-Type: application/json
  Content-Encoding: br
  Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

  iwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==

</artwork>
               </figure>
            </section>
         </section>
         <section anchor="want-digest-solicited-digest-responses"
                  title="Want-Digest solicited digest responses">
            <section anchor="client-request-data-is-fully-contained-in-the-payload"
                     title="Client request data is fully contained in the payload">
               <t>The client requests a digest, preferring sha. The server is free to reply with sha-256 anyway.</t>
               <figure>
                  <artwork>
Request:

  GET /items/123
  Want-Digest: sha-256;q=0.3, sha;q=1

Response:

  HTTP/1.1 200 Ok
  Content-Type: application/json
  Content-Encoding: identity
  Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

  {"hello": "world"}
</artwork>
               </figure>
            </section>
            <section anchor="a-client-requests-an-unsupported-digest-the-server-may-reply-with-an-unsupported-digest"
                     title="A client requests an unsupported Digest, the server MAY reply with an unsupported digest">
               <t>The client requests a sha digest only. The server is currently free to reply with a Digest containing an unsupported algorithm</t>
               <figure>
                  <artwork>
Request:

  GET /items/123
  Want-Digest: sha;q=1

Response:

  HTTP/1.1 200 Ok
  Content-Type: application/json
  Content-Encoding: identity
  Digest: sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

  {"hello": "world"}
</artwork>
               </figure>
            </section>
            <section anchor="a-client-requests-an-unsupported-digest-the-server-may-reply-with-a-400"
                     title="A client requests an unsupported Digest, the server MAY reply with a 400">
               <t>The client requests a sha Digest, the server advises for sha-256 and sha-512</t>
               <figure>
                  <artwork>
Request:

  GET /items/123
  Want-Digest: sha;q=1

Response:

  HTTP/1.1 400 Bad Request
  Want-Digest: sha-256, sha-512
</artwork>
               </figure>
               <t>…</t>
            </section>
         </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> headers, from certain kinds of accidental corruption.</t>
            <t>While it is not intended as general protection against malicious tampering with HTTP messages, this goal can be achieved using <spanx style="verb">Digest</spanx> together with a transport-layer security mechanism and digital signatures.</t>
         </section>
         <section anchor="broken-cryptographic-algorithms"
                  title="Broken cryptographic algorithms">
            <t>Cryptogrphic alorithms 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-1 algorithms are vulnerable to collisions attacks and they are NOT RECOMMENDED.</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="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"/>.</t>
            <t>It’s important to note that, being the <spanx style="verb">Digest</spanx> header an hash of a resource representation, signing only the <spanx style="verb">Digest</spanx> header, without all the <spanx style="verb">representation metatada</spanx> (eg. the values of <spanx style="verb">Content-Type</spanx> and <spanx style="verb">Content-Encoding</spanx>) may expose the communication to tampering.</t>
            <t>
               <spanx style="verb">Digest</spanx> SHOULD always be used over a connection which provides integrity at transport layer that protects HTTP headers.</t>
            <t>A <spanx style="verb">Digest</spanx> header using NOT RECOMMENDED digest-algorithms SHOULD NOT be used in signatures.</t>
         </section>
         <section anchor="message-truncation" title="Message Truncation">
            <t>…</t>
         </section>
         <section anchor="algorithm-agility" title="Algorithm Agility">
            <t>…</t>
         </section>
      </section>
      <section anchor="iana-considerations" title="IANA Considerations">
         <section anchor="establish-the-http-digest-algorithm-values"
                  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="the-status-field-in-the-http-digest-algorithm-values"
                  title="The “status” 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">Specify “standard”, “experimental”, “historic”, “obsoleted”, or “deprecated” according to the type and status of the primary document in which the algorithm is defined.</t>
               </list>
            </t>
         </section>
         <section anchor="iana-MD5" title="Obsolete “MD5” 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-SHA" title="Obsolete “SHA” 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-ID-SHA-256" title="The “ID-SHA-256” 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 “ID-SHA-512” 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 status has been updated to “obsoleted” for both “SHA” and “MD5”, and their descriptions states that those algorithms are NOT RECOMMENDED.</t>
            <t>The status for all other algorithms have 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-header-field-registration"
                  title="Want-Digest Header Field Registration">
            <t>This section registers the <spanx style="verb">Want-Digest</spanx> header field in the “Permanent Message Header Field Names” registry (<xref target="RFC3864"/>).</t>
            <t>Header field name: <spanx style="verb">Want-Digest</spanx>
            </t>
            <t>Applicable protocol: http</t>
            <t>Status: standard</t>
            <t>Author/Change controller: IETF</t>
            <t>Specification document(s): <xref target="want-digest-header"/> 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> header field in the “Permanent Message Header Field Names” registry (<xref target="RFC3864"/>).</t>
            <t>Header field name: <spanx style="verb">Digest</spanx>
            </t>
            <t>Applicable protocol: http</t>
            <t>Status: standard</t>
            <t>Author/Change controller: IETF</t>
            <t>Specification document(s): <xref target="digest-header"/> 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="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="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="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="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="RFC7230">
            <front>
               <title>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</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="7230"/>
            <seriesInfo name="DOI" value="10.17487/RFC7230"/>
         </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="RFC7233">
            <front>
               <title>Hypertext Transfer Protocol (HTTP/1.1): Range Requests</title>
               <author fullname="R. Fielding"
                       initials="R."
                       role="editor"
                       surname="Fielding"/>
               <author fullname="Y. Lafon" initials="Y." role="editor" surname="Lafon"/>
               <author fullname="J. Reschke"
                       initials="J."
                       role="editor"
                       surname="Reschke"/>
               <date month="June" year="2014"/>
            </front>
            <seriesInfo name="RFC" value="7233"/>
            <seriesInfo name="DOI" value="10.17487/RFC7233"/>
         </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="FIPS180-1" target="http://csrc.nist.gov/fips/fip180-1.txt">
            <front>
               <title>NIST FIPS 180-1, Secure Hash Standard</title>
               <author fullname="NIST"
                       initials="National Institute of Standards and Technology, U.S."
                       surname="Department of Commerce"/>
               <date month="April" year="1995"/>
            </front>
         </reference>
         <reference anchor="FIPS180-3"
                    target="https://csrc.nist.gov/csrc/media/publications/fips/180/3/archive/2008-10-31/documents/fips180-3_final.pdf">
            <front>
               <title>NIST FIPS 180-3, Secure Hash Standard</title>
               <author fullname="NIST"
                       initials="National Institute of Standards and Technology, U.S."
                       surname="Department of Commerce"/>
               <date month="October" year="2008"/>
            </front>
         </reference>
         <reference anchor="UNIX">
            <front>
               <title>The Single UNIX Specification, Version 2 - 6 Vol Set for UNIX 98</title>
               <author fullname="The Open Group" initials="." surname="The Open Group"/>
               <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 fullname="NIST"
                       initials="National Institute of Standards and Technology, U.S."
                       surname="Department of Commerce"/>
               <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 fullname="CMU"
                       initials="."
                       surname="Carnagie Mellon University, Software Engineering Institute"/>
               <date day="31" month="December" year="2008"/>
            </front>
         </reference>
         <reference anchor="IACR-2019-459" target="https://eprint.iacr.org/2019/459.pdf">
            <front>
               <title>From Collisions to Chosen-Prefix Collisions Application to Full SHA-1</title>
               <author fullname="Leurent, G, Peyrin, T"
                       initials="."
                       surname="Inria, France; Nanyang Technological University, Singapore; Temasek Laboratories, Singapore"/>
               <date day="06" month="May" year="2019"/>
            </front>
         </reference>
         <reference anchor="RFC3864">
            <front>
               <title>Registration Procedures for Message Header Fields</title>
               <author fullname="G. Klyne" initials="G." surname="Klyne"/>
               <author fullname="M. Nottingham" initials="M." surname="Nottingham"/>
               <author fullname="J. Mogul" initials="J." surname="Mogul"/>
               <date month="September" year="2004"/>
            </front>
            <seriesInfo name="BCP" value="90"/>
            <seriesInfo name="RFC" value="3864"/>
            <seriesInfo name="DOI" value="10.17487/RFC3864"/>
         </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="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">
            <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>
         </reference>
      </references>
      <section anchor="change-log" title="Change Log">
         <t>RFC EDITOR PLEASE DELETE THIS SECTION.</t>
      </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"/> The PATCH verb brings some complexities (eg. about representation metadata headers, patch document format, …), <list style="symbols">
                     <t>PATCH entity-headers apply to the patch document and MUST NOT be applied to the target resource, see <xref target="RFC5789" x:fmt="," x:sec="2"/>.</t>
                     <t>servers shouldn’t assume PATCH semantics for generic media types like “application/json” but should instead use a proper content-type, eg <xref target="RFC7396"/>
                     </t>
                     <t>a <spanx style="verb">200 OK</spanx> response to a PATCH request would contain the digest of the patched item, and the etag of the new object. This behavior - tighly coupled to the application logic - gives the client low probability of guessing the actual outcome of this operation (eg. concurrent changes, …)</t>
                  </list>
               </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"/> We allow to use the <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.</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>
   </back>
</rfc>
