<?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-rfc version 1.7.17 (Ruby 3.3.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-steele-cose-hash-envelope-01" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.22.0 -->
  <front>
    <title>COSE Hash Envelope</title>
    <seriesInfo name="Internet-Draft" value="draft-steele-cose-hash-envelope-01"/>
    <author fullname="Orie Steele">
      <organization>Transmute</organization>
      <address>
        <email>orie@transmute.industries</email>
      </address>
    </author>
    <author fullname="Steve Lasker">
      <organization>DataTrails</organization>
      <address>
        <email>steve.lasker@datatrails.ai</email>
      </address>
    </author>
    <author initials="H." surname="Birkholz" fullname="Henk Birkholz">
      <organization abbrev="Fraunhofer SIT">Fraunhofer SIT</organization>
      <address>
        <postal>
          <street>Rheinstrasse 75</street>
          <city>Darmstadt</city>
          <code>64295</code>
          <country>Germany</country>
        </postal>
        <email>henk.birkholz@ietf.contact</email>
      </address>
    </author>
    <date year="2024" month="July" day="08"/>
    <area>Security</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <?line 44?>

<t>This document defines new COSE header parameters for signaling a payload as an output of a hash function.
This mechanism enables faster validation as access to the original payload is not required for signature validation.
Additionally, hints of the detached payload's content format and availability are defined providing references to optional discovery mechanisms that can help to find original payload content.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://OR13.github.io/draft-steele-cose-hash-envelope/draft-steele-cose-hash-envelope.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-steele-cose-hash-envelope/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        CBOR Object Signing and Encryption Working Group mailing list (<eref target="mailto:cose@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/cose/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/cose/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/OR13/draft-steele-cose-hash-envelope"/>.</t>
    </note>
  </front>
  <middle>
    <?line 50?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>COSE defined detached payloads in Section 2 of <xref target="RFC9052"/>, using <tt>nil</tt> as the payload.
In order to verify a signature over a detached payload, the verifier must have access to the payload content.
Storing a hash of the content allows for small signature envelopes, that are easy to transport and verify independently.</t>
      <t>Additional hints in the protected header ensure cryptographic agility for the hashing &amp; signing algorithms, and discoverability for the original content which could be prohibitively large to move over a network.</t>
      <section anchor="attached-payload">
        <name>Attached Payload</name>
        <t>COSE_sign1 envelope with an attached payload, providing for signature validation.</t>
        <sourcecode type="cbor-diag"><![CDATA[
18(                                 / COSE Sign 1                   /
    [
      h'a4013822...3a616263',       / Protected                     /
      {}                            / Unprotected                   /
      h'317cedc7...c494e772',       / Payload                       /
      h'15280897...93ef39e5'        / Signature                     /
    ]
)
]]></sourcecode>
      </section>
      <section anchor="detached-payload">
        <name>Detached Payload</name>
        <t>COSE_sign1 envelope with a detached payload (<tt>nil</tt>), which is compact but the payload must be distributed out of band to validate the signature</t>
        <sourcecode type="cbor-diag"><![CDATA[
18(                                 / COSE Sign 1                   /
    [
      h'a4013822...3a616263',       / Protected                     /
      {}                            / Unprotected                   /
      nil,                          / Detached Payload              /
      h'15280897...93ef39e5'        / Signature                     /
    ]
)
]]></sourcecode>
      </section>
      <section anchor="hashed-payload">
        <name>Hashed Payload</name>
        <t>A hashed payload functions equivalently to an attached payload, with the benefits of being compact in size and providing the ability to validate the signature.</t>
        <sourcecode type="cbor-diag"><![CDATA[
18(                                 / COSE Sign 1                   /
    [
      h'a4013822...3a616263',       / Protected                     /
      {}                            / Unprotected                   /
      h'935b5a91...e18a588a',       / Payload                       /
      h'15280897...93ef39e5'        / Signature                     /
    ]
)
]]></sourcecode>
      </section>
    </section>
    <section anchor="header-parameters">
      <name>Header Parameters</name>
      <t>To represent a hash of a payload, the following headers are defined:</t>
      <dl>
        <dt>TBD_1:</dt>
        <dd>
          <t>the hash algorithm used to generate the hash of the payload</t>
        </dd>
        <dt>TBD_2:</dt>
        <dd>
          <t>the content type of the payload the hash represents</t>
        </dd>
        <dt>TBD_3:</dt>
        <dd>
          <t>an identifier enabling a verifier to retrieve the full payload preimage.</t>
        </dd>
      </dl>
      <section anchor="signed-hash-envelopes-example">
        <name>Signed Hash Envelopes Example</name>
        <sourcecode type="cddl"><![CDATA[
Hash_Envelope_Protected_Header = {
    ; Cryptographic algorithm to use
    ? &(alg: 1) => int,

    ; Type of the envelope
    ? &(typ: 16) => int / tstr

    ; Hash algorithm used to produce the payload from content
    ; -16 for SHA-256,
    ; See https://www.iana.org/assignments/cose/cose.xhtml
    &(payload_hash_alg: TBD_1) => int

    ; Content type of the preimage
    ; (content to be hashed) of the payload
    ; 50 for application/json,
    ; See https://datatracker.ietf.org/doc/html/rfc7252#section-12.3
    &(payload_preimage_content_type: TBD_2) => int

    ; Location the content of the hashed payload is stored
    ; For example:
    ; storage.example/244f...9c19
    ? &(payload_location: TBD_3) => tstr

    * int => any
}

Hash_Envelope_Unprotected_Header = {
    * int => any
}

Hash_Envelope_as_COSE_Sign1 = [
    protected : bstr .cbor Hash_Envelope_Protected_Header,
    unprotected : Hash_Envelope_Unprotected_Header,
    payload: bstr / nil,
    signature : bstr
]

Hash_Envelope = #6.18(Hash_Envelope_as_COSE_Sign1)
]]></sourcecode>
      </section>
      <section anchor="protected-header">
        <name>Protected Header</name>
        <t>16 (typ), TBD_1 (payload hash alg) and TBD_2 (content type of the preimage of the payload) <bcp14>MUST</bcp14> be present in the protected header and <bcp14>MUST NOT</bcp14> be present in the unprotected header.
TBD_3 (payload_location) <bcp14>MAY</bcp14> be added to the protected header and <bcp14>MUST NOT</bcp14> be presented in the unprotected header.</t>
        <t>For example:</t>
        <sourcecode type="cbor-diag"><![CDATA[
{
  / alg : ES384 / 1: -35,
  / kid / 4: h'75726e3a...32636573',
  / typ / 16: application/hashed+cose
  / payload_hash_alg sha-256 / TBD_1: 1
  / payload_preimage_content_type / TBD_2: application/jwk+json
  / payload_location / TBD_3 : storage.example/244f...9c19
}
]]></sourcecode>
      </section>
    </section>
    <section anchor="encrypted-hashes">
      <name>Encrypted Hashes</name>
      <t>Should we define this?</t>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>TODO Security</t>
      <section anchor="choice-of-hash-function">
        <name>Choice of Hash Function</name>
        <t>It is <bcp14>RECOMMENDED</bcp14> to align the strength of the chosen hash function to the strength of the chosen signature algorithm.
For example, when signing with ECDSA using P-256 and SHA-256, use SHA-256 to hash the payload.</t>
      </section>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <section anchor="requirements-notation">
        <name>Requirements Notation</name>
        <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
        <?line -18?>

</section>
      <section anchor="cose-header-algorithm-parameters">
        <name>COSE Header Algorithm Parameters</name>
        <ul spacing="normal">
          <li>
            <t>Name: payload hash algorithm</t>
          </li>
          <li>
            <t>Label: TBD_1</t>
          </li>
          <li>
            <t>Value type: int</t>
          </li>
          <li>
            <t>Value registry: https://www.iana.org/assignments/named-information/named-information.xhtml</t>
          </li>
          <li>
            <t>Description: Hash algorithm used to produce the payload.</t>
          </li>
        </ul>
      </section>
      <section anchor="named-information-hash-algorithm-registry">
        <name>Named Information Hash Algorithm Registry</name>
        <ul spacing="normal">
          <li>
            <t>Name: SHAKE256</t>
          </li>
          <li>
            <t>Label: TBD_2</t>
          </li>
          <li>
            <t>Value type: int</t>
          </li>
          <li>
            <t>Value registry: https://www.iana.org/assignments/named-information/named-information.xhtml</t>
          </li>
          <li>
            <t>Description: SHAKE256 a described in https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf</t>
          </li>
          <li>
            <t>Name: ASCON128</t>
          </li>
          <li>
            <t>Label: TBD_3</t>
          </li>
          <li>
            <t>Value type: int</t>
          </li>
          <li>
            <t>Value registry: https://www.iana.org/assignments/named-information/named-information.xhtml</t>
          </li>
          <li>
            <t>Description: ASCON128 a described in https://csrc.nist.gov/CSRC/media/Projects/lightweight-cryptography/documents/round-2/spec-doc-rnd2/ascon-spec-round2.pdf</t>
          </li>
        </ul>
      </section>
    </section>
  </middle>
  <back>
    <references anchor="sec-normative-references">
      <name>Normative References</name>
      <reference anchor="RFC9052">
        <front>
          <title>CBOR Object Signing and Encryption (COSE): Structures and Process</title>
          <author fullname="J. Schaad" initials="J." surname="Schaad"/>
          <date month="August" year="2022"/>
          <abstract>
            <t>Concise Binary Object Representation (CBOR) is a data format designed for small code size and small message size. There is a need to be able to define basic security services for this data format. This document defines the CBOR Object Signing and Encryption (COSE) protocol. This specification describes how to create and process signatures, message authentication codes, and encryption using CBOR for serialization. This specification additionally describes how to represent cryptographic keys using CBOR.</t>
            <t>This document, along with RFC 9053, obsoletes RFC 8152.</t>
          </abstract>
        </front>
        <seriesInfo name="STD" value="96"/>
        <seriesInfo name="RFC" value="9052"/>
        <seriesInfo name="DOI" value="10.17487/RFC9052"/>
      </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"/>
          <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">
        <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"/>
          <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>
    </references>
    <?line 238?>

<section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>The following individuals provided input into the final form of the document: Carsten Bormann, Henk Birkholz, Antoine Delignat-Lavaud, Cedric Fournet.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA+VZ63LbNhb+z6fAKjNx3IqkKVm+aJsmiizXnnUsr+XsTqeT
cSESEhFTJAuAUhWP91n2WfbJ9hwAJCVZtrszO5Mf9Q+ZBHAOzuU7F4Cu6zrz
Lmk7iquEdUmjPxwNyBmVMRmkc5ZkOWs4IVVdIlXkRFmY0hksiwSdKFcqxhLm
hplkbgwkLrMk7l7gSCUYnXXJ+eDm1EmL2ZiJrhNmqWSpLGSXKFEwh8Ia2HTE
wkJwtWw4d2y5yEQEZKliImXKPcGtnDlLC9Z1CJmKrMhRzg/DazIcf2GhIiM+
TXk6JTSNQOpQLHPFs7QBq9UyR6X+mYk7XPATEuP4jPIExlHy95ypiZeJKY5T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