<?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-00" 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-00"/>
    <author fullname="Paul Bastian">
      <organization>Bundesdruckerei GmbH</organization>
      <address>
        <email>bastianpaul@googlemail.com</email>
      </address>
    </author>
    <date year="2024" month="January" day="16"/>
    <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:
<tt>
+------------------+--------------------------------+-----------------+
| Algorithm Name   | Algorithm Explanation          | Implementation  |
|                  |                                | Requirements    |
+------------------+--------------------------------+-----------------+
| ECDH-P256-HS256  | ECDH using NIST P-256 and      | Optional        |
|                  | HMAC using SHA-256             |                 |
| ECDH-BP256-HS256 | ECDH using BrainpoolP256r1 and | Optional        |
|                  | HMAC using SHA-256             |                 |
+------------------+--------------------------------+-----------------+
</tt>
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:
<tt>
{
    "typ" : "JWT",
    "alg" : "ECDH-P256-HS256",
    "x5c" : &lt;issuer certificate chain that signs the epk&gt;,
    "epk" : &lt;JWK used for ECDH&gt;,
    "kid" : &lt;key ID of Verifying Party&gt;
}
</tt></t>
        <t>The JWT/JWS payload:
<tt>
{
    "iss" : "https://example.as.com",
    "iat" : "1701870613",
    "given_name" : "Erika",
    "family_name" : "Mustermann"
}
</tt></t>
        <t>The JWT/JWS signature:
<tt>
base64-encoded MAC
</tt></t>
      </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 190?>

<section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>TODO acknowledge.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA+1Z23LcuBF951cg9EPsrDiyfN8px7u62RrbusSSrWylUhGG
xMzAQxJcgJQ8sf0v+ZZ8WU43SA45GtnOllO1D/GDzAGBRvfp0xeAURQFpS5T
NRThy+PTfSHTqbG6nGVOTIwV+7t7B9Hh9m40lk4lwulpLsvKKhcGcjy26hLr
mjm8gISEQSxLBTmLodD5xARBYuJcZtgksXJSkrBSyzx6b5yKsGOk4mQWZTKO
7t4NXDXOtHPa5OWiwJLR/tlzIW5BM2ewm84TVSj8yctwQ4Qq0SUUlin9GG3v
4D9oEY7enD0Pg7zKxsoOgwTqDIPY5E7lrnJDUdpKBdD9fiCtkpB6quIKZi/C
4MrY+dSaqiBE5KV0sdVFKY7H71VcilMAo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