Password-based key protection
InfoTeCS2B stroenie 1, ul. Otradnaya Moscow127273Russian Federation+7 (495) 737-61-92Ekaterina.Karelina@infotecs.ru
General
Network Working Group
This document supplements . 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.
This document supplements . It describes the recommendations for using in the information systems with the realisations
of 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 methods described in these recommendations are designed to generate key information using the user's password and protect information using the generated keys.
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 when, and only when,
they appear in all capitals, as shown here.
Throughout this document, the following notations are used:
Pa password in Unicode UTF-8Sa random initializing valueca number of iterations of algorithm, a positive integerdkLena length in bytes of derived key, a positive integerDKa derived key of length dkLenB_n
a set of all byte row vectors of length n, n >= 0;
if n = 0, then the set B_n consists of an empty string of length 0A||Ca 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\xora bit-wise exclusive-or of two byte strings of the same lengthR^n_r: B_n -> B_ra truncating a byte string to size r by removing the least significant n-r bytes Int(i)a four-byte encoding of the integer i =< 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_4b[i, j]a substring extraction operator: extracts bytes i through j, 0 =< i =< j.CEIL(x)the smallest integer greater than, or equal to, x
This document uses the following abbreviations and symbols:HMAC_GOSTR3411Hashed-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 .
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:
DK = PBKDF2(P,S,c,dkLen).
The diversification function is calculated using the following algorithm:
If dkLen > (2^32 - 1) * 64, output "derived key too long" and stop.
Calculate n = CEIL(dkLen / 64).
Calculate a set of values for each i from 1 to n:
U_1(i) = HMAC_GOSTR3411 (P, S || INT (i))U_2(i) = HMAC_GOSTR3411 (P, U_1(i))...U_c(i) = HMAC_GOSTR3411 (P, U_{c-1}(i))T(i) = U_1(i) \xor U_2(i) \xor ... \xor U_c(i)
Concatenate the byte strings T(i) and extract the first dkLen bytes to
produce a derived key DK:
DK = R^{n * 64}_dkLen(T(1)||T(2)||...||T(n))Data encryption using the DK key is carried out in accordance with the PBES2 scheme (see ,
section 6.2) using GOST R 34.12-2015 in CTR_ACPKM mode (see ).
The encryption process for PBES2 consists of the following steps:
Select the random value S of length from 8 to 32 bytes. The recommended length is 32 bytes.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.Set the value dkLen = 32.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 .
Generate the sequence T(1) and trunc it to 32 bytes, i.e.,
DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).Generate the value ukm of size n, where n takes a value of 12 or 16 bytes, depending on the selected encryption algorithm:
GOST R 34.12-2015 "Kuznyechik" n = 16 (see )GOST R 34.12-2015 "Magma" n = 12 (see )Set the value S^{'} = ukm[1..n-8]For id-gostr3412-2015-magma-ctracpkm and id-gostr3412-2015-kuznyechik-ctracpkm algorithms (see )
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.For id-gostr3412-2015-magma-ctracpkm-omac and id-gostr3412-2015-kuznyechik-ctracpkm-omac algorithms (see )
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:
- Generate two keys from the derived key DK using the KDF_TREE_GOSTR3411_2012_256 algorithm (see ):
encryption key K(1)MAC key K(2).
Input parameters for the KDF_TREE_GOSTR3411_2012_256 algorithm takes the folowing values:
K_in = DKlabel = "kdf tree"seed = ukm[n-7..n]R = 1 - Compute MAC for the message M using the K(2) key. Append to the end of the message M the computing MAC value. - 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.Save the parameters S, c, ukm as algorithm parameters in accordance with .
The decryption process for PBES2 consists of the following steps:
Set the value dkLen = 32.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 .
Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).Set the value S^{'} = ukm[1..n-8], where n is the size of ukm in bytes.For id-gostr3412-2015-magma-ctracpkm and id-gostr3412-2015-kuznyechik-ctracpkm algorithms (see )
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.For id-gostr3412-2015-magma-ctracpkm-omac and id-gostr3412-2015-kuznyechik-ctracpkm-omac algorithms (see )
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:
- Generate two keys from the derived key DK using the KDF_TREE_GOSTR3411_2012_256 algorithm:
encryption key K(1)MAC key K(2).
Input parameters for the KDF_TREE_GOSTR3411_2012_256 algorithm takes the folowing values:
K_in = DKlabel = "kdf tree"seed = ukm[n-7..n]R = 1 - 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. - Compute MAC for the text[1..m - k] using the K(2) key, where m is the size of text. - Compare the original mac and the receiving MAC. If the sizes or values do not match, the message is distorted.PBMAC1 scheme is used for message authentication (see .
This scheme bases on the HMAC_GOSTR3411 function with the key DK = PBKDF2 (P, S, c, 32).The MAC generation operation for PBMAC1 consists of the following steps:
Select the random value S of length from 8 to 32 bytes. The recommended length is 32 bytes.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.Set the dkLen at least 32 bytes. It depend on the selected key generation scheme.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 .
Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).Process the message M with the underlying message authentication scheme under the derived key DK to generate a message authentication code T.Save the parameters S, c, ukm as algorithm parameters in accordance with .The MAC verification operation for PBMAC1 consists of the following steps:
Set the dkLen at least 32 bytes. It depend on the selected key generation scheme.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 .
Generate the sequence T(1) and trunc it to 32 bytes, i.e., DK = PBKFD2(P,S,c,32) = R^64_32(T(1)).Process the message M with the underlying message authentication scheme under the derived key DK to generate a message authentication code 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. The focus of this document is security; hence security considerations permeate this specification.This section defines ASN.1 syntax for the key derivation functions, the encryption schemes, the message authentication scheme, and
supporting techniques ().The object identifier id-PBKDF2 identifies the PBKDF2 key derivation function:The parameters field associated with this OID in an AlgorithmIdentifier shall have type PBKDF2-params:The fields of type PBKDF2-params have the following meanings:
- salt contains the random value S in OCTET STRING.- iterationCount specifies the iteration count c.- 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.- prf identifies the pseudorandom function. The identifier value must be id-tc26-hmac-gost-3411-12-512, the parameters value must be NULL:The object identifier id-PBES2 identifies the PBES2 encryption scheme:The parameters field associated with this OID in an AlgorithmIdentifier shall have type PBES2-params:The fields of type PBES2-params have the following meanings:
- keyDerivationFunc identifies the key derivation function in accordance with .- encryptionScheme identifies the encryption scheme in accordance with .The Gost34.12-2015 encryption algorithm identifier SHOULD take one of the following values: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 .
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.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 ,
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.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 .
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.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 ,
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.The parameters field in an AlgorithmIdentifier shall have type Gost3412-15-Encryption-Parameters:The field of type Gost3412-15-Encryption-Parameters have the following meanings:
- ukm must be present and must contain n bytes. It's value depends on the selected encryption algorithm:
GOST R 34.12-2015 "Kuznyechik" n = 16 (see )GOST R 34.12-2015 "Magma" n = 12 (see )The object identifier id-PBMAC1 identifies the PBMAC1 message authentication scheme:The parameters field associated with this OID in an AlgorithmIdentifier shall have type PBMAC1-params:The fields of type PBMAC1-params have the following meanings:
- keyDerivationFunc is identifier and parameters of key diversification function in accordance with - messageAuthScheme is identifier and parameters of HMAC_GOSTR3411 algorithm.These test vectors are formed by analogy with test vectors from .
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.