﻿<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes"?>
<!-- generate a table of contents -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<?rfc compact="no" ?>
<!-- do start each main section on a new page -->



<rfc category="info" docName="draft-pkcs5-gost-00" ipr="trust200902">

    <front>
        <title abbrev="Abbreviated Title">
            Password-based key protection
        </title>

        <author fullname="Karelina Ekaterina" initials="E.K." role="editor" surname="Karelina">
            <organization>InfoTeCS</organization>
            <address>
                <postal>
                    <street>2B stroenie 1, ul. Otradnaya </street>
                    <city>Moscow</city>
                    <code>127273</code>
                    <country>Russian Federation</country>
                </postal>
                <phone>+7 (495) 737-61-92</phone>
                <email>Ekaterina.Karelina@infotecs.ru</email>
            </address>
        </author>
        

        <date year="2021" />
        <!--если не указываем число и месяц, они подставляются автоматически-->
        <area>General</area>
        <!--как в rfc7748-->
        <workgroup>Network Working Group</workgroup>
        <keyword></keyword>

        <abstract>
            <t>
                This document supplements <xref target="RFC8018"/>. It contains the specifications of the cryptographic algorithms defined by the Russian national standards 
                for their implementation of generating general key in the password-based schemes.
            </t>        
        </abstract>
    </front>


    <middle>
        <section title="Introduction" anchor="Introduction">
            <t>
            This document supplements <xref target="RFC8018"/>. It describes the recommendations for using in the information systems with the realisations 
            of the GOST 28147-89 and GOST R 34.12-2015 encryption algorithms and the GOST R 34.11-2012 hashing functions
            in public and corporate networks to protect non-state information. 
            
            The use of the GOST 28147-89 encryption algorithm in these mechanisms remains for compatibility with existing implementations.
            
            The methods described in these recommendations are designed to generate key information using the user's password and protect information using the generated keys.
            </t>
        </section>

        <section title="Conventions Used in This Document">
            <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="Basic Terms and Definitions" anchor="Definition">
           <t>
           Throughout this document, the following notations are used:
           </t>
            <texttable align="center" style="none">
            <ttcol align="left" width="40%"></ttcol>
            <ttcol align="left" width="70%"></ttcol>
            
            <c>P</c>
            <c>a password in Unicode UTF-8</c>
            
            <c>S</c>
            <c>a random initializing value</c>
            
            <c>c</c>
            <c>a number of iterations of algorithm, a positive integer</c>
            
            <c>dkLen</c>
            <c>a length in bytes of derived key, a positive integer</c>
            
            <c>DK</c>
            <c>a derived key of length dkLen</c>
            
            <c>B_n</c>
            <c>
            a set of all byte row vectors of length n, n &gt;= 0; 
            if n = 0, then the set B_n consists of an empty string of length 0</c>
            
            <c>A||C</c>
            <c>a concatenation of two byte strings A, C, i.e., a vector from B_(|A|+|C|), where the left subvector from B_(|A|) 
            is equal to the vector A and the right subvector from B_(|C|) is equal to the vector C</c>
            
            <c>\xor</c>
            <c>a bit-wise exclusive-or of two byte strings of the same length</c>
            
            <c>R^n_r: B_n -> B_r</c>
            <c>a truncating a byte string to size r by removing the least significant n-r bytes </c>
            
            <c>Int(i)</c>
            <c>a four-byte encoding of the integer i =&lt; 2^32: (i_1, i_2, i_3, i_4) \in B_4, i = i_1 + 2^8 * i_2 + 2^16 * i_3 + 2^24 * i_4</c>
            
            <c>b[i, j]</c>
            <c>a substring extraction operator: extracts bytes i through j, 0 =&lt; i =&lt; j.</c>
            <c>CEIL(x)</c>
            <c>the smallest integer greater than, or equal to, x</c>
            </texttable>
            <t>
            This document uses the following abbreviations and symbols:</t>
            <texttable align="center" style="none">
            <ttcol align="left" width="40%"></ttcol>
            <ttcol align="left" width="70%"></ttcol>
            <c>HMAC_GOSTR3411</c>
            <c>Hashed-based Message Authentication Code.  A function for calculating a message authentication code, 
            based on the GOST R 34.11-2012 hash function with 512-bit output in accordance with <xref target="RFC2104"/>.</c>
            </texttable>
        </section>
        <section title="Algorithm for generating a key from a password" anchor="Algorithm">
            <t>
            The DK key is calculated as a diversification function PBKDF2(P, S, c, dkLen) using the 
            HMAC_GOSTR3411 function as the PRF pseudo-random function:
            <list style="empty">
            <t>DK = PBKDF2(P,S,c,dkLen).</t>
            </list>
            The diversification function is calculated using the following algorithm:
            
            <list style="numbers">
            <t>
            If dkLen &gt; (2^32 - 1) * 64, output "derived key too long" and stop.
            </t>
            <t>
            Calculate n = CEIL(dkLen / 64).
            </t>
            <t>
            Calculate a set of values for each i from 1 to n:
                <list style="empty">
                <t>U_1(i) = HMAC_GOSTR3411 (P, S || INT (i))</t>
                <t>U_2(i) = HMAC_GOSTR3411 (P, U_1(i))</t>
                <t>...</t>
                <t>U_c(i) = HMAC_GOSTR3411 (P, U_{c-1}(i))</t>
                <t>T(i) = U_1(i) \xor U_2(i) \xor ... \xor U_c(i)</t>
                </list>
            </t>
            <t>
            Concatenate the byte strings T(i) and extract the first dkLen bytes to
            produce a derived key DK:
            <list style="empty">
            <t>DK = R^{n * 64}_dkLen(T(1)||T(2)||...||T(n))</t>
            </list>
            </t>
            </list>
            </t>
        </section>
        <section title="Data encryption" anchor="Encryption">
            <section title="GOST 28147-89 data encryption" anchor="GOST-28147-89">
            <t>Data encryption using the DK key is carried out in accordance with the PBES2 scheme (see <xref target="RFC8018"/>, 
            section 6.2) using GOST 28147-89 in the Cipher Feedback Mode (CFB) (see <xref target="RFC5830"/>).</t>
                <section title="Encryption" anchor="Enc_GOST-28147-89">
                <t>
                The encryption process for PBES2 consists of the following steps:
                <list style="numbers">
                <t>Select the random value S of length from 8 to 32 bytes. The recommended length is 32 bytes.</t>
                <t>Select the iteration count c depending on the conditions of use. 
                The minimum allowable value for the parameter is 1000, the recommended value is 2000.</t>
                <t>Set the value dkLen = 32.</t>
                <t>Apply the key derivation function to the password P, the salt S and the iteration count c 
                to produce a derived key DK of length dkLen bytes in accordance with the algorithm from <xref target="Algorithm"/>.
                Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).</t>
                <t>Select the random value S^{'} of length from 8 bytes.</t>
                <t>Encrypt the message M with GOST 28147-89 algorithm in CFB mode under the derived key DK and the random value S^{'} to produce a ciphertext C.</t>
                <t>Save the parameters S, S^{'}, c as algorithm parameters in accordance with <xref target="Appendix"/>.</t>
                </list>
                </t>
                </section>
                
                <section title="Decryption" anchor="Dec_GOST-28147-89">
                <t>
                The decryption process for PBES2 consists of the following steps:
                <list style="numbers">
                <t>Set the value dkLen = 32.</t>
                <t>Apply the key derivation function to the password P, the salt S and the iteration count c 
                to produce a derived key DK of length dkLen bytes in accordance with the algorithm from <xref target="Algorithm"/>.
                Generate the sequence T(1) and trunc it to 32 bytes, i.e., 
                <list style="empty">
                <t>DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).</t>
                </list>
                </t>
                <t>Decrypt the ciphertext C with GOST 28147-89 algorithm in CFB mode under the derived key DK and the random value S^{'} to produce the message M.</t>
                </list>
                </t>
                </section>
            </section>
            
            <section title="GOST R 34.12-2015 data encryption" anchor="GOST-34.12-2015">
            <t>Data encryption using the DK key is carried out in accordance with the PBES2 scheme (see <xref target="RFC8018"/>, 
            section 6.2) using GOST R 34.12-2015 in CTR_ACPKM mode (see <xref target="RFC8645"/>).</t>
                <section title="Encryption" anchor="Enc_GOST-34.12-2015">
                <t>
                The encryption process for PBES2 consists of the following steps:
                <list style="numbers">
                <t>Select the random value S of length from 8 to 32 bytes. The recommended length is 32 bytes.</t>
                <t>Select the iteration count c depending on the conditions of use. 
                The minimum allowable value for the parameter is 1000, the recommended value is 2000.</t>
                <t>Set the value dkLen = 32.</t>
                <t>Apply the key derivation function to the password P, the salt S and the iteration count c 
                to produce a derived key DK of length dkLen bytes in accordance with the algorithm from <xref target="Algorithm"/>.
                Generate the sequence T(1) and trunc it to 32 bytes, i.e., 
                <list style="empty">
                <t>DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).</t>
                </list>
                </t>
                <t>Generate the value ukm of size n, where n takes a value of 12 or 16 bytes, depending on the selected encryption algorithm:
                <list style="empty">
                <t>GOST R 34.12-2015 "Kuznyechik"   n = 16 (see <xref target="RFC7801"/>)</t>
                <t>GOST R 34.12-2015 "Magma" n = 12 (see <xref target="RFC8891"/>)</t>
                </list>
                </t>
                <t>Set the value S^{'} = ukm[1..n-8]</t>
                <t>For id-gostr3412-2015-magma-ctracpkm and id-gostr3412-2015-kuznyechik-ctracpkm algorithms (see <xref target="ParamGost3412-2015"/>)
                encrypt the message M with GOST R 34.12-2015 algorithm under the derived key DK and the random value S^{'} to produce a ciphertext C.</t>
                
                <t>For id-gostr3412-2015-magma-ctracpkm-omac and id-gostr3412-2015-kuznyechik-ctracpkm-omac algorithms (see <xref target="ParamGost3412-2015"/>)
                encrypt the message M with GOST R 34.12-2015 algorithm under the derived key DK and the ukm in accordance with the following steps:
                    <list style="empty">
                    <t>- Generate two keys from the derived key DK using the KDF_TREE_GOSTR3411_2012_256 algorithm (see <xref target="RFC7836"/>):
                    <list style="empty">
                    <t>encryption key K(1)</t>
                    <t>MAC key K(2).</t>
                    </list>
                    Input parameters for the KDF_TREE_GOSTR3411_2012_256 algorithm takes the folowing values:
                    <list style="empty">
                    <t>K_in = DK</t>
                    <t>label = "kdf tree"</t>
                    <t>seed = ukm[n-7..n]</t>
                    <t>R = 1</t>
                    </list>
                    </t>
                    <t> - Compute MAC for the message M using the K(2) key. Append to the end of the message M the computing MAC value.</t>
                    <t> - Encrypt the resulting byte string with MAC with GOST R 34.12-2015 algorithm under the derived key K(1) and the random value S^{'} to produce a ciphertext C.</t>
                    </list>
                </t>
                <t>Save the parameters S, c, ukm as algorithm parameters in accordance with <xref target="Appendix"/>.</t>
                </list>
                </t>
                </section>
                
                <section title="Decryption" anchor="Dec_GOST-34.12-2015">
                <t>
                The decryption process for PBES2 consists of the following steps:
                <list style="numbers">
                <t>Set the value dkLen = 32.</t>
                <t>Apply the key derivation function to the password P, the salt S and the iteration count c 
                to produce a derived key DK of length dkLen bytes in accordance with the algorithm from <xref target="Algorithm"/>.
                Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).</t>
                <t>Set the value S^{'} = ukm[1..n-8], where n is the size of ukm in bytes.</t>
                <t>For id-gostr3412-2015-magma-ctracpkm and id-gostr3412-2015-kuznyechik-ctracpkm algorithms (see <xref target="ParamGost3412-2015"/>)
                decrypt the ciphertext C with GOST R 34.12-2015 algorithm under the derived key DK and the random value S^{'} to produce the message M.</t>
                
                <t>For id-gostr3412-2015-magma-ctracpkm-omac and id-gostr3412-2015-kuznyechik-ctracpkm-omac algorithms (see <xref target="ParamGost3412-2015"/>)
                decrypt the ciphertext C with GOST R 34.12-2015 algorithm under the derived key DK and the ukm in accordance with the following steps:
                    <list style="empty">
                    <t>- Generate two keys from the derived key DK using the KDF_TREE_GOSTR3411_2012_256 algorithm:
                    <list style="empty">
                    <t>encryption key K(1)</t>
                    <t>MAC key K(2).</t>
                    </list>
                    Input parameters for the KDF_TREE_GOSTR3411_2012_256 algorithm takes the folowing values:
                    <list style="empty">
                    <t>K_in = DK</t>
                    <t>label = "kdf tree"</t>
                    <t>seed = ukm[n-7..n]</t>
                    <t>R = 1</t>
                    </list>
                    </t>
                    <t> - Decrypt the ciphertext C with GOST R 34.12-2015 algorithm under the derived key K(1) and the random value S^{'} to produce the text.
                    The last k bytes of the text are the mac, where k depends on the selected encryption algorithm.</t>
                    <t> - Compute MAC for the text[1..m - k] using the K(2) key, where m is the size of text.</t>
                    <t> - Compare the original mac and the receiving MAC. If the sizes or values do not match, the message is distorted.</t>
                    </list>
                </t>
                </list>
                </t>
                </section>
            </section>
        </section>
        <section title="Message Authentication" anchor="Integrity">
        <t>PBMAC1 scheme is used for message authentication (see <xref target="RFC8018"/>. 
        This scheme bases on the HMAC_GOSTR3411 function with the key DK = PBKDF2 (P, S, c, 32).</t>
            <section  title="The MAC generation" anchor="MAC_generation">
            <t>The MAC generation operation for PBMAC1 consists of the following steps:
            <list style="numbers">
            <t>Select the random value S of length from 8 to 32 bytes. The recommended length is 32 bytes.</t>
            <t>Select the iteration count c depending on the conditions of use. 
            The minimum allowable value for the parameter is 1000, the recommended value is 2000.</t>
            <t>Set the dkLen at least 32 bytes. It depend on the selected key generation scheme.</t>
            <t>Apply the key derivation function to the password P, the salt S and the iteration count c 
            to produce a derived key DK of length dkLen bytes in accordance with the algorithm from <xref target="Algorithm"/>.
            Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).</t>
            <t>Process the message M with the underlying message authentication scheme under the derived key DK to generate a message authentication code T.</t>
            <t>Save the parameters S, c, ukm as algorithm parameters in accordance with <xref target="Appendix"/>.</t>
            </list>
            </t>
            </section>
            
            <section  title="The MAC verification" anchor="MAC_verification">
            <t>The MAC verification operation for PBMAC1 consists of the following steps:
            <list style="numbers">
            <t>Set the dkLen at least 32 bytes. It depend on the selected key generation scheme.</t>
            <t>Apply the key derivation function to the password P, the salt S and the iteration count c 
            to produce a derived key DK of length dkLen bytes in accordance with the algorithm from <xref target="Algorithm"/>.
            Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).</t>
            <t>Process the message M with the underlying message authentication scheme under the derived key DK to generate a message authentication code T^{'}.</t>
            <t>Compare the original message authentication code T and the receiving message authentication code T^{'}. If the sizes or values do not match, the message is distorted. </t>
            </list>
            </t>
            </section>
        </section>       
        <section anchor="Security" title="Security Considerations">
           <t>The focus of this document is security; hence security considerations permeate this specification.</t>
        </section>

    </middle>


    <back>
        <references title="Normative References">
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8018.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2104.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5830.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8645.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7801.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8891.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7836.xml' ?>
            <?rfc include='http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6070.xml' ?>
        </references>

        <section title="Identifiers and parameters" anchor="Appendix">
        <t>This section defines ASN.1 syntax for the key derivation functions, the encryption schemes, the message authentication scheme, and
        supporting techniques (<xref target="RFC8018"/>).</t>
        <figure><artwork>
rsadsi OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) 113549 }
pkcs OBJECT IDENTIFIER ::= { rsadsi 1 }
pkcs-5 OBJECT IDENTIFIER ::= { pkcs 5 }
        </artwork></figure>
            <section title="PBKDF2" anchor="PBKDF2">
            <t>The object identifier id-PBKDF2 identifies the PBKDF2 key derivation function:</t>
            <figure><artwork>
id-PBKDF2 OBJECT IDENTIFIER ::= { pkcs-5 12 }
             </artwork></figure>
             <t>The parameters field associated with this OID in an AlgorithmIdentifier shall have type PBKDF2-params:</t>
            <figure><artwork>
PBKDF2-params ::= SEQUENCE
{
    salt            CHOICE
    {
        specified       OCTET STRING, 
        otherSource     AlgorithmIdentifier {{PBKDF2- SaltSources}} 
    },
    iterationCount  INTEGER (1000..MAX), 
    keyLength       INTEGER (32..MAX) OPTIONAL, 
    prf             AlgorithmIdentifier {{PBKDF2-PRFs}} 
} 
            </artwork></figure>
            <t>The fields of type PBKDF2-params have the following meanings:
            <list style="empty">
            <t>- salt contains the random value S in OCTET STRING.</t>
            <t>- iterationCount specifies the iteration count c.</t>
            <t>- keyLength is the length of the derived key in bytes. It is optional field for PBES2 sheme since it is always 32 bytes.
            It must be present for PBMAC1 sheme and must be at least 32 bytes since the HMAC_GOSTR3411 function has a variable key size.</t>
            <t>- prf identifies the pseudorandom function. The identifier value must be id-tc26-hmac-gost-3411-12-512, the parameters value must be NULL:</t>
            </list>
            </t>
            <figure><artwork>
id-tc26-hmac-gost-3411-12-512 OBJECT IDENTIFIER ::= 
{
    iso(1) member-body(2) ru(643) reg7(7) 
    tk26(1) algorithms(1) hmac(4) 512(2)
}
            </artwork></figure>
            </section>
            <section title="PBES2" anchor="PBES2">
            <t>The object identifier id-PBES2 identifies the PBES2 encryption scheme:</t>
            <figure><artwork>
id-PBES2 OBJECT IDENTIFIER ::= { pkcs-5 13 }
            </artwork></figure>
            <t>The parameters field associated with this OID in an AlgorithmIdentifier shall have type PBES2-params:</t>
            <figure><artwork>
PBES2-params ::= SEQUENCE
{
    keyDerivationFunc   AlgorithmIdentifier { { PBES2-KDFs } }, 
    encryptionScheme    AlgorithmIdentifier { { PBES2-Encs } } 
}
            </artwork></figure>
            <t>The fields of type PBES2-params have the following meanings:
            <list style="empty">
            <t>- keyDerivationFunc identifies the key derivation function in accordance with <xref target="PBKDF2"/>.</t>
            <t>- encryptionScheme identifies the encryption scheme in accordance with <xref target="ParamGost28147-89"/>, <xref target="ParamGost3412-2015"/>.</t>
            </list>
            </t>
            </section>
                <section title="Identifier and parametrs of Gost28147-89 encryption sheme" anchor="ParamGost28147-89">
                <t>The GOST 28147-89 encryption algorithm identifier should take the following value:</t>
                <figure><artwork>
id-Gost28147-89 OBJECT IDENTIFIER ::=
{
    iso(1) member-body(2) ru(643) rans(2) 
    cryptopro(2) gost28147-89(21)
}
                </artwork></figure>
                <t>The parameters field associated with this OID in an AlgorithmIdentifier shall have type Gost28147-89-Parameters:</t>
                <figure><artwork>
Gost28147-89-Parameters ::= SEQUENCE
{
    iv                      Gost28147-89-IV, 
    encryptionParamSet      OBJECT IDENTIFIER 
}
Gost28147-89-IV ::= OCTET STRING (SIZE (8))
                </artwork></figure>
                <t>The fields of type Gost28147-89-Parameters have the following meanings:
                <list style="empty">
                <t>- iv contains the random value S^{'} in OCTET STRING.</t>
                <t>- encryptionParamSet identifies the substitution block for encryption. For PBES2 sheme it is recommended to use the set of substitutions described in <xref target="RFC7836"/>. 
                The OID of this block is:</t>
                </list>
                </t>
                <figure><artwork>
id-tc26-gost-28147-param-Z OBJECT IDENTIFIER ::= 
{
    iso(1) member-body(2) ru(643) rosstandart(7) 
    tc26(1) constants(2) cipher(5) gost28147(1) paramZ(1)
}
                </artwork></figure>
                </section>
                <section title="Identifier and parametrs of Gost34.12-2015 encryption sheme" anchor="ParamGost3412-2015">
                <t>The Gost34.12-2015 encryption algorithm identifier SHOULD take one of the following values:</t>
                <figure><artwork>
id-gostr3412-2015-magma-ctracpkm OBJECT IDENTIFIER ::=
{
    iso(1) member-body(2) ru(643) rosstandart(7) 
    tc26(1) algorithms(1) cipher(5) 
    gostr3412-2015-magma(1) mode-ctracpkm(1) 
}
                </artwork></figure>
                <t>In case of use id-gostr3412-2015-magma-ctracpkm identifier the data is encrypted by the GOST R 34.12-2015 Magma cipher in CTR_ACPKM mode in accordance with <xref target="RFC8645"/>.
                The length of gamma block s is 64 bits, the section size is fixed within a specific protocol based on the requirements of the system capacity and the key lifetime.</t>
                <figure><artwork>
id-gostr3412-2015-magma-ctracpkm-omac OBJECT IDENTIFIER ::= 
{
    iso(1) member-body(2) ru(643) rosstandart(7) 
    tc26(1) algorithms(1) cipher(5) 
    gostr3412-2015-magma(1) mode-ctracpkm-omac(2) 
}
                </artwork></figure>
                <t>In  case of use id-gostr3412-2015-magma-ctracpkm-omac identifier the data is encrypted by the GOST R 34.12-2015 Magma cipher in CTR_ACPKM mode in accordance with <xref target="RFC8645"/>, 
                and MAC is computed by the GOST R 34.12-2015 Magma cipher in MAC mode (MAC size is 64 bits).
                The length of gamma block s is 64 bits, the section size is fixed within a specific protocol based on the requirements of the system capacity and the key lifetime.</t>
                <figure><artwork>
id-gostr3412-2015-kuznyechik-ctracpkm OBJECT IDENTIFIER ::=
{
    iso(1) member-body(2) ru(643) rosstandart(7) 
    tc26(1) algorithms(1) cipher(5) 
    gostr3412-2015-kuznyechik(2) mode-ctracpkm(1) 
}
                </artwork></figure>
                <t>In case of use id-gostr3412-2015-kuznyechik-ctracpkm identifier the data is encrypted by the GOST R 34.12-2015 Kuznyechik cipher in CTR_ACPKM mode in accordance with <xref target="RFC8645"/>.
                The length of gamma block s is 128 bits, the section size is fixed within a specific protocol based on the requirements of the system capacity and the key lifetime.</t>
                <figure><artwork>
id-gostr3412-2015-kuznyechik-ctracpkm-omac OBJECT IDENTIFIER ::= 
{
    iso(1) member-body(2) ru(643) rosstandart(7) 
    tc26(1) algorithms(1) cipher(5) 
    gostr3412-2015-kuznyechik(2) mode-ctracpkm-omac(2) 
}
                </artwork></figure>
                <t>In  case of use id-gostr3412-2015-kuznyechik-ctracpkm-omac identifier the data is encrypted by the GOST R 34.12-2015 Kuznyechik cipher in CTR_ACPKM mode in accordance with <xref target="RFC8645"/>, 
                and MAC is computed by the GOST R 34.12-2015 Kuznyechik cipher in MAC mode (MAC size is 128 bits).
                The length of gamma block s is 128 bits, the section size is fixed within a specific protocol based on the requirements of the system capacity and the key lifetime.</t>
                <t>The parameters field in an AlgorithmIdentifier shall have type Gost3412-15-Encryption-Parameters:</t>
                <figure><artwork>
Gost3412-15-Encryption-Parameters ::= SEQUENCE 
{
    ukm OCTET STRING 
}
                </artwork></figure>
                <t>The field of type Gost3412-15-Encryption-Parameters have the following meanings:
                <list style="empty">
                <t>- ukm must be present and must contain n bytes. It's value depends on the selected encryption algorithm:
                <list style="empty">
                <t>GOST R 34.12-2015 "Kuznyechik" n = 16 (see <xref target="RFC7801"/>)</t>
                <t>GOST R 34.12-2015 "Magma" n = 12 (see <xref target="RFC8891"/>)</t>
                </list></t>
                </list>
                </t>
                </section>
            <section title="PBMAC1" anchor="PBMAC1">
            <t>The object identifier id-PBMAC1 identifies the PBMAC1 message authentication scheme:</t>
            <figure><artwork>
id-PBMAC1 OBJECT IDENTIFIER ::= { pkcs-5 14 }
            </artwork></figure>
            <t>The parameters field associated with this OID in an AlgorithmIdentifier shall have type PBMAC1-params:</t>
            <figure><artwork>
PBMAC1-params ::=  SEQUENCE 
{
    keyDerivationFunc AlgorithmIdentifier { { PBMAC1-KDFs } },
    messageAuthScheme AlgorithmIdentifier { { PBMAC1-MACs } }
}
            </artwork></figure>
            <t>The fields of type PBMAC1-params have the following meanings:
            <list style="empty">
            <t>- keyDerivationFunc is identifier and parameters of key diversification function in accordance with <xref target="PBKDF2"/> </t>
            <t>- messageAuthScheme is identifier and parameters of HMAC_GOSTR3411 algorithm.</t>
            </list>
            </t>
            </section>
        </section>
        
        <section title="PBKDF2 HMAC_GOSTR3411 Test Vectors" anchor="Example">
        <t>These test vectors are formed by analogy with test vectors from <xref target="RFC6070"/>. 
        The input strings below are encoded using ASCII.
        The sequence "\0" (without quotation marks) means a literal ASCII NULL
        value (1 octet).  "DK" refers to the Derived Key.</t>
        <figure><artwork>
Input: 
    P = "password" (8 octets) 
    S = "salt" (4 octets) 
    c = 1 
    dkLen = 64 
    
Output:
    DK = 64 77 0a f7 f7 48 c3 b1 c9 ac 83 1d bc fd 85 c2 
         61 11 b3 0a 8a 65 7d dc 30 56 b8 0c a7 3e 04 0d 
         28 54 fd 36 81 1f 6d 82 5c c4 ab 66 ec 0a 68 a4 
         90 a9 e5 cf 51 56 b3 a2 b7 ee cd db f9 a1 6b 47
         
Input: 
    P = "password" (8 octets) 
    S = "salt" (4 octets) 
    c = 2 
    dkLen = 64 
    
Output:
    DK = 5a 58 5b af df bb 6e 88 30 d6 d6 8a a3 b4 3a c0 
         0d 2e 4a eb ce 01 c9 b3 1c 2c ae d5 6f 02 36 d4 
         d3 4b 2b 8f bd 2c 4e 89 d5 4d 46 f5 0e 47 d4 5b 
         ba c3 01 57 17 43 11 9e 8d 3c 42 ba 66 d3 48 de
         
Input: 
    P = "password" (8 octets) 
    S = "salt" (4 octets) 
    c = 4096 
    dkLen = 64 
    
Output:
    DK = e5 2d eb 9a 2d 2a af f4 e2 ac 9d 47 a4 1f 34 c2 
         03 76 59 1c 67 80 7f 04 77 e3 25 49 dc 34 1b c7 
         86 7c 09 84 1b 6d 58 e2 9d 03 47 c9 96 30 1d 55 
         df 0d 34 e4 7c f6 8f 4e 3c 2c da f1 d9 ab 86 c3
         
Input: 
    P = "password" (8 octets) 
    S = "salt" (4 octets) 
    c = 16777216 
    dkLen = 64 

Output:
    DK = 49 e4 84 3b ba 76 e3 00 af e2 4c 4d 23 dc 73 92 
         de f1 2f 2c 0e 24 41 72 36 7c d7 0a 89 82 ac 36 
         1a db 60 1c 7e 2a 31 4e 8c b7 b1 e9 df 84 0e 36 
         ab 56 15 be 5d 74 2b 6c f2 03 fb 55 fd c4 80 71
         
Input: 
    P = "passwordPASSWORDpassword" (24 octets) 
    S = "saltSALTsaltSALTsaltSALTsaltSALTsalt" (36 octets) 
    c = 4096 
    dkLen = 100

Output:
    DK = b2 d8 f1 24 5f c4 d2 92 74 80 20 57 e4 b5 4e 0a 
         07 53 aa 22 fc 53 76 0b 30 1c f0 08 67 9e 58 fe 
         4b ee 9a dd ca e9 9b a2 b0 b2 0f 43 1a 9c 5e 50 
         f3 95 c8 93 87 d0 94 5a ed ec a6 eb 40 15 df c2 
         bd 24 21 ee 9b b7 11 83 ba 88 2c ee bf ef 25 9f 
         33 f9 e2 7d c6 17 8c b8 9d c3 74 28 cf 9c c5 2a 
         2b aa 2d 3a
         
Input: 
    P = "pass\0word" (9 octets) 
    S = "sa\0lt" (5 octets) 
    c = 4096 
    dkLen = 64 

Output:
    DK = 50 df 06 28 85 b6 98 01 a3 c1 02 48 eb 0a 27 ab 
         6e 52 2f fe b2 0c 99 1c 66 0f 00 14 75 d7 3a 4e 
         16 7f 78 2c 18 e9 7e 92 97 6d 9c 1d 97 08 31 ea 
         78 cc b8 79 f6 70 68 cd ac 19 10 74 08 44 e8 30
        </artwork></figure>            
         </section>
    
        <section title="Acknowledgments">
            
        </section>

    </back>
</rfc>
