Botan 1.10.17
gost_28147.h
Go to the documentation of this file.
1/*
2* GOST 28147-89
3* (C) 1999-2009 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#ifndef BOTAN_GOST_28147_89_H__
9#define BOTAN_GOST_28147_89_H__
10
11#include <botan/block_cipher.h>
12
13namespace Botan {
14
15/**
16* The GOST 28147-89 block cipher uses a set of 4 bit Sboxes, however
17* the standard does not actually define these Sboxes; they are
18* considered a local configuration issue. Several different sets are
19* used.
20*/
21class BOTAN_DLL GOST_28147_89_Params
22 {
23 public:
24 /**
25 * @param row the row
26 * @param col the column
27 * @return sbox entry at this row/column
28 */
29 byte sbox_entry(size_t row, size_t col) const;
30
31 /**
32 * @return name of this parameter set
33 */
34 std::string param_name() const { return name; }
35
36 /**
37 * Default GOST parameters are the ones given in GOST R 34.11 for
38 * testing purposes; these sboxes are also used by Crypto++, and,
39 * at least according to Wikipedia, the Central Bank of Russian
40 * Federation
41 * @param name of the parameter set
42 */
43 GOST_28147_89_Params(const std::string& name = "R3411_94_TestParam");
44 private:
45 const byte* sboxes;
46 std::string name;
47 };
48
49/**
50* GOST 28147-89
51*/
52class BOTAN_DLL GOST_28147_89 : public Block_Cipher_Fixed_Params<8, 32>
53 {
54 public:
55 void encrypt_n(const byte in[], byte out[], size_t blocks) const;
56 void decrypt_n(const byte in[], byte out[], size_t blocks) const;
57
58 void clear() { zeroise(EK); }
59
60 std::string name() const;
61 BlockCipher* clone() const { return new GOST_28147_89(SBOX); }
62
63 /**
64 * @param params the sbox parameters to use
65 */
67 private:
68 GOST_28147_89(const SecureVector<u32bit>& other_SBOX) :
69 SBOX(other_SBOX), EK(8) {}
70
71 void key_schedule(const byte[], size_t);
72
73 SecureVector<u32bit> SBOX;
74 SecureVector<u32bit> EK;
75 };
76
77}
78
79#endif
std::string param_name() const
Definition gost_28147.h:34
byte sbox_entry(size_t row, size_t col) const
GOST_28147_89_Params(const std::string &name="R3411_94_TestParam")
void decrypt_n(const byte in[], byte out[], size_t blocks) const
void encrypt_n(const byte in[], byte out[], size_t blocks) const
GOST_28147_89(const GOST_28147_89_Params &params)
BlockCipher * clone() const
Definition gost_28147.h:61
void zeroise(MemoryRegion< T > &vec)
Definition secmem.h:428