<?xml version="1.0" encoding="UTF-8"?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" consensus="true" docName="draft-sipos-cose-gmac-kmac-00" ipr="trust200902" submissionType="IETF" symRefs="true" tocInclude="true" version="3" xml:lang="en">
  <front>
    <title abbrev="GMAC/KMAC in COSE/JOSE">GMAC and KMAC for COSE and JOSE</title>
    <seriesInfo name="Internet-Draft" value="draft-sipos-cose-gmac-kmac-00"/>
    <author fullname="Brian Sipos" initials="B." surname="Sipos">
      <organization abbrev="JHU/APL">The Johns Hopkins University Applied Physics Laboratory</organization>
      <address>
        <postal>
          <street>11100 Johns Hopkins Rd.</street>
          <city>Laurel</city>
          <region>MD</region>
          <code>20723</code>
          <country>United States of America</country>
        </postal>
        <email>brian.sipos+ietf@gmail.com</email>
      </address>
    </author>
    <date/>
    <area>Security</area>
    <workgroup>CBOR Object Signing and Encryption</workgroup>
    <keyword>GMAC</keyword>
    <keyword>KMAC</keyword>
    <abstract>
      <t>
This document registers JOSE and COSE algorithm code points for using two new Message Authentication Code (MAC) algorithm families.
One is the Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) to generate a MAC (AES-GMAC), the other is the SHA-3-derived Keccak MAC (KMAC).
      </t>
    </abstract>
  </front>
  <middle>
    <section>
      <name>Introduction</name>
      <t>
The base COSE specification <xref target="RFC9052"/> defines a container for Message Authentication Code (MAC) parameters and results, and the base JOSE specification <xref target="RFC7515"/> defines a similar container for "Signature" data including MAC results.
Each type of container is parameterized on an algorithm identifier used to verify the MAC result.
This document defines new fully specified algorithm identifiers for the use of Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) to generate a MAC (AES-GMAC) as defined in <xref target="NIST-SP800-38D"/>, as well as the SHA-3-derived Keccak MAC (KMAC) as defined in <xref target="NIST-SP800-185"/>.
      </t>
      <t>
Unlike the use of AES-GMAC in CMS <xref target="RFC9044"/> and IPsec <xref target="RFC4543"/> or KMAC in CMS <xref target="RFC8702"/>, the COSE and JOSE algorithm identifiers are "fully specified" meaning they rely on no extra parameters (<em>e.g.</em>, tag length) to determine their exact operation.
      </t>
      <section>
        <name>Scope</name>
        <t>
This document does not define any new algorithms it only defines code points in COSE and JOSE registries so that the AES-GMAC and KMAC can be used in those respective security environments with specific combinations of parameters.
        </t>
        <t>
To avoid confusion, the AES-GMAC algorithm family specified in this document is unrelated to the "AES-MAC" algorithm family from <xref section="3.2" target="RFC9053"/>.
	</t>
      </section>
      <section>
        <name>Terminology</name>
        <t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" 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>
      </section>
    </section>
    <section anchor="sec-algo">
      <name>Algorithm Families</name>
      <t>
Both the AES-GMAC algorithm from <xref target="NIST-SP800-38D"/> and the KMAC algorithm from <xref target="NIST-SP800-185"/> have a set of parameters associated with their uses.
For the sake of adhering to COSE and JOSE best practices about fully specifying what gets assigned an "algorithm" code point in each respective registry, the AES-GMAC and KMAC will be treated as an <em>algorithm family</em> with a single code point referring to the algorithm itself along with a specific set of parameter values.
      </t>
      <section anchor="sec-algo-gmac">
        <name>AES-GMAC Family</name>
        <t>
While the general GMAC algorithm can be used with any underlying authenticated encryption with additional data (AEAD) block cipher, this document focuses on its use with the AES-GCM cipher.
	</t>
        <t>
The parameters associated with AES-GMAC are: key length and tag length.
This document restricts the allocated code points to the commonly used key lengths of 128, 192, and 256-bits, a fixed IV length of 96 bits (the recommended default), and restricts the use of a single tag length of 128 bits, which happens to be the longest possible tag length, as indicated in <xref target="tab-fam-aesgmac"/>.
Future allocations can define the use of AES-GMAC with shortened tag lengths.
	</t>
        <t>
One required input for AES-GMAC is an initialization vector (IV) which is already provided by the header parameter "IV" from the "COSE Header Parameters" registry of <xref target="IANA-COSE"/>.
The use of the AES-GMAC algorithms in COSE <bcp14>SHALL</bcp14> be combined with the IV header parameter in the same COSE layer.
A valid IV for these algorithms <bcp14>SHALL</bcp14> be exactly 96 bits (12 octets) in length.
The combination of key and IV <bcp14>SHALL</bcp14> be unique for each created MAC.
The IV generation mechanism <bcp14>SHALL</bcp14> be deterministic (not random).
The specifics of that mechanism are left to an implementation.
	</t>
        <t>
These IV and tag lengths are consistent with the COSE use of AES-GCM encryption in <xref section="4.1" target="RFC9053"/>.
	</t>
        <table anchor="tab-fam-aesgmac">
          <name>Registered AES-GMAC combinations</name>
          <thead>
            <tr>
              <th>COSE Value</th>
              <th>JOSE Name</th>
              <th>Algorithm</th>
              <th>Key Length</th>
              <th>IV Length</th>
              <th>Tag Length</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <cref>TBA1</cref>
              </td>
              <td>A128GMAC128</td>
              <td>AES-GMAC</td>
              <td>128</td>
              <td>96</td>
              <td>128</td>
            </tr>
            <tr>
              <td>
                <cref>TBA2</cref>
              </td>
              <td>A192GMAC128</td>
              <td>AES-GMAC</td>
              <td>192</td>
              <td>96</td>
              <td>128</td>
            </tr>
            <tr>
              <td>
                <cref>TBA3</cref>
              </td>
              <td>A256GMAC128</td>
              <td>AES-GMAC</td>
              <td>256</td>
              <td>96</td>
              <td>128</td>
            </tr>
          </tbody>
        </table>
        <t>
Implementations creating and validating AES-GMAC values <bcp14>SHALL</bcp14> validate that the key type, key length, and algorithm are correct and appropriate for the entities involved.
	</t>
        <t>
When using a COSE key for these algorithms, the following checks are made:
	</t>
        <ul>
          <li>The "kty" field <bcp14>MUST</bcp14> be present.</li>
          <li>The "kty" field <bcp14>MUST</bcp14> be "Symmetric".</li>
          <li>If the "alg" field is present, it <bcp14>MUST</bcp14> match the algorithm being used.</li>
          <li>If the "key_ops" field is present, it <bcp14>MUST</bcp14> include "MAC create" when creating an authentication tag.</li>
          <li>If the "key_ops" field is present, it <bcp14>MUST</bcp14> include "MAC verify" when verifying an authentication tag.</li>
        </ul>
      </section>
      <section>
        <name>KMAC Family</name>
        <t>
The KMAC family is actually two different variants, <tt>KMAC128</tt> and <tt>KMAC256</tt>, related to the provided security strength of 128 and 256-bits respectively and expected to be used with identical respective minimum key lengths.
	</t>
        <t>
The parameters associated with KMAC are: key length and tag length.
This document restricts the allowed code points to the commonly used key lengths of 128 and 256-bits and restricts the use of a single "standard" tag length for each variant as indicated in <xref target="tab-fam-kmac"/>.
Future allocations can define the use of KMAC with other tag lengths.
	</t>
        <t>
An optional input for KMAC is a "customization bit string" used as additional context data.
When used with COSE the KMAC customization bit string <bcp14>SHALL</bcp14> be the ASCII <xref target="RFC20"/> text string "COSE" without null termination.
When used with JOSE the KMAC customization bit string <bcp14>SHALL</bcp14> be the ASCII <xref target="RFC20"/> text string "JOSE" without null termination.
	</t>
        <table anchor="tab-fam-kmac">
          <name>Registered KMAC combinations</name>
          <thead>
            <tr>
              <th>COSE Value</th>
              <th>JOSE Name</th>
              <th>Algorithm</th>
              <th>Key Length</th>
              <th>Tag Length</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>
                <cref>TBA4</cref>
              </td>
              <td>KMAC128</td>
              <td>KMAC128</td>
              <td>128</td>
              <td>256</td>
            </tr>
            <tr>
              <td>
                <cref>TBA5</cref>
              </td>
              <td>KMAC256</td>
              <td>KMAC256</td>
              <td>256</td>
              <td>512</td>
            </tr>
          </tbody>
        </table>
        <t>
Implementations creating and validating KMAC values <bcp14>SHALL</bcp14> validate that the key type, key length, and algorithm are correct and appropriate for the entities involved.
	</t>
        <t>
When using a COSE key for these algorithms, the following checks are made:
	</t>
        <ul>
          <li>The "kty" field <bcp14>MUST</bcp14> be present.</li>
          <li>The "kty" field <bcp14>MUST</bcp14> be "Symmetric".</li>
          <li>If the "alg" field is present, it <bcp14>MUST</bcp14> match the algorithm being used.</li>
          <li>If the "key_ops" field is present, it <bcp14>MUST</bcp14> include "MAC create" when creating an authentication tag.</li>
          <li>If the "key_ops" field is present, it <bcp14>MUST</bcp14> include "MAC verify" when verifying an authentication tag.</li>
        </ul>
      </section>
    </section>
    <section>
      <name>Security Considerations</name>
      <t>
This document does not define any new modes of operation for the relevant MAC algorithms, and so does not introduce any new security considerations.
All of the applicable considerations from <xref target="NIST-SP800-38D"/> and <xref target="NIST-SP800-185"/> apply when the algorithm is used in COSE or JOSE.
      </t>
      <t>
The requirement to use non-random IV generation in <xref target="sec-algo-gmac"/> is meant to satisfy the critical constraint on GMAC (and nonce-based MACs generally) described in Chapter 10 of <xref target="PR2011"/> to guarantee the uniqueness of the combination of key and IV.
Whether the mechanism is a simple counter, a determistic PRF, or something else does not affect the constraint to be non-random.
      </t>
    </section>
    <section anchor="sec-iana">
      <name>IANA Considerations</name>
      <t>
This section provides guidance to the Internet Assigned Numbers Authority (IANA) regarding registration of code points in accordance with BCP 26 <xref target="RFC1155"/>.
      </t>
      <section anchor="sec-iana-cose">
        <name>COSE Algorithms</name>
        <t>
A new set of entries have been added to the "COSE Algorithms" registry <xref target="IANA-COSE"/> with the following parameters.
        </t>
        <section>
          <name>AES-GMAC 128/128</name>
          <dl newline="false">
            <dt>Name:</dt>
            <dd>AES-GMAC 128/128</dd>
            <dt>Value:</dt>
            <dd>
              <cref>TBA1</cref>
            </dd>
            <dt>Description:</dt>
            <dd>AES-GMAC with 128-bit key and 128-bit tag</dd>
            <dt>Capabilities:</dt>
            <dd>[kty]</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
          </dl>
        </section>
        <section>
          <name>AES-GMAC 192/128</name>
          <dl newline="false">
            <dt>Name:</dt>
            <dd>AES-GMAC 192/128</dd>
            <dt>Value:</dt>
            <dd>
              <cref>TBA2</cref>
            </dd>
            <dt>Description:</dt>
            <dd>AES-GMAC with 192-bit key and 128-bit tag</dd>
            <dt>Capabilities:</dt>
            <dd>[kty]</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
          </dl>
        </section>
        <section>
          <name>AES-GMAC 256/128</name>
          <dl newline="false">
            <dt>Name:</dt>
            <dd>AES-GMAC 256/128</dd>
            <dt>Value:</dt>
            <dd>
              <cref>TBA3</cref>
            </dd>
            <dt>Description:</dt>
            <dd>AES-GMAC with 256-bit key and 128-bit tag</dd>
            <dt>Capabilities:</dt>
            <dd>[kty]</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
          </dl>
        </section>
        <section>
          <name>KMAC 128/256</name>
          <dl newline="false">
            <dt>Name:</dt>
            <dd>KMAC 128/256</dd>
            <dt>Value:</dt>
            <dd>
              <cref>TBA4</cref>
            </dd>
            <dt>Description:</dt>
            <dd>KMAC128 with 128-bit key and 256-bit tag</dd>
            <dt>Capabilities:</dt>
            <dd>[kty]</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
          </dl>
        </section>
        <section>
          <name>KMAC 256/512</name>
          <dl newline="false">
            <dt>Name:</dt>
            <dd>KMAC 256/512</dd>
            <dt>Value:</dt>
            <dd>
              <cref>TBA5</cref>
            </dd>
            <dt>Description:</dt>
            <dd>KMAC256 with 256-bit key and 512-bit tag</dd>
            <dt>Capabilities:</dt>
            <dd>[kty]</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
          </dl>
        </section>
      </section>
      <section anchor="sec-iana-jose">
        <name>JOSE Algorithms</name>
        <t>
A new set of entries have been added to the "JSON Web Signature and Encryption Algorithms" registry <xref target="IANA-JOSE"/> with the following parameters.
        </t>
        <section>
          <name>A128GMAC128</name>
          <dl newline="false">
            <dt>Algorithm Name:</dt>
            <dd>A128GMAC128</dd>
            <dt>Algorithm Description:</dt>
            <dd>AES-GMAC with 128-bit key and 128-bit tag</dd>
            <dt>Algorithm Usage Location(s):</dt>
            <dd>alg</dd>
            <dt>JOSE Implementation Requirements:</dt>
            <dd>Optional</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
            <dt>Algorithm Analysis Document(s):</dt>
            <dd>
              <xref target="NIST-SP800-38D"/>
            </dd>
          </dl>
        </section>
        <section>
          <name>A192GMAC128</name>
          <dl newline="false">
            <dt>Algorithm Name:</dt>
            <dd>A192GMAC128</dd>
            <dt>Algorithm Description:</dt>
            <dd>AES-GMAC with 192-bit key and 128-bit tag</dd>
            <dt>Algorithm Usage Location(s):</dt>
            <dd>alg</dd>
            <dt>JOSE Implementation Requirements:</dt>
            <dd>Optional</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
            <dt>Algorithm Analysis Document(s):</dt>
            <dd>
              <xref target="NIST-SP800-38D"/>
            </dd>
          </dl>
        </section>
        <section>
          <name>A256GMAC128</name>
          <dl newline="false">
            <dt>Algorithm Name:</dt>
            <dd>A256GMAC128</dd>
            <dt>Algorithm Description:</dt>
            <dd>AES-GMAC with 256-bit key and 128-bit tag</dd>
            <dt>Algorithm Usage Location(s):</dt>
            <dd>alg</dd>
            <dt>JOSE Implementation Requirements:</dt>
            <dd>Optional</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
            <dt>Algorithm Analysis Document(s):</dt>
            <dd>
              <xref target="NIST-SP800-38D"/>
            </dd>
          </dl>
        </section>
        <section>
          <name>KMAC128</name>
          <dl newline="false">
            <dt>Algorithm Name:</dt>
            <dd>KMAC128</dd>
            <dt>Algorithm Description:</dt>
            <dd>KMAC with 128-bit key and 256-bit tag</dd>
            <dt>Algorithm Usage Location(s):</dt>
            <dd>alg</dd>
            <dt>JOSE Implementation Requirements:</dt>
            <dd>Optional</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
            <dt>Algorithm Analysis Document(s):</dt>
            <dd>
              <xref target="NIST-SP800-185"/>
            </dd>
          </dl>
        </section>
        <section>
          <name>KMAC256</name>
          <dl newline="false">
            <dt>Algorithm Name:</dt>
            <dd>KMAC256</dd>
            <dt>Algorithm Description:</dt>
            <dd>KMAC with 256-bit key and 512-bit tag</dd>
            <dt>Algorithm Usage Location(s):</dt>
            <dd>alg</dd>
            <dt>JOSE Implementation Requirements:</dt>
            <dd>Optional</dd>
            <dt>Change controller:</dt>
            <dd>IESG</dd>
            <dt>Reference:</dt>
            <dd>[This document]</dd>
            <dt>Recommended:</dt>
            <dd>Yes</dd>
            <dt>Algorithm Analysis Document(s):</dt>
            <dd>
              <xref target="NIST-SP800-185"/>
            </dd>
          </dl>
          <t>
            <cref>Others TBD</cref>
          </t>
        </section>
      </section>
    </section>
  </middle>
  <back>
    <displayreference target="NIST-SP800-38D" to="SP800-38D"/>
    <displayreference target="NIST-SP800-185" to="SP800-185"/>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="IANA-COSE" target="https://www.iana.org/assignments/cose/">
          <front>
            <title>CBOR Object Signing and Encryption (COSE)</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>
        <reference anchor="IANA-JOSE" target="https://www.iana.org/assignments/jose/">
          <front>
            <title>JSON Object Signing and Encryption (JOSE)</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.20.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7515.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9052.xml"/>
        <reference anchor="NIST-SP800-38D" target="https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-38d.pdf">
          <front>
            <title>Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC</title>
            <author>
              <organization>National Institute of Standards and Technology</organization>
            </author>
            <date month="November" year="2007"/>
          </front>
        </reference>
        <reference anchor="NIST-SP800-185" target="https://nvlpubs.nist.gov/nistpubs/specialpublications/nist.sp.800-185.pdf">
          <front>
            <title>SHA-3 Derived Functions: cSHAKE, KMAC, TupleHash, and ParallelHash</title>
            <author>
              <organization>National Institute of Standards and Technology</organization>
            </author>
            <date month="December" year="2016"/>
          </front>
        </reference>
      </references>
      <references>
        <name>Informative References</name>
	<reference anchor="PR2011" target="https://www.cs.ucdavis.edu/~rogaway/papers/modes.pdf">
          <front>
            <title>Evaluation of Some Blockcipher Modes of Operation</title>
            <author fullname="Phillip Rogaway">
              <organization>University of California, Davis</organization>
              <address>
                <email>rogaway@cs.ucdavis.edu</email>
              </address>
            </author>
            <date day="10" month="February" year="2011"/>
          </front>
	</reference>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.1155.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.4543.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8702.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9044.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9053.xml"/>
      </references>
    </references>
  </back>
</rfc>
