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