GOST 28147-89 (Part 1. Introduction and general principles)
I decided to fix this by writing a
Algorithm description
GOST 28147-89 is a domestic block cipher. That is, the plaintext is divided into blocks (in this case, 64 bits), and each block is converted separately.
The algorithm is based on the Feistel network shown in the figure below.

I will explain the operation of this scheme.
- Each block is divided into two “sub-blocks” (left and right, respectively).
- The initial filling of the right block is recorded in the left block at the output.
- A cryptographic conversion using key data is performed above the right block.
- The left (source) and right (converted) blocks are added modulo 2 in the adder modulo 2.
- This is repeated several times.
Algorithm block diagram

This scheme contains:
- Four drives of 32 bits: N 1 , N 2 , N 3 , N 4 .
- Two 32-bit drives: N 5 and N 6 , - with constant fillings C 2 and C 1 recorded in them, respectively.
- 256-bit key storage device (RAM). The RAM consists of eight drives of 32 bits each: X 0 , X 1 , X 2 , X 3 , X 4 , X 5 , X 6 , X 7 .
- 32-bit adder modulo 2: CM 2 .
- Another modulo 2 adder that has no bit limit (but uses 64 bits): CM 5 .
- Two adders modulo 2 32 bits of 32 bits: SM 1 , SM 3 .
- Modular adder (2 32 -1): CM 4 .
- Substitution block K : eight replacement nodes K 1 , K 2 , K 3 , K 4 , K 5 , K 6 , K 7 , K 8 , each with 64-bit memory.
- Cyclic shift register to the left by 11 bits R .
The keys
In KZU
256-bit RAM is allocated, GOST 28147-89 uses a 256-bit key. The key is divided into eight blocks of 32 bits, and each bit of each block is sequentially inserted into the drive X of the corresponding order.
That is, the 1st bit of the key is inserted into the 1st discharge of drive X 0 , the 2nd into the 2nd discharge of drive X 0 , the 33rd into the 1st discharge of drive X 1 , the 65th into 1 -th bit of drive X 2 , and so on, the 224th bit of the key is inserted into the 1st bit of drive X 7 , the 256th bit of the key is inserted into the 32nd bit of drive X 7 .
The key is read in accordance with the selected mode of the algorithm, but in the following parts of the article.
In the substitution block K
The substitution block contains a 16x8 replacement table, which is a long-term key.
Rows of the table determine, roughly speaking, what needs to be replaced (a number from 0 to 15 in the hexadecimal number system). The columns indicate what to replace. At the same time, the incoming 32-bit vector into the block is divided into eight 4-bit ones, each of which is converted in accordance with the replacement table.
The keys in both the KZU and block K are secret, and measures are required to prevent their compromise.
Operating modes
In conclusion, I want to note that GOST 28147-89 works in 4 modes, each of which will be discussed in the following 4 articles (with C ++ code):
- Simple replacement mode.
- Gamma mode.
- Gamma mode with feedback.
- The mode of development of the imitation.
Yes, at the moment everything, gentlemen, is the next time we will consider a simple replacement mode, which is basic for all other modes.
UPD: The next part of the article “Easy Replacement Mode” is available here .