<?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.4 (Ruby 3.2.2) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-bastian-jose-alg-ecdh-mac-01" category="info" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.19.0 -->
  <front>
    <title abbrev="ECDH-MAC for JOSE">JOSE algorithms for ECDH-MAC-based signatures</title>
    <seriesInfo name="Internet-Draft" value="draft-bastian-jose-alg-ecdh-mac-01"/>
    <author fullname="Paul Bastian">
      <organization>Bundesdruckerei GmbH</organization>
      <address>
        <email>bastianpaul@googlemail.com</email>
      </address>
    </author>
    <date year="2024" month="January" day="17"/>
    <area>Security</area>
    <workgroup>Javascript Object Signing and Encryption</workgroup>
    <keyword>next generation</keyword>
    <keyword>unicorn</keyword>
    <keyword>sparkling distributed ledger</keyword>
    <abstract>
      <?line 39?>

<t>This specification defines a JSON Web Algorithm for JOSE, that uses a combination of key agreement and MAC to construct a signature-like mechanism.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://paulbastian.github.io/paulbastian-jose-ecdh-mac-algorithms/draft-bastian-jose-alg-ecdh-mac.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-bastian-jose-alg-ecdh-mac/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        Javascript Object Signing and Encryption Working Group mailing list (<eref target="mailto:jose@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/jose/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/jose/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/paulbastian/paulbastian-jose-ecdh-mac-algorithms"/>.</t>
    </note>
  </front>
  <middle>
    <?line 43?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>JWS defines cryptographic algorithms to digitally sign or create Message Authentication Codes (MAC) of the contents of the JWS Protected Header and the JWS Payload in Section-3 <xref target="RFC7518"/>. JWS also offers ephemeral-static Elliptic Curve Diffie-Hellman key exchange in combination with a key derivation function ("ECDH-ES" and its variations) as a mechanism for key management in Section-4.6 <xref target="RFC7518"/>, however these are only used for symmetric encryption.</t>
      <t>This specification describes a combination of an ECDH key exchange with a MAC, that enables a feature set that is similar to digital signatures with repudiation.</t>
      <t>This specification and all described algorithms should respect the efforts for Fully Specified Algorithms (https://www.ietf.org/archive/id/draft-jones-jose-fully-specified-algorithms-00.html).</t>
      <t>This algorithm is intended for use with digital credentials ecosystems, including the Issuer-Holder-Verifier model described by W3C VCDM or IETF SD-JWT-VC.</t>
    </section>
    <section anchor="conventions-and-definitions">
      <name>Conventions and Definitions</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="terminology">
      <name>Terminology</name>
      <dl>
        <dt>Generating Party:</dt>
        <dd>
          <t>The Party that performs the key agreement first and generates the MAC. Similar to a Signer.</t>
        </dd>
        <dt>Verifying Party:</dt>
        <dd>
          <t>The Party that performs the key agreement second, generates the MAC and compares it to a given value. Similar to a Verifier.</t>
        </dd>
      </dl>
    </section>
    <section anchor="parameters">
      <name>Parameters</name>
      <t>For the generation of an ECDH-based MAC the following parameters must be chosen:</t>
      <ol spacing="normal" type="1"><li>
          <t>the domain parameters for the ECDH "curve"</t>
        </li>
        <li>
          <t>the key derivation algorithm "kd"</t>
        </li>
        <li>
          <t>the MAC algorithm "mac"</t>
        </li>
      </ol>
      <t>In general, these parameters are chosen by the Generating Party. These parameters need to be communicated to the Verifying Party before the generation of an ECDH-based MAC.</t>
    </section>
    <section anchor="cryptographic-algorithm">
      <name>Cryptographic Algorithm</name>
      <t>The generation of the ECDH-based MAC takes the private key of the Generating Party and the public key of the Verifying Party as inputs. The retrieval and communication of the Verifying Party's public key is out of scope of this specification and subject to the implementing protocols.</t>
      <t>The generation of ECDH-based MAC follows these steps:</t>
      <ol spacing="normal" type="1"><li>
          <t>Perform ECDH as defined as defined by "curve"
  - use the specified elliptic curve to generate a key pair and set the <tt>epk</tt>
  - use the Verifier's public key defined by <tt>kid</tt> to perform the key agreement
  - optionally provide a certificate chain defined by <tt>x5c</tt></t>
        </li>
        <li>
          <t>Derive symmetric key as defined by "kd"
  - use the output from the key agreement as an input for the key derivation algorithm
  - derive the MAC key</t>
        </li>
        <li>
          <t>Generate a MAC as defined by "mac"
  - use the output from the key derivation algorithm as an input for the MAC algorithm
  - generate the MAC</t>
        </li>
      </ol>
      <t>The verification of ECDH-based MAC follows these steps:</t>
      <ol spacing="normal" type="1"><li>
          <t>Perform ECDH as defined as defined by "curve"
  - use the specified elliptic curve to generate an ephemeral key pair and set the <tt>kid</tt>
  - provide the public key <tt>kid</tt> to the Generating Party
  - use the Generating Party's public key defined by <tt>epk</tt> and perform the key agreement
  - optionally validate the certificate chain defined by <tt>x5c</tt></t>
        </li>
        <li>
          <t>Derive symmetric key as defined by "kd"
  - use the output from the key agreement as an input for the key derivation algorithm
  - derive the MAC key</t>
        </li>
        <li>
          <t>Generate a MAC as defined by "mac"
  - use the output from the key derivation algorithm as an input for the MAC algorithm
  - generate the MAC
  - compare the generated MAC with the signature value</t>
        </li>
      </ol>
      <section anchor="header-parameter-alg">
        <name>Header parameter "alg"</name>
        <t>The following values <bcp14>MUST</bcp14> be used for the "alg" header parameter:</t>
        <artwork type="ascii-art"><![CDATA[
+--------------------+--------------------------------+----------------+
| Algorithm Name     | Algorithm Explanation          | Implementation |
|                    |                                | Requirements   |
+--------------------+--------------------------------+----------------+
| ECDH-P256-CC-HS256 | ECDH using NIST P-256,         | Optional       |
|                    | ConcatKDF and                  |                |
|                    | HMAC using SHA-256             |                |
| ECDH-BP256-CC-HS256| ECDH using BrainpoolP256r1,    | Optional       |
|                    | ConcatKDF and                  |                |
|                    | HMAC using SHA-256             |                |
+--------------------+--------------------------------+----------------+
]]></artwork>
        <t>Other algorithms <bcp14>SHOULD</bcp14> follow the naming <tt>ECDH-&lt;elliptic curve domain parameters&gt;-&lt;KD algorithm&gt;-&lt;MAC algorithm&gt;</tt>.</t>
      </section>
      <section anchor="header-parameter-epk">
        <name>Header parameter "epk"</name>
        <t>The "epk" (ephemeral public key) value is created by the Generating Party for the use in the key agreement algorithm. This header parameter <bcp14>MUST</bcp14> be present and <bcp14>MUST</bcp14> contain the Generating Party's public key represented as a JSON Web Key according to <xref target="RFC7517"/>. It <bcp14>MUST</bcp14> contain only public key parameters and <bcp14>SHOULD</bcp14> contain only the minimum JWK parameters necessary to represent the key. Other JWK parameters included may be checked for consistency or may be ignored.</t>
      </section>
      <section anchor="header-parameter-x5c">
        <name>Header parameter "x5c"</name>
        <t>The "x5c" (X.509 certificate chain) value is created by the Generating Party for the trust management of the "epk". This header parameter is <bcp14>OPTIONAL</bcp14> and if present <bcp14>MUST</bcp14> contain the X.509 certificate chain with the JWK from "epk" being the public key of the leaf certificate. Alternatively, the Generating Party may use "x5t", x5t#S256" or "x5u".</t>
      </section>
      <section anchor="header-parameter-kid">
        <name>Header parameter "kid"</name>
        <t>The "kid" (key identifier) value is created by the Generating Party for the use in the key agreement algorithm. This header parameter <bcp14>MUST</bcp14> be present and <bcp14>MUST</bcp14> contain the Verifying Party's public key ID user by the Generating Party for the ECDH.</t>
      </section>
      <section anchor="example-jwt">
        <name>Example JWT</name>
        <t>The JWT/JWS header:</t>
        <artwork><![CDATA[
{
    "typ" : "JWT",
    "alg" : "ECDH-P256-HS256",
    "x5c" : <issuer certificate chain that signs the epk>,
    "epk" : <JWK used for ECDH>,
    "kid" : <key ID of Verifying Party>
}
]]></artwork>
        <t>The JWT/JWS payload:</t>
        <artwork><![CDATA[
{
    "iss" : "https://example.as.com",
    "iat" : "1701870613",
    "given_name" : "Erika",
    "family_name" : "Mustermann"
}
]]></artwork>
        <t>The JWT/JWS signature:</t>
        <artwork><![CDATA[
base64-encoded MAC
]]></artwork>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>TODO Security</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
  </middle>
  <back>
    <references anchor="sec-normative-references">
      <name>Normative References</name>
      <reference anchor="RFC7517">
        <front>
          <title>JSON Web Key (JWK)</title>
          <author fullname="M. Jones" initials="M." surname="Jones"/>
          <date month="May" year="2015"/>
          <abstract>
            <t>A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. This specification also defines a JWK Set JSON data structure that represents a set of JWKs. Cryptographic algorithms and identifiers for use with this specification are described in the separate JSON Web Algorithms (JWA) specification and IANA registries established by that specification.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="7517"/>
        <seriesInfo name="DOI" value="10.17487/RFC7517"/>
      </reference>
      <reference anchor="RFC7518">
        <front>
          <title>JSON Web Algorithms (JWA)</title>
          <author fullname="M. Jones" initials="M." surname="Jones"/>
          <date month="May" year="2015"/>
          <abstract>
            <t>This specification registers cryptographic algorithms and identifiers to be used with the JSON Web Signature (JWS), JSON Web Encryption (JWE), and JSON Web Key (JWK) specifications. It defines several IANA registries for these identifiers.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="7518"/>
        <seriesInfo name="DOI" value="10.17487/RFC7518"/>
      </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 197?>

<section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>TODO acknowledge.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA+1Z3XLbxhW+x1Ns4YvajUCZ8W84rhOZlC3a1k8tJWqm06mW
wJJcC8Aiu4Bk1nGepc/SJ+t3zgIgQFFxmslFOlNd2OBi9+w53/nOzy6iKApK
XaZqJMLXx6f7QqYLY3W5zJyYGyv2x5OD6HBvHM2kU4lwepHLsrLKhYGczay6
wrpmDi8gIWEQy1JBzmokdD43QZCYOJcZNkmsnJckrNQyj94bpyLsGKk4WUaZ
jKP7w8BVs0w7p01ergosme6fvRTiDjRzBrvpPFGFwj95Ge6IUCW6hMIypR/T
vRf4D1q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