<?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.1) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-steele-cose-hash-envelope-00" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.21.0 -->
  <front>
    <title>COSE Hash Envelope</title>
    <seriesInfo name="Internet-Draft" value="draft-steele-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>
    <date year="2024" month="June" day="21"/>
    <area>Security</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <?line 36?>

<t>This document defines new COSE header parameters for signaling that a payload is the 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.</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 42?>

<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.</t>
      <t>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="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>
    <section anchor="header-parameters">
      <name>Header Parameters</name>
      <t>To represent a hash of a detached payload, the following headers are defined:</t>
      <dl>
        <dt>TBD 0:</dt>
        <dd>
          <t>will be assigned by <xref target="I-D.ietf-cose-typ-header-parameter"/>, represents the content type of the code envelope, including the protected header and payload</t>
        </dd>
        <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: TBD_0) => 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 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

    ; Identifier for an artifact repository
    ; For example:
    ; pkg:container...image@sha256:244f...9c?repo..._url=dev.example
    ? &(artifact_repository: TBD) => tstr

    ; Type of Verifiable Data Structure, e.g. RFC9162_SHA256
    ; ? &(verifiable-data-structure: -111) => int,

    ; additional parameters allows.

}

Verifiable_Data_Proofs = {
  ? &(inclusion-proofs: -1) => [ bstr .cbor inclusion-proof ]
  ? &(consistency-proofs: -2) => [ bstr .cbor consistency-proof ]
  ; ... other proofs are allowed here.
}

Hash_Envelope_Unprotected_Header = {
  ; ? &(verifiable-data-proofs: 222) => Verifiable_Data_Proofs
  ; ... other unprotected header values are still allowed here.
}

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>TBD 0 (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.</t>
        <t>For example:</t>
        <sourcecode type="cbor-diag"><![CDATA[
{
  / alg : ES384 / 1: -35,
  / kid / 4: h'75726e3a...32636573',
  / typ / TBD 0: application/hashed+cose
  / payload_hash_alg sha-256 / TBD 1: 1
  / payload_preimage_content_type / TBD 2: application/jwk+json
  / artifact_repository / TBD 3 : \
  pkg:container/image@sha256:244f...?repository_url=dev.example
}
]]></sourcecode>
        <t>TBD 0 will be assigned by <xref target="I-D.ietf-cose-typ-header-parameter"/>, it represents the content type of the code envelope, which includes the protected header and payload.</t>
        <t>TBD 1 will be assigned by this draft.
TBD 2 will be assigned by this draft.
TBD 3 will be assigned by this draft.</t>
      </section>
      <section anchor="attached-payload">
        <name>Attached Payload</name>
        <t>The payload <bcp14>MAY</bcp14> be attached.</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>The payload <bcp14>MAY</bcp14> be detached.</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>
    <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="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="I-D.ietf-cose-typ-header-parameter">
        <front>
          <title>COSE "typ" (type) Header Parameter</title>
          <author fullname="Michael B. Jones" initials="M. B." surname="Jones">
            <organization>Self-Issued Consulting</organization>
          </author>
          <author fullname="Orie Steele" initials="O." surname="Steele">
            <organization>Transmute</organization>
          </author>
          <date day="3" month="April" year="2024"/>
          <abstract>
            <t>   This specification adds the equivalent of the JSON Object Signing and
   Encryption (JOSE) typ (type) header parameter to CBOR Object Signing
   and Encryption (COSE).  This enables the benefits of explicit typing,
   as defined in the JSON Web Token Best Current Practices BCP, to be
   brought to COSE objects.  The syntax of the COSE type header
   parameter value is the same as the existing COSE content type header
   parameter.

            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-cose-typ-header-parameter-05"/>
      </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 235?>

<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>
  <!-- ##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