<?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.18 (Ruby 3.3.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-cose-hash-envelope-00" 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-ietf-cose-hash-envelope-00"/>
    <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="August" day="15"/>
    <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://cose-wg.github.io/draft-ietf-cose-hash-envelope/draft-ietf-cose-hash-envelope.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-ietf-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/cose-wg/draft-ietf-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+z6fAKjNJ3JqkJVm+aJsmiizXnnUsr+XsTqeT
cSESEhFTIAuAUhWP91n2WfbJ9hwAJCVZdrozO5Mf9Q+ZBHAOzuU7F4C+73vz
Lml7muuUdUmjPxwNyBlVCRmIOUuznDW8iOouUTr24iwSdAbLYkkn2udMT/wo
U8xPgMBnjsDf2/OUlozOuuR8cHPqiWI2ZrLrRZlQTKhCdYmWBfMorIEtRywq
JNfLhnfHlotMxkAmNJOCaf8EN/LmTBSs6xEylVmRo5Tvh9dkOP7MIk1GfCq4
mBIqYpA5kstc80w0YLVe5qjSPzN5hwt+QmIcn1GewjhK/g51CDI5xXEqowTG
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