Back to Home

The many faces of GOST R 34.11-94

GOST R 34.11-94 · Guess the hash three times

The many faces of GOST R 34.11-94



I somehow prepared tests for a system, one of the modules of which, among other things, calculated the value of the hash function for the downloaded file. The necessary algorithm was also specified in the statement of work - GOST R 34.11-94. As a standard, I took the value of the hash calculated by the third-party utility Rhash .

f86c9ecfb6e63726b35ebc79528d013d52b781e06e29d7eb0c9d1cb256efb7c1

Realizing that the function is calculated by the standard library, I sent a request to clean up my conscience that corresponds to loading the file into the module. But the fate of man is full of surprises. And you just have to relax, as you see something like this:

964ba8755ca782ec3c5e0f98c93347f9b96d9f39cf5c7fdef43a23273fe8868a

Who is wrong - the developer of the module or utility?

It turned out neither one nor the other.

The fact is that GOST R 34.11-94 implies the use of parameters - the so-called replacement nodes and the starting hash vector. But it does not regulate specific values. Nevertheless, in the appendix to GOST there are examples of these values ​​and a recommendation:
Use only in test cases for this standard.

After studying the subject area, it turned out that there are two RFCs. RFC 4357 , which uses the parameters created by CryptoPro, and RFC 5831 with the same values ​​from GOST. Rhash by default considers a hash according to RFC 5831. The use of CryptoPro parameters must be explicitly specified: It would seem that the problem has been solved. But to make it even more interesting, the standard does not define a hash output format. And so the question is with byte order . For the uninitiated, there are two main ways of presenting data. From high byte to low (Big-endian), and vice versa (Little-endian). Consider an example. For clarity, bytes are highlighted. Big-endian byte order: Little-endian order:

rhash --gost-cryptopro <Имя файла>











rhash --gost-cryptopro --gost-reverse <Имя файла>
8a86e83f27233af4de7f5ccf399f6db9f94733c9980f5e3cec82a75c75a84b96




rhash --gost-cryptopro <Имя файла>
964ba8755ca782ec3c5e0f98c93347f9b96d9f39cf5c7fdef43a23273fe8868a


Thus, there is no contradiction - all of the above values, and also comply with GOST R 34.11-94. Links: Wikipedia Detailed Description

rhash --gost --gost-reverse <Имя файла>
c1b7ef56b21c9d0cebd7296ee081b7523d018d5279bc5eb32637e6b6cf9e6cf8






Read Next