<?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.10 -->
<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">
<?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-00" category="std" obsoletes="" updates="" submissionType="IETF" xml:lang="en" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 2.47.0 -->
  <front>
    <title>The "id-" prefix for Digest Algorithms</title>
    <seriesInfo name="Internet-Draft" value="draft-polli-id-digest-algorithms-00"/>
    <author initials="R." surname="Polli" fullname="Roberto Polli">
      <organization>Digital Transformation Department, Italian Government</organization>
      <address>
        <email>robipolli@gmail.com</email>
      </address>
    </author>
    <date year="2020" month="September" day="08"/>
    <area>General</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>This document defines
the "id-" prefix for digest-algorithms
used in the Digest HTTP field.
This prefix explicits that the value of the digest-algorithm
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-Retry-Scope">https://github.com/ioggstream/draft-polli-Retry-Scope</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 "id-" 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&nbsp;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 "payload body" 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="the-id-prefix-for-digest-algorithms" numbered="true" toc="default">
      <name>The "id-" prefix for digest-algorithms</name>
      <t>A digest-algorithm to be registered within the
<eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref>
MUST NOT start with the string "id-".</t>
      <t>The following two examples show two digest-algorithm names that cannot be registered</t>
      <artwork type="example" name="" align="left" alt=""><![CDATA[
   id-crc32c
   id-adler32
]]></artwork>
      <t>For every digest-algorithm registered in the 
<eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref>
the associate "id-" 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>
      <t>This definition is compatible, and thus extends, the definition
of the "id-sha-256" and "id-sha-512" digest-algorithms
contained in Section X of <xref target="DIGEST" format="default"/>.</t>
    </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>Like the "id-sha-256" digest-algoritm defined in <xref target="DIGEST" format="default"/>
if the content-coding provides encryption features,
sending the checksum of unencoded representation can
disclose information.</t>
      </section>
    </section>
    <section anchor="iana-considerations" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <section anchor="tbd-how-to-reserve-id-prefix" numbered="true" toc="default">
        <name>TBD how to reserve "id-" prefix?</name>
      </section>
    </section>
    <section anchor="examples" numbered="true" toc="default">
      <name>Examples</name>
      <section anchor="the-id-crc32c-digest-algorithm" numbered="true" toc="default">
        <name>The id-crc32c digest-algorithm</name>
        <t>The following request conveys a brotli encoded
json object</t>
        <artwork type="example" name="" align="left" alt=""><![CDATA[
{"hello": "world"}
]]></artwork>
        <t>The <tt>Digest</tt> computed using the "crc32c" digest-algorithm present in 
<eref target="https://www.iana.org/assignments/http-dig-alg/http-dig-alg.xhtml">HTTP Digest Algorithm Values</eref>
is content-coding aware,
while its associated "id-" digest-algorithm is not "id-crc32c"</t>
        <artwork type="example" name="" align="left" alt=""><![CDATA[
POST /data HTTP/1.1
Content-Type: application/json
Content-Encoding: br
Digest: id-crc32c=43794720, crc32c=DB329237

CwGAZG9nAw==
]]></artwork>
      </section>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="DIGEST" target="http://www.ietf.org/internet-drafts/draft-ietf-httpbis-digest-headers-03.txt">
        <front>
          <title>Digest Headers</title>
          <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-digest-headers-03"/>
          <author initials="R" surname="Polli" fullname="Roberto Polli">
            <organization/>
          </author>
          <author initials="L" surname="Pardue" fullname="Lucas Pardue">
            <organization/>
          </author>
          <date month="September" day="7" year="2020"/>
          <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.  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>
        </front>
      </reference>
      <reference anchor="SEMANTICS" target="https://www.rfc-editor.org/info/rfc7231">
        <front>
          <title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
          <seriesInfo name="DOI" value="10.17487/RFC7231"/>
          <seriesInfo name="RFC" value="7231"/>
          <author initials="R." surname="Fielding" fullname="R. Fielding" role="editor">
            <organization/>
          </author>
          <author initials="J." surname="Reschke" fullname="J. Reschke" role="editor">
            <organization/>
          </author>
          <date year="2014" month="June"/>
          <abstract>
            <t>The Hypertext Transfer Protocol (HTTP) is a stateless \%application- level protocol for distributed, collaborative, hypertext information systems.  This document defines the semantics of HTTP/1.1 messages, as expressed by request methods, request header fields, response status codes, and response header fields, along with the payload of messages (metadata and body content) and mechanisms for content negotiation.</t>
          </abstract>
        </front>
      </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>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="BCP" value="14"/>
          <author initials="S." surname="Bradner" fullname="S. Bradner">
            <organization/>
          </author>
          <date year="1997" month="March"/>
          <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>
      </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>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="BCP" value="14"/>
          <author initials="B." surname="Leiba" fullname="B. Leiba">
            <organization/>
          </author>
          <date year="2017" month="May"/>
          <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>
      </reference>
      <reference anchor="RFC5234" target="https://www.rfc-editor.org/info/rfc5234">
        <front>
          <title>Augmented BNF for Syntax Specifications: ABNF</title>
          <seriesInfo name="DOI" value="10.17487/RFC5234"/>
          <seriesInfo name="RFC" value="5234"/>
          <seriesInfo name="STD" value="68"/>
          <author initials="D." surname="Crocker" fullname="D. Crocker" role="editor">
            <organization/>
          </author>
          <author initials="P." surname="Overell" fullname="P. Overell">
            <organization/>
          </author>
          <date year="2008" month="January"/>
          <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>
      </reference>
      <reference anchor="RFC7405" target="https://www.rfc-editor.org/info/rfc7405">
        <front>
          <title>Case-Sensitive String Support in ABNF</title>
          <seriesInfo name="DOI" value="10.17487/RFC7405"/>
          <seriesInfo name="RFC" value="7405"/>
          <author initials="P." surname="Kyzivat" fullname="P. Kyzivat">
            <organization/>
          </author>
          <date year="2014" month="December"/>
          <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>
      </reference>
    </references>
    <section anchor="acknowledgements" numbered="true" 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="faq" toc="default">
      <name>FAQ</name>
      <dl newline="false" spacing="normal">
        <dt>Q: Question 1</dt>
        <dd>
  Answer 1</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 and validate the <tt>Digest</tt> values shown in the examples
throughout this document?</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, crc32c

identity = lambda x: x

def digest(item, content_coding=identity, algorithm=crc32c.crc32c):
    json_bytes = json.dumps(item).encode()
    content_encoded = content_coding(json_bytes)
    checksum = algorithm(content_encoded)
    # encode result has uppercase hex
    return hex(checksum)[2:].upper()


item = {"hello": "world"}

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

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

]]></artwork>
    </section>
    <section numbered="false" anchor="change-log" toc="default">
      <name>Change Log</name>
      <t>RFC EDITOR PLEASE DELETE THIS SECTION.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIANCiV18AA7VY63LbuBX+j6dAlT92RhdbdjYJW3VXsZTEHd9iKZ22mYwD
kZCENUlwAdCyxpM8S5+lT9bvAKRkSU5mO9PND4cEce7nfOcctVot5pRLZcTH
c8kbKmk1eGHkVN3zqTZ8oGbSOt5PZ9ooN88sE5OJkXcRS3Sciwx0iRFT1yp0
mqoWyBNP0RIritbBAYuFk3hfRty6hDFVmIg7U1rXPTh4fdBlwkgR8Xcyl0ak
bKHN7czosojYrVziLYn4ae6kyaVrDUgcY9aJPLkRqc6hwlJaVqiIf3I6bnL8
UXkic9fkVhsHYyyelln14I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