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

<!DOCTYPE rfc SYSTEM "rfc2629-xhtml.ent">
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" number="8750" category="std"
     consensus="true" docName="draft-ietf-ipsecme-implicit-iv-11"
     ipr="trust200902" obsoletes="" updates="" submissionType="IETF"
     xml:lang="en" tocInclude="true" symRefs="true" sortRefs="true"
     version="3">

  <front>
    <title abbrev="Implicit IV in ESP">Implicit Initialization Vector (IV) for Counter-Based
Ciphers in Encapsulating Security Payload (ESP) </title>


<seriesInfo name="RFC" value="8750"/>
    <author fullname="Daniel Migault" initials="D." surname="Migault">
      <organization>Ericsson</organization>
      <address>
        <postal>
          <street>8275 Trans Canada Route</street>
          <city>Saint Laurent</city>
          <region>QC</region>
          <code>H4S 0B6</code>
          <country>Canada</country>
        </postal>
        <email>daniel.migault@ericsson.com</email>
      </address>
    </author>
    <author fullname="Tobias Guggemos" initials="T." surname="Guggemos">
      <organization>LMU Munich</organization>
      <address>
        <postal>
          <street>Oettingenstr. 67</street>
          <city>Munich</city>
          <code>80538</code>
          <country>Germany</country>
        </postal>
        <phone/>
        <email>guggemos@nm.ifi.lmu.de</email>
        <uri>http://mnm-team.org/~guggemos</uri>
      </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 month="March" year="2020"/>
    <area>INTERNET</area>
    <workgroup>IPSECME</workgroup>

<keyword>IKE</keyword>
<keyword>IPsec</keyword>
<keyword>GCM</keyword>
<keyword>CCM</keyword>
<keyword>ChaCha20</keyword>

    <abstract>
      <t>Encapsulating Security Payload (ESP) sends an initialization vector
      (IV) in each packet. The size of the IV depends on the applied transform
      and is usually 8 or 16 octets for the transforms defined at the time
      this document was written. When used with IPsec, some algorithms, such
      as AES-GCM, AES-CCM, and ChaCha20-Poly1305, take the IV to generate a
      nonce that is used as an input parameter for encrypting and
      decrypting. This IV must be unique but can be predictable.  As a result,
      the value provided in the ESP Sequence Number (SN) can be used instead
      to generate the nonce. This avoids sending the IV itself and saves 8
      octets per packet in the case of AES-GCM, AES-CCM, and
      ChaCha20-Poly1305. This document describes how to do this.</t>
    </abstract>
  </front>
  <middle>

    <section anchor="intro" numbered="true" toc="default">
      <name>Introduction</name>
      <t>Counter-based AES modes of operation such as AES-CCM <xref
      target="RFC4309" format="default"/> and AES-GCM <xref target="RFC4106"
      format="default"/> require the specification of a nonce for each ESP
      packet. The same applies for ChaCha20-Poly1305 <xref target="RFC7634"
      format="default"/>. Currently, this nonce is generated thanks to the
      initialization vector (IV) provided in each ESP packet <xref
      target="RFC4303" format="default"/>. This practice is designated in
      this document as "explicit IV".</t>

      <t>In some contexts, such as the Internet of Things (IoT), it may be
      preferable to avoid carrying the extra bytes associated to the IV and
      instead generate it locally on each peer. The local generation of the IV
      is designated in this document as "implicit IV".</t>
      <t>The size of this IV depends on the specific algorithm, but all of the
      algorithms mentioned above take an 8-octet IV.</t>
      <t>This document defines how to compute the IV locally when it is
      implicit. It also specifies how peers agree with the Internet Key
      Exchange version 2 (IKEv2) <xref target="RFC7296" format="default"/> on
      using an implicit IV versus an explicit IV.</t>
      <t>This document limits its scope to the algorithms mentioned above.
      Other algorithms with similar properties may later be defined to use
      similar mechanisms.</t>
      <t> This document does not consider AES-CBC <xref target="RFC3602"
      format="default"/>, as AES-CBC requires the IV to be
      unpredictable. Deriving it directly from the packet counter as described
      below is insecure, as mentioned in <xref target="RFC3602"
      sectionFormat="of" section="6"/>, and has led to real-world chosen
      plaintext attacks such as BEAST <xref target="BEAST"
      format="default"/>.</t>
      <t>This document does not consider AES-CTR <xref target="RFC3686" format="default"/>, as
it focuses on the recommended Authenticated Encryption with Associated Data (AEAD) suites provided in <xref target="RFC8221" format="default"/>.</t>
    </section>

    <section numbered="true" toc="default">
      <name>Requirements Notation</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="sec_terminology" numbered="true" toc="default">
      <name>Terminology</name>

      <dl newline="false" indent="9" spacing="normal">
        <dt>IoT:</dt> <dd>Internet of Things</dd>
        <dt>IV:</dt> <dd>Initialization Vector</dd>
        <dt>IIV:</dt> <dd>Implicit Initialization Vector</dd>

        <dt>Nonce:</dt> <dd>A fixed-size octet string used only once. In this
        document, the IV is used to generate the nonce input for the
        encryption/decryption. </dd>
      </dl>

    </section>

        <section anchor="sec-aes-ctr-ccm-cgm" numbered="true" toc="default">
      <name>Implicit IV</name>
      <t>With the algorithms listed in <xref target="intro"
      format="default"/>, the 8-byte IV <bcp14>MUST NOT</bcp14> repeat for a
      given key. The binding between an ESP packet and its IV is provided
      using the Sequence Number or the Extended Sequence Number.  

Figures <xref target="fig-aes-ctr-ccm-gcm-iv-sn" format="counter"/> and <xref
target="fig-aes-ctr-ccm-gcm-iv-esn" format="counter"/> represent the IV with a
regular 4-byte Sequence Number and an 8-byte Extended Sequence Number,
respectively.</t>
      <figure anchor="fig-aes-ctr-ccm-gcm-iv-sn">
        <name>Implicit IV with a 4-Byte Sequence Number</name>
        <artwork name="" type="" align="left" alt=""><![CDATA[
0                   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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
|                              Zero                             | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
|                      Sequence Number                          | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    ]]></artwork>
      </figure>

      <dl newline="true" spacing="normal">
        <dt>Sequence Number:</dt> 
        <dd>The 4-byte Sequence Number carried in the ESP packet.</dd>

        <dt>Zero:</dt> 
        <dd>A 4-byte array with all bits set to zero.</dd>
      </dl>

      <figure anchor="fig-aes-ctr-ccm-gcm-iv-esn">
        <name>Implicit IV with an 8-Byte Extended Sequence Number</name>
        <artwork name="" type="" align="left" alt=""><![CDATA[
0                   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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
|                         Extended                              |
|                      Sequence Number                          | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    ]]></artwork>
      </figure>
      <dl newline="true" spacing="normal">
        <dt>Extended Sequence Number:</dt> <dd>The 8-byte Extended Sequence
        Number of the Security Association. The four low-order bytes are
        carried in the ESP packet.</dd>
      </dl>
      <t> This document solely defines the IV generation of the algorithms
      defined in <xref target="RFC4106"/> for AES-GCM, <xref
      target="RFC4309"/> for AES-CCM, and <xref target="RFC7634"/> for
      ChaCha20-Poly1305. All other aspects and parameters of those algorithms
      are unchanged and are used as defined in their respective
      specifications.</t>

</section>

    <section numbered="true" toc="default">
      <name>IKEv2 Initiator Behavior</name>
      <t>An initiator supporting this feature <bcp14>SHOULD</bcp14> propose implicit IV (IIV)
algorithms in the Transform Type 1 (Encryption Algorithm) Substructure
of the Proposal Substructure inside the Security Association (SA)
payload in the IKEv2 Exchange. To facilitate backward compatibility
with non-supporting peers, the initiator <bcp14>SHOULD</bcp14> also include those same
algorithms with explicit IV as separate transforms.</t>
    </section>
    <section numbered="true" toc="default">
      <name>IKEv2 Responder Behavior</name>
      <t>The rules of SA payload processing require that the responder pick its
algorithms from the proposal sent by the initiator, thus
ensuring that the responder will never send an SA payload containing the
IIV transform to an initiator that did not propose it.</t>
    </section>
    <section numbered="true" toc="default">
      <name>Security Considerations</name>

      <t>Nonce generation for these algorithms has not been explicitly
      defined. It has been left to the implementation as long as certain
      security requirements are met. Typically, for AES-GCM, AES-CCM, and
      ChaCha20-Poly1305, the IV is not allowed to be repeated for one
      particular key. This document provides an explicit and normative way to
      generate IVs. The mechanism described in this document meets the IV
      security requirements of all relevant algorithms.</t>
      <t> As the IV must not repeat for one SA when Counter-Mode ciphers are
      used, implicit IV as described in this document <bcp14>MUST NOT</bcp14>
      be used in setups with the chance that the Sequence Number overlaps for
      one SA.  

The sender's counter and the receiver's counter <bcp14>MUST</bcp14> be reset
(by establishing a new SA and thus a new key) prior to the transmission of the
2^32nd packet for an SA that does not use an Extended Sequence Number and
prior to the transmission of the 2^64th packet for an SA that does use an
Extended Sequence Number. This prevents Sequence Number overlaps for the
mundane point-to-point case. Multicast as described in <xref target="RFC5374"
format="default"/>, <xref target="RFC6407" format="default"/>, and <xref
target="I-D.ietf-ipsecme-g-ikev2" format="default"/> is a prominent example in which
many senders share one secret and thus one SA.  As such, implicit IV may only
be used with Multicast if some mechanisms are employed that prevent the
Sequence Number from overlapping for one SA; otherwise, implicit IV
<bcp14>MUST NOT</bcp14> be used with Multicast.  </t>

      <t>This document defines three new encryption transforms that use
      implicit IV. Unlike most encryption transforms defined to date, which
      can be used for both ESP and IKEv2, these transforms are defined for ESP
      only and cannot be used in IKEv2. The reason for this is that IKEv2 messages
      don't contain a unique per-message value that can be used for IV
      generation. The Message-ID field in the IKEv2 header is similar to the SN
      field in the ESP header, but recent IKEv2 extensions <xref target="RFC6311"
      format="default"/> <xref target="RFC7383" format="default"/> do allow
      it to repeat, so there is not an easy way to derive unique IV from IKEv2
      header fields.</t>
    </section>
    <section numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>IANA has updated the "Internet Key Exchange Version 2 (IKEv2)
      Parameters" registry <xref target="RFC7296" format="default"/> by adding
      the following new code points to the "Transform Type 1 - Encryption
      Algorithm Transform IDs" subregistry under the "Transform Type Values"
      registry <xref target="IANA" format="default"/>:

</t>

<table anchor="iana-registry" align="left">
  <name>Additions to "Transform Type 1 - Encryption Algorithm Transform IDs" Registry</name>    
  <thead>
    <tr>
      <th>Number</th>
      <th>Name</th>
      <th>ESP Reference</th>
      <th>IKEv2 Reference</th>
    </tr>
  </thead>
  <tbody>   
    <tr>
      <td>29</td>
      <td>ENCR_AES_CCM_8_IIV</td>
      <td>RFC 8750</td>
      <td>Not allowed</td>
    </tr>
    <tr>
      <td>30</td>
      <td>ENCR_AES_GCM_16_IIV</td>
      <td>RFC 8750</td>
      <td>Not allowed</td>
    </tr>
    <tr>
      <td>31</td>
      <td>ENCR_CHACHA20_POLY1305_IIV</td>
      <td>RFC 8750</td>
      <td>Not allowed</td>
    </tr>
  </tbody>
</table>

    </section>

  </middle>
  <back>


<displayreference target="I-D.ietf-ipsecme-g-ikev2" to="G-IKEv2"/>

    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3602.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3686.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4106.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4303.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4309.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5374.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6311.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6407.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7296.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7634.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7383.xml"/>
   
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8221.xml"/>
      </references>
      <references>
        <name>Informative References</name>

<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-ipsecme-g-ikev2.xml"/>


        <reference anchor="BEAST" target="https://www.researchgate.net/publication/266529975_Here_Come_The_Ninjas">
          <front>
            <title>Here Come The xor Ninjas</title>
            <author initials="T." surname="Duong" fullname="Thai Duong">
              <organization/>
            </author>
            <author initials="J." surname="Rizzo" fullname="Juliano Rizzo">
              <organization/>
            </author>
            <date  month="May" year="2011"/>
          </front>
        </reference>

        <reference anchor="IANA" target="https://www.iana.org/assignments/ikev2-parameters">
          <front>
            <title>Internet Key Exchange Version 2 (IKEv2) Parameters</title>
<author><organization>IANA</organization></author>

          </front>
        </reference>
      </references>

    </references>

    <section numbered="false" toc="default">
      <name>Acknowledgements</name>
      <t>We would like to thank <contact fullname="Valery Smyslov"/>, <contact
      fullname="Éric Vyncke"/>, <contact fullname="Alexey Melnikov"/>,
      <contact fullname="Adam Roach"/>, and <contact fullname="Magnus
      Nyström"/> (security directorate) as well as our three Security ADs --
      <contact fullname="Eric Rescorla"/>, <contact fullname="Benjamin
      Kaduk"/>, and <contact fullname="Roman Danyliw"/> -- for their valuable
      comments. We also would like to thank <contact fullname="David
      Schinazi"/> for his implementation as well as
      <contact fullname="Tero Kivinen"/> and <contact fullname="David
      Waltermire"/> (the IPSECME Chairs) for moving this work forward.</t>

    </section>

  </back>
</rfc>
