<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2104 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2104.xml">
<!ENTITY RFC2119 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC3279 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3279.xml">
<!ENTITY RFC3370 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3370.xml">
<!ENTITY RFC4055 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4055.xml">
<!-- <!ENTITY RFC4086 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4086.xml">  --> 
<!ENTITY RFC5480 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5480.xml">
<!ENTITY RFC5652 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5652.xml">
<!ENTITY RFC5753 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5753.xml">
<!ENTITY RFC5911 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5911.xml">
<!ENTITY RFC6268 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6268.xml">
<!ENTITY RFC6979 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6979.xml">
<!ENTITY RFC8017 SYSTEM "https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8017.xml">
<!ENTITY RFC8174 PUBLIC "" "http://xml.resource.org/public/rfc/bibxml/reference.RFC.8174.xml">
<!ENTITY I-D.ietf-lamps-pkix-shake SYSTEM "https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-lamps-pkix-shake.xml">
<!ENTITY I-D.draft-housley-lamps-cms-sha3-hash SYSTEM "http://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.I-D.draft-housley-lamps-cms-sha3-hash-00.xml">
]>

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space 
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc category="std" docName="draft-ietf-lamps-cms-shakes-14" ipr="trust200902" updates="3370">
  <!-- category values: std, bcp, info, exp, and historic
     ipr="full3978" (probably old)
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->
	<front>
	  <title abbrev="SHAKEs in CMS">Use of the SHAKE One-way Hash 
	  Functions in the Cryptographic Message Syntax (CMS)</title>
	  
	  <author fullname="Panos Kampanakis" initials="P." surname="Kampanakis">
	    <organization>Cisco Systems</organization>
	    <address><email>pkampana@cisco.com</email></address>
	  </author>
	  
	  <author fullname="Quynh Dang" initials="Q." surname="Dang">
	    <organization>NIST</organization>
	    <address><postal><street>100 Bureau Drive</street>
	    <street>Gaithersburg, MD 20899</street>
	    </postal>
	    <email>quynh.Dang@nist.gov</email>
	    </address>
	  </author>
      
	  <date year="2019"/>
      <area>General</area>
      <workgroup>LAMPS WG</workgroup>
	  
	  <abstract>
	    <t>This document updates the “Cryptographic Message Syntax Algorithms” 
		(RFC3370) and describes the conventions for using the SHAKE family of 
		hash functions in the Cryptographic Message Syntax as one-way hash 
	    functions with the RSA Probabilistic signature and ECDSA signature 
		algorithms. The conventions for the 
	    associated signer public keys in CMS are also described. </t>
	  </abstract>
	</front>

	<middle>
	
    <section title="Change Log">
	  <t>[ EDNOTE: Remove this section before publication. ]</t>
      <t><list style="symbols"> 
	    <t>draft-ietf-lamps-cms-shake-13:
		  <list> 
		  <t>Fixing error with incorrect preimage resistance bits for SHA128 and SHA256.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-13:
		  <list> 
		  <t>Addressing comments from Dan M.'s secdir review.</t>
		  <t>Addressing comment from Scott B.'s opsdir review about references in the abstract.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-12:
		  <list> 
		  <t>Nits identified by Roman, Barry L. in ballot position review.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-11:
		  <list> 
		  <t>Minor nits.</t>
		  <t>Nits identified by Roman in AD Review.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-10:
		  <list> 
		  <t>Updated IANA considerations section to request for OID assignments. </t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-09:
		  <list> 
		  <t>Fixed minor text nit.</t>
		  <t>Updates in Sec Considerations section.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-08:
		  <list> 
		  <t>id-shake128-len and id-shake256-len were replaced with id-sha128 with 32 bytes output length and id-shake256 with 64 bytes output length.</t>
		  <t>Fixed a discrepancy between section 3 and 4.4 about the KMAC OIDs that have parameters as optional. </t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-07:
		  <list> 
		  <t>Small nit from Russ while in WGLC.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-06:
		  <list> 
		  <t>Incorporated Eric's suggestion from WGLC.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-05:
		  <list> 
		  <t>Added informative references.</t>
		  <t>Updated ASN.1 so it compiles.</t>
		  <t>Updated IANA considerations.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-04:
		  <list> 
		  <t>Added RFC8174 reference and text. </t>
		  <t>Explicitly explained why RSASSA-PSS-params are omitted in section 4.2.1.</t>
		  <t>Simplified Public Keys section by removing redundant info from RFCs.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-03:
		  <list> 
		  <t>Removed paragraph suggesting KMAC to be used in generating k in Deterministic ECDSA. That should be RFC6979-bis. </t>
		  <t>Removed paragraph from Security Considerations that talks about randomness of k because we are using deterministic ECDSA.</t>
		  <t>Completed ASN.1 module and fixed KMAC ASN.1 based on Jim's feedback.</t>
		  <t>Text fixes.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-02:
		  <list> 
		  <t>Updates based on suggestions and clarifications by Jim. </t>
		  <t>Started ASN.1 module.</t>
	    </list></t>
	    <t>draft-ietf-lamps-cms-shake-01:
		  <list> 
		    <t>Significant reorganization of the sections to simplify the introduction, the new OIDs and their use in CMS.</t>
		    <t>Added new OIDs for RSASSA-PSS that hardcodes hash, salt and MGF, according the WG consensus.</t>
		    <t>Updated Public Key section to use the new RSASSA-PSS OIDs and clarify the algorithm identifier usage.</t>
		    <t>Removed the no longer used SHAKE OIDs from section 3.1.</t>
	    </list></t>
  	    <t>draft-ietf-lamps-cms-shake-00:
		  <list> 
  		    <t>Various updates to title and section names.</t>
		    <t>Content changes filling in text and references.</t>
	    </list></t>
	    <t>draft-dang-lamps-cms-shakes-hash-00:
		  <list> 
	       <t>Initial version</t>
	    </list></t>
	  </list></t>
    </section>
	
	<section title="Introduction" anchor="intro">
	<t>The "Cryptographic Message Syntax (CMS)" <xref target="RFC5652"/> is used to 
	digitally sign, digest, authenticate, or encrypt arbitrary message contents. 
	"Cryptographic Message Syntax (CMS) Algorithms" <xref target="RFC3370"/> 
	defines the use of common cryptographic algorithms with CMS. This 
	specification updates RFC3370 and describes the use of the SHAKE128 and SHAKE256 
    specified in <xref target="SHA3"/> as new hash functions in CMS. In addition, 
    it describes the use of these functions with the RSASSA-PSS signature 
	algorithm <xref target="RFC8017"/> and the Elliptic Curve Digital Signature 
	Algorithm (ECDSA) <xref target="X9.62"/> with the CMS signed-data content type.</t>

    <t>In the SHA-3 family, two extendable-output functions (SHAKEs), SHAKE128 and SHAKE256, 
	are defined. Four other hash function instances, SHA3-224, SHA3-256, 
	SHA3-384, and SHA3-512, are also defined but are out of scope for this document. 
	A SHAKE is a variable length hash function defined as SHAKE(M, d) where the 
	output is a d-bits-long digest of message M. The corresponding collision and  second-preimage-resistance strengths for SHAKE128 are min(d/2,128) and min(d,128) bits, 
	respectively (Appendix A.1 <xref target="SHA3"/>). And the 
	corresponding collision and second-preimage-resistance 
	strengths for SHAKE256 are min(d/2,256) and min(d,256) bits, respectively. 
	In this specification we use d=256 (for SHAKE128) and d=512 (for SHAKE256).</t>

	<t>A SHAKE can be used in CMS as the message digest function (to hash the 
    message to be signed) in RSASSA-PSS and ECDSA, message 
    authentication code and as the mask generation function (MGF) in RSASSA-PSS. 
	This specification describes the identifiers for SHAKEs to be used in 
	CMS and their meaning. </t>
    
    <!--  <section title="ASN.1" anchor="section-1.1">
	  <t>CMS values are generated using ASN.1 <xref target="ASN1-B"/>, using the Basic 
      Encoding Rules (BER) and the Distinguished Encoding Rules (DER)
      <xref target="ASN1-E"/>.</t>
      </section> -->
      
    <section anchor="terminology" title="Terminology">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL 
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "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>  <!-- Terminology -->
	</section>

	<section title="Identifiers" anchor="oids">
		<!-- <figure><artwork><![CDATA[
    id-RSASSA-PSS  OBJECT IDENTIFIER  ::=  { pkcs-1 10 }

    RSASSA-PSS-params  ::=  SEQUENCE  {
         hashAlgorithm      HashAlgorithm,
         maskGenAlgorithm   MaskGenAlgorithm,
         saltLength         INTEGER,
         trailerField       INTEGER }
]]></artwork></figure> -->

	  <!-- Commention out the below OIDs as they are no longer pertinent for the below public keys and sigs -->
  
	 <!-- The mask generation function used in RSASSA-PSS 
	 is defined in <xref target="RFC8017"/>, but we include it here as well 
	 for convenience:
     <t><figure><artwork><![CDATA[
    id-mgf1  OBJECT IDENTIFIER  ::=  { pkcs-1 8 }]]></artwork></figure></t>
  
     <t>The parameters field associated with id-mgf1 MUST have a
     hashAlgorithm value that identifies the hash used with MGF1. To use
     SHAKE as this hash, this parameter MUST be id-shake128-len or id-
     shake256-len as specified in <xref target="mdmgf" /> above. </t>    -->

     <t>This section identifies eight new object identifiers (OIDs) 
	 for using SHAKE128 and SHAKE256 in CMS.</t>
	 
	 <t>Two object identifiers for SHAKE128 and SHAKE256 hash functions are defined 
	 in <xref target="shake-nist-oids"/> and we include them here for convenience.</t>
	 <t><figure><artwork><![CDATA[
  id-shake128 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) 
       country(16) us(840) organization(1) gov(101) csor(3) 
       nistAlgorithm(4) 2 11 }

  id-shake256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) 
       country(16) us(840) organization(1) gov(101) csor(3) 
       nistAlgorithm(4) 2 12 }
]]></artwork></figure></t>
 
     <t>In this specification, when using the id-shake128 or id-shake256 algorithm identifiers, the parameters MUST be absent. That is, the identifier SHALL be a SEQUENCE of one component, the OID. 
	  <!-- present, and they MUST employ the ShakeOutputLen -->
	  <!-- "MUST employ syntax borrowed from RFC4055 -->
	  <!-- syntax that contains an encoded positive integer value of 32 or 64 respectively.--></t>
	 
	 
	 <t><xref target="I-D.ietf-lamps-pkix-shake"/> 
	 [ EDNOTE: Update reference with the RFC when it is ready ] 
	 defines two identifiers for RSASSA-PSS signatures using SHAKEs which we include here for 
	 convenience.</t>
	 <t><figure><artwork><![CDATA[
  id-RSASSA-PSS-SHAKE128  OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD1 }

  id-RSASSA-PSS-SHAKE256  OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD2 }
]]></artwork></figure></t>

	 <t>The same RSASSA-PSS algorithm identifiers can be used for identifying 
	 public keys and signatures.</t> 

 	 <t><xref target="I-D.ietf-lamps-pkix-shake"/> 
	 [ EDNOTE: Update reference with the RFC when it is ready ] 
	 also defines two algorithm 
	 identifiers of ECDSA signatures using SHAKEs which we include here for 
	 convenience.</t> 
	 <t><figure><artwork><![CDATA[
  id-ecdsa-with-shake128 OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD3 }            

  id-ecdsa-with-shake256 OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD4 }
]]></artwork></figure></t>

     <t>The parameters for the four RSASSA-PSS and ECDSA identifiers 
	 MUST be absent. That is, each identifier SHALL be a SEQUENCE of one component, 
	 the OID.</t>
     
<!--   <figure><artwork><![CDATA[
   sigAlgs OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16)
       us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) 3 }

   id-ecdsa-with-shake128 ::= { sigAlgs x }

   id-ecdsa-with-shake256 ::= { sigAlgs y }
   
Note: x and y will be specified by NIST.
]]></artwork> </figure> -->

	 <t>Two object identifiers for KMACs using SHAKE128 and SHAKE256 as 
	 defined in by the National Institute of Standards and Technology (NIST) 
	 in <xref target="shake-nist-oids"/> and we include them here for 
	 convenience.</t>
	 <t><figure><artwork><![CDATA[
   id-KmacWithSHAKE128 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) 
       country(16) us(840) organization(1) gov(101) csor(3) 
       nistAlgorithm(4) 2 19 }

   id-KmacWithSHAKE256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) 
       country(16) us(840) organization(1) gov(101) csor(3) 
       nistAlgorithm(4) 2 20 }
]]></artwork></figure></t>
     
	 <t>The parameters for id-KmacWithSHAKE128 and id-KmacWithSHAKE256 are OPTIONAL.</t>
<!--       <figure><artwork><![CDATA[
   hashAlgs OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16)
       us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) 2 }

   id-KmacWithSHAKE128 OBJECT IDENTIFIER ::= { x }

   id-KmacWithSHAKE256 OBJECT IDENTIFIER ::= { y }

   Note: x and y will be specified by NIST.
]]></artwork></figure> -->

     <t><xref target="md"/>, <xref target="rsa-sigs"/>, <xref target="ecdsa-sigs"/> 
	 and <xref target="kmac"/> specify the required output length for each use 
	 of SHAKE128 or SHAKE256 in message digests, RSASSA-PSS, ECDSA 
	 and KMAC.</t> 
	</section>
	  

	<section title="Use in CMS">
	  <section anchor="md" title="Message Digests"> 
	    <t>The id-shake128 and id-shake256 OIDs (<xref target="oids"/>) can 
		be used as the digest algorithm identifiers located in the SignedData, 
		SignerInfo, DigestedData,  and the AuthenticatedData digestAlgorithm fields 
		in CMS <xref target="RFC5652"/>. The OID encoding MUST omit the parameters field and the output length of SHA256 or SHAKE256 as the message digest MUST be 256 or 512 bits, respectively.</t>
	    
	    <t>The digest values are located in the DigestedData field and the Message 
	    Digest authenticated attribute included in the signedAttributes of the 
	    SignedData signerInfo. In addition, digest values are input to 
	    signature algorithms. The digest algorithm MUST be the same as the 
		message hash algorithms used in signatures.</t>
      </section> 
	    
	  <section title="Signatures" anchor="sigs">      	  
        <t>In CMS, signature algorithm identifiers are located in the SignerInfo 
        signatureAlgorithm field of SignedData content type and countersignature attribute. 
        Signature values are located in the SignerInfo signature field of 
		SignedData content type and countersignature attribute.</t>
		
		<t>Conforming implementations that process RSASSA-PSS and 
		ECDSA with SHAKE signatures when processing CMS data MUST recognize the 
		corresponding OIDs specified in <xref target="oids"/>.</t>
		
	    <t>When using RSASSA-PSS or ECDSA with SHAKEs, the RSA modulus or ECDSA 
		curve order SHOULD be chosen in line with the SHAKE output length. Refer to <xref target="sec_cons"/> for more details.</t>
		     	    
	    <section title="RSASSA-PSS Signatures" anchor="rsa-sigs"> 
	      <t>The RSASSA-PSS algorithm is defined in <xref target="RFC8017"/>.
		  When id-RSASSA-PSS-SHAKE128 or id-RSASSA-PSS-SHAKE256 specified in <xref target="oids"/> 
		  is used, the encoding MUST omit the parameters field. That is, 
		  the AlgorithmIdentifier SHALL be a SEQUENCE of one component,  
		  id-RSASSA-PSS-SHAKE128 or id-RSASSA-PSS-SHAKE256. <xref target="RFC4055"/>
		  defines RSASSA-PSS-params that are used to define the algorithms and inputs 
		  to the algorithm. This specification does not use parameters because the 
		  hash, mask generation algorithm, trailer and salt are embedded in 
		  the OID definition.</t>
		  
		  <t>The hash algorithm to hash a message being signed and the hash 
          algorithm as the mask generation function used in RSASSA-PSS MUST be
          the same: both SHAKE128 or both SHAKE256. The output length of
          the hash algorithm which hashes the message SHALL be 32 (for SHAKE128) 
		  or 64 bytes (for SHAKE256). </t> 
		  
	      <t>The mask generation function takes an octet string of variable length 
          and a desired output length as input, and outputs an octet string of 
          the desired length. In RSASSA-PSS with SHAKEs, the SHAKEs MUST be 
          used natively as the MGF function, instead of the MGF1 algorithm that 
          uses the hash function in multiple iterations as specified in 
          Section B.2.1 of [RFC8017].  In other words, the MGF is defined as 
          the SHAKE128 or SHAKE256 with input being the mgfSeed for id-RSASSA-PSS-
          SHAKE128 and id-RSASSA-PSS-SHAKE256, respectively.  The mgfSeed is the seed 
		  from which mask is generated, an octet string <xref target="RFC8017"/>.		  
		  As explained in Step 9 of section 9.1.1 of <xref target="RFC8017"/>, the output 
		  length of the MGF is emLen - hLen - 1 bytes. emLen is the maximum message 
		  length ceil((n-1)/8), where n is the RSA modulus in bits. hLen is 32 and 
		  64-bytes for id-RSASSA-PSS-SHAKE128 and id-RSASSA-PSS-SHAKE256, respectively. 
		  Thus when SHAKE is used as the MGF, the SHAKE output length maskLen is 
		  (8*emLen - 264) or (8*emLen - 520) bits, respectively. For example, when RSA modulus n is 2048, 
		  the output length of SHAKE128 or SHAKE256 as the MGF will be 1784 or 1528-bits 
		  when id-RSASSA-PSS-SHAKE128 or id-RSASSA-PSS-SHAKE256 is used, respectively.</t>
		  
		  <t>The RSASSA-PSS saltLength MUST be 32 bytes for id-RSASSA-PSS-SHAKE128 
		  or 64 bytes for id-RSASSA-PSS-SHAKE256. 
          Finally, the trailerField MUST be 1, which represents the trailer
          field with hexadecimal value 0xBC <xref target="RFC8017"/>.</t>
	    </section>
      
        <section title="ECDSA Signatures" anchor="ecdsa-sigs">
	      <t>The Elliptic Curve Digital Signature Algorithm (ECDSA) is defined in 
	      <xref target="X9.62"/>. When the id-ecdsa-with-shake128 or id-ecdsa-with-shake256
		  (specified in <xref target="oids"/>) algorithm identifier appears, the 
		  respective SHAKE function is used as the hash. 
		  The encoding MUST omit the parameters field. That is, the AlgorithmIdentifier 
		  SHALL be a SEQUENCE of one component, the OID id-ecdsa-with-shake128 or 
		  id-ecdsa-with-shake256.</t> 
		  
		  <t>For simplicity and compliance with the ECDSA standard specification, 
		  the output length of the hash function must be explicitly determined. 
		  The output length for SHAKE128 or SHAKE256 used in ECDSA MUST be 256 
		  or 512 bits, respectively. </t> 
		  
		  <t>Conforming CA implementations that generate ECDSA with SHAKE signatures 
		  in certificates or CRLs SHOULD generate such signatures with a 
		  deterministically generated, non-random k in accordance with all 
		  the requirements specified in <xref target="RFC6979"/>.  
		  <!-- Sections 7.2 and 7.3 of 
		  <xref target="X9.62"/> or with all the requirements specified in Section 
		  4.1.3 of <xref target="SEC1"/>. -->
		  They MAY also generate such signatures 
		  in accordance with all other recommendations in <xref target="X9.62"/> or 
		  <xref target="SEC1"/> if they have a stated policy that requires 
		  conformance to those standards. Those standards have not specified  
		  SHAKE128 and SHAKE256 as hash algorithm options. However, SHAKE128 and 
		  SHAKE256 with output length being 32 and 64 octets, respectively can  
		  be used instead of 256 and 512-bit output hash algorithms such as SHA256 
		  and SHA512.</t>

		  <!-- <t>In Section 3.2 "Generation of k" of <xref target="RFC6979"/>, HMAC is used to derive 
		  the deterministic k. Conforming implementations that generate deterministic 
		  ECDSA with SHAKE signatures in X.509 MUST use KMAC with SHAKE128 or KMAC with 
		  SHAKE256 as specfied in <xref target="SP800-185"/> when SHAKE128 or SHAKE256 is 
		  used as the message hashing algorithm, respectively. In this situation, KMAC with 
		  SHAKE128 and KMAC with SHAKE256 have 256-bit and 512-bit outputs respectively, 
		  and the optional customization bit string S is an empty string.</t> -->
	    </section>
	  </section>

  	  <section title="Public Keys">
	    <t>In CMS, the signer's public key algorithm identifiers are located in the 
	    OriginatorPublicKey's algorithm attribute.
		The conventions and encoding for RSASSA-PSS and ECDSA <!-- and EdDSA --> 
		public keys algorithm identifiers are as specified in 
		Section 2.3 of <xref target="RFC3279"/>, 
		Section 3.1 of <xref target="RFC4055"/> 
		and Section 2.1 of <xref target="RFC5480"/>. 
		<!-- and <xref target="I-D.josefsson-pkix-eddsa"/> --></t>
	    
		<t>Traditionally, the rsaEncryption object identifier is used to
		identify RSA public keys. The rsaEncryption object identifier 
		continues to identify the public key when the RSA private 
		key owner does not wish to limit the use of the public key 
		exclusively to RSASSA-PSS with SHAKEs. When the RSA private key 
		owner wishes to limit the use of the public key exclusively 
		to RSASSA-PSS, the AlgorithmIdentifier for RSASSA-PSS defined 
		in <xref target="oids"/> SHOULD be used as the algorithm attribute 
		in the OriginatorPublicKey sequence. Conforming client 
		implementations that process RSASSA-PSS with SHAKE public keys 
		in CMS message MUST recognize the corresponding OIDs in <xref target="oids"/>.</t>
		
		<t>Conforming implementations MUST specify and process the 
		algorithms explicitly by using the OIDs specified in 
		<xref target="oids"/> when encoding ECDSA with SHAKE 
		public keys in CMS messages. </t>
		
		<t>The identifier parameters, as explained in <xref target="oids"/>, 
		MUST be absent. </t>
	  </section>
      
	  
	  <section anchor="kmac"  title="Message Authentication Codes">
	    <t>KMAC message authentication code (KMAC) is specified in <xref target="SP800-185"/>. 
	    In CMS, KMAC algorithm identifiers are located in the AuthenticatedData 
	    macAlgorithm field. The KMAC values are located in the AuthenticatedData mac field.</t>
      
	    <t>When the id-KmacWithSHAKE128 or id-KmacWithSHAKE256 OID  
	    is used as the MAC algorithm identifier, the parameters field is optional 
	    (absent or present). If absent, the SHAKE256 output length used in KMAC is 
	    256 or 512 bits, respectively, and the customization string is an empty string by default.</t>

		<t>Conforming implementations that process KMACs with the SHAKEs 
		when processing CMS data MUST recognize these identifiers.</t>
	    
	    <t>When calculating the KMAC output, the variable N is 0xD2B282C2, S 
	    is an empty string, and L, the integer representing the requested output 
	    length in bits, is 256 or 512 for KmacWithSHAKE128 or KmacWithSHAKE256, 
	    respectively, in this specification.</t>
	  </section>
	</section> 
	
    <section anchor="IANA" title="IANA Considerations">
	  <t>One object identifier for the ASN.1 module in <xref target="section-a"/> 
	  was requested for the SMI Security for S/MIME Module Identifiers 
	  (1.2.840.113549.1.9.16.0) registry: </t>
	  <texttable>
        <ttcol align='center'>Decimal</ttcol>
        <ttcol align='center'>Description</ttcol>
        <ttcol align='center'>References</ttcol>
        <c>TBD</c>
        <c>CMSAlgsForSHAKE-2019</c>
        <c>[EDNOTE: THIS RFC]</c>
      </texttable>

	  <!-- <t>EDNOTE: If the PKIX draft is standardized first maybe we should not 
	  keep these OIDS as they are not new. </t>	
	
	  <t>IANA has assigned four OID identifiers in the 
	  SMI Security for PKIX Algorithms <xref target="SMI-PKIX"/> 
	  (1.3.6.1.5.5.7.6) registry </t>
	 	  
      <t><figure><artwork><![CDATA[
  id-RSASSA-PSS-SHAKE128  OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD1 }
  id-RSASSA-PSS-SHAKE256  OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD2 }
  id-ecdsa-with-shake128 OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD3 }
  id-ecdsa-with-shake256 OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD4 }
]]></artwork></figure></t> -->
		
    </section>
      
	<section title="Security Considerations" anchor="sec_cons">
      
	  <t>This document updates <xref target="RFC3370"/>. The security considerations
      section of that document applies to this specification as well.</t>
	  
      <!-- <t>The SHAKEs are deterministic functions. Like any other deterministic
      function, executing each function with the same input multiple times
      will produce the same output. Therefore, users should not expect
      unrelated outputs (with the same or different output lengths) from
      excuting a SHAKE function with the same input multiple times. 
	  The shorter one of any 2 outputs produced from a SHAKE with the same 
	  input is a prefix of the longer one. It is a similar situation as 
	  truncating a 512-bit output of SHA-512 by taking its 256 left-most bits. 
	  These 256 left-most bits are a prefix of the 512-bit output.</t> -->
	  
	  <!-- <t>Implementations must protect the signer's private key. Compromise of
      the signer's private key permits masquerade.</t> -->
      
	  <t>NIST has defined appropriate use of the hash functions in terms of the algorithm 
      strengths and expected time frames for secure use in Special Publications (SPs) 
      <xref target="SP800-78-4"/> and <xref target="SP800-107"/>. 
      These documents can be used as guides to choose appropriate key sizes 
      for various security scenarios. </t>
	  
	  <t>SHAKE128 with output length of 256-bits offers 128-bits of collision preimage resistance. Thus, SHAKE128 OIDs in this specification are RECOMMENDED with 2048 (112-bit security) or 3072-bit (128-bit security) RSA modulus or curves with group order of 256-bits (128-bit security). SHAKE256 with 512-bits output length offers 256-bits of collision and preimage resistance. Thus, the SHAKE256 OIDs in this specification are RECOMMENDED with 4096-bit RSA modulus or higher or curves with group order of 521-bits (256-bit security) or higher. Note that we recommended 4096-bit RSA because we would need 15360-bit modulus for 256-bits of security which is impractical for today's technology.</t>
	  
	  <t>When more than two parties share the same message-authentication key,
      data origin authentication is not provided. Any party that knows the
      message-authentication key can compute a valid MAC, therefore the
      content could originate from any one of the parties.</t>
      
	  <!-- <t>Implementations must randomly generate message-authentication keys
      and one-time values, such as the k value when generating a ECDSA
      signature. In addition, the generation of public/private key pairs
      relies on random numbers. The use of inadequate pseudo-random
      number generators (PRNGs) to generate such cryptographic values can
      result in little or no security. The generation of quality random
      numbers is difficult. <xref target="RFC4086"/> offers important guidance 
	  in this area, and <xref target="SP800-90A"/> series provide acceptable 
      PRNGs.</t> --> 
      
	  <!--<t>Implementers should be aware that cryptographic algorithms may 
	  become weaker with time. As new cryptanalysis techniques are developed 
	  and computing power increases, the work factor or time required to break 
	  a particular cryptographic algorithm may decrease. Therefore, cryptographic 
	  algorithm implementations should be modular allowing new algorithms to 
	  be readily inserted.  That is, implementers should be prepared to 
	  regularly update the set of algorithms in their implementations.</t> -->
	  	  
    </section>
	
	<section title="Acknowledgements" anchor="ack">
	  <t>This document is based on Russ Housley's draft 
	  <xref target="I-D.housley-lamps-cms-sha3-hash"/>. 
	  It replaces SHA3 hash functions by SHAKE128 and SHAKE256 as the LAMPS 
	  WG agreed.</t>
	  <t>The authors would like to thank Russ Housley for his guidance and 
	  very valuable contributions with the ASN.1 module. Valuable 
	  feedback was also provided by Eric Rescorla. </t>
	</section>
	</middle>

	<back>
	<references title="Normative References">
      &RFC2119; 
	  &RFC3370; 
	  &RFC8174; 
 	  &RFC5652;
	  &RFC8017; <!-- RFC8017 is Informational draft but we are keeping it in the Normative References even though idnits complains because we need a normative reference for RSASSA-PSS. RFC4056 does the same thing with RSASS-PSS v2.1 -->
	  &RFC4055;
      &RFC5480;
	  <reference anchor="SHA3">
	    <front>
	      <title>SHA-3 Standard - Permutation-Based Hash and Extendable-Output Functions</title>
	      <author>
	        <organization>National Institute of Standards and Technology, U.S. Department of Commerce</organization>
	      </author>
	      <date month="August" year="2015"/>
	    </front>
	    <seriesInfo name="FIPS" value="PUB 202"/>
	  </reference>
      <reference anchor="SP800-185" target="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf">
        <front>
          <title>SHA-3 Derived Functions: cSHAKE, KMAC, TupleHash and ParallelHash. NIST SP 800-185</title>
          <author>
            <organization>National Institute of Standards and Technology</organization>
          </author>
          <date month="December" year="2016" />
        </front>
      </reference>
	  <!-- <reference anchor="ASN1-B"><front>
	  <title>Information technology - Abstract Syntax Notation One (ASN.1): Specification of basic notation</title>
	  <author>
	  <organization>ITU-T</organization>
	  </author>
	  <date year="2015"/>
	  </front>
	  <seriesInfo name="ITU-T" value="Recommendation X.680"/>
	  </reference> -->
	  <!-- <reference anchor="ASN1-E"><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="2015"/>
	  </front>
	  <seriesInfo name="ITU-T" value="Recommendation X.690"/>
	  </reference> -->
	  <!-- <reference anchor="DSS"><front>
	  <title>Digital Signature Standard, version 4</title>
	  <author>
	  <organization>National Institute of Standards and Technology, U.S. Department of Commerce</organization>
	  </author>
	  <date year="2013"/>
	  </front>
	  <seriesInfo name="NIST" value="FIPS PUB 186-4"/>
	  </reference> -->
	</references>

	<references title="Informative References">
	  &RFC3279;
	  <!-- &RFC4086; -->
	  &RFC5753;
	  &RFC5911;
	  &RFC6268;
	  &RFC6979;
	  &I-D.ietf-lamps-pkix-shake;
	  <?rfc include="http://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.I-D.draft-housley-lamps-cms-sha3-hash-00.xml"?>
      <reference anchor="shake-nist-oids" target="https://csrc.nist.gov/Projects/Computer-Security-Objects-Register/Algorithm-Registration">
        <front>
          <title>Computer Security Objects Register</title>
          <author>
            <organization>National Institute of Standards and Technology</organization>
          </author>
          <date month="October" year="2017" />
        </front>
      </reference>
      <reference anchor="X9.62">
        <front>
          <title>X9.62-2005 Public Key Cryptography for the Financial Services Industry: The Elliptic Curve Digital Signature Standard (ECDSA)</title>
          <author>
            <organization>American National Standard for Financial Services (ANSI)</organization>
          </author>
          <date month="November" year="2005" />
        </front>
      </reference>
      <reference anchor="SP800-78-4" target="https://csrc.nist.gov/csrc/media/publications/sp/800-78/4/final/documents/sp800_78-4_revised_draft.pdf">
        <front>
          <title>SP800-78-4: Cryptographic Algorithms and Key Sizes for Personal Identity Verification</title>
          <author>
            <organization>National Institute of Standards and Technology (NIST)</organization>
          </author>
          <date month="May" year="2014" />
        </front>
      </reference>
      <reference anchor="SP800-107" target="https://csrc.nist.gov/csrc/media/publications/sp/800-107/rev-1/final/documents/draft_revised_sp800-107.pdf">
        <front>
          <title>SP800-107: Recommendation for Applications Using Approved Hash Algorithms</title>
          <author>
            <organization>National Institute of Standards and Technology (NIST)</organization>
          </author>
          <date month="May" year="2014" />
        </front>
      </reference>
      <reference anchor="SEC1" target="http://www.secg.org/sec1-v2.pdf">
        <front>
          <title>SEC 1: Elliptic Curve Cryptography</title>
          <author>
            <organization>Standards for Efficient Cryptography Group</organization>
          </author>
          <date month="May" year="2009" />
        </front>
      </reference>
      <!-- <reference anchor="SMI-PKIX" target="https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#smi-numbers-1.3.6.1.5.5.7.6">
        <front>
          <title>SMI Security for PKIX Algorithms</title>
          <author>
            <organization>IANA</organization>
          </author>
          <date month="March" year="2019" />
        </front>
      </reference> -->
      <!-- <reference anchor="SP800-90A" target="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">
        <front>
          <title>Recommendation for Random Number Generation Using Deterministic Random Bit Generators. NIST SP 800-90A</title>
          <author>
            <organization>National Institute of Standards and Technology</organization>
          </author>
          <date month="June" year="2015" />
        </front>
      </reference> -->
	</references>
	<section title="ASN.1 Module" anchor="section-a">
    <t>This appendix includes the ASN.1 modules for SHAKEs in CMS. 
    This module includes some ASN.1 from other standards for reference.</t>
    <t><figure><artwork><![CDATA[ 
   CMSAlgsForSHAKE-2019 { iso(1) member-body(2) us(840)
        rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) modules(0)
        id-mod-cms-shakes-2019(TBD) }

   DEFINITIONS EXPLICIT TAGS ::=

   BEGIN

   -- EXPORTS ALL;

   IMPORTS

   DIGEST-ALGORITHM, MAC-ALGORITHM, SMIME-CAPS
   FROM AlgorithmInformation-2009
     { iso(1) identified-organization(3) dod(6) internet(1) security(5)
       mechanisms(5) pkix(7) id-mod(0)
       id-mod-algorithmInformation-02(58) }

   RSAPublicKey, rsaEncryption, id-ecPublicKey
   FROM PKIXAlgs-2009 { iso(1) identified-organization(3) dod(6)
        internet(1) security(5) mechanisms(5) pkix(7) id-mod(0)
        id-mod-pkix1-algorithms2008-02(56) } ;

   --
   -- Message Digest Algorithms (mda-)
   -- used in SignedData, SignerInfo, DigestedData,
   -- and the AuthenticatedData digestAlgorithm
   -- fields in CMS
   --
   MessageDigestAlgs DIGEST-ALGORITHM ::= {
    -- This expands MessageAuthAlgs from [RFC5652]
    -- and MessageDigestAlgs in [RFC5753]
    mda-shake128   |
    mda-shake256,
    ...
   }

   --
   -- One-Way Hash Functions
   -- SHAKE128
   mda-shake128 DIGEST-ALGORITHM ::= {
     IDENTIFIER id-shake128  -- with output length 32 bytes.
   }
   id-shake128 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16)
                                       us(840) organization(1) gov(101)
                                       csor(3) nistAlgorithm(4)
                                       hashAlgs(2) 11 }

   -- SHAKE256
   mda-shake256 DIGEST-ALGORITHM ::= {
     IDENTIFIER id-shake256  -- with output length 64 bytes.
   }
   id-shake256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16)
                                       us(840) organization(1) gov(101)
                                       csor(3) nistAlgorithm(4)
                                       hashAlgs(2) 12 }

   --
   -- Public key algorithm identifiers located in the
   -- OriginatorPublicKey's algorithm attribute in CMS.
   -- And Signature identifiers used in SignerInfo
   -- signatureAlgorithm field of SignedData content
   -- type and countersignature attribute in CMS.
   --
   -- From RFC5280, for reference.
   -- rsaEncryption OBJECT IDENTIFIER ::=  { pkcs-1 1 }
      -- When the rsaEncryption algorithm identifier is used
      -- for a public key, the AlgorithmIdentifier parameters
      -- field MUST contain NULL.
   --
   id-RSASSA-PSS-SHAKE128  OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD1 }
   id-RSASSA-PSS-SHAKE256  OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD2 }
      -- When the id-RSASSA-PSS-* algorithm identifiers are used
      -- for a public key or signature in CMS, the AlgorithmIdentifier
      -- parameters field MUST be absent. The message digest algorithm
      -- used in RSASSA-PSS MUST be SHAKE128 or SHAKE256 with a 32 or
      -- 64 byte outout length, respectively. The mask generation 
      -- function MUST be SHAKE128 or SHAKE256 with an output length
      -- of (8*ceil((n-1)/8) - 264) or (8*ceil((n-1)/8) - 520) bits, 
      -- respectively, where n is the RSA modulus in bits. 
      -- The RSASSA-PSS saltLength MUST be 32 or 64 bytes, respectively. 
      -- The trailerField MUST be 1, which represents the trailer 
      -- field with hexadecimal value 0xBC. Regardless of 
      -- id-RSASSA-PSS-* or rsaEncryption being used as the 
      -- AlgorithmIdentifier of the OriginatorPublicKey, the RSA 
      -- public key MUST be encoded using the RSAPublicKey type.

   -- From RFC4055, for reference.
   -- RSAPublicKey ::= SEQUENCE {
   --   modulus INTEGER, -- -- n
   --   publicExponent INTEGER } -- -- e

   id-ecdsa-with-shake128 OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD3 } 
   id-ecdsa-with-shake256 OBJECT IDENTIFIER  ::=  { iso(1) 
            identified-organization(3) dod(6) internet(1) 
            security(5) mechanisms(5) pkix(7) algorithms(6)
            TBD4 }
      -- When the id-ecdsa-with-shake* algorithm identifiers are
      -- used in CMS, the AlgorithmIdentifier parameters field
      -- MUST be absent and the signature algorithm should be 
      -- deterministic ECDSA [RFC6979]. The message digest MUST
      -- be SHAKE128 or SHAKE256 with a 32 or 64 byte outout
      -- length, respectively. In both cases, the ECDSA public key,
      -- MUST be encoded using the id-ecPublicKey type.

   -- From RFC5480, for reference.
   -- id-ecPublicKey OBJECT IDENTIFIER ::= {
   --    iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 }
        -- The id-ecPublicKey parameters must be absent or present
        -- and are defined as
   -- ECParameters ::= CHOICE {
   --     namedCurve         OBJECT IDENTIFIER
   --     -- -- implicitCurve   NULL
   --     -- -- specifiedCurve  SpecifiedECDomain
   --  }

   --
   -- Message Authentication (maca-) Algorithms
   -- used in AuthenticatedData macAlgorithm in CMS
   --
   MessageAuthAlgs MAC-ALGORITHM ::= {
       -- This expands MessageAuthAlgs from [RFC5652] and [RFC6268]
       maca-KMACwithSHAKE128   |
       maca-KMACwithSHAKE256,
       ...
   }

   SMimeCaps SMIME-CAPS ::= {
       -- The expands SMimeCaps from [RFC5911]
      maca-KMACwithSHAKE128.&smimeCaps   |
      maca-KMACwithSHAKE256.&smimeCaps,
      ...
    }

   --
   -- KMAC with SHAKE128
   maca-KMACwithSHAKE128 MAC-ALGORITHM ::= {
         IDENTIFIER id-KMACWithSHAKE128
         PARAMS TYPE KMACwithSHAKE128-params ARE optional
           -- If KMACwithSHAKE128-params parameters are absent
           -- the SHAKE128 output length used in KMAC is 256 bits
           -- and the customization string is an empty string.
         IS-KEYED-MAC TRUE
         SMIME-CAPS {IDENTIFIED BY id-KMACWithSHAKE128}
   }
   id-KMACWithSHAKE128 OBJECT IDENTIFIER ::=  { joint-iso-itu-t(2)
                                country(16) us(840) organization(1)
                                gov(101) csor(3) nistAlgorithm(4)
                                hashAlgs(2) 19 }
   KMACwithSHAKE128-params ::= SEQUENCE {
     kMACOutputLength     INTEGER DEFAULT 256, -- Output length in bits
     customizationString  OCTET STRING DEFAULT ''H
   }

   -- KMAC with SHAKE256
   maca-KMACwithSHAKE256 MAC-ALGORITHM ::= {
         IDENTIFIER id-KMACWithSHAKE256
         PARAMS TYPE KMACwithSHAKE256-params ARE optional
            -- If KMACwithSHAKE256-params parameters are absent
            -- the SHAKE256 output length used in KMAC is 512 bits
            -- and the customization string is an empty string.
         IS-KEYED-MAC TRUE
         SMIME-CAPS {IDENTIFIED BY id-KMACWithSHAKE256}
   }
   id-KMACWithSHAKE256 OBJECT IDENTIFIER ::=  { joint-iso-itu-t(2)
                               country(16) us(840) organization(1)
                               gov(101) csor(3) nistAlgorithm(4)
                               hashAlgs(2) 20 }
   KMACwithSHAKE256-params ::= SEQUENCE {
      kMACOutputLength     INTEGER DEFAULT 512, -- Output length in bits
      customizationString  OCTET STRING DEFAULT ''H
   }

   END
   ]]></artwork></figure>
   </t>
	</section>

	</back>

</rfc>
	
