<?xml version="1.0" encoding="utf-8"?>
<?oxygen RNGSchema="xml2rfc/rfc2629xslt/rfc2629-ext.rnc" type="compact"?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!-- U+00A0 NO-BREAK SPACE                             (special " ")
    -->
  <!ENTITY eacute  "&#233;">
  <!-- U+00E9 LATIN SMALL LETTER E WITH ACUTE            ("e")
    -->

  <!-- RFC Keywords. -->
  
  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
  >MAY</bcp14>">
  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >MUST</bcp14>">
  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >MUST NOT</bcp14>">
  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >OPTIONAL</bcp14>">
  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >RECOMMENDED</bcp14>">
  <!ENTITY NOT-RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >NOT RECOMMENDED</bcp14>">
  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >REQUIRED</bcp14>">
  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >SHALL</bcp14>">
  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >SHALL NOT</bcp14>">
  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >SHOULD</bcp14>">
  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'
   >SHOULD NOT</bcp14>">

  <!-- Get references from the online citation libraries. -->
  <!-- RFC вообще -->
  <!ENTITY HMAC          SYSTEM 'bibxml/rfc.2104.xml'>
  <!ENTITY RFC2119       SYSTEM 'bibxml/rfc.2119.xml'>

  <!-- IPsec RFCs -->
  <!ENTITY RFC4301      SYSTEM 'bibxml/rfc.4301.xml'>
  <!ENTITY AH           SYSTEM 'bibxml/rfc.4302.xml'>
  <!ENTITY RFC4303      SYSTEM 'bibxml/rfc.4303.xml'>
  <!ENTITY RFC2407      SYSTEM 'bibxml/rfc.2407.xml'>
  <!ENTITY RFC2408      SYSTEM 'bibxml/rfc.2408.xml'>
  <!ENTITY RFC2409      SYSTEM 'bibxml/rfc.2409.xml'>
  <!ENTITY ESN          SYSTEM 'bibxml/rfc.4304.xml'>
  <!ENTITY RFC2675      SYSTEM 'bibxml/rfc.2675.xml'>
  <!ENTITY RFC4106      SYSTEM 'bibxml/rfc.4106.xml'>
  <!ENTITY RFC4309      SYSTEM 'bibxml/rfc.4309.xml'>
  <!ENTITY RFC6071      SYSTEM 'bibxml/rfc.6071.xml'>

  <!-- IPsec IKEv2 AEA RFCs -->
  <!ENTITY RFC5116      SYSTEM 'bibxml/rfc.5116.xml'>
  <!ENTITY RFC5282      SYSTEM 'bibxml/rfc.5282.xml'>
  <!ENTITY RFC5996      SYSTEM 'bibxml/rfc.5996.xml'>
  <!ENTITY RFC6311      SYSTEM 'bibxml/reference.RFC.6311.xml'>

  <!-- PKIX&CMS RFCs -->
  <!ENTITY PKALGS       SYSTEM 'bibxml/rfc.3279.xml'>
  <!ENTITY PROFILE      SYSTEM 'bibxml/rfc.3280.xml'>
  <!ENTITY CMS	        SYSTEM 'bibxml/rfc.3852.xml'>
  <!ENTITY RFC4134      SYSTEM "bibxml/reference.RFC.4134.xml">

  <!-- ISO STDs -->
  <!ENTITY X.208-88     SYSTEM 'bibxml2/x208-88.xml'>
  <!ENTITY X.209-88     SYSTEM 'bibxml2/x209-88.xml'>
  <!ENTITY X.680-02     SYSTEM 'bibxml2/x680-02.xml'>
  <!ENTITY X.690-02     SYSTEM 'bibxml2/x690-02.xml'>
  <!ENTITY X.509-00     SYSTEM 'bibxml2/x509-00.xml'>

  <!-- Законодательство РФ -->
  <!ENTITY RFEDSL       SYSTEM 'bibxml2/rus-law.rfedsl.xml'>
  <!ENTITY RFLLIC       SYSTEM 'bibxml2/rus-law.rfllic.xml'>
  <!ENTITY CRYPTOLIC    SYSTEM 'bibxml2/rus-law.cryptolic.xml'>

  <!-- Стандарты РФ и СНГ -->
  <!ENTITY GOST28147    SYSTEM 'bibxml2/gost.28147.xml'>
  <!ENTITY GOSTR341094  SYSTEM 'bibxml2/gost.r341094.xml'>
  <!ENTITY GOSTR341001  SYSTEM 'bibxml2/gost.r341001.xml'>
  <!ENTITY GOSTR341194  SYSTEM 'bibxml2/gost.r341194.xml'>
  <!ENTITY GOST3431095  SYSTEM 'bibxml2/gost.3431095.xml'>
  <!ENTITY GOST3431004  SYSTEM 'bibxml2/gost.3431004.xml'>
  <!ENTITY GOST3431195  SYSTEM 'bibxml2/gost.3431195.xml'>

  <!-- Российская криптография для Internet (IETF) -->
  <!ENTITY RFC4357      SYSTEM 'bibxml/rfc.4357.xml'>
  <!ENTITY RFC4490      SYSTEM 'bibxml/rfc.4490.xml'>
  <!ENTITY RFC4491      SYSTEM 'bibxml/rfc.4491.xml'>
  <!ENTITY ENG-GOST28147    SYSTEM 'bibxml/rfc.5830.xml'>
  <!ENTITY ENG-GOSTR341001  SYSTEM 'bibxml/rfc.5832.xml'>
  <!ENTITY ENG-GOSTR341194  SYSTEM 'bibxml/rfc.5831.xml'>

  <!-- Локальные сокращения -->
  <!ENTITY gencr        "GOST&nbsp;28147-89">
  <!ENTITY ghash        "GOST&nbsp;R&nbsp;34.11-94">
  <!ENTITY gsign        "GOST&nbsp;R&nbsp;34.10-2001">
  <!ENTITY gvko         "VKO&nbsp;GOST&nbsp;R&nbsp;34.10-2001">

  <!ENTITY namegike     'Using &gencr;, &ghash; and &gsign; with 
                         IKE and ISAKMP'>
  <!ENTITY namegesp     'Using &gencr; with IPsec Encapsulating 
                         Security Payload (ESP)'>
  <!ENTITY namegah      'The Use of &ghash; within ESP and AH'>
]>

<?xml-stylesheet type='text/xsl' 
  href='xml2rfc/rfc2629xslt/rfc2629.xslt'
?>
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocappendix="no"?>
<?rfc tocdepth="3"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc category="info"
     ipr="trust200902"
     docName="draft-fedchenko-ipsecme-cpesp-gost-00"
     obsoletes=""
     updates=""
     submissionType="IETF"
     xml:lang="en"
     xmlns:x='http://purl.org/net/xml2rfc/ext'>

  <front>
    <!-- The abbreviated title is used in the page header - 
         it is only necessary if the full title is longer 
         than 39 characters -->
    <title abbrev="GOST for IPsec ESP">
      &namegesp;
    </title>

    <author fullname="Serguei E. Leontiev" initials="S.Е." role="editor"
            surname="Leontiev">
      <organization abbrev="CRYPTO-PRO">
        "CRYPTO-PRO", LLC
      </organization>
      <address>
        <postal>
          <street>18, Suschevsky Val str.</street>
          <country>Russian Federation</country>
          <code>127018</code>
          <city>Moscow</city>
        </postal>
        <phone>+7 (916) 686 10 81</phone>
        <facsimile>+74957804820</facsimile>
        <email>lse@cryptopro.ru</email>
        <uri>http://www.cryptopro.ru</uri>
      </address>
    </author>

    <author fullname="Dmitry N. Pichulin" initials="D.N." role="editor"
            surname="Pichulin">
      <organization abbrev="CRYPTO-PRO">
        "CRYPTO-PRO", LLC
      </organization>
      <address>
        <postal>
          <street>18, Suschevsky Val str.</street>
          <country>Russian Federation</country>
          <code>127018</code>
          <city>Moscow</city>
        </postal>
        <phone>+7 (905) 540 88 60</phone>
        <facsimile>+74957804820</facsimile>
        <email>pdn@cryptopro.ru</email>
        <uri>http://www.cryptopro.ru</uri>
      </address>
    </author>

    <author fullname="Andrey A. Fedchenko" initials="A.A." role="editor"
            surname="Fedchenko">
      <organization abbrev="S-Terra">
        "S-Terra" LLC
      </organization>
      <address>
        <postal>
          <street>Zelenograd, 6, driveway 4806</street>
          <country>Russian Federation</country>
          <code>124460</code>
          <city>Moscow</city>
        </postal>
        <facsimile>+74999409061</facsimile>
        <email>hell@s-terra.com</email>
        <uri>http://www.s-terra.com/</uri>
      </address>
    </author>

    <date/> <!-- Текущая, потом <date month="November" year="2013"/> -->

    <area>Secutity</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <!-- WG name at the upperleft corner of the doc,
           IETF is fine for individual submissions. 
           If this element is not present, the default is 
           "Network Working Group", which is used by the 
           RFC Editor as a nod to the history of the IETF. -->

    <keyword>GOST 28147-89</keyword>
    <keyword>IPsec</keyword>
    <keyword>ISAKMP</keyword>
    <keyword>ESP</keyword>
    <keyword>IKE</keyword>
    <keyword>IP</keyword>
    <!-- Keywords will be incorporated into HTML output
           files in a meta tag but they have no effect on text or nroff
           output. If you submit your draft to the RFC Editor, the
           keywords will be used for the search engine. -->

    <abstract>
      <t>
        This document defines the usage of GOST 28147-89 algorithm
        when providing data integrity and confidentiality in ESP protocol.
      </t>

      <t>
        The contents of this document is technically equivalent to
        its TC26 ROSSTANDART specification.
      </t>

      <t>
        This specification
        is maintained by TC26 ROSSTANDART and further updates are available at:
        http://www.tc26.ru/.
      </t>

    </abstract>
  </front>

  <middle>
    <section title="Introduction">
        <t>
          This document contains a technical specification approved by the 
          Technical Committee #26 ("Cryptography and security mechanisms") of 
          Federal Agency on Technical Regulating and Metrology of 
          the Russian Federation (ROSSTANDART)
          <xref target="TC26-ESP"/>.
        </t>
        <t>
        This memo describes implementation features and additional
        identification types of ESP protocol <xref target="RFC4303"/>
        when used with GOST 28147-89 encryption algorithm.
        This document defines the following payload transforms in
        ESP protocol:
        <list style="symbols">
          <t>combined mode transform ESP_GOST-4M-IMIT;</t>
          <t>combined mode transform ESP_GOST-1K-IMIT.</t>
        </list>
      </t>

      <t>
        This memo does not define GOST 28147-89 cryptographic
        algorithm and formats of a cryptographic data representation.
        The algorithm itself is defined in GOST 28147-89 national
        standard <xref target="GOST28147"/> <xref target="RFC5830"/>,
        the data and parameters representation corresponds
        <xref target="RFC4357"/>, <xref target="RFC4491"/>,
        <xref target="RFC4490"/> and <xref target="TC26-IKE"/>.
      </t>

      <t>
        The development objective of this document is to provide interoperability 
        of IPsec protocol implementations, produced by Russian vendors.
      </t>
      </section>

    <section title="Terms and Definitions">
      <t>
        This document operates with terms and definitions from
        IPsec <xref target="RFC4301"/> and ESP <xref target="RFC4303"/>
        standards, only additional definitions are described below.
      </t>
      
      <section title="Requirements Terminology">
        <t>
          The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
          "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED",
          "MAY", and "OPTIONAL" in this document are to be
          interpreted as described in <xref target="RFC2119"/>.
        </t>
       </section>

      <section title="Notation">
        <t>
          <list style='hanging'>
            <t hangText="encryptCNT(IV, K, D):">
              GOST 28147-89 encryption of data D in CNT mode with
              key K and initialization vector IV;
            </t>
            

            <t hangText="decryptCNT(IV, K, D):">
              GOST 28147-89 decryption of data D in CNT mode with
              key K and initialization vector IV;
            </t>
           

            <t hangText="Divers(K, D): ">
              diversification of key K by diversification data D
              (<xref target="RFC4357" x:sec="7"/>), S-box identifiers
              are defined in
              <xref target="Gost28147-89-Parameters"/>, in this document
              diversification data is a sequence of 8 bytes, interpreted
              as a 64-bit unsigned integer in network
              byte order;
            </t>
            
            <t hangText="gost28147IMIT(IV, K, D): ">
              generation of GOST 28147-89 MAC on data D with key K,
              initialization vector IV and inner zero padding to
              8-byte boundary;
            </t>
            
            <t hangText="A:">
              associated data (AEAD in <xref target="RFC5116" x:sec="2.1"/>,
              according to GOST &MAY; contain address, timestamp, IV et al.);
            </t>
            <!-- ассоциированные данные (AEAD в RFC5116, по ГОСТ 
              могут содержать адресную часть, отметку времени, 
              синхро-посылку и др.); 
            -->

            <t hangText="Seq#:">
              64-bit packet number (if ESN <xref target="RFC4304"/>
              is not negotiated, Seq# value always belongs 
              to the range 1..2^32-1);
            </t>
            
            <t hangText="Seq#h:">
              upper portion of Seq#;
            </t>
            
            <t hangText="Seq#l:">
              lower portion of Seq#;
            </t>
            
            <t hangText="IV(Seq#): ">
              initialization vector of Seq#-th packet;
            </t>
           
            <t hangText="Kc_e(Seq#):">
              combined mode encryption algorithm key of Seq#-th packet;
            </t>
            
            <t hangText="Kc_i(Seq#):">
              combined mode MAC algorithm key of Seq#-th packet;
            </t>
           

            <t hangText="Kc_i2(Seq#):">
              preliminary packet check key of Seq#-th packet and SA
              (only for ESP_GOST-1K-IMIT);
            </t>
            
            <t hangText="Kr_e:">
              base encryption key of SA;
            </t>
           
            <t hangText="Kr_i:">
              base MAC key of SA;
            </t>
            
            <t hangText="KeyMeshing:">
              key meshing algorithm as described in <xref target="RFC4357"/>;
            </t>
            
            <t hangText="SPI-Auth-Code:">
              authentication code computed in the 
              ISAKMP SA context (of IKE protocol or another key
              negotiation protocol) for given IPsec SA and intended for 
              auditing and preliminary check of packet;
            </t>
            
            <t hangText="substr(s..f, bytes):">
              bytes from byte s to byte f, coherently chosen from
              the sequence of "bytes" in network byte order.
            </t>
            

          </list>
        </t>
      </section>
    </section>

    <section anchor="ESP_GOST-SA"
             title="Establishing of ESP Security Association (SA) ">
      <t>
        ISAKMP protocol provides mechanisms of security
        attributes negotiation. The basic specification of ISAKMP
        protocol is defined in <xref target="RFC2408"/>.
      </t>
      
      <t>
        In the framework of ISAKMP SA (IKE or another key
        negotiation protocol) for the given IPsec SA at least the
        following components are negotiated:
        

        <list style="symbols">
          <t>
            32-bit SPI authentication code (non-confidential);
          </t>
          
          <t>
            256-bit symmetric key Kr_e;
          </t>
          
          <t>
            256-bit symmetric key Kr_i (only for ESP_GOST-1K-IMIT);
          </t>
          
          <t>
            GOST 28147-89 parameters (S-box set);
          </t>
          
          <t>
            SA lifetime in kilobytes (SA Lifetime, Kbytes);
          </t>
          
          <t>
            SA lifetime in seconds (SA Lifetime, seconds);
          </t>
          
          <t>
            maximum number of invalid packets.
          </t>
          
        </list>
      </t>

      <t>
        Depending on the transform type, the amount of
        the negotiated keying material (KEYMAT) is:
        
        <list style="hanging">
          <t hangText="For ESP_GOST-4M-IMIT:">
            36 bytes (Kr_e and SPI-Auth-Code);
          </t>
          <t hangText="For ESP_GOST-1K-IMIT:">
            68 bytes (Kr_e, Kr_i and SPI-Auth-Code).
          </t>
        </list>
      </t>

    </section>

    <section anchor="ESP_GOST-transforms"
             title="Encapsulating Security Payloads">
      <t>
        ESP packet payload &MUST; meet the requirements to combined mode
        payload transform defined in <xref target="RFC4303" x:sec="2"/>.
        Encapsulating security payloads with GOST 28147-89 encryption
        algorithm &MUST; comply with the following requirements:
        <list style="symbols">
          <t>
            Initialization Vector (IV) of 8 bytes is sent in the packet;
          </t>
            
          <t>
            ESP payload is padded to align on 8-byte boundary;
          </t>
            
          <t>
            in case of ESN usage, Seq#h value is not included in the transmitted packet;
          </t>
            
          <t>
            ICV is not explicitly padded;
          </t>
            
          <t>
            ICV of 4 bytes (for ESP_GOST-4M-IMIT transform) 
            or 8 bytes (for ESP_GOST-1K-IMIT transform) is transmitted in the packet.
          </t>
     
        </list>
      </t>
      

      <t>
        For being negotiated IPsec SAs it is &RECOMMENDED; to:
        <list style="symbols">

          <t>
            turn on an anti-replay service;
          </t>
          
          <t>
            limit the total number of ESP packets and the total size of
            the ESP payloads with same Seq# by applying additional
            organizational and technical measures in case of
            an anti-replay service is not used or
            partially applied.
          </t>
          
        </list>
      </t>

      <section anchor="ESP_GOST-GOST28147"
               title="Using GOST 28147-89 for ESP Payloads">
        <t>
          Associated data involved in the ESP MAC generation
          &MUST; contain the following ancillary information:
          
          <list style="empty">
            <t>
              A = SPI&nbsp;| Seq#l&nbsp;| IV
            </t>
          </list>
        </t>

        <figure align="center" anchor="ESP_GOST-ESP-AAD"
                title="Associated data (A) for ESP">
          <artwork align="center">
            <![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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              SPI                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             Seq#l                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            IV(Seq#)                           |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                    ]]>
          </artwork>
        </figure>

        <t>
          The transforms use vector IV(Seq#),
          the format of this vector is shown below:
        </t>
        
        <figure align="center" anchor="ESP_GOST-ESP-AAD-2"
                  title="IV for ESP_GOST-4M-IMIT and ESP_GOST-1K-IMIT">
          <artwork align="center">
            <![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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           IVRandom                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           IVCounter                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                    ]]>
          </artwork>
        </figure>

        <t>
          In this case:
          <!-- В этом случае: -->

          <list style="empty">
            <t>
              IVRandom - 4 random bytes
            </t>
            <!-- IVRandom - случайные 4 байта -->

            <t>
              IVCounter = (SPI-Auth-Code + SPI + Seq#l + IVRandom) mod&nbsp;2^32
            </t>
            <!-- IVCounter = (SPI-Auth-Code + SPI + Seq#l + IVRandom) mod 2^32
            </t -->

          </list>
        </t>

        <t>
          A receiver &MUST; control IVCounter value on
          the Seq# preliminary check phase and &MUST-NOT; perform
          any cryptographic operations in case of failure in preliminary check.
        </t>
        
        <t>
          If an ESP implementation supports audit logging, this
          failure &MAY; be classified as an error in Seq#
          checking. Particularly, packets with an incorrect
          IVCounter &MUST-NOT; cause changes in the counter
          of invalid packets and the counter of SA lifetime
          in kilobytes.
        </t>
        
      </section>

      <section anchor="ESP_GOST-Outbound-Processing"
               title="Outbound Packet Processing">
        <t>
          Outbound packet processing &MUST; comply with the requirements
          specified in <xref target="RFC4303" x:sec="3.3"/> with the
          following modifications:
          
          <list style="symbols">
            <t>
              in addition to the checks specified in
              <xref target="RFC4303" x:sec="3.3.1"/>,
              it is &RECOMMENDED; to check the ESP payload length
              in accordance with SA parameters;
              
            </t>

            <t>
              MAC in the transforms is calculated as follows:
              
              <list style="empty" hangIndent="1">
                <t>substr(0..3, ICV) = gost28147IMIT(0, Kc_i(Seq#), A&nbsp;| Payload&nbsp;Data&nbsp;| Padding&nbsp;| Pad&nbsp;Length&nbsp;| Next&nbsp;Header [&nbsp;|&nbsp;Seq#h&nbsp;])</t>
              </list>
            </t>

            <t>
              encryption in ESP_GOST-4M-IMIT transform is performed
              without a key meshing;
            </t>

            <t>
              encryption in ESP_GOST-1K-IMIT transform is performed with
              the key meshing mode id-Gost28147-89-CryptoPro-KeyMeshing;
            </t>

            <t>
              encryption in the transforms is performed by the formula:
              
              <list style="empty">
                <t>
                  encryptCNT(IV(Seq#), Kc_e(Seq#), Payload&nbsp;Data&nbsp;| Padding&nbsp;| Pad&nbsp;Length&nbsp;| Next&nbsp;Header)
                </t>
              </list>
            </t>

            <t>
              additional MAC in ESP_GOST-1K-IMIT transform is
              calculated as follows:
              
              <list style="empty">
                <t>
                  substr(4..7, ICV) = gost28147IMIT(0, Kc_i2(Seq#), A&nbsp;| Encrypted&nbsp;Payload [&nbsp;|&nbsp;Seq#h&nbsp;]&nbsp;| substr(0..3,&nbsp;ICV))
                </t>
              </list>
            </t>

            <t>
              the sender is &RECOMMENDED; to increase the counter of
              SA lifetime in kilobytes and compare this value with
              the maximum of SA lifetime (in kilobytes) for this SA.
              In case of exceeding the maximum it is &RECOMMENDED; to disable this SA.
             
            </t>

          </list>
        </t>
      </section>

      <section anchor="ESP_GOST-Inbound-Processing"
               title="Inbound Packet Processing">
        <t>
          Inbound packet processing &MUST; comply with the requirements
          specified in <xref target="RFC4303" x:sec="3.4"/> with
          the following modifications:
          
          <list style="symbols">
            <t>
              in addition to the checks specified in
              <xref target="RFC4303" x:sec="3.4.2"/>, it is
              &RECOMMENDED; to check the ESP payload length
              in accordance with SA parameters;
            </t>
            
            <t>
              during the preliminary check phase for ESP_GOST-4M-IMIT
              and ESP_GOST-1K-IMIT transforms it is
              &RECOMMENDED; to validate IV(Seq#) of
              the packet (<xref target="ESP_GOST-GOST28147"/> of
              this document);
            </t>
            
            <t>
              during the preliminary check phase for
              ESP_GOST-1K-IMIT transform ICVchk2 &MUST;
              be generated, if substr(4..7, ICV) does not match
              with ICVchk2, a receiver &MUST; abort
              the packet processing, and &MUST-NOT; change the state
              of the corresponding SA, and &MAY; not audit such
              events, and it is NOT &RECOMMENDED; to audit such
              events without specific requirements.
              ICVchk2 is calculated as follows:
             
              <list style="empty">
                <t>
                  ICVchk2 = gost28147IMIT(0, Kc_i2(Seq#), A&nbsp;| Encrypted&nbsp;Payload [&nbsp;|&nbsp;Seq#h&nbsp;]&nbsp;| substr(0..3,&nbsp;ICV))
                </t>
              </list>
            </t>

            <t>
              the receiver is &RECOMMENDED; to increase the
              counter of SA lifetime in kilobytes and
              compare them with the maximum value of SA lifetime
              (in kilobytes). In case of exceeding the maximum  
              it is &RECOMMENDED; to disable this SA;
            </t>
            
            <t>
              encryption in ESP_GOST-1K-IMIT transform
              performed with the key meshing
              mode id-Gost28147-89-CryptoPro-KeyMeshing;
            </t>
            
            <t>
              decryption in ESP_GOST-4M-IMIT transform
              performed without a key meshing;
            </t>
            
            <t>
              decryption in ESP_GOST-1K-IMIT transform
              performed with the key meshing
              mode id-Gost28147-89-CryptoPro-KeyMeshing;
            </t>
            
            <t>
              decryption in the transforms performed by the formula:

              <list style="empty">
                <t>
                  decryptCNT(IV(Seq#), Kc_e(Seq#), Encrypted&nbsp;Payload)
                </t>
              </list>
            </t>

            <t>
              during the MAC check phase for the transforms
              ICVchk &MUST; be generated, if substr(0..3, ICV)
              does not match with ICVchk, the receiver is &RECOMMENDED;
              to increase the counter of
              invalid packets of the SA and compare this value with
              the maximum number of invalid packets for this SA.
              In case of exceeding the maximum it is &RECOMMENDED; to disable this SA.
              ICVchk is calculated as follows:
              
              <list style="empty">
                <t>
                  ICVchk = gost28147IMIT(0, Kc_i(Seq#), A&nbsp;| ..&nbsp;| Next&nbsp;Header [&nbsp;|&nbsp;Seq#h])
                </t>
              </list>
            </t>
          </list>
        </t>
      </section>

      <section anchor="ESP_GOST-MTU"
               title="MTU Calculation">
        <t>
          In determining the MTU in the case of using ESP_GOST-4M-IMIT or
          ESP_GOST-1K-IMIT transform should be guided by
          the rules specified in <xref target="RFC4303" x:sec="2"/>,
          with the addition of 12 bytes for ESP GOST-4M-IMIT (8 bytes IV plus 4 bytes ICV) or
          16 bytes for ESP_GOST-1K-IMIT (8 bytes IV and 8 bytes ICV), rounding the result to the higher multiple of 8.
        </t>
        
      </section>

      <section anchor="ESP_GOST-4M-IMIT"
               title="ESP_GOST-4M-IMIT Transform">
        <t>
          Parameter values for ESP_GOST-4M-IMIT transform are shown below:
        </t>

        <t>
          <list style="empty">
            <t>
              KeyMeshing = id-Gost28147-89-None-KeyMeshing
            </t>

            <t>
              Kc_e(Seq#) = Divers(Divers(Divers(Kr_e,
              Seq#&amp;0xffffffff00000000),
              <vspace/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Seq#&amp;0xffffffffffff0000),
              <vspace/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Seq#&amp;0xffffffffffffffc0)
            </t>

            <t>
              Kc_i(Seq#) = Kc_e(Seq#)
            </t>
          </list>
        </t>

      </section>

      <section anchor="ESP_GOST-1K-IMIT"
                 title="ESP_GOST-1K-IMIT Transform">
        <t>
          Parameter values for ESP_GOST-1K-IMIT transform are shown below:
          <!--  преобразовании ESP_GOST-1K-IMIT используется: -->

          <list style="empty">
            <!-- t>
              IV(Seq#l) получается так же,
              как в <xref target="ESP_GOST-4M-IMIT"/>;
            </t -->
            <t>
              KeyMeshing = id-Gost28147-89-CryptoPro-KeyMeshing;
            </t>

            <t>
              Kc_e(Seq#) = Divers(Divers(Divers(Kr_e,
              Seq#&amp;0xffffffff00000000),
              <vspace/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Seq#&amp;0xffffffffffff0000),
              <vspace/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Seq#)
            </t>

            <t>
              Kc_i(Seq#) = Kc_e(Seq#)
            </t>

            <t>
              Kc_i2(Seq#) = Divers(Divers(Divers(Kr_i,
              Seq#&amp;0xffffffff00000000),
              <vspace/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Seq#&amp;0xffffffffffff0000),
              <vspace/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              Seq#)
            </t>

          </list>
        </t>
      </section>
    </section>

    <section anchor="GOST-DOI"
            title="Additional ESP SA Parameters and Attributes">
      <t>
        To match the attributes of transform using the protocol IKE
        <xref target="RFC2409"/>
        both sides &MUST; negotiate the application ID, ESP_GOST_Vendor_ID.
        The format of this ID is shown below:
      </t>
      
      <t>
        <figure align="center" anchor="ESP_GOST-VENDOR-ID"
               title="ESP_GOST_Vendor_ID">
          <artwork align="center">
            <![CDATA[
0                   1            
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           |M|M|
|       ESP_GOST_BASE       |J|N|
|                           |R|R|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                  ]]>
          </artwork>
        </figure>
        In this case ESP_GOST_BASE =
        { '\x03', '\x10', '\x17', '\xE0', '\x7F', '\x7A', '\x82', '\xE3',
        '\xAA', '\x69', '\x50', '\xC9', '\x99', '\x99' }
        (first 14 bytes of GOST R 34.11-94 hash function for "IKE/GOST" string). MJR and MNR bytes represent the 
        values of the major and minor parts of version number for 
        ESP_GOST transform, respectively (i.e. MJR = 1, MNR = 1).

      </t>
      <texttable anchor="ESP_GOST-DOI-table"
                title="ESP_GOST SA Parameters">
        <ttcol align="left">Parameter</ttcol>
        <ttcol align="left">Attribute Value</ttcol>
        <ttcol align="left">Format</ttcol>
        <ttcol align="left">Default Value</ttcol>

        <c>GOST 28147-89 Parameters</c>
        <c>32401</c>
        <c>B</c>
        <c>-</c>

        <c>Maximum packet size</c>
        <c>32403</c>
        <c>V</c>
        <c>65536</c>

        <c>Maximum number of invalid packets (SA Life Type)</c>
        <c>64402</c>
        <c>-</c>
        <c>10^5</c>
      </texttable>

      
      <section anchor="Gost28147-89-Parameters"
                title="GOST 28147-89 Parameters">
        
        <texttable anchor="GOST-DOI-table"
                title="GOST 28147-89 Parameters">
          <ttcol align="left">GOST-28147-89-SBOX</ttcol>
          <ttcol align="left">Attribute Value</ttcol>

          <c>id-Gost28147-89-CryptoPro-A-ParamSet</c>
          <c>65403</c>

          <c>id-Gost28147-89-CryptoPro-B-ParamSet</c>
          <c>65404</c>

          <c>id-Gost28147-89-CryptoPro-C-ParamSet</c>
          <c>65405</c>

          <c>id-Gost28147-89-CryptoPro-D-ParamSet</c>
          <c>65406</c>
        </texttable>

        <t>
          IPsec implementations compliant with the requirements
          of this document &MUST; implement
          id-Gost28147-89-CryptoPro-B-ParamSet, which is
          &RECOMMENDED; for Internet usage. Other parameter sets
          are &OPTIONAL; and &MAY; be used in networks with
          specific requirements (e.g. for multilevel encryption usage).
        </t>
        
      </section>

      <section anchor="Max-integrity-fails"
               title="Maximum Value of Invalid Packets Counter">
        <t>
          In the case of SA-Life-Type = Max-Integrity-Fails when counter of
          invalid packets is reached SA-Life-Duration, it is
          &RECOMMENDED; to block packet processing for this SA
          and &RECOMMENDED; to start deletion procedure for this SA.
        </t>
        
      </section>

      <section anchor="Max-packet-size"
               title="Maximum Packet Length">
        <t>
          Attribute class: Max-Packet-Len (32403), attribute
          format: variable length (V)
        </t>
        
        <t>
          In case of using ESP protocol with IPv6 Jumbograms
          <xref target="RFC2675"/> (sizes from 64 KB to 4 GB),
          it is &RECOMMENDED; to negotiate
          the maximum packet length parameter.
        </t>
        
      </section>
    </section>

    <section anchor="IKEv2-ESP_GOST-transforms"
             title="IKEv2 Encrypted Payloads">

      <t>
        Integrity verification as a whole meets the requirements described in
        <xref target="RFC5282" x:sec="5"/> and
        <xref target="RFC5116" /> which extends the basic
        integrity control method <xref target="RFC5996" /> for case of combined
        mode algorithms.
      </t>
      
      <t>
        Key material derivation for ESP transforms performed in accordance with the
        <xref target="RFC5996" x:sec="2.14"/>, but integrity control keys of IKEv2
        (SK_ai and SK_ar) are not used and their size
        &MUST; be treated as 0 octets.
      </t>
      
      <t>
        The size of the key material for SK_ei and SK_er keys
        complies with the size defined in <xref target="RFC5996" x:sec="2.14"/>,
        specifically, 36 or 68 bytes for each key when
        using ESP_GOST-4M-IMIT or ESP_GOST-1K-IMIT respectively.
        The required key material is derived iteratively by
        applying PRF function without alignment
        to the size of the hash function value.
      </t>
      
      <section anchor="IKEv2-ESP_GOST-GOST28147"
               title="Using GOST 28147-89 for IKEv2 Payloads">
        <t>
          Associated data involved in the IKEv2 MAC generation
          &MUST; contain the following ancillary information:
          
          <list style="empty">
            <t>
              A = IKEv2-Header&nbsp;| Unencrypted&nbsp;IKE&nbsp;Payloads&nbsp;| Payload&nbsp;Header&nbsp;| IV(Seq#)
            </t>
          </list>

          <figure align="center" anchor="ESP_GOST-IKEv2-AAD"
                  title="Associated data (A) for IKEv2 payloads">
            <artwork align="center">
              <![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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    IKE_SA Initiator's SPI                     |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    IKE_SA Responder's SPI                     |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Payload | MjVer | MnVer | Exchange Type |     Flags     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          Message-ID                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Length                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
~                   Unencrypted IKE Payloads                    ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Payload  |C|  RESERVED   |        Payload Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            IV(Seq#)                           |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                    ]]>
            </artwork>
          </figure>
        </t>

        <!-- section anchor="Blablabla for IKEv2" title="Blablabla for IKEv2" -->

        <t>
          The transforms use vector IV(Seq#), the format
          and recommendations for which are 
          described in <xref target="ESP_GOST-GOST28147"/> of
          this document with the following clarifications:
          
          <list style="empty">
            <t>Seq# = Message-ID*2 + R-flag</t>
            <t>SPI = SPIi#h + SPIi#l (for packets from Initiator)</t>
            <t>SPI = SPIr#h + SPIr#l (for packets from Responder)</t>
          </list>
        </t>

        <t>
          In the case of applying the requirements of <xref target="RFC6311"/>
          it is &RECOMMENDED; either to avoid 
          IKEV2_MESSAGE_ID_SYNC_SUPPORTED negotiation, or to limit
          the number of packets with 
          Message-ID = 0 (<xref target="RFC6311" x:sec="12"/>) and total size of that packets, 
          starting from second packet.
        </t>
        <!-- 
          При применении требований RFC6311 РЕКОМЕНДУЕТСЯ, 
          либо отказаться от согласования 
          IKEV2_MESSAGE_ID_SYNC_SUPPORTED, либо ограничить 
          количество и суммарный объём второго и последующих 
          пакетов с Message-ID равными 0 (раздел 12 RFC6311). 
        -->

        <!-- /section -->
      </section>
    </section>

    <section anchor="Acknowledgments" title="Acknowledgements">
      <t>
        The authors express their gratitude to Alex S. Kuzmin,
        a chairman of Rosstandart subcommittee on cryptography (TC26),
        who initiated a creation of IPsec Working Group,
        and not only infuse the initial impetus to
        the development of national standardized IPsec solution
        based on GOST 28147-89 algorithm but also constantly supported 
        this work methodologically and practically.
      </t>
      
      <t>
        The authors would like to thank Russian representatives of CISCO
        and CheckPoint, as well as Gazprom, company, which
        initiates a process to ensure compatibility of IPsec
        products from different vendors.
      </t>
      
      <t>
        The authors express special thanks to
        Dmitry N. Zakharov (LLC "Factor-TS") for protocol
        implementation verification,
        Valery A. Smyslov (JSC "ELVIS-PLUS") and
        Andrew L. Chmora (JSC "InfoTeCS") for
        number of valuable suggestions and improvements
        in the protocol itself and its description,
        Viktor M. Timakov (JSC "Signal-COM") for
        productive discussions on the cryptographically
        strong GOST 28147-89 MAC generation mode.
      </t>
      
      <figure align="left" alt="" height="" suppress-title="false" title=""
        width="">
        <preamble>TC26 Author's Addresses</preamble>

        <artwork align="left" alt="" height="" name="" type="" width=""
                 xml:space="preserve">      
Vladimir O. Popov
"CRYPTO-PRO", LLC
18, Suschevsky Val str.
Moscow, 127018, Russian Federation
Phone: +74957804820
EMail: vpopov@cryptopro.ru
            <!--
            Попов Владимир Олегович
            "CRYPTO-PRO", LLC
            127018, Москва, ул. Сущевский вал, д. 18.
            Российская Федерация
            Phone:+74957804820
            Email: vpopov@cryptopro.ru
            -->

Mikhail M. Gruntovich
"OKB SAPR", PJSC 
8, 2nd Kozhevnichesky lane
Moscow, 115114, Russian Federation
Phone: +74952356265
EMail: gmm@accord.ru
            <!--
            Грунтович Михаил Михайлович
            "ОКБ "САПР", PJSC
            115114, Москва г, Кожевнический 2-й пер, дом 8
            Российская Федерация
            Phone: +74952356265
            Email: в CRM нет
            -->

Dmitry M. Avramenko
"R-alfa", LLC 
4/1, Raspletina str.
Moscow, 123060, Russian Federation
EMail: info@alpha.ru
            <!--
            Авраменко Дмитрий Михайлович
            "R-alfa", LLC
            Москва, 
            Российская Федерация
            Phone:
            Email:
            -->

Mark Y. Koshelev
"ELVIS-PLUS", PJSC
Zelenograd, 5/23, driveway 4806
Moscow, 124498, Russian Federation
Phone: +74952760211
EMail: info@elvis.ru
            <!--
            Кошелев Марк Юрьевич
            "ЭЛВИС-ПЛЮС", PJSC
            124498, Москва г, Зеленоград г, проезд 4806, дом 5, стр. 23
            Российская Федерация
            Phone: +74952760211
            Email: info@elvis.ru
            -->

George O. Martanov
Federal State Unital Enterprise "Scientific and Technical Centre Atlas"  
38, Obraztsova str.
Moscow, 127018, Russian Federation
Phone: +74956892352
EMail: atlas@stcnet.ru
            <!--
            Мартанов Георгий Олегович
            Federal State Unital Enterprise "Scientific and Technical Centre Atlas"
            127018, г. Москва, ул. Образцова, д.38
            Российская Федерация
            Phone: +74956892352
            Email: atlas@stcnet.ru
            -->

Yury Y. Sidorin
Federal State Unital Enterprise "Scientific and Technical Centre Atlas"  
38, Obraztsova str.
Moscow, 127018, Russian Federation
Phone: +74956892352
EMail: atlas@stcnet.ru
            <!--
            Сидорин Юрий Юрьевич
            Federal State Unital Enterprise "Scientific and Technical Centre Atlas"
            127018, г. Москва, ул. Образцова, д.38
            Российская Федерация
            Phone: +74956892352
            Email: atlas@stcnet.ru
            -->

Valery A. Smyslov
"ELVIS-PLUS", PJSC
Zelenograd, 5/23, driveway 4806
Moscow, 124498, Russian Federation
Phone: +74952760211
EMail: info@elvis.ru
            <!--
            Смыслов Валерий Анатольевич
            "ЭЛВИС-ПЛЮС", PJSC
            124498, Москва г, Зеленоград г, проезд 4806, дом 5, стр. 23
            Российская Федерация
            Phone: +74952760211
            Email: info@elvis.ru
            -->

Stanislav V. Smyshlyaev
"CRYPTO-PRO", LLC
18, Suschevsky Val str.
Moscow, 127018, Russian Federation
Phone: +74957804820
EMail: svs@cryptopro.ru
            <!--
            Смышляев Станислав Витальевич
            "CRYPTO-PRO", LLC
            127018, Москва, ул. Сущевский вал, д. 18.
            Российская Федерация
            Phone:+74957804820
            Email: svs@cryptopro.ru
            -->

Viktor M. Timakov
"Signal-COM", PJSC
19, Usievicha str.
Moscow, 125315, Russian Federation
Phone: +74956632365
EMail: v.timakov@signal.ru
            <!--
            Тимаков Виктор Михайлович
            "Сигнал-КОМ", PJSC
            125315, Москва г, Усиевича ул, дом № 19
            Российская Федерация
            Phone: +74956632365
            Email: в CRM нет
            -->

Andrey V. Fedotov
"Factor-TS", LLC  
11A, 1st Magistralny lane
Moscow, 123290, Russian Federation
Phone: +74956443130
EMail: fedotov@factor-ts.ru
            <!--
            Федотов Андрей Владимирович
            "Faktor-TS", LLC
            123290,г.  Москва, 1-й Магистральный проезд, д. 11, стр. 1
            Российская Федерация
            Phone: +74956443130
            Email: vkolpakov@factor-ts.ru
            -->

Artem V. Chuprina
"Сryptokom", LLC
1, Pionerskaya str., office 001
Vladivostok, 690001, Russian Federation
Phone: +74232605201
EMail: kript225@gmail.com
            <!--
            Чуприна Артем Валентинович
            "Сryptokom", LLC
            690001, Приморский край, г. Владивосток, ул. Пионерская, д. 1, оф. 001 
            Российская Федерация
            Phone: +74232605201
            Email: kript225@gmail.com
            -->

	</artwork>
      </figure>
    </section>

    <section anchor="IANA" title="IANA Consideration">
      <t>

        IANA has assigned two numbers for ESP transforms:
        <list style="empty">
          <t>&lt;TBD-3&gt; for ESP_GOST-4M-IMIT;</t>
          <t>&lt;TBD-4&gt; for ESP_GOST-1K-IMIT.</t>
        </list>
      </t>
      <section anchor="IANAremove"
                 title="Remove After IANA Consideration">
        <t>
          Currently, preliminary implementations are using the following private numbers for transforms:
        </t>
        <t>
          <list style="empty">
            <t>253 for ESP_GOST-4M-IMIT;</t>
            <t>252 for ESP_GOST-1K-IMIT.</t>
          </list>
        </t>
      </section>

      <section anchor="IANAdontneed"
                 title="Not Subject for IANA Consideration">
        <t>
          Private "magic numbers" used in this document:
        </t>
        <texttable anchor="ESP_GOST-DOI-magic"
                title='ESP_GOST "magic numbers"'>
          <ttcol align="left">Class</ttcol>
          <ttcol align="left">Value</ttcol>
          <ttcol align="left">Type</ttcol>
          <ttcol align="left">Reference</ttcol>

          <c>GOST-28147-89-SBOX</c>
          <c>32401</c>
          <c>B</c>
          <c>
            <xref target="Gost28147-89-Parameters"/>
          </c>

          <c>Max-Packet-Len</c>
          <c>32403</c>
          <c>B</c>
          <c>
            <xref target="Max-packet-size"/>
          </c>
        </texttable>
        <t>
          Private values used in this document:
        </t>
        <texttable anchor="ESP_GOST-DOI-private"
			title='ESP_GOST private values'
			>
          <ttcol align="left" width="60%">Name</ttcol>
          <ttcol align="left" width="10%">Value</ttcol>
          <ttcol align="left">Attribute</ttcol>

          <c>Max-Integrity-Fails</c>
          <c>64402</c>
          <c>
            SA-Life-Type <xref target="RFC2407"/>
          </c>

          <c>id-Gost28147-89-CryptoPro-A-ParamSet</c>
          <c>65403</c>
          <c>
            GOST-28147-89-SBOX <xref target="Gost28147-89-Parameters"/>
          </c>

          <c>id-Gost28147-89-CryptoPro-B-ParamSet</c>
          <c>65404</c>
          <c>
            GOST-28147-89-SBOX <xref target="Gost28147-89-Parameters"/>
          </c>

          <c>id-Gost28147-89-CryptoPro-C-ParamSet</c>
          <c>65405</c>
          <c>
            GOST-28147-89-SBOX <xref target="Gost28147-89-Parameters"/>
          </c>

          <c>id-Gost28147-89-CryptoPro-D-ParamSet</c>
          <c>65406</c>
          <c>
            GOST-28147-89-SBOX <xref target="Gost28147-89-Parameters"/>
          </c>
        </texttable>
      </section>

    </section>

    <section anchor="Security"
             title="Security Considerations">
      <t>
        Implementations are &RECOMMENDED; to examine for
        compliance with requirements specified by the Decree of the
        Government of the Russian Federation (#957).
        The parameters of cryptographic algorithm affect the strength of the encryption.
        The use of parameters not described in <xref target="RFC4357"/> are
        &NOT-RECOMMENDED; for implementation, unless tested
        according to <xref target="RFC4357" x:sec="9"/>.
      </t>
      
      <t>
        GOST 28147-89 block length is 64-bit, so to ensure the confidentiality 
        and integrity of data IPsec implementations are
        &RECOMMENDED; to use the following limitations:
        
        <list style="symbols">
          <t>
            For ESP_GOST-4M-IMIT transform it is &RECOMMENDED; to process
            packets that do not exceed the size of 64 Kbytes.
            For IPv6 packets it is NOT &RECOMMENDED; to negotiate Max-Packet-Len
            value more than 64 Kbytes and
            it is NOT &RECOMMENDED; to use IPv6 Jumbograms
            (<xref target="RFC2675"/>) without appropriate research.
            It is &RECOMMENDED; to renegotiate keys for a new
            ESP SA after the transfer of maximum amount of data 
            for SA (SA Lifetime, Kbytes) - 2^80 bytes;
          </t>
          
          <t>
            For ESP_GOST-1K-IMIT transform it is &RECOMMENDED; to renegotiate
            keys for a new ESP SA after the transfer of maximum amount of data for SA 
            (SA Lifetime, Kbytes) - 2^80 bytes;
          </t>
          
          <t>
            For implementations it is &RECOMMENDED; to negotiate
            SA lifetime in kilobytes and seconds,
            <xref target="RFC4301" x:sec="4.4.2.1"/>;
          </t>
          
          <t>
            It is &NOT-RECOMMENDED; to negotiate SA lifetime in
            seconds more than 86400 seconds (24 hours);
          </t>
          <!-- 
            НЕ РЕКОМЕНДУЕТСЯ согласовывать время жизни SA 
            (Lifetime SA) в секундах более чем на 86400 сек (1 сутки); 
          -->

          <t>
            It is &NOT-RECOMMENDED; to negotiate Max-Integrity-Fails
            value more than 10^5 without appropriate research.
          </t>
          
        </list>
      </t>
    </section>

    <section anchor="Examples" title="Examples">
      <t>
        The examples below use default settings. Encryption with
        id-Gost28147-89-CryptoPro-B-ParamSet.
      </t>

      <section anchor="Example-ESP_GOST-4M-IMIT"
               title="ESP_GOST-4M-IMIT Example">
        <t>
          <figure>
            <preamble>
              ESP_GOST-4M-IMIT plaintext (length - 53. bytes):
            </preamble>
            <artwork>
              <![CDATA[
4500001d 04050607 08090a0b 0c0d0e0f 10111213 14151617 18191a1b 1c1d1e1f
20212223 24252627 28292a2b 2c2d2e2f 30313233 34
            ]]>
            </artwork>
          </figure>

          <figure>
            <preamble>
              ESP_GOST-4M-IMIT parameters:
            </preamble>
            <artwork>
              <![CDATA[
SPI
 31323334
Seq#l
 0000007d
ESN
 not negotiated
Padding | Pad Length | Next Header
 000104

SPI-Auth-Code
 cb4e1a7f
Kr_e
 b63d156f 7aac0dc7 cd915c35 63f61b9d 5c730a74 e331bc8c 3fc24a36 06463893
Kr_e2 = Divers(Kr_e, Seq# & 0xffffffff00000000)
 3a742e54 a9e8a3a1 1f4af5f7 c92fdac1 55142bee 86766e8c 03fad68d 35baf3d7
Kr_e1 = Divers(Kr_e2, Seq# & 0xffffffffffff0000)
 752bdd27 99dcde7b 92c04591 40fac2cb 974f39dc cf589d45 00a67c75 99ff9fcc
Kc_e = Divers(Kr_e1, Seq# & 0xffffffffffffffc0)
 0772fe26 c770590f 22902ad2 1a919eee ccab5396 baf2f1b5 54366c30 27a38614
            ]]>
            </artwork>
          </figure>

          <figure>
            <preamble>
              ESP_GOST-4M-IMIT encrypted data (length - 76. bytes (== 8.+8.+53.+3.+4.)):
            </preamble>
            <artwork>
              <![CDATA[
 31323334 0000007d 05060708 01865538 fa104495 3cd50f2b cca22b90 f4f36257
 8f4c2435 f04ada62 d0abc8b3 099e0473 d1ccd142 1586d564 a5e3d1c2 34e529ff
 fe652e24 caad891c 0bd8ba08
            ]]>
            </artwork>
          </figure>
        </t>
      </section>

      <section anchor="Example-ESP_GOST-1K-IMIT"
               title="ESP_GOST-1K-IMIT Example">
        <t>
          <figure>
            <preamble>
              ESP_GOST-1K-IMIT plaintext (length - 1049. bytes):
            </preamble>
            <artwork>
              <![CDATA[
 4500001d 04050607 08090a0b 0c0d0e0f 10111213 14151617 18191a1b 1c1d1e1f
 20212223 24252627 28292a2b 2c2d2e2f 30313233 34353637 38393a3b 3c3d3e3f
 40414243 44454647 48494a4b 4c4d4e4f 50515253 54555657 58595a5b 5c5d5e5f
 60616263 64656667 68696a6b 6c6d6e6f 70717273 74757677 78797a7b 7c7d7e7f
 80818283 84858687 88898a8b 8c8d8e8f 90919293 94959697 98999a9b 9c9d9e9f
 a0a1a2a3 a4a5a6a7 a8a9aaab acadaeaf b0b1b2b3 b4b5b6b7 b8b9babb bcbdbebf
 c0c1c2c3 c4c5c6c7 c8c9cacb cccdcecf d0d1d2d3 d4d5d6d7 d8d9dadb dcdddedf
 e0e1e2e3 e4e5e6e7 e8e9eaeb ecedeeef f0f1f2f3 f4f5f6f7 f8f9fafb fcfdfeff
 00010203 04050607 08090a0b 0c0d0e0f 10111213 14151617 18191a1b 1c1d1e1f
 20212223 24252627 28292a2b 2c2d2e2f 30313233 34353637 38393a3b 3c3d3e3f
 40414243 44454647 48494a4b 4c4d4e4f 50515253 54555657 58595a5b 5c5d5e5f
 60616263 64656667 68696a6b 6c6d6e6f 70717273 74757677 78797a7b 7c7d7e7f
 80818283 84858687 88898a8b 8c8d8e8f 90919293 94959697 98999a9b 9c9d9e9f
 a0a1a2a3 a4a5a6a7 a8a9aaab acadaeaf b0b1b2b3 b4b5b6b7 b8b9babb bcbdbebf
 c0c1c2c3 c4c5c6c7 c8c9cacb cccdcecf d0d1d2d3 d4d5d6d7 d8d9dadb dcdddedf
 e0e1e2e3 e4e5e6e7 e8e9eaeb ecedeeef f0f1f2f3 f4f5f6f7 f8f9fafb fcfdfeff
 00010203 04050607 08090a0b 0c0d0e0f 10111213 14151617 18191a1b 1c1d1e1f
 20212223 24252627 28292a2b 2c2d2e2f 30313233 34353637 38393a3b 3c3d3e3f
 40414243 44454647 48494a4b 4c4d4e4f 50515253 54555657 58595a5b 5c5d5e5f
 60616263 64656667 68696a6b 6c6d6e6f 70717273 74757677 78797a7b 7c7d7e7f
 80818283 84858687 88898a8b 8c8d8e8f 90919293 94959697 98999a9b 9c9d9e9f
 a0a1a2a3 a4a5a6a7 a8a9aaab acadaeaf b0b1b2b3 b4b5b6b7 b8b9babb bcbdbebf
 c0c1c2c3 c4c5c6c7 c8c9cacb cccdcecf d0d1d2d3 d4d5d6d7 d8d9dadb dcdddedf
 e0e1e2e3 e4e5e6e7 e8e9eaeb ecedeeef f0f1f2f3 f4f5f6f7 f8f9fafb fcfdfeff
 00010203 04050607 08090a0b 0c0d0e0f 10111213 14151617 18191a1b 1c1d1e1f
 20212223 24252627 28292a2b 2c2d2e2f 30313233 34353637 38393a3b 3c3d3e3f
 40414243 44454647 48494a4b 4c4d4e4f 50515253 54555657 58595a5b 5c5d5e5f
 60616263 64656667 68696a6b 6c6d6e6f 70717273 74757677 78797a7b 7c7d7e7f
 80818283 84858687 88898a8b 8c8d8e8f 90919293 94959697 98999a9b 9c9d9e9f
 a0a1a2a3 a4a5a6a7 a8a9aaab acadaeaf b0b1b2b3 b4b5b6b7 b8b9babb bcbdbebf
 c0c1c2c3 c4c5c6c7 c8c9cacb cccdcecf d0d1d2d3 d4d5d6d7 d8d9dadb dcdddedf
 e0e1e2e3 e4e5e6e7 e8e9eaeb ecedeeef f0f1f2f3 f4f5f6f7 f8f9fafb fcfdfeff
 00010203 04050607 08090a0b 0c0d0e0f 10111213 14151617 18
            ]]>
            </artwork>
          </figure>

          <figure>
            <preamble>
              ESP_GOST-1K-IMIT parameters:
            </preamble>
            <artwork>
              <![CDATA[
SPI
 31323334
Seq#l
 0000007d
ESN
 negotiated
Seq#h
 0000000b
Padding | Pad Length | Next Header
 00000000 000504

SPI-Auth-Code
 c4c08a66
Kr_e
 b63d156f 7aac0dc7 cd915c35 63f61b9d 5c730a74 e331bc8c 3fc24a36 06463893
Kr_e2 = Divers(Kr_e, Seq# & 0xffffffff00000000)
 59f1548e a0b38639 c546fb94 2164d780 f075460a cb72e4cf f3068a03 a184d544
Kr_e1 = Divers(Kr_e2, Seq# & 0xffffffffffff0000)
 c210c1fc 6988bb00 6ed69111 9d63a619 6c4cee21 799786db 2af3bda9 c77f9e20
Kc_i = Kc_e = Divers(Kr_e1, Seq#)
 fdcd7812 74018a14 5aee2da7 f21a1581 148378b9 272e3d88 0585ac2e 94b4bbe2
Kr_i
 cb4e1a7f 2d61710d f264423c ad4384de ce01d676 90556865 f1cb7f7f ab4103c0
Kr_i2 = Divers(Kr_i, Seq# & 0xffffffff00000000)
 52aa9784 2ee74f7a 5c3c7436 9fe4f415 5a4bc218 05fc6263 2a1ef408 4d8de3a2
Kr_i1 = Divers(Kr_i2, Seq# & 0xffffffffffff0000)
 7ea6c8f3 209ac480 f181aa61 5c38d07b fd680717 16581ff9 c2963646 6094cc3a
Kc_i2 = Divers(Kr_i1, Seq#)
 138309a0 5813c2bf d3bfb2a9 aff9b511 555c2088 ababcac7 f21f0871 1036aff8
            ]]>
            </artwork>
          </figure>

          <figure>
            <preamble>
              ESP_GOST-1K-IMIT encrypted data (length - 1080. bytes (== 8.+8.+1049.+7.+4.+4.)):
            </preamble>
            <artwork>
              <![CDATA[
 31323334 0000007d 05060708 faf8c51f 85bc7a31 676f1453 c167d042 1e87a0d1
 a23cbb97 cefbd7fe e95c3d1a b9f3fa9e 144dc92a 97e6de75 5b1fda97 8436c90b
 289c222f 80de286b bdf190b3 be7f6abb f627c56d 25ecc471 9bc9a5f3 403f1852
 67b43b70 a860b606 625ab17b 839078dd a55c9e76 78388625 27f17ef8 da3c964f
 0e320c68 6e71c9bb e17381d0 321fdfb5 8092f205 2df6d199 90ec758d 31eb6eeb
 3e152d43 89d4d402 9ab77fb4 09fcf757 b4086948 cf9d8843 5a2b21f2 6c41aa5f
 6b881623 be08b64e 4aeaba95 706598f3 5d56ee18 0feafff4 32b35a54 b37a7c77
 6e408d09 65aa2aa4 41f69040 03cec18a e1529416 88afe127 1c0fd90b c9699020
 9a98527f e8d4a285 de2f1d09 3b0f6779 a2391f71 d12d1219 c98b74ce 30b35b04
 381896c5 205ca00b ed4df571 d24ecfd3 7134b910 7c8eeb2d 6e3dedf3 ffab4af1
 1e69b296 fb4a9d0d 3dc364e0 4f0c6ab9 925322e4 0a8ff71e 4281d099 87260500
 bdfbdaf2 7669db9e 5b6021c7 91e77aa9 e7e4fe4a c6cafefc 80ff180b e3ec8d33
 6fb8172f 460daaf0 1f407230 bc282c25 9f14bc46 2d8d972e d27bf894 29696abb
 03d37ff0 f4ff8c0b c1f62112 eba15368 218a94ca 16847d57 55522e27 60913848
 50e84cbb 75438c26 9d216dee 67f82392 4f90a745 1b62b561 badadf9e d9bd481f
 6c8d1152 307e5b3b ead13bea 6b3d0b8b 20c0e17e 84109d55 3c431bb3 20ce8ea1
 c69e7cfb d720e186 dd4bbdb0 00008b23 f7271bcd ab1f10f2 009d98d1 66af8d49
 bf41d101 7aec62b3 1c4ad813 f3508887 d626f23d 387e5398 0ac70ddb 2a5688b4
 97f16918 b75f52ca d70751ce 3df694ff 7a07f6ba c1de8abd 6ff88df4 c48299b5
 c3e056ec 28ab6d6b 7cd16a59 4f41617b 8cb3bdff a5819619 348cb287 6bf4dcdd
 4985141b 2dd6f25a 49fce6cb b43a3dc3 8ca7dfcc fb3b4eca 4b1750eb 0d9da228
 80bedd9a 56d1768e 5e883cb1 282c6746 792a9fe9 2a2eabfd 9e48f25c 25ee1f6e
 f75c0d05 8ea213a4 f355cac0 608625f1 d78bc810 7d382ef3 0e87240a 4a4c1b87
 0c0714a5 7ddd9d09 e12eaf2d 032a1264 cdaf6feb 52b4f3ea 3abb0304 518a11ec
 3086d016 cc81461a 34fe9c5a 112a213d ffee305a 7133184c e05df5aa eabd1d9f
 341c2951 a126eabf aad3fd0c 6f81faa4 1ccea61e 9a654dec 266147e4 cf14fed7
 17656776 781ac09c 6b1e5650 e0a37e3d 98c7a384 3f3c001f e8e5db0f d9c03490
 9775bf74 25cf5f63 5befb502 af14595a 56517525 5c3752d9 2f6c7de7 7e80fb37
 b6c7d772 d117e4aa e6b1f3a3 1215889f 02111e63 93bd59cb b263a914 275efa37
 8069f230 994564af 9f340363 293286ac 6a97d66b 8045fba9 41f41575 6f52d018
 162d445c 2f8e6d47 99d00bf7 f419207f bfc51477 7c217b7d bfe9f660 acdd2c43
 b6fcb8fc 37db0f6d 78e29e58 88f35340 18217600 cbae06d1 1f24f66c e3c876b6
 5157a1e1 356aeed2 e5f4f5c9 3e4784c2 22678beb a7113bc2 e2de9439 382395c6
 9c4d0e84 b900f9e1 88f6ec28 651d9462 bb3465d8 eb50af47
            ]]>
            </artwork>
          </figure>
        </t>

      </section>
    </section>
  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <references title="Normative References">
      &RFC2119;
      &RFC4303;
      &ESN;
      &RFC2407;
      &GOST28147;
      &RFC4357;

      <reference anchor='TC26-ESP'>
        <front>
          <title>
            Cryptographic Protection for Data Processing
            System,
            Technical specification
            Use GOST 28147-89 for Encapsulating Security Payload (ESP)
            IPsec protocol
            (In Russian) (in press)
            
          </title>

          <author>
            <organization>
              Technical committee #26 of
              Federal Agency on Technical Regulating and Metrology of
              the Russian Federation
            </organization>
          </author>

          <date year='2013' />
          <abstract>
            <t>[TODO:XXX xml2rfc required abstract] Empty abstract</t>
          </abstract>
        </front>
      </reference>

    </references>

    <references title="Informative References">
      &RFC2408;
      &RFC4301;
      &RFC6071;
      <!-- &RFC4106; -->

      <!-- &RFC4309; -->
      &RFC2409;
      &RFC5996;
      &RFC5282;
      &RFC5116;
      &RFC6311;
      &RFC2675;

      <reference anchor='TC26-IKE'>
        <front>
          <title>
            Cryptographic Protection for Data Processing
            System,
            Technical specification
            Use GOST 28147-89, GOST R 34.11-94, GOST R 34.10-2001,
            for IKE and ISAKMP
            (In Russian) (in press)
            <!--
              СИСТЕМЫ ОБРАБОТКИ ИНФОРМАЦИИ
              ЗАЩИТА КРИПТОГРАФИЧЕСКАЯ

              ТЕХНИЧЕСКАЯ СПЕЦИФИКАЦИЯ 
              ПО ИСПОЛЬЗОВАНИЮ ГОСТ 28147-89, ГОСТ Р 34.11-94
              И ГОСТ Р 34.10-2001 ПРИ СОГЛАСОВАНИИ КЛЮЧЕЙ
              В ПРОТОКОЛАХ IKE И ISAKMP
            -->
          </title>

          <author>
            <organization>
              Technical committee #26 of
              Federal Agency on Technical Regulating and Metrology of
              the Russian Federation
            </organization>
          </author>

          <date year='2013' />
          <abstract>
            <t>[TODO:XXX xml2rfc required abstract] Empty abstract</t>
          </abstract>
        </front>
      </reference>


      &ENG-GOST28147;

      &RFC4490;
      &RFC4491;

    </references>





    <!--appendix-->
    <section anchor="Compatibility" title="Compatibility">
      <t>
        Requirements for a transforms implementation:
        <list style="symbols">
          <t>ESP_GOST-4M-IMIT - REQUIRED;</t>
          <t>
            ESP_GOST-1K-IMIT - &OPTIONAL;, it is required for
            applications that must be strictly robust to
            attacks based on timing and EMI analysis, and in case
            of usage very big IPv6 packets (more than 64 kilobytes);
          </t>

          <t>
            id-Gost28147-89-CryptoPro-B-ParamSet - &REQUIRED;.
          </t>
        </list>
      </t>
    </section>
    <!--/appendix-->
    <!--appendix-->

    <section anchor="Bug-IKEv1-Compatibility"
             title="Compatibility with Older IKEv1 Implementations">
      <t>
        Some IKEv1 implementations are incompatible with
        the recommendations
        <xref target="RFC4301"/>, <xref target="RFC4303"/>,
        <xref target="RFC6071"/>,
        and do not support ICV implementation and ICV check in
        case of negotiation "NULL" integrity algorithm,
        i.e. a proposal doesn't have
        an "Authentication Algorithm" (5) attribute.
      </t>
      
      <t>
        Such IKEv1 protocol implementations &MAY; negotiate
        this attribute value for "Authentication Algorithm" (5):
        <list style="empty">
          <t>GOST-NULL-INTEGRITY-ALGORITHM - 65411.</t>
        </list>
      </t>
      
      <t>
        ESP SA behavior in such case &MUST; be the same as there is an absence of "Authentication Algorithm" (5) attribute.
      </t>
      
    </section>
    <!--/appendix-->

  </back>
</rfc>
