<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.5.17 -->
<?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 xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-polli-id-digest-algorithms-02" category="exp" obsoletes="" updates="" submissionType="IETF" xml:lang="en" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.11.1 -->
  <front>
    <title>The "id-" prefix for Digest Algorithms</title>
    <seriesInfo name="Internet-Draft" value="draft-polli-id-digest-algorithms-02"/>
    <author initials="R." surname="Polli" fullname="Roberto Polli">
      <organization>Digital Transformation Department, Italian Government</organization>
      <address>
        <postal>
          <country>Italy</country>
        </postal>
        <email>robipolli@gmail.com</email>
      </address>
    </author>
    <date year="2021" month="December" day="02"/>
    <area>General</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>This document defines
the "id-" prefix for digest-algorithms
used in the Digest Fields.
This prefix explicits that the computed checksum value
is independent from Content-Encoding.</t>
    </abstract>
    <note>
      <name>Note to Readers</name>
      <t><em>RFC EDITOR: please remove this section before publication</em></t>
      <t>Discussion of this draft takes place on the HTTP working group mailing list
(ietf-http-wg@w3.org), which is archived at
<eref target="https://lists.w3.org/Archives/Public/ietf-http-wg/">https://lists.w3.org/Archives/Public/ietf-http-wg/</eref>.</t>
      <t>The source code and issues list for this draft can be found at
<eref target="https://github.com/ioggstream/draft-polli-id-digest-algorithms">https://github.com/ioggstream/draft-polli-id-digest-algorithms</eref>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
      <t>The <xref target="DIGEST" format="default"/> defines a way to convey a checksum of a representation-data
as specified in <xref target="SEMANTICS" format="default"/>.</t>
      <t>As the representation data depends on the value of <tt>Content-Encoding</tt>, it is useful
to convey the checksum value of a representation without any content coding applied.</t>
      <t>This proposal introduces the <tt>id-</tt> prefix
to specify that the provided digest-algorithm value is computed on the representation-data
without any content coding applied.</t>
      <section anchor="notational-conventions" numbered="true" toc="default">
        <name>Notational Conventions</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
"MAY", and "OPTIONAL" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119" format="default"/> <xref target="RFC8174" format="default"/> when, and only when, they
appear in all capitals, as shown here.
These words may also appear in this document in
lower case as plain English words, absent their normative meanings.</t>
        <t>This document uses the Augmented BNF defined in <xref target="RFC5234" format="default"/> and updated
by <xref target="RFC7405" format="default"/>.</t>
        <t>The definitions "representation", "selected representation", "representation
data", "representation metadata", and "content" in this document are to be
interpreted as described in <xref target="SEMANTICS" format="default"/>.</t>
        <t>The definitions "digest-algorithm" and "representation-data-digest" in this document
are to be interpreted as described in <xref target="DIGEST" format="default"/>.</t>
      </section>
    </section>
    <section anchor="id-prefix" numbered="true" toc="default">
      <name>The "id-" prefix for digest-algorithms</name>
      <t>A new digest-algorithm to be registered within the
<eref target="https://www.iana.org/assignments/http-dig-alg/">HTTP Digest Algorithm Values Registry</eref>
MUST NOT start with the string <tt>id-</tt>.</t>
      <t>The following two examples show two digest-algorithm names that cannot be registered</t>
      <sourcecode type="example"><![CDATA[
   id-sha-256
   id-sha-512
]]></sourcecode>
      <t>For every digest-algorithm registered in the 
<eref target="https://www.iana.org/assignments/http-dig-alg/">HTTP Digest Algorithm Values</eref>
the associate <tt>id-</tt> digest-algorithm has the following properties:</t>
      <ul spacing="normal">
        <li>the checksum is computed on the representation-data of the resource
when no content coding is applied;</li>
        <li>the checksum is computed according to the original digest-algorithm
"Description" field, and uses the same encoding of the original digest-algorithm.</li>
      </ul>
    </section>
    <section anchor="security-considerations" numbered="true" toc="default">
      <name>Security Considerations</name>
      <section anchor="disclosure-of-encrypted-content" numbered="true" toc="default">
        <name>Disclosure of encrypted content</name>
        <t>If the content coding provides encryption features,
sending the checksum of unencoded representation can
disclose information about the original content.</t>
      </section>
    </section>
    <section anchor="iana-considerations" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>Please, add the following text to the "Note" section
of the <eref target="https://www.iana.org/assignments/http-dig-alg/">HTTP Digest Algorithm Values</eref>.</t>
      <t>"
For each registered Digest Algorithm, an associated <tt>id-</tt> algorithm is defined.</t>
      <t>The associated representation-data-digest is computed according to <xref target="id-prefix" format="default"/>
of this document.
"</t>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="DIGEST" target="https://www.ietf.org/archive/id/draft-ietf-httpbis-digest-headers-07.txt">
        <front>
          <title>Digest Fields</title>
          <author fullname="Roberto Polli">
            <organization>Team Digitale, Italian Government</organization>
          </author>
          <author fullname="Lucas Pardue">
            <organization>Cloudflare</organization>
          </author>
          <date day="16" month="November" year="2021"/>
          <abstract>
            <t>   This document defines HTTP fields that support integrity checksums.
   The Digest field can be used for the integrity of HTTP
   representations.  The Content-Digest field can be used for the
   integrity of HTTP message content.  Want-Digest and Want-Content-
   Digest can be used to indicate a sender's desire to receive integrity
   fields respectively.

   This document obsoletes RFC 3230.

            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-digest-headers-07"/>
      </reference>
      <reference anchor="SEMANTICS" target="https://www.ietf.org/archive/id/draft-ietf-httpbis-semantics-19.txt">
        <front>
          <title>HTTP Semantics</title>
          <author fullname="Roy T. Fielding">
            <organization>Adobe</organization>
          </author>
          <author fullname="Mark Nottingham">
            <organization>Fastly</organization>
          </author>
          <author fullname="Julian Reschke">
            <organization>greenbytes GmbH</organization>
          </author>
          <date day="12" month="September" year="2021"/>
          <abstract>
            <t>   The Hypertext Transfer Protocol (HTTP) is a stateless application-
   level protocol for distributed, collaborative, hypertext information
   systems.  This document describes the overall architecture of HTTP,
   establishes common terminology, and defines aspects of the protocol
   that are shared by all versions.  In this definition are core
   protocol elements, extensibility mechanisms, and the "http" and
   "https" Uniform Resource Identifier (URI) schemes.

   This document updates RFC 3864 and obsoletes RFC 2818, RFC 7231, RFC
   7232, RFC 7233, RFC 7235, RFC 7538, RFC 7615, RFC 7694, and portions
   of RFC 7230.

            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-semantics-19"/>
      </reference>
      <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner">
            <organization/>
          </author>
          <date month="March" year="1997"/>
          <abstract>
            <t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author fullname="B. Leiba" initials="B." surname="Leiba">
            <organization/>
          </author>
          <date month="May" year="2017"/>
          <abstract>
            <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
      <reference anchor="RFC5234" target="https://www.rfc-editor.org/info/rfc5234">
        <front>
          <title>Augmented BNF for Syntax Specifications: ABNF</title>
          <author fullname="D. Crocker" initials="D." role="editor" surname="Crocker">
            <organization/>
          </author>
          <author fullname="P. Overell" initials="P." surname="Overell">
            <organization/>
          </author>
          <date month="January" year="2008"/>
          <abstract>
            <t>Internet technical specifications often need to define a formal syntax.  Over the years, a modified version of Backus-Naur Form (BNF), called Augmented BNF (ABNF), has been popular among many Internet specifications.  The current specification documents ABNF. It balances compactness and simplicity with reasonable representational power.  The differences between standard BNF and ABNF involve naming rules, repetition, alternatives, order-independence, and value ranges.  This specification also supplies additional rule definitions and encoding for a core lexical analyzer of the type common to several Internet specifications.  [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="STD" value="68"/>
        <seriesInfo name="RFC" value="5234"/>
        <seriesInfo name="DOI" value="10.17487/RFC5234"/>
      </reference>
      <reference anchor="RFC7405" target="https://www.rfc-editor.org/info/rfc7405">
        <front>
          <title>Case-Sensitive String Support in ABNF</title>
          <author fullname="P. Kyzivat" initials="P." surname="Kyzivat">
            <organization/>
          </author>
          <date month="December" year="2014"/>
          <abstract>
            <t>This document extends the base definition of ABNF (Augmented Backus-Naur Form) to include a way to specify US-ASCII string literals that are matched in a case-sensitive manner.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="7405"/>
        <seriesInfo name="DOI" value="10.17487/RFC7405"/>
      </reference>
    </references>
    <section anchor="examples" numbered="true" toc="default">
      <name>Examples</name>
      <section anchor="the-id-sha-256-digest-algorithm" numbered="true" toc="default">
        <name>The id-sha-256 digest-algorithm</name>
        <t>The following request conveys a brotli encoded
json object</t>
        <sourcecode type="example"><![CDATA[
{"hello": "world"}
]]></sourcecode>
        <t>The <tt>Digest</tt> computed using the "sha-256" digest-algorithm present in 
<eref target="https://www.iana.org/assignments/http-dig-alg/">HTTP Digest Algorithm Values</eref>
is content coding aware,
while its associated "id-" digest-algorithm is not.</t>
        <sourcecode type="example"><![CDATA[
POST /data HTTP/1.1
Content-Type: application/json
Content-Encoding: br
Digest: sha-256=4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=,
        id-sha-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=

CwGAZiwiAeyJoZWxsbyI6ICJ3b3JsZCJ9Aw==
]]></sourcecode>
      </section>
    </section>
    <section numbered="false" anchor="faq" toc="default">
      <name>FAQ</name>
      <t><em>RFC Editor: Please remove this section before publication.</em></t>
      <dl>
        <dt>
Q: Why to convey the checksum independent from the content codings?  </dt>
        <dd>
          <t>This is useful to identify and validate a resource downloaded
from different sources using different content codings, or
to compare a resource with its stored or signed counterpart.</t>
        </dd>
        <dt>
Q: How does it improve the life of checksum providers?  </dt>
        <dd>
          <t>If providers use reverse proxies to eg. compress responses,
this could invalidate content coding aware checksums.
Providing an id- algorithm, allows the digest checksum to be
validated.</t>
        </dd>
      </dl>
    </section>
    <section numbered="false" anchor="code-samples" toc="default">
      <name>Code Samples</name>
      <t><em>RFC Editor: Please remove this section before publication.</em></t>
      <t>How can I generate an identity digest value?</t>
      <t>The following python3 code can be used to generate digests for json objects
using crc32c algorithm. 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>
      <artwork name="" type="" align="left" alt=""><![CDATA[
import base64, json, brotli, hashlib

identity = lambda x: x

def digest(item, content_coding=identity, algorithm=hashlib.sha256) -> bytes:
    json_bytes = json.dumps(item).encode()
    content_encoded = content_coding(json_bytes)
    checksum = algorithm(content_encoded)
    return base64.encodebytes(checksum.digest())


item = {"hello": "world"}

print("sha-256 digest value for a br-coded representation: ",
    digest(item, content_coding=brotli.compress)
)

print("id-sha-256 digest value for a br-coded representation: ",
    digest(item, content_coding=identity)
)


]]></artwork>
    </section>
    <section numbered="false" anchor="acknowledgements" toc="default">
      <name>Acknowledgements</name>
      <t>This specification was born from a thread created by James Manger
and the subsequent discussion here https://github.com/httpwg/http-extensions/issues/885.</t>
    </section>
    <section numbered="false" anchor="change-log" toc="default">
      <name>Change Log</name>
      <t><em>RFC Editor: Please remove this section before publication.</em></t>
      <section numbered="false" anchor="since-draft-polli-id-digest-algorithms-01" toc="default">
        <name>Since draft-polli-id-digest-algorithms-01</name>
        <ul spacing="normal">
          <li>Include id-sha-256 and id-sha-512.</li>
        </ul>
      </section>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIACuoqGEAA7VZ23bbNhZ9x1dglBc7S6LiS26aUVvFchK5ie3YTjNNV5cD
kpCEmCIYArSseiXfMt8yXzb7AKCuTtqulemDK5LAuWOffZBWq8Wsspns8Iux
5A2Vthq8KOVQ3fChLnlfjaSxvJeNdKnseGKYiONSXndYqpNcTLAvLcXQtgqd
ZaqF7anb0RLzHa0HuywRVuJ51uHypmBMFWWH27IydvfBg6f4LkopOvyFzGUp
MjbV5dWo1FXRYVdyhqe0wwe5lWUubatP6hgzVuTppch0DhNm0rBCdfhvVidN
jj8qT2Vum9zo0sIZg1+zSfhhS5XgU6InhQg/JliMTyrPVC6bHK5NRFGofPQ7
Y6KyY112GG8xjv9Ubjr8LOKn5K9746NwpmNZWr30XpejDsVPWZHxi1LkBgGd
CKt0zvuyEKWdOBsH+K5Ezl/oa3hI79x2OREq6/BSx8rF9qcRvYhgrfuc6Cq3
FFDaPmMs97KvZQfhzYdLT61Wi4sYbsNbxi7GypCDFSniKRKdI3j2rtxvZJJV
RqaIAKfloTKeK5mlJvJyw2bkOFOJsgYLhXWrKdqVxe5kLJMrU034tcgqybCJ
clVIlzA+LPWEH2jkOretwzzRKZIQeR9ybeXlMf2x+vJMilSWhrH7Z88P+GF/
cHFy1uFFJoWRvJQTxBJ6Id3IxEU8lnBJ8qKKYZpLwn3G+soklTH0XQ/9elfN
3IorCXcykUiuvb8vLy5OOVUmLOKuOjklhJ4yZSzbUtIOW2Nri9Z09NN0L0L+
t5t8OlbJmEOwKJMxEpJyYdm/aJnptNu000R+cbvnV5j2qTOy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