1#ifndef CRYPTOPP_SHARK_H
2#define CRYPTOPP_SHARK_H
3
4/** \file
5*/
6
7#include "config.h"
8#include "seckey.h"
9#include "secblock.h"
10
11NAMESPACE_BEGIN(CryptoPP)
12
13//! _
14struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>, public VariableRounds<6, 2>
15{
16	static const char *StaticAlgorithmName() {return "SHARK-E";}
17};
18
19/// <a href="http://www.weidai.com/scan-mirror/cs.html#SHARK-E">SHARK-E</a>
20class SHARK : public SHARK_Info, public BlockCipherDocumentation
21{
22	class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
23	{
24	public:
25		void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &param);
26
27	protected:
28		unsigned int m_rounds;
29		SecBlock<word64> m_roundKeys;
30	};
31
32	class CRYPTOPP_NO_VTABLE Enc : public Base
33	{
34	public:
35		void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
36
37		// used by Base to do key setup
38		void InitForKeySetup();
39
40	private:
41		static const byte sbox[256];
42		static const word64 cbox[8][256];
43	};
44
45	class CRYPTOPP_NO_VTABLE Dec : public Base
46	{
47	public:
48		void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
49
50	private:
51		static const byte sbox[256];
52		static const word64 cbox[8][256];
53	};
54
55public:
56	typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
57	typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
58};
59
60typedef SHARK::Encryption SHARKEncryption;
61typedef SHARK::Decryption SHARKDecryption;
62
63NAMESPACE_END
64
65#endif
66