<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-lamps-cms-cek-hkdf-sha256-05" number="9709" updates="" obsoletes="" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3" xml:lang="en">

  <front>
    <title abbrev="Encryption Key Derivation in CMS">Encryption Key Derivation in the Cryptographic Message Syntax (CMS) Using HKDF with SHA-256</title>
    <seriesInfo name="RFC" value="9709"/>
    <author initials="R." surname="Housley" fullname="Russ Housley">
      <organization abbrev="Vigil Security">Vigil Security, LLC</organization>
      <address>
        <postal>
          <city>Herndon</city>
	  <region>VA</region>
          <country>United States of America</country>
        </postal>
        <email>housley@vigilsec.com</email>
      </address>
    </author>
    <date year="2025" month="January"/>
    <area>SEC</area>
    <workgroup>lamps</workgroup>


<keyword>content-encryption key</keyword>
<keyword>content-authenticated-encryption key</keyword>

    <abstract>

<t>This document specifies the derivation of the content-encryption key or the
content-authenticated-encryption key in the Cryptographic Message Syntax (CMS)
using the HMAC-based Extract-and-Expand Key Derivation Function (HKDF) with SHA-256.
The use of this mechanism provides protection against an attacker that manipulates the
content-encryption algorithm identifier or the content-authenticated-encryption
algorithm identifier.</t>
    </abstract>
  </front>
  <middle>


<section anchor="introduction">
      <name>Introduction</name>
      <t>This document specifies the derivation of the content-encryption key for the
Cryptographic Message Syntax (CMS) enveloped-data content type <xref target="RFC5652"/>, the
content-encryption key for the CMS encrypted-data content type <xref target="RFC5652"/>, or the
content-authenticated-encryption key for the authenticated-enveloped-data
content type <xref target="RFC5083"/>.</t>
      <t>The use of this mechanism provides protection against an attacker that manipulates the
content-encryption algorithm identifier or the content-authenticated-encryption
algorithm identifier.  Johannes Roth and Falko Strenzke presented such an attack
at IETF 118 <xref target="RS2023"/>, where:</t>
      <ol spacing="normal" type="1"><li>
          <t>The attacker intercepts a CMS authenticated-enveloped-data content <xref target="RFC5083"/>
that uses either AES-CCM or AES-GCM <xref target="RFC5084"/>.</t>
        </li>
        <li>
          <t>The attacker turns the intercepted content into a "garbage" CMS enveloped-data
content (<xref section="6" sectionFormat="of" target="RFC5652"/>) that is composed of AES-CBC guess blocks.</t>
        </li>
        <li>
         <t>The attacker sends the "garbage" message to the victim, and the victim reveals
the result of the decryption to the attacker.</t>
        </li>
        <li>
          <t>If any of the transformed plaintext blocks match the guess for that block, then
the attacker learns the plaintext for that block.</t>
        </li>
      </ol>
      <t>With highly structured messages, one block can reveal the only sensitive part of
the original message.</t>
      <t>This attack is thwarted if the encryption key depends upon the delivery of
the unmodified algorithm identifier.</t>
      <t>The mitigation for this attack has three parts:</t>
      <ol spacing="normal" type="1">
        <li>Potential recipients include the id-alg-cek-hkdf-sha256 algorithm
        identifier (with no parameters) in S/MIME Capabilities to indicate
        support for this mitigation.</li>
        <li>As a flag to the recipient that this mitigation is being used,
        carry the id-alg-cek-hkdf-sha256 algorithm identifier as the
        contentEncryptionAlgorithm in the EncryptedContentInfo structure.
        This structure is used in the enveloped-data content type, the
        encrypted-data content type, and the authenticated-enveloped-data
        content type.  The parameters field of the id-alg-cek-hkdf-sha256
        algorithm identifier identifies the content-encryption algorithm or
        the content-authenticated-encryption algorithm and any associated
        parameters.
        </li>
        <li><t>Perform encryption with a derived content-encryption key or
        content-authenticated-encryption key:</t>

      <artwork><![CDATA[
      CEK' = HKDF(CEK, AlgorithmIdentifier)
]]></artwork>
        </li>
      </ol>

      <section anchor="asn1">
        <name>ASN.1</name>
        <t>CMS values are generated using ASN.1 <xref target="X680"/>, using the Basic
Encoding Rules (BER) and the Distinguished Encoding Rules
(DER) <xref target="X690"/>.</t>
      </section>
      <section anchor="terminology">
        <name>Terminology</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&nbsp;14 <xref target="RFC2119"/> <xref
    target="RFC8174"/> when, and only when, they appear in all capitals, as
    shown here.
        </t>
      </section>
      <section anchor="cryptographic-algorithm-agility-considerations">
        <name>Cryptographic Algorithm Agility Considerations</name>
        <t>There is no provision for key derivation functions other than HKDF, and
there is no provision for hash functions other than SHA-256.  If there is
ever a need to support another key derivation function or another hash
function, it will be very straightforward to assign a new object
identifier.  At this point, keeping the design very simple seems most
important.</t>
      </section>
    </section>
    <section anchor="cmskdf">
      <name>Use of HKDF with SHA-256 to Derive Encryption Keys</name>

      <t>The mitigation uses the HMAC-based Extract-and-Expand Key Derivation
Function (HKDF) <xref target="RFC5869"/> to derive output keying material (OKM) from
input keying material (IKM).  HKDF is used with the SHA-256 hash function
<xref target="FIPS180"/>.  The derivation includes the DER-encoded AlgorithmIdentifier as
the optional info input value.  The encoded value includes the ASN.1 tag
for SEQUENCE (0x30), the length, and the value.  This AlgorithmIdentifier is
carried as the parameter to the id-alg-cek-hkdf-sha256 algorithm identifier.  If
an attacker were to change the originator-provided AlgorithmIdentifier, then the
recipient will derive a different content-encryption key or
content-authenticated-encryption key.</t>
      <t>The CMS_CEK_HKDF_SHA256 function uses the HKDF-Extract and HKDF-Expand functions
to derive the OKM from the IKM:</t>

<dl spacing="normal" newline="true">
<dt>Inputs:</dt>
<dd><dl newline="false" spacing="compact" indent="6">
<dt>IKM</dt><dd>input keying material</dd>
<dt>info</dt><dd>DER-encoded AlgorithmIdentifier</dd>
</dl>
</dd>
<dt>Output:</dt>
<dd><dl newline="false" spacing="compact" indent="6">
<dt>OKM</dt><dd>output keying material (same size as IKM)</dd>
</dl>
</dd>
</dl>

<t>The output OKM is calculated as follows:</t>

<artwork><![CDATA[
   OKM_SIZE = len(IKM)  /* length in octets */
   IF OKM_SIZE > 8160 THEN raise error

   salt = "The Cryptographic Message Syntax"
   PRK = HKDF-Extract(salt, IKM)

   OKM = HKDF-Expand(PRK, info, OKM_SIZE)
]]></artwork>
    </section>
    <section anchor="alg-def">
      <name>The id-alg-cek-hkdf-sha256 Algorithm Identifier</name>
      <t>The id-alg-cek-hkdf-sha256 algorithm identifier indicates that the CMS_CEK_HKDF_SHA256
function defined in <xref target="cmskdf"/> is used to derive the content-encryption key or the
content-authenticated-encryption key.</t>
      <t>The following object identifier identifies the id-alg-cek-hkdf-sha256
algorithm:</t>
      <sourcecode type="asn.1"><![CDATA[
   id-alg-cek-hkdf-sha256 OBJECT IDENTIFIER ::= { iso(1)
      member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
      id-smime(16) alg(3) 31 }
]]></sourcecode>
      <t>The id-alg-cek-hkdf-sha256 parameters field has an ASN.1 type of AlgorithmIdentifier.</t>
      <t>Using the conventions from <xref target="RFC5911"/>, the id-alg-cek-hkdf-sha256 algorithm identifier
is defined as:</t>
      <sourcecode type="asn.1"><![CDATA[
  ContentEncryptionAlgorithmIdentifier ::=
    AlgorithmIdentifier{CONTENT-ENCRYPTION, { ... } }

  cea-CEKHKDFSHA256 CONTENT-ENCRYPTION ::= {
    IDENTIFIER id-alg-cek-hkdf-sha256
    PARAMS TYPE ContentEncryptionAlgorithmIdentifier ARE required
    SMIME-CAPS { IDENTIFIED BY id-alg-cek-hkdf-sha256 } }
]]></sourcecode>
    </section>
    <section anchor="smimecapabilities-attribute-conventions">
      <name>SMIMECapabilities Attribute Conventions</name>
      <t>The SMIMECapabilities attribute is defined in <xref section="2.5.2" sectionFormat="of" target="RFC8551"/>.  An
S/MIME client announces the set of cryptographic functions it supports using the
SMIMECapabilities attribute.</t>
      <t>If an S/MIME client supports the mechanism in this document, the
id-alg-cek-hkdf-sha256 object identifier <bcp14>SHOULD</bcp14> be included in the set of
cryptographic functions.  The parameter with this encoding <bcp14>MUST</bcp14> be absent.</t>
      <t>The encoding for id-alg-cek-hkdf-sha256, in hexadecimal, is:</t>
      <artwork><![CDATA[
   30 0d 06 0b 2a 86 48 86 f7 0d 01 09 10 03 1f
]]></artwork>
    </section>
    <section anchor="use-of-hkdf-with-sha-256-with-cms">
      <name>Use of HKDF with SHA-256 with CMS</name>
      <t>This section describes the originator and recipient processing to implement
this mitigation for each of the CMS encrypting content types.</t>
      <section anchor="enveloped-data-content-type">
        <name>Enveloped-Data Content Type</name>
        <t>The fourth step of constructing an enveloped-data content type is repeated below
from <xref section="6" sectionFormat="of" target="RFC5652"/>:</t>
        <blockquote>
<ol start="4"><li>The content is encrypted with the content-encryption key.
    Content encryption may require that the content be padded to a
    multiple of some block size; see Section <xref target="RFC5652" sectionFormat="bare" section="6.3"/>.</li>
</ol>
</blockquote>

        <t>To implement this mitigation, the originator expands this step as follows:</t>
        <ul spacing="normal">
          <li>Include the id-alg-cek-hkdf-sha256 algorithm identifier in the
          contentEncryptionAlgorithm.algorithm field of the
          EncryptedContentInfo structure, and set the
          contentEncryptionAlgorithm.parameters field to the
          AlgorithmIdentifier for the content-encryption algorithm that will
          be used to encrypt the content, including both the algorithm and
          optional parameters.</li>
          <li><t>Derive the new content-encryption key (CEK') from the original
          content-encryption key (CEK) and the
          ContentEncryptionAlgorithmIdentifier, which is carried in the
          contentEncryptionAlgorithm.parameters field:</t>

        <artwork><![CDATA[
CEK' = CMS_CEK_HKDF_SHA256(CEK, ContentEncryptionAlgorithmIdentifier)
]]></artwork>
	  </li>
          <li>The content is encrypted with the new content-encryption key
          (CEK').  Content encryption may require that the content be padded
          to a multiple of some block size; see <xref section="6.3"
          sectionFormat="of" target="RFC5652"/>.</li>
        </ul>
        <t>The presence of the id-alg-cek-hkdf-sha256 algorithm identifier in the
contentEncryptionAlgorithm.algorithm field of the EncryptedContentInfo
structure tells the recipient to derive the new content-encryption
key (CEK') as shown above, and then use it for decryption of the
EncryptedContent.  If the id-alg-cek-hkdf-sha256 algorithm identifier
is not present in the contentEncryptionAlgorithm.algorithm field of
the EncryptedContentInfo structure, then the recipient uses the original
content-encryption key (CEK) for decryption of the EncryptedContent.</t>
      </section>
      <section anchor="encrypted-data-content-type">
        <name>Encrypted-Data Content Type</name>
        <t>As specified in <xref section="8" sectionFormat="of" target="RFC5652"/>, the content-encryption key
is managed by other means.</t>
        <t>To implement this mitigation, the originator performs the following:</t>
        <ul spacing="normal">
          <li>Include the id-alg-cek-hkdf-sha256 algorithm identifier in
          the contentEncryptionAlgorithm.algorithm field of the
          EncryptedContentInfo structure, and set the
          contentEncryptionAlgorithm.parameters field to the
          AlgorithmIdentifier for the content-encryption algorithm that will
          be used to encrypt the content, including both the algorithm and
          optional parameters.</li>
          <li><t>Derive the new content-encryption key (CEK') from the
          original content-encryption key (CEK) and the
          ContentEncryptionAlgorithmIdentifier, which is carried in the
          contentEncryptionAlgorithm.parameters field:</t>
        <artwork><![CDATA[
CEK' = CMS_CEK_HKDF_SHA256(CEK, ContentEncryptionAlgorithmIdentifier)
]]></artwork>
	  </li>
          <li>The content is encrypted with the new content-encryption key
          (CEK').  Content encryption may require that the content be padded
          to a multiple of some block size; see <xref section="6.3"
          sectionFormat="of" target="RFC5652"/>.</li>
        </ul>
        <t>The presence of the id-alg-cek-hkdf-sha256 algorithm identifier in the
contentEncryptionAlgorithm.algorithm field of the EncryptedContentInfo
structure tells the recipient to derive the new content-encryption
key (CEK') as shown above, and then use it for decryption of the
EncryptedContent.  If the id-alg-cek-hkdf-sha256 algorithm identifier
is not present in the contentEncryptionAlgorithm.algorithm field of
the EncryptedContentInfo structure, then the recipient uses the original
content-encryption key (CEK) for decryption of the EncryptedContent.</t>
      </section>
      <section anchor="authenticated-enveloped-data-content-type">
        <name>Authenticated-Enveloped-Data Content Type</name>
        <t>The fifth step of constructing an authenticated-enveloped-data content type is
repeated below from <xref section="2" sectionFormat="of" target="RFC5083"/>:</t>

        <blockquote>
<ol start="5"><li> The attributes collected in step 4 are authenticated and the CMS
    content is authenticated and encrypted with the content-
    authenticated-encryption key.  If the authenticated encryption
    algorithm requires either the additional authenticated data (AAD)
    or the content to be padded to a multiple of some block size,
    then the padding is added as described in Section <xref target="RFC3852" sectionFormat="bare" section="6.3"/> of [CMS].</li></ol></blockquote>

<aside><t>Note that [CMS] refers to <xref target="RFC3852"/>, which has been obsoleted by <xref target="RFC5652"/>, but the text in Section 6.3 was unchanged in RFC 5652.</t></aside>

        <t>To implement this mitigation, the originator expands this step as follows:</t>
        <ul spacing="normal">
          <li>Include the id-alg-cek-hkdf-sha256 algorithm identifier in the
          contentEncryptionAlgorithm.algorithm field of the
          EncryptedContentInfo structure, and set the
          contentEncryptionAlgorithm.parameters field to the
          AlgorithmIdentifier for the content-authenticated-encryption
          algorithm that will be used for authenticated encryption of the
          content, including both the algorithm and optional parameters.</li>
          <li><t>Derive the new content-authenticated-encryption key (CEK')
          from the original content-authenticated-encryption key (CEK) and the
          ContentEncryptionAlgorithmIdentifier:</t>
        <artwork><![CDATA[
CEK' = CMS_CEK_HKDF_SHA256(CEK, ContentEncryptionAlgorithmIdentifier)
]]></artwork>
	  </li>
          <li>The attributes collected in step 4 are authenticated and the CMS
          content is authenticated and encrypted with the new
          content-authenticated-encryption key (CEK').  If the authenticated
          encryption algorithm requires either the additional authenticated
          data (AAD) or the content to be padded to a multiple of some block
          size, then the padding is added as described in <xref section="6.3"
          sectionFormat="of" target="RFC5652"/>.</li>
        </ul>
        <t>The presence of the id-alg-cek-hkdf-sha256 algorithm identifier in the
contentEncryptionAlgorithm.algorithm field of the EncryptedContentInfo
structure tells the recipient to derive the new content-authenticated-encryption
key (CEK') as shown above, and then use it for authenticated decryption of the
EncryptedContent and the authentication of the AAD.  If the id-alg-cek-hkdf-sha256
algorithm identifier is not present in the contentEncryptionAlgorithm.algorithm
field of the EncryptedContentInfo structure, then the recipient uses the original
content-authenticated-encryption (CEK) for decryption and authentication of
the EncryptedContent and the authentication of the AAD.</t>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>This mitigation always uses HKDF with SHA-256.  One KDF algorithm was
selected to avoid the need for negotiation.  In the future, if a weakness
is found in the KDF algorithm, a new attribute  will need to be assigned for
use with an alternative KDF algorithm.</t>
      <t>If the attacker removes the id-alg-cek-hkdf-sha256 object identifier from the
contentEncryptionAlgorithm.algorithm field of the EncryptedContentInfo
structure prior to delivery to the recipient, then the recipient will not
attempt to derive CEK', which will deny the recipient access to the content
but will not assist the attacker in recovering the plaintext content.</t>
      <t>If the attacker changes contentEncryptionAlgorithm.parameters field of the
EncryptedContentInfo structure prior to delivery to the recipient, then the
recipient will derive a different CEK', which will not assist the attacker in
recovering the plaintext content.  Providing the object identifier as an input to
the key derivation function is sufficient to mitigate the attack described
in <xref target="RS2023"/>, but this mitigation includes both the object identifier and the
parameters to protect against some yet-to-be-discovered attack that only
manipulates the parameters.</t>
      <t>Implementations <bcp14>MUST</bcp14> protect the content-encryption keys and
content-authenticated-encryption keys, including the CEK and CEK'.
Compromise of a content-encryption key may result in disclosure of the
associated encrypted content.  Compromise of a content-authenticated-encryption
key may result in disclosure of the associated encrypted content or allow
modification of the authenticated content and the AAD.</t>
      <t>Implementations <bcp14>MUST</bcp14> randomly generate content-encryption keys and
content-authenticated-encryption keys.  Using an inadequate pseudorandom
number generator (PRNG) to generate cryptographic keys can result in little or
no security.  An attacker may find it much easier to reproduce the PRNG
environment that produced the keys and then search the resulting small set
of possibilities, rather than brute-force searching the whole key space.  The
generation of quality random numbers is difficult.  <xref target="RFC4086"/> offers important
guidance on this topic.</t>
    </section>
    <section anchor="privacy-considerations">
      <name>Privacy Considerations</name>
      <t>If the message-digest attribute is included in the AuthAttributes,
then the attribute value will contain the unencrypted one-way hash
value of the plaintext of the content.  Disclosure of this hash value
enables content tracking, and it can be used to determine if the
content matches one or more candidates.  For these reasons,
the AuthAttributes <bcp14>SHOULD NOT</bcp14> contain the message-digest attribute.</t>
    </section>
    <section anchor="operational-considerations">
      <name>Operational Considerations</name>

      <t>CMS is often used to provide encryption in messaging environments,
where various forms of unsolicited messages (such as spam and phishing)
represent a significant volume of unwanted traffic.  Mitigation strategies for
unwanted message traffic involve analysis of plaintext message content.  When
recipients accept unsolicited encrypted messages, they become even more
vulnerable to unwanted traffic since many mitigation strategies will be
unable to access the plaintext message content.  Therefore, software that
receives messages that have been encrypted using CMS ought to provide alternate
mechanisms to handle the unwanted message traffic.  One approach that
does not require disclosure of keying material to a server is to reject
or discard encrypted messages unless they purport to come from a member
of a previously approved originator list.</t>
    </section>
    <section anchor="iana">
      <name>IANA Considerations</name>
      <t>For the ASN.1 module in <xref target="appendix-asn1"/> of this document, IANA has assigned the following object identifier (OID) in the "SMI Security for S/MIME Module Identifier (1.2.840.113549.1.9.16.0)" registry: </t>

<table anchor="tab1">
  <name></name>
  <thead>
    <tr>
      <th>Decimal</th>
      <th>Description</th>
      <th>References</th>
    </tr>
  </thead>
  <tbody>      
    <tr>
      <td>80</td>
      <td>id-mod-CMS-CEK-HKDF-SHA256-2023</td>
      <td>RFC 9709</td>
    </tr>
  </tbody>
</table>

      <t>IANA has allocated the id-alg-cek-hkdf-sha256 algorithm identifier as specified
in <xref target="alg-def"/> in the "SMI Security for S/MIME Algorithms (1.2.840.113549.1.9.16.3)" registry as follows:  </t>

<table anchor="tab2">
  <name></name>
  <thead>
    <tr>
      <th>Decimal</th>
      <th>Description</th>
      <th>References</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>31</td>
      <td>id-alg-cek-hkdf-sha256</td>
      <td>RFC 9709</td>
    </tr>
  </tbody>
</table>


    </section>
  </middle>
  <back>
    <references anchor="sec-combined-references">
      <name>References</name>
      <references anchor="sec-normative-references">
        <name>Normative References</name>

	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5083.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5652.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5869.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8551.xml"/>

<!-- [FIPS180] -->
        <reference anchor="FIPS180" target="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf">
          <front>
            <title>Secure Hash Standard (SHS)</title>
            <author>
              <organization>National Institute of Standards and Technology (NIST)</organization>
            </author>
            <date year="2015" month="August"/>
          </front>
          <seriesInfo name="FIPS PUB" value="180-4"/>
	  <seriesInfo name="DOI" value="10.6028/NIST.FIPS.180-4"/>
        </reference>

<!-- [X680] -->
        <reference anchor="X680" target="https://www.itu.int/rec/T-REC-X.680">
          <front>
            <title>Information technology -- Abstract Syntax Notation One (ASN.1): Specification of basic notation</title>
            <author>
              <organization>ITU-T</organization>
            </author>
            <date year="2021" month="February"/>
          </front>
          <seriesInfo name="ITU-T Recommendation" value="X.680"/>
          <seriesInfo name="ISO/IEC" value="8824-1:2021"/>
        </reference>

<!-- [X690] -->
        <reference anchor="X690" target="https://www.itu.int/rec/T-REC-X.690">
          <front>
            <title>Information technology -- ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)</title>
            <author>
              <organization>ITU-T</organization>
            </author>
            <date year="2021" month="February"/>
          </front>
          <seriesInfo name="ITU-T Recommendation" value="X.690"/>
          <seriesInfo name="ISO/IEC" value="8825-1-2021"/>
        </reference>

	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>

      </references>
      <references anchor="sec-informative-references">
        <name>Informative References</name>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3852.xml"/> 
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4086.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5084.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5911.xml"/>

<!-- [RS2023] -->
       <reference anchor="RS2023" target="https://datatracker.ietf.org/meeting/118/materials/slides-118-lamps-attack-against-aead-in-cms">
          <front>
            <title>AEAD-to-CBC Downgrade Attacks on CMS</title>
            <author initials="J." surname="Roth" fullname="Johannes Roth">
              <organization>MTG AG</organization>
            </author>
            <author initials="F." surname="Strenzke" fullname="Falko Strenzke">
              <organization>MTG AG</organization>
            </author>
            <date year="2023" month="November" day="08"/>
          </front>
	  <refcontent>IETF 118 Proceedings</refcontent>
        </reference>

      </references>
    </references>
    <?line 485?>

<section anchor="appendix-asn1">
      <name>ASN.1 Module</name>


      <t>This ASN.1 module builds upon the conventions established in <xref target="RFC5911"/>.</t>

      <sourcecode type="asn.1" markers="true"><![CDATA[
CMS-CEK-HKDF-SHA256-Module-2023
  { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
    id-smime(16) id-mod(0) id-mod-CMS-CEK-HKDF-SHA256-2023(80) }

DEFINITIONS IMPLICIT TAGS ::= BEGIN

EXPORTS ALL;

IMPORTS
  AlgorithmIdentifier{}, CONTENT-ENCRYPTION, SMIME-CAPS
  FROM AlgorithmInformation-2009 -- in RFC 5911
    { iso(1) identified-organization(3) dod(6) internet(1)
      security(5) mechanisms(5) pkix(7) id-mod(0)
      id-mod-algorithmInformation-02(58) } ;


--
-- CEK-HKDF-SHA256 Algorithm
--

id-alg-cek-hkdf-sha256 OBJECT IDENTIFIER ::= { iso(1) member-body(2)
    us(840) rsadsi(113549) pkcs(1) pkcs-9(9) id-smime(16) alg(3) 31 }

ContentEncryptionAlgorithmIdentifier ::=
    AlgorithmIdentifier{CONTENT-ENCRYPTION, { ... } }

cea-CEKHKDFSHA256 CONTENT-ENCRYPTION ::= {
    IDENTIFIER id-alg-cek-hkdf-sha256
    PARAMS TYPE ContentEncryptionAlgorithmIdentifier ARE required
    SMIME-CAPS { IDENTIFIED BY id-alg-cek-hkdf-sha256 } }

--
-- S/MIME Capability for CEK-HKDF-SHA256 Algorithm
--

SMimeCaps SMIME-CAPS ::= { cap-CMSCEKHKDFSHA256, ... }

cap-CMSCEKHKDFSHA256 SMIME-CAPS ::=
    { -- No value -- IDENTIFIED BY id-alg-cek-hkdf-sha256 }
     
END
]]></sourcecode>
    </section>
    <section anchor="cmscekhkdfsha256-function-examples">
      <name>CMS_CEK_HKDF_SHA256 Function Examples</name>
      <t>This appendix provides two test vectors for the CMS_CEK_HKDF_SHA256 function.</t>
      <section anchor="cmscekhkdfsha256-with-aes-128-gcm">
        <name>CMS_CEK_HKDF_SHA256 with AES-128-GCM</name>
        <t>This test vector includes an AlgorithmIdentifier for AES-128-GCM.</t>

        <sourcecode type="test-vectors"><![CDATA[
IKM = c702e7d0a9e064b09ba55245fb733cf3

The AES-128-GCM AlgorithmIdentifier:
 algorithm=2.16.840.1.101.3.4.1.6
 parameters=GCMParameters:
  aes-nonce=0x5c79058ba2f43447639d29e2
  aes-ICVlen is omitted; it indicates the DEFAULT of 12

DER-encoded AlgorithmIdentifier:
  301b0609608648016503040106300e040c5c79058ba2f43447639d29e2

OKM = 2124ffb29fac4e0fbbc7d5d87492bff3
]]></sourcecode>
      </section>
      <section anchor="cmscekhkdfsha256-with-aes-128-cbc">
        <name>CMS_CEK_HKDF_SHA256 with AES-128-CBC</name>
        <t>This test vector uses includes an AlgorithmIdentifier for AES-128-CBC.</t>
        <sourcecode type="test-vectors"><![CDATA[
IKM = c702e7d0a9e064b09ba55245fb733cf3

The AES-128-CBC AlgorithmIdentifier:
 algorithm=2.16.840.1.101.3.4.1.2
 parameters=AES-IV=0x651f722ffd512c52fe072e507d72b377

DER-encoded AlgorithmIdentifier:
  301d06096086480165030401020410651f722ffd512c52fe072e507d72b377

OKM = 9cd102c52f1e19ece8729b35bfeceb50
]]></sourcecode>
      </section>
    </section>
    <section anchor="acknowledgements" numbered="false">
      <name>Acknowledgements</name>
      <t>Thanks to <contact fullname="Mike Ounsworth"/>, <contact
      fullname="Carl Wallace"/>, and <contact fullname="Joe Mandel"/> their
      careful review and constructive comments.</t>
    </section>

  </back>

</rfc>
