Botan  2.4.0
Crypto and TLS for C++11
Public Member Functions | List of all members
Botan::GOST_28147_89_Params Class Referencefinal

#include <gost_28147.h>

Public Member Functions

 GOST_28147_89_Params (const std::string &name="R3411_94_TestParam")
 
std::string param_name () const
 
uint8_t sbox_entry (size_t row, size_t col) const
 
uint8_t sbox_pair (size_t row, size_t col) const
 

Detailed Description

The GOST 28147-89 block cipher uses a set of 4 bit Sboxes, however the standard does not actually define these Sboxes; they are considered a local configuration issue. Several different sets are used.

Definition at line 21 of file gost_28147.h.

Constructor & Destructor Documentation

◆ GOST_28147_89_Params()

Botan::GOST_28147_89_Params::GOST_28147_89_Params ( const std::string &  name = "R3411_94_TestParam")
explicit

Default GOST parameters are the ones given in GOST R 34.11 for testing purposes; these sboxes are also used by Crypto++, and, at least according to Wikipedia, the Central Bank of Russian Federation

Parameters
nameof the parameter set

Definition at line 26 of file gost_28147.cpp.

26  : m_name(n)
27  {
28  // Encoded in the packed fromat from RFC 4357
29 
30  // GostR3411_94_TestParamSet (OID 1.2.643.2.2.31.0)
31  static const uint8_t GOST_R_3411_TEST_PARAMS[64] = {
32  0x4E, 0x57, 0x64, 0xD1, 0xAB, 0x8D, 0xCB, 0xBF, 0x94, 0x1A, 0x7A,
33  0x4D, 0x2C, 0xD1, 0x10, 0x10, 0xD6, 0xA0, 0x57, 0x35, 0x8D, 0x38,
34  0xF2, 0xF7, 0x0F, 0x49, 0xD1, 0x5A, 0xEA, 0x2F, 0x8D, 0x94, 0x62,
35  0xEE, 0x43, 0x09, 0xB3, 0xF4, 0xA6, 0xA2, 0x18, 0xC6, 0x98, 0xE3,
36  0xC1, 0x7C, 0xE5, 0x7E, 0x70, 0x6B, 0x09, 0x66, 0xF7, 0x02, 0x3C,
37  0x8B, 0x55, 0x95, 0xBF, 0x28, 0x39, 0xB3, 0x2E, 0xCC };
38 
39  // GostR3411-94-CryptoProParamSet (OID 1.2.643.2.2.31.1)
40  static const uint8_t GOST_R_3411_CRYPTOPRO_PARAMS[64] = {
41  0xA5, 0x74, 0x77, 0xD1, 0x4F, 0xFA, 0x66, 0xE3, 0x54, 0xC7, 0x42,
42  0x4A, 0x60, 0xEC, 0xB4, 0x19, 0x82, 0x90, 0x9D, 0x75, 0x1D, 0x4F,
43  0xC9, 0x0B, 0x3B, 0x12, 0x2F, 0x54, 0x79, 0x08, 0xA0, 0xAF, 0xD1,
44  0x3E, 0x1A, 0x38, 0xC7, 0xB1, 0x81, 0xC6, 0xE6, 0x56, 0x05, 0x87,
45  0x03, 0x25, 0xEB, 0xFE, 0x9C, 0x6D, 0xF8, 0x6D, 0x2E, 0xAB, 0xDE,
46  0x20, 0xBA, 0x89, 0x3C, 0x92, 0xF8, 0xD3, 0x53, 0xBC };
47 
48  if(m_name == "R3411_94_TestParam")
49  m_sboxes = GOST_R_3411_TEST_PARAMS;
50  else if(m_name == "R3411_CryptoPro")
51  m_sboxes = GOST_R_3411_CRYPTOPRO_PARAMS;
52  else
53  throw Invalid_Argument("GOST_28147_89_Params: Unknown " + m_name);
54  }

Member Function Documentation

◆ param_name()

std::string Botan::GOST_28147_89_Params::param_name ( ) const
inline
Returns
name of this parameter set

Definition at line 34 of file gost_28147.h.

34 { return m_name; }

◆ sbox_entry()

uint8_t Botan::GOST_28147_89_Params::sbox_entry ( size_t  row,
size_t  col 
) const
Parameters
rowthe row
colthe column
Returns
sbox entry at this row/column

Definition at line 13 of file gost_28147.cpp.

14  {
15  const uint8_t x = m_sboxes[4 * col + (row / 2)];
16  return (row % 2 == 0) ? (x >> 4) : (x & 0x0F);
17  }

◆ sbox_pair()

uint8_t Botan::GOST_28147_89_Params::sbox_pair ( size_t  row,
size_t  col 
) const

Return a representation used for building larger tables For internal use

Definition at line 19 of file gost_28147.cpp.

Referenced by Botan::GOST_28147_89::GOST_28147_89().

20  {
21  const uint8_t x = m_sboxes[4 * (col % 16) + row];
22  const uint8_t y = m_sboxes[4 * (col / 16) + row];
23  return (x >> 4) | (y << 4);
24  }

The documentation for this class was generated from the following files: