<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<rfc category="info" ipr="trust200902" docName="draft-smyslov-ike2-gost-08">

<?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="GOST algorithms in IKEv2">Using GOST Cryptographic Algorithms 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>Russian Federation</country>
                </postal>
                <phone>+7 495 276 0211</phone>
                <email>svan@elvis.ru</email>
            </address>
        </author>
        <date/>

        <keyword></keyword>

        <abstract>
            <t> This document defines a set of cryptographic transforms for use in the Internet Key Exchange protocol version 2 (IKEv2). 
            The transforms are based on Russian cryptographic standard algorithms (GOST). Using GOST ciphers in IKEv2 was defined
            in RFC 9227, this document aims to define using GOST algorithms for the rest of cryptographic transforms used in IKEv2.
            </t>

            <t> This specification was developed to facilitate implementations that wish to support the GOST algorithms.  This document does not imply
            IETF endorsement of the cryptographic algorithms used in this document.
            </t>
        </abstract>
    </front>

    <middle>
        <section title="Introduction">
            <t> The Internet Key Exchange protocol version 2 (IKEv2) defined in <xref target="RFC7296" /> is an important part
            of the IP Security (IPsec) architecture. It is used for the authenticated key exchange and for the negotiation of various protocol
            parameters and features.
            </t>

            <t> This document defines a number of transforms for IKEv2, based on Russian cryptographic standard algorithms (often reffered to as "GOST" 
            algorithms) for hash function, digital signature and key exchange method. These definitions are based on the
            recommendations <xref target="GOST-IKEv2" /> established by the Standardisation Technical Committee "Cryptographic information protection", 
            which describe how Russian cryptographic standard algorithms are used in IKEv2. Along with the transforms defined in <xref target="RFC9227" />, 
            the transforms defined in this specification allow using GOST cryptographic algorithms in IPsec protocols.
            </t>

            <t> This specification was developed to facilitate implementations that
            wish to support the GOST algorithms.  This document does not imply
            IETF endorsement of the cryptographic algorithms used in this
            document.
            </t>
        </section>

        <section title="Terminology and Notation" anchor="mustshouldmay" >
            <t> The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", 
            "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted 
            as described in BCP 14 <xref target="RFC2119" /> <xref target="RFC8174" /> when, and only when, 
            they appear in all capitals, as shown here.
            </t>
        </section>

        <section title="Overview" anchor="overview">
            <t> Russian cryptographic standard (GOST) algorithms are a set of cryptographic algorithms of different types - 
            ciphers, hash functions, digital signatures etc. In particular, Russian cryptographic standard <xref target="GOST3412-2015" /> defines 
            block ciphers "Kuznyechik" (also defined in <xref target="RFC7801" />) and "Magma" (also defined in <xref target="RFC8891" />). 
            Cryptographic standard <xref target="GOST3410-2012" />  defines elliptic curve digital signature algorithm 
            (also defined in <xref target="RFC7091" />), while <xref target="GOST3411-2012" /> defines two cryptographic hash functions "Streebog", 
            with different output length (also defined in <xref target="RFC6986" />).
            The parameters for the elliptic curves used in GOST signature and key exchange algorithms are defined in <xref target="RFC7836" />.
            </t>
        </section>

        <section title="IKE SA Protection" anchor="protection" >
            <t> <xref target="RFC9227" /> defines two transforms of type 1 (Encryption Algorithm Transform IDs) 
            based on GOST block ciphers that can be used for IKE SA protection: ENCR_KUZNYECHIK_MGM_KTREE (32) based on "Kuznyechik" 
            block cipher and ENCR_MAGMA_MGM_KTREE (33) based on "Magma" block cipher. Since these transforms 
            use ciphers in Multilinear Galois Mode (MGM), which provides Authenticated Encryption with Associated Data (AEAD)
            and thus provide both encryption and authentication, there is no need for new transform type 3 (Integrity Algorithm Transform IDs) for use in IKEv2, 
            because integrity transforms cannot be used with encryption transforms providing AEAD (see Section 3.3 of <xref target="RFC7296" />).
            </t>
        </section>

        <section title="Pseudo Random Function" anchor="prf" >
            <t> This specification defines a new transform of type 2 (Pseudorandom Function Transform IDs) - PRF_HMAC_STREEBOG_512 (9).
            This transform uses PRF HMAC_GOSTR3411_2012_512 defined in Section 4.1.2 of <xref target="RFC7836" />.
            The PRF uses GOST R 34.11-2012 ("Streebog") hash-function with 512-bit output defined in 
            <xref target="RFC6986" /><xref target="GOST3411-2012" /> with HMAC <xref target="RFC2104" /> construction. 
            The PRF has a 512-bit block size and a 512-bit output length.
            </t>
        </section>

        <section title="Shared Key Calculation" anchor="ecdh" >
            <t> This specification defines two new transforms of type 4 (Diffie-Hellman Group Transform IDs): GOST3410_2012_256 (33) and
            GOST3410_2012_512 (34). These transforms uses Elliptic Curve Diffie-Hellman (ECDH) key exchange algorithm over Twisted Edwards curves.
            The parameters for these curves are defined in Section A.2 of <xref target="RFC7836" />. In particular, transform GOST3410_2012_256
            uses id-tc26-gost-3410-2012-256-paramSetA parameter set and GOST3410_2012_512 uses id-tc26-gost-3410-2012-512-paramSetC
            parameter set (both defined in <xref target="RFC7836" />).
            </t>

            <t> Shared secret is computed as follows. The initiator randomly selects its private key d_i from {1,..,q - 1}, where q is the group order 
            and is a parameter of the selected curve. Then a public key Q_i is computed as a point on the curve: Q_i = d_i * G, where G is the generator 
            for the selected curve, and then is sent to the responder. The responder makes the same calculations to get d_r and Q_r and sends Q_r to the initiator.
            After peers exchange Q_i and Q_R both sides can compute a point on the curve S = ((m / q) * d_i) * Q_r = ((m / q) * d_r) * Q_i, 
            where m is the subgroup order and is a parameter of the selected curve. The shared secret K is an x coordinate of S in a little-endian representation. 
            The size of K is determined by the size of used curve and is either 256 or 512 bit.
            </t>

            <t> When GOST public key is transmitted in the KE payload, it MUST be represented as x coordinate immediately followed by y coordinate, 
            each in a little-endian representation. The size of each coordinate is determined by the size of the used curve and is either 256 or 512 bits,
            so that the size of the Key Exchange Data field in the KE payload is either 64 or 128 octets.
            </t>

            <section title="Recipient Tests" anchor="ecdh-tests" >
                <t> Upon receiving peer's public key implementations MUST check that the key is actually a point on the curve, otherwise the exchange fails.
                Implementations MUST check that the calculated public value S is not an identity element of the curve, in which case the exchange fails. 
                The INVALID_SYNTAX notification MAY be sent in these cases.
                </t>
            </section>
        </section>

        <section title="Authentication" anchor="sign" >
            <t> GOST digital signatures algorithm GOST R 34.10-2012 is defined in <xref target="RFC7091" /><xref target="GOST3410-2012" />. There are
            two variants of GOST signature algorithm - one over 256-bit elliptic curve and the other over 512-bit key elliptic curve.
            </t>

            <t> When GOST digital signature is used in IKEv2 for authentication purposes, an Authentication Method "Digital Signature" (14)
            MUST be specified in the AUTH payload. The AlgorithmIdentifier ASN.1 objects for GOST digital signature algorithm
            are defined in <xref target="asn1" />.
            </t>

            <t> The signature value, as defined in <xref target="RFC7091" /><xref target="GOST3410-2012" />, consists of two integers r and s.
            The size of each integer is either 256 bit or 512 bit depending on the used elliptic curve.
            The content of the Signature Value field in the AUTH payload MUST consist of s immediately followed by r, each in a big-endian representation,
            so that the size of the field is either 64 or 128 octets.
            </t>

            <section title="Hash Functions" anchor="hash" >
                <t> GOST digital signatures algorithm uses GOST hash functions GOST R 34.11-2012 ("Streebog") defined in 
                <xref target="RFC6986" /><xref target="GOST3411-2012" />. There are two "Streebog" hash functions - 
                one with 256-bit output length and the other with 512-bit output length. 
                </t>

                <t> This specification defines two new values for IKEv2 Hash Algorithms registry: STREEBOG_256 (6)
                for GOST hash function with 256-bit output length and STREEBOG_512 (7) for the 512-bit length output.
                These values MUST be included in the SIGNATURE_HASH_ALGORITHMS notify if a corresponding GOST digital signature
                algorithm is supported by the sender.
                </t>
            </section>

            <section title="ASN.1 Objects" anchor="asn1" >
                <t> This section lists GOST signature algorithm ASN.1 AlgorithmIdentifier objects in binary form.
                This objects are defined in <xref target="RFC9215" /><xref target="USING-GOST-IN-CERTS" /> and are provided here for convenience.
                </t>

                <section title="id-tc26-signwithdigest-gost3410-12-256" anchor="gost256" >
                    <t> id-tc26-signwithdigest-gost3410-12-256 OBJECT IDENTIFIER ::= { iso(1) member-body(2) ru(643) rosstandart(7) tc26(1) algorithms(1) signwithdigest(3) gost3410-12-256(2) }
                    </t>

                    <t>Parameters are absent. 
                    </t>

                    <figure>
                        <preamble></preamble>
                        <artwork align="left"><![CDATA[
Name = id-tc26-signwithdigest-gost3410-12-256
OID = 1.2.643.7.1.1.3.2
Length = 12
0000: 300a 0608 2a85 0307 0101 0302
                      ]]></artwork>
                      </figure>

                </section>

                <section title="id-tc26-signwithdigest-gost3410-12-512" anchor="gost512" >
                    <t> id-tc26-signwithdigest-gost3410-12-512 OBJECT IDENTIFIER ::= { iso(1) member-body(2) ru(643) rosstandart(7) tc26(1) algorithms(1) signwithdigest(3) gost3410-12-512(3) }
                    </t>

                    <t>  Parameters are absent. 
                    </t>

                    <figure>
                        <preamble></preamble>
                        <artwork align="left"><![CDATA[
Name = id-tc26-signwithdigest-gost3410-12-512
OID = 1.2.643.7.1.1.3.3
Length = 12
0000: 300a 0608 2a85 0307 0101 0303
                      ]]></artwork>
                      </figure>

                </section>
            </section>
        </section>

        <section title="Security Considerations" anchor="security" >
            <t> The security considerations of <xref target="RFC7296" /> apply accordingly.
            </t>

            <t> The security of GOST elliptic curves is discussed in <xref target="GOST-EC-SECURITY" />. The security
            of "Streebog" hash function is discussed in <xref target="STREEBOG-SECURITY" />. 
            A second preimage attack on "Streebog" is described in <xref target="STREEBOG-PREIMAGE" />
            if message size exceeds 2^259 blocks. This attack is not relevant to how "Streebog" is used in IKEv2.
            </t>
        </section>

        <section title="IANA Considerations" anchor="iana" >
            <t> IANA has assigned one Transform ID in the "Transform Type 2 - Pseudorandom Function Transform IDs" registry
            (where RFCXXXX is this document):
            </t>

            <figure>
                <preamble></preamble>
                <artwork align="left"><![CDATA[
Number      Name                        Reference
-------------------------------------------------
9           PRF_HMAC_STREEBOG_512       [RFCXXXX]
              ]]></artwork>
              </figure>

            <t> IANA has assigned two Transform IDs in the "Transform Type 4 - Diffie-Hellman Group Transform IDs" registry
            (where RFCXXXX is this document):
            </t>

            <figure>
                <preamble></preamble>
                <artwork align="left"><![CDATA[
Number      Name                    Recipient Tests         Reference
---------------------------------------------------------------------
33          GOST3410_2012_256       [RFCXXXX] Sec. 6.1      [RFCXXXX]
34          GOST3410_2012_512       [RFCXXXX] Sec. 6.1      [RFCXXXX]
              ]]></artwork>
              </figure>

            <t> IANA has assigned two values in the "IKEv2 Hash Algorithms" registry
            (where RFCXXXX is this document):
            </t>

            <figure>
                <preamble></preamble>
                <artwork align="left"><![CDATA[
Number      Hash Algorithm              Reference
-------------------------------------------------
6           STREEBOG_256                [RFCXXXX]
7           STREEBOG_512                [RFCXXXX]
              ]]></artwork>
              </figure>

        </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.6986.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7091.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.7836.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9215.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.9227.xml" ?>
        </references>

        <references title='Informative References'>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2104.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7801.xml" ?>
            <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8891.xml" ?>
            <reference anchor="GOST3410-2012">
                <front>
                    <title>Information technology. Cryptographic data security. Signature and verification processes of [electronic] digital signature</title>
                    <author>
                        <organization>Federal Agency on Technical Regulating and Metrology</organization>
                    </author>
                    <date year="2012"/>
                </front>
                <seriesInfo name="GOST R" value="34.10-2012"/>
                <annotation>(In Russian)</annotation>
            </reference>
            <reference anchor="GOST3411-2012">
                <front>
                    <title>Information technology. Cryptographic data security. Hashing function</title>
                    <author>
                        <organization>Federal Agency on Technical Regulating and Metrology</organization>
                    </author>
                    <date year="2012"/>
                </front>
                <seriesInfo name="GOST R" value="34.11-2012"/>
                <annotation>(In Russian)</annotation>
            </reference>
            <reference anchor="GOST3412-2015">
                <front>
                    <title>Information technology. Cryptographic data security. Block ciphers</title>
                    <author>
                        <organization>Federal Agency on Technical Regulating and Metrology</organization>
                    </author>
                    <date year="2015"/>
                </front>
                <seriesInfo name="GOST R" value="34.12-2015"/>
                <annotation>(In Russian)</annotation>
            </reference>
            <reference anchor="GOST-IKEv2">
                <front>
                    <title>Information technology. Cryptographic information protection. The use of Russian cryptographic algorithms in the IKEv2 key exchange protocol</title>
                    <author>
                        <organization>Standardisation Technical Committee "Cryptographic information protection"</organization>
                    </author>
                    <date year="2022"/>
                </front>
                <seriesInfo name="MR" value="26.2.001-22"/>
                <annotation>(In Russian)</annotation>
            </reference>
            <reference anchor="USING-GOST-IN-CERTS">
                <front>
                    <title>Information technology. Cryptographic data security. Using GOST R 34.10-2012 and GOST R 34.11-2012 algorithms 
                    in X.509 Certificates, CRLs and PKCS #10 Certificate Requests</title>
                    <author>
                        <organization>Federal Agency on Technical Regulating and Metrology</organization>
                    </author>
                    <date year="2018"/>
                </front>
                <seriesInfo name="R" value="1323565.1.023-2018"/>
                <annotation>(In Russian)</annotation>
            </reference>
            <reference anchor="GOST-EC-SECURITY">
                <front>
                    <title>On the security properties of Russian standardized elliptic curves</title>
                    <author initials='E.' surname="Alekseev" />
                    <author initials='V.' surname="Nikolaev" />
                    <author initials='S.' surname="Smyshlyaev" />
                    <date year="2018"/>
                </front>
                <seriesInfo name="" value="https://doi.org/10.4213/mvk260" />
            </reference>
            <reference anchor="STREEBOG-SECURITY">
                <front>
                    <title>Cryptanalysis of GOST R hash function</title>
                    <author initials='Z.' surname="Wang" />
                    <author initials='H.' surname="Yu" />
                    <author initials='X.' surname="Wang" />
                    <date year="2014"/>
                </front>
                <seriesInfo name="" value="https://doi.org/10.1016/j.ipl.2014.07.007" />
            </reference>
            <reference anchor="STREEBOG-PREIMAGE">
                <front>
                    <title>The Usage of Counter Revisited: Second-Preimage Attack on New Russian Standardized Hash Function</title>
                    <author initials='J.' surname="Guo" />
                    <author initials='J.' surname="Jean" />
                    <author initials='G.' surname="Leurent" />
                    <author initials='T.' surname="Peyrin" />
                    <author initials='L.' surname="Wang" />
                    <date year="2014"/>
                </front>
                <seriesInfo name="" value="https://eprint.iacr.org/2014/675" />
            </reference>
        </references>
    </back>
</rfc>


