<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<rfc category="std" ipr="trust200902" docName="draft-smyslov-ipsecme-ikev2-mceliece-02">

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc toc="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="no"?>
<?rfc iprnotified="no" ?>
<?rfc strict="yes" ?>

    <front>
        <title abbrev="Classic McEliece in IKEv2">Using Classic McEliece in the Internet Key Exchange Protocol Version 2 (IKEv2)</title>
        <author initials='V.' surname="Smyslov" fullname='Valery Smyslov'>
            <organization>ELVIS-PLUS</organization>
            <address>
                <postal>
                    <street>PO Box 81</street>
                    <city>Moscow (Zelenograd)</city>
                    <code>124460</code>
                    <country>RU</country>
                </postal>
                <email>svan@elvis.ru</email>
            </address>
        </author>
        <author initials="Y." surname="Nir" fullname="Yoav Nir">
            <organization>Dell Technologies</organization>
            <address>
                <postal>
                    <street>9 Andrei Sakharov St</street>
                    <city>Haifa</city>
                    <code>3190500</code>
                    <country>Israel</country>
                </postal>
                <email>ynir.ietf@gmail.com</email>
            </address>
        </author>
        <date/>

        <abstract>
            <t> This document specifies how Classic McEliece Key Encapsulation Mechanism (KEM) is used to
              generate keys in the Internet Key Exchange version 2 (IKEv2) protocol.</t>
        </abstract>
    </front>

    <middle>
        <section title="Introduction">
          <t> IKEv2 (<xref target="RFC7296"/>) is a protocol for authentication and for generating keys 
            for IPsec (<xref target="RFC4301"/>). Part of it is generating keys. Classic McEliece (<xref 
            target="I-D.josefsson-mceliece"/>) provides a code-based Key Encapsulation Method (KEM) designed 
            to be safe even against an adversary equipped with a quantum computer.  The twelve parameter  
            sets described in section 9 of <xref target="I-D.josefsson-mceliece"/> offers different balances
            between performance and output sizes.</t>
          <t> The information needed for key agreement (in the case of McEliece this is a public key and a 
            ciphertext) is carried in Key Exchange (KE) payloads. With the most common parameter set from 
            the draft, mceliece6688128, the public key requires (see section 8.2.7 of the McEliece document) 
            1044992 octets to encode. This is almost 16 times as big as a standard KE payload (or any other 
            payload) can carry, so we need to use a big payload, as specified in the big payload draft 
            (<xref target="I-D.nir-ipsecme-big-payload"/>).</t>
          <t> Because large payloads cannot be used in the IKE_SA_INIT exchange
          (see section 2.3 of <xref target="I-D.nir-ipsecme-big-payload" />), the first key exchange 
          has to use another algorithm, such as classic Diffie-
            Hellman or an elliptic curve variant.  The McEliece exchange needs to be carried in an 
            IKE_INTERMEDIATE exchange (<xref target="RFC9242"/>), after negotiating in the IKE_SA_INIT both
            support for big payloads and the additional key exchange exchange through the 
            INTERMEDIATE_EXCHANGE_SUPPORTED notify message (<xref target="RFC9370"/>). The Classic Mceliece
            KEM can also be used in CREATE_CHILD_SA. For that, support for the intermediate exchange is not
            necessary.</t>
          <t> TBD if this document should make any recommendations about which DH group to use for the 
            initial key exchange, or whether it should remain silent on the topic.</t>
        </section>

        <section anchor="mustshouldmay" title="Terminology and Notation">
            <t> The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", 
            "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted 
            as described in BCP 14 <xref target="RFC2119" /> <xref target="RFC8174" /> when, and only when, 
            they appear in all capitals, as shown here.</t>
            <t> It is assumed that readers are familiar with the IKEv2 protocol <xref target="RFC7296" />.
            </t>
        </section>

        <section anchor="mceliece" title="Classic McEliece KEM">
          <t>Classic McEliece <xref target="I-D.josefsson-mceliece"/> is a code-based Key Encapsulation Mechanism 
          (KEM) that is considered conservative and very thoroughly analysed.
          </t>

          <t> The <xref target="I-D.josefsson-mceliece"/> document specifies 12 parameter sets. Should we
            just leave it at that, or specify just one? The current SSH candidate draft specifies only
            mceliece6688128. The current TLS candidate draft specifies 3: mceliece6688128, mceliece6960119,
            and mceliece8192128. Official Classic McEliece site <xref target="MCELIECE" /> lists 5
            parameter sets. What should we do?</t>

            <!-- The number of parameter sets in draft-josefsson-mceliece is confusing. First, 
            the other Simon's draft - draft-josefsson-ssh-mceliece says that "f" parameter sets 
            only define a different algorithm for key generation - faster, but more complex.
            The generated keys are compatible with non-"f" algorithms. Thus, we may consider
            choice between "f" and non-"f" implementation dependand and do not allocate 
            code points for "f" parameter sets.

            Then, there are "pc" and non-"pc" parameter sets. From what I learned reading
            official site https://classic.mceliece.org/impl.html, "pc" stands for "plaintext confirmation"
            and it seems to be older McEliece variants. Can we disregard them?

            Thus only 3 variants are left: mceliece6688128, mceliece6960119, mceliece8192128.
            liboqs also lists mceliece348864 and mceliece 460896.

            The main puzzle for me is the difference between mceliece6688128 and mceliece6960119 - 
            they have almost identical key size (and presumably security). Why both are needed?
            Another puzzle is that draft-josefsson-mceliece for some reason ignores
            parameter sets for NIST level less than 5. I would list all of variants
            from official site.
            -->

          <t> This is up to the working group. Until this is decided, we added 
            a comparison table between the parameter sets here. Ultimately, there is nothing special about IKEv2. 
            What is fitting for TLS and SSH is likely fitting for IKEv2 as well.</t>

          <table title="Classic McEliece Parameter Set Summary">
            <thead>
              <tr>
                  <th>Parameter Set</th>
                  <th>Claimed NIST Leve</th>
                  <th>Public key size (bytes)</th>
                  <th>Secret key size (bytes)</th>
                  <th>Ciphertext size (bytes)</th>
                  <th>Shared secret size (bytes)</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                  <th>mceliece348864</th>
                  <th>1</th>
                  <th>261120</th>
                  <th>6492</th>
                  <th>96</th>
                  <th>32</th>
              </tr>
              <tr>
                  <th>mceliece460896</th>
                  <th>3</th>
                  <th>524160</th>
                  <th>13608</th>
                  <th>156</th>
                  <th>32</th>
              </tr>
              <tr>
                  <th>mceliece6688128</th>
                  <th>5</th>
                  <th>1044992</th>
                  <th>13932</th>
                  <th>208</th>
                  <th>32</th>
              </tr>
              <tr>
                  <th>mceliece6960119</th>
                  <th>5</th>
                  <th>1047319</th>
                  <th>13948</th>
                  <th>194</th>
                  <th>32</th>
              </tr>
              <tr>
                  <th>mceliece8192128</th>
                  <th>5</th>
                  <th>1357824</th>
                  <th>14120</th>
                  <th>208</th>
                  <th>32</th>
              </tr>
            </tbody>
          </table>

        </section>

        <section anchor="mceliece-ikev2" title="Using Classic McEliece in IKEv2">
          <t> To negotiate the use of the McEliece KEM, an IKEv2 initiator and responder <bcp14>MUST</bcp14> negotiate
            three things in the IKE_SA_INIT exchange:</t>
          <ul>
            <li> The support for big IKE payloads <xref target="I-D.nir-ipsecme-big-payload"/> </li>
            <li> Support for IKE fragmentation <xref target="RFC7383"/> </li>
            <li> The use of these groups, see <xref target="iana"/>, in an ADDKE* transform. This implies support for
              the IKE_INTERMEDIATE exchange <xref target="RFC9242" /></li>
          </ul>
          <t> Since all of the above have to be specified in the IKE_SA_INIT request, the McEliece key
            exchange, cannot be used in the IKE_SA_INIT exchange and a Responder <bcp14>MUST</bcp14> reject any McEliece group offered in the KE transform. 
            Additionally, it <bcp14>MUST</bcp14> reject any McEliece group offered in an ADDKE* transform if the initiator has not also proposed the use of three extensions: 
            IKE_INTERMEDIATE exchange, big payloads and IKE fragmentation.</t>

          <t> Within the IKE_INTERMEDIATE exchange, such payloads will normally encode the large public
            keys. A diagram is provided here for illustration:. The format below is the big payload version
            of the Key Exchange payload from section 3.4 of <xref target="RFC7296"/>.</t>
         <figure> 
            <artwork><![CDATA[
                        1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Next Payload  |C|L| RESERVED  |       Payload Length...        
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
      ...length continued          |      Key Exchange Method      | 
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   
   |           RESERVED            |                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
   |                                                               |
   ~                     McEliece KEM key data                     ~
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

           ]]></artwork>
          </figure>
          <ul>
            <li> L is 1, indicating that the length field is 32-bit.</li>
            <li> The Key Exchange Method is TBD, the value assigned by IANA (see 
              <xref target="iana"/>)</li>
            <li> The McEliece KEM key data is as described in section 6.3 of <xref 
              target="I-D.josefsson-mceliece"/>. </li>
          </ul>
          <t> Note that when the KE payload is used to carry ciphertext, it can fit with the 
          short payload format. It is not required to always use the big payload format to
          use Classic McEliece.</t>

          <section anchor="child_sa" title="Using Classic McEliece for Child SAs and for IKE SA Rekey">
            <t> The Classic McEliece KEM can also be used in the CREATE_CHILD_SA exchange (or in the IKE_FOLLOWUP_KE exchange 
            as defined in <xref target="RFC9370"/>) to rekey
            IKE SA and to create/rekey IPsec SAs. The format and size are just the same, so doing this also requires
            support for big payloads and for IKE fragmentation. However, if Classic McEliece 
            is only used in these exchanges, there is no need to negotiate the IKE_INTERMEDIATE exchange.
            </t>
          </section>  
        </section>

        <section anchor="transport" title="Transport Considerations">
            <t> While an IKE SA that utilizes Classic McEliece can run over UDP, in most settings 
            this will be problematic. The reason is that with tipical MTU size of 1500 bytes, 
            an IKE message containing Classic McEliece public key will be splitted into several
            hundreds IKE fragment messages, which will be sent to the network at once.
            This may lead to network congestion causing loss of some messages, in which case all
            the fragment messages will be re-sent again (after timeout), since IKE fragment messages are not 
            individually acknowledged. This will also lead to congestion and the process will repeat
            until all the fragment messages will be received, but this might not happen.
            </t>

            <t> For this reason peers may want to use TCP as a transport. Peers may choose between 
            using TCP for both IKE and ESP as specified in <xref target="RFC9329"/> or using separate 
            transports for them <xref target="I-D.smyslov-ipsecme-ikev2-reliable-transport"/>.
            The latter allows to avoid performance degradation when tunnelling TCP trafic 
            and thus is <bcp14>RECOMMENDED</bcp14>.
            </t>

            <t>Note, that despite the fact, that TCP can tranfer messages of any size without
            having problems with IP fragmentation, in case of Classic McEliece peers
            still have to negotiate IKE fragmentation <xref target="RFC7383" /> as defined
            in <xref target="mceliece-ikev2" />, even when they choose to use TCP as a transport for IKE.
            This is due to the limitation imposed by <xref target="RFC9329"/> that individual
            IKE message in TCP stream cannot exceed 64 Kbytes. Thus, larger IKE messages
            need to be be fragmented to this size by IKE fragmentation mechanism before sending over TCP.
            </t>
        </section>

        <section anchor="security" title="Security Considerations">
          <t> This inherits the security of IKEv2, the additional key exchange extension, the big
            payload extension, and of course, classic McEliece.</t>
          <t> Some discussion about choice of group for the initial key exchange should be added here.</t>
          <t> Probably more about McEliece here.</t>
        </section>

        <section anchor="iana" title="IANA Considerations">
          <t> IANA is requested to assign one (or is it three) values from the "Transform Type 4 - Key 
            Exchange Method Transform IDs" registry with name "mceliece6688128" (and maybe also 
            "mceliece6960119" and "mceliece8192128") and this document as reference.</t>
        </section>

    </middle>

    <back>
        <references title='Normative References'>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7296.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7383.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9242.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9370.xml" ?>
            <?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.josefsson-mceliece.xml"?>
            <?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.nir-ipsecme-big-payload.xml"?>
        </references>

        <references title='Informative References'>
            <reference anchor="MCELIECE" target="https://classic.mceliece.org/">
                <front>
                    <title>Classic McEliece</title>
                    <author>
                        <organization/>
                    </author>
                </front>
            </reference>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9329.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4301.xml" ?>
            <?rfc include="https://xml2rfc.tools.ietf.org/public/rfc/bibxml3/reference.I-D.smyslov-ipsecme-ikev2-reliable-transport.xml"?>
        </references>

        <section anchor="ack" title="Acknowledgements" numbered="false">
            <t> To be added.
            </t>
        </section>

    </back>
</rfc>





