1#ifndef CRYPTOPP_GOST_H
2#define CRYPTOPP_GOST_H
3
4/** \file
5*/
6
7#include "seckey.h"
8#include "secblock.h"
9
10NAMESPACE_BEGIN(CryptoPP)
11
12//! _
13struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32>
14{
15	static const char *StaticAlgorithmName() {return "GOST";}
16};
17
18/// <a href="http://www.weidai.com/scan-mirror/cs.html#GOST">GOST</a>
19class GOST : public GOST_Info, public BlockCipherDocumentation
20{
21	class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<GOST_Info>
22	{
23	public:
24		void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
25
26	protected:
27		static void PrecalculateSTable();
28
29		static const byte sBox[8][16];
30		static bool sTableCalculated;
31		static word32 sTable[4][256];
32
33		FixedSizeSecBlock<word32, 8> key;
34	};
35
36	class CRYPTOPP_NO_VTABLE Enc : public Base
37	{
38	public:
39		void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
40	};
41
42	class CRYPTOPP_NO_VTABLE Dec : public Base
43	{
44	public:
45		void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
46	};
47
48public:
49	typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
50	typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
51};
52
53typedef GOST::Encryption GOSTEncryption;
54typedef GOST::Decryption GOSTDecryption;
55
56NAMESPACE_END
57
58#endif
59