GOST (hash function)
The GOST hash function, defined in the standards GOST R 34.11-94 and GOST 34.311-95 is a 256-bit cryptographic hash function. It was initially defined in the Russian national standard GOST R 34.11-94 Information Technology – Cryptographic Information Security – Hash Function. The equivalent standard used by other member-states of the CIS is GOST 34.311-95.
This function must not be confused with a different Streebog hash function, which is defined in the new revision of the standard GOST R 34.11-2012.
The GOST hash function is based on the GOST block cipher.
Algorithm
GOST processes a variable-length message into a fixed-length output of 256 bits. The input message is broken up into chunks of 256-bit blocks ; the message is padded by appending as many zeros to it as are required to bring the length of the message up to 256 bits. The remaining bits are filled up with a 256-bit integer arithmetic sum of all previously hashed blocks and then a 256-bit integer representing the length of the original message, in bits.Basic notation
The algorithm descriptions uses the following notations:- — j-bit block filled with zeroes.
- — length of the M block in bits modulo 2256.
- — concatenation of two blocks.
- — arithmetic sum of two blocks modulo 2256
- — logical xor of two blocks
Description
The input message is split into 256-bit blocks.In the case the last block contains less than 256 bits, it is prepended left by zero bits to achieve the desired length.
Each block is processed by the step hash function,
where,, are a 256-bit blocks.
Each message block, starting the first one, is processed by the step hash function, to calculate intermediate hash value
The value can be arbitrary chosen, and usually is.
After is calculated, the final hash value is obtained in the following way
- , where L — is the length of the message M in bits modulo
- , where K — is 256-bit control sum of M:
So, the algorithm works as follows.
- Initialization:
- # — Initial 256-bit value of the hash function, determined by user.
- # — Control sum
- # — Message length
- Compression function of internal iterarions: for i = 1 … n — 1 do the following :
- # – apply step hash function
- # – recalculate message length
- # – calculate control sum
- Compression function of final iteration:
- # – calculate the full message length in bits
- # – pad the last message with zeroes
- # – update control sum
- # – process the last message block
- # – MD – strengthen up by hashing message length
- # – hash control sum
- The output value is.
Step hash function
It consist of three parts:
- Generating of keys
- Enciphering transformation using keys
- Shuffle transformation
Key generation
- Two transformations of 256-bit blocks:
- * Transformation, where are 64-bit sub-blocks of Y.
- * Transformation, where, and are 8-bit sub-blocks of Y.
- Three constants:
- * C2 =
- * C3 =
- * C4 =
- For j = 2,3,4 do the following:
- :
Enciphering transformation
Let's denote the enciphering transformation as E. For enciphering, the is split into four 64-bit blocks:, and each of these blocks is enciphered as:
Shuffle transformation
On the last step, the shuffle transformation is applied to, S and m using a Linear feedback shift register. In the result, the intermediate hash value is obtained.First we define the ψ function, doing LFSR on a 256-bit block:, where are 16-bit sub-blocks of the Y.
The shuffle transformation is, where denotes an i-th power of the function.
Initial values
There are two commonly used sets of initial parameters for GOST R 34.11 94.The starting vector for the both sets is
=0x00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000.
Although the GOST R 34.11 94 standard itself doesn't specify the algorithm initial value and S-box of the enciphering transformation, but uses the following "test parameters" in the samples sections.
"Test parameters" S-box
RFC 5831 specifies only these parameters, but RFC 4357 names them as "test parameters" and does not recommend them for use in production applications.CryptoPro S-box
The CryptoPro S-box comes from "production ready" parameter set developed by CryptoPro company, it is also specified as part of RFC 4357, section 11.2.Cryptanalysis
In 2008, an attack was published that breaks the full-round GOST hash function. The paper presents a collision attack in 2105 time, and first and second preimage attacks in 2192 time.GOST hash test vectors
Hashes for "test parameters"
The 256-bit GOST hashes are typically represented as 64-digit hexadecimal numbers.Here are test vectors for the GOST hash with "test parameters"
GOST =
77b7fa410c9ac58a25f49bca7d0468c9296529315eaca76bd1a10f376d1f4294
Even a small change in the message will, with overwhelming probability, result in a completely different hash due to the avalanche effect. For example, changing d to c:
GOST =
a3ebc4daaab78b0be131dab5737a7f67e602670d543521319150d2e14eeec445
Two samples coming from the GOST R 34.11-94 standard:
GOST =
b1c466d37519b82e8319819ff32595e047a28cb6f83eff1c6916a815a637fffa
GOST =
471aba57a60a770d3a76130635c1fbea4ef14de51f78b4ae57dd893b62f55208
More test vectors:
GOST =
ce85b99cc46752fffee35cab9a7b0278abb4c2d2055cff685af4912c49490f8d
GOST =
d42c539e367c66e9c88a801f6649349c21871b4344c6a573f849fdce62f314dd
GOST =
ad4434ecb18f2c99b60cbe59ec3d2469582b65273f48de72db2fde16a4889a4d
GOST =
53a3a3ed25180cef0c1d85a074273e551c25660a87062a52d926a9e8fe5733a4
GOST =
5c00ccc2734cdd3332d3d4749576e3c1a7dbaf0e7ea74e9fa602413c90a129fa
Hashes for CryptoPro parameters
GOST algorithm with CryptoPro S-box generates different set of hash values.GOST = 981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0
GOST = e74c52dd282183bf37af0079c9f78055715a103f17e3133ceff1aacf2f403011
GOST = b285056dbf18d7392d7677369524dd14747459ed8143997e163b2986f92fd42c
GOST =
bc6041dd2aa401ebfa6e9886734174febdb4729aa972d60f549ac39b29721ba0
GOST =
9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76
GOST =
73b70a39497de53a6e08c67b6d4db853540f03e9389299d9b0156ef7e85d0f61
GOST =
6bc7b38989b28cf93ae8842bf9d752905910a7528a61e5bce0782de43e610c90
GOST =
2cefc2f7b7bdc514e18ea57fa74ff357e7fa17d652c75f69cb1be7893ede48eb
GOST =
c3730c5cbccacf915ac292676f21e8bd4ef75331d9405e5f1a61dc3130a65011
GOST = 1c4ac7614691bbf427fa2316216be8f10d92edfd37cd1027514c1008f649c4e8
GOST = 8693287aa62f9478f7cb312ec0866b6c4e4a0f11160441e8f4ffcd2715dd554f