Line | Count | Source (jump to first uncovered line) |
1 | | // gost.h - originally written and placed in the public domain by Wei Dai |
2 | | |
3 | | /// \file gost.h |
4 | | /// \brief Classes for the GIST block cipher |
5 | | |
6 | | #ifndef CRYPTOPP_GOST_H |
7 | | #define CRYPTOPP_GOST_H |
8 | | |
9 | | #include "seckey.h" |
10 | | #include "secblock.h" |
11 | | |
12 | | NAMESPACE_BEGIN(CryptoPP) |
13 | | |
14 | | /// \brief GOST block cipher information |
15 | | /// \since Crypto++ 2.1 |
16 | | struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32> |
17 | | { |
18 | 0 | CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "GOST";} |
19 | | }; |
20 | | |
21 | | /// \brief GOST block cipher |
22 | | /// \sa <a href="http://www.cryptopp.com/wiki/GOST">GOST</a> |
23 | | /// \since Crypto++ 2.1 |
24 | | class GOST : public GOST_Info, public BlockCipherDocumentation |
25 | | { |
26 | | /// \brief GOST block cipher default operation |
27 | | class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<GOST_Info> |
28 | | { |
29 | | public: |
30 | | void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); |
31 | | |
32 | | protected: |
33 | | static void PrecalculateSTable(); |
34 | | |
35 | | static const byte sBox[8][16]; |
36 | | static volatile bool sTableCalculated; |
37 | | static word32 sTable[4][256]; |
38 | | |
39 | | FixedSizeSecBlock<word32, 8> m_key; |
40 | | }; |
41 | | |
42 | | /// \brief GOST block cipher encryption operation |
43 | | class CRYPTOPP_NO_VTABLE Enc : public Base |
44 | | { |
45 | | public: |
46 | | void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
47 | | }; |
48 | | |
49 | | /// \brief GOST block cipher decryption operation |
50 | | class CRYPTOPP_NO_VTABLE Dec : public Base |
51 | | { |
52 | | public: |
53 | | void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
54 | | }; |
55 | | |
56 | | public: |
57 | | typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption; |
58 | | typedef BlockCipherFinal<DECRYPTION, Dec> Decryption; |
59 | | }; |
60 | | |
61 | | typedef GOST::Encryption GOSTEncryption; |
62 | | typedef GOST::Decryption GOSTDecryption; |
63 | | |
64 | | NAMESPACE_END |
65 | | |
66 | | #endif |