GOST Encrypt

Category: Ciphers

Status: Registered and callable in the CyberChef 11.3.0 compatibility inventory.

Input / output: string → string

Background: https://wikipedia.org/wiki/GOST_(block_cipher)

What it does

The GOST block cipher (Magma), defined in the standard GOST 28147-89 (RFC 5830), is a Soviet and Russian government standard symmetric key block cipher with a block size of 64 bits. The original standard, published in 1989, did not give the cipher any name, but the most recent revision of the standard, GOST R 34.12-2015 (RFC 7801, RFC 8891), specifies that it may be referred to as Magma. The GOST hash function is based on this cipher. The new standard also specifies a new 128-bit block cipher called Kuznyechik. Developed in the 1970s, the standard had been marked ‘Top Secret’ and then downgraded to ‘Secret’ in 1990. Shortly after the dissolution of the USSR, it was declassified and it was released to the public in 1994. GOST 28147 was a Soviet alternative to the United States standard algorithm, DES. Thus, the two are very similar in structure.

Note

Status here means the operation name is implemented and callable. It does not by itself promise byte-for-byte parity for every upstream option. See Compatibility and current status for the verified scope and known boundaries.

Arguments and options

Arguments are positional. Keep their order when using bake() or Pipeline.then().

Index

Name

UI type

PyChef default

Accepted values / format

0

Key

toggleString

{'string': '', 'option': 'Hex'}

''

1

IV

toggleString

{'string': '', 'option': 'Hex'}

''

2

Input type

option

'Raw'

'Raw', 'Hex'

3

Output type

option

'Hex'

'Hex', 'Raw'

4

Algorithm

argSelector

'GOST 28147 (1989)'

'GOST 28147 (1989)', 'GOST R 34.12 (Magma, 2015)', 'GOST R 34.12 (Kuznyechik, 2015)'

5

sBox

option

'E-A'

'E-TEST', 'E-A', 'E-B', 'E-C', 'E-D', 'E-SC', 'E-Z', 'D-TEST', 'D-A', 'D-SC'

6

Block mode

option

'ECB'

'ECB', 'CFB', 'OFB', 'CTR', 'CBC'

7

Key meshing mode

option

'NO'

'NO', 'CP'

8

Padding

option

'PKCS5'

'NO', 'PKCS5', 'ZERO', 'RANDOM', 'BIT'

Recipe template

Important

This is a call template built from the documented defaults. Replace placeholder values such as empty keys, paths, patterns, or lookup data before running it.

from pychef import bake

input_value = "example"
args = [{'string': '', 'option': 'Hex'}, {'string': '', 'option': 'Hex'}, 'Raw', 'Hex', 'GOST 28147 (1989)', 'E-A', 'ECB', 'NO', 'PKCS5']
result = bake(input_value, [{"op": 'GOST Encrypt', "args": args}])
print(result)

Pipeline example

from pychef import Pipeline

args = [{'string': '', 'option': 'Hex'}, {'string': '', 'option': 'Hex'}, 'Raw', 'Hex', 'GOST 28147 (1989)', 'E-A', 'ECB', 'NO', 'PKCS5']
transform = Pipeline().then('GOST Encrypt', *args)
result = transform("example")

Dedicated operation module

The registered entry point lives in pychef.operations.by_operation.gost_encrypt. Direct calls receive the input value and a positional argument tuple:

from pychef.operations.by_operation.gost_encrypt import run

result = run("example", tuple([{'string': '', 'option': 'Hex'}, {'string': '', 'option': 'Hex'}, 'Raw', 'Hex', 'GOST 28147 (1989)', 'E-A', 'ECB', 'NO', 'PKCS5']))
pychef.operations.by_operation.gost_encrypt.run(value, args)

Run this operation using its shared internal implementation.

Parameters:
  • value (str | bytes)

  • args (Sequence[Any])

Return type:

str | bytes