~zooko/cryptopp/trunk

1 by weidai
Initial revision
1
#ifndef CRYPTOPP_IDEA_H
2
#define CRYPTOPP_IDEA_H
3
4
/** \file
5
*/
6
7
#include "seckey.h"
8
#include "secblock.h"
9
10
NAMESPACE_BEGIN(CryptoPP)
11
173 by weidai
fix documentation, fix PanamaMAC, fix algorithm names
12
//! _
1 by weidai
Initial revision
13
struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
14
{
15
	static const char *StaticAlgorithmName() {return "IDEA";}
16
};
17
18
/// <a href="http://www.weidai.com/scan-mirror/cs.html#IDEA">IDEA</a>
19
class IDEA : public IDEA_Info, public BlockCipherDocumentation
20
{
202 by weidai
fix MSVC 2005 warnings
21
public:		// made public for internal purposes
22
#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
23
	typedef word Word;
24
#else
25
	typedef hword Word;
26
#endif
27
28
private:
75 by weidai
create DLL version, fix GetNextIV() bug in CTR and OFB modes
29
	class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info>
1 by weidai
Initial revision
30
	{
31
	public:
412 by weidai
changes for 5.6:
32
		unsigned int OptimalDataAlignment() const {return 2;}
1 by weidai
Initial revision
33
		void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
34
232 by weidai
port to GCC 4, reorganize implementations of SetKey
35
		void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
1 by weidai
Initial revision
36
37
	private:
38
		void EnKey(const byte *);
39
		void DeKey();
202 by weidai
fix MSVC 2005 warnings
40
		FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key;
1 by weidai
Initial revision
41
42
	#ifdef IDEA_LARGECACHE
43
		static inline void LookupMUL(word &a, word b);
44
		void LookupKeyLogs();
45
		static void BuildLogTables();
46
		static bool tablesBuilt;
47
		static word16 log[0x10000], antilog[0x10000];
48
	#endif
49
	};
50
51
public:
75 by weidai
create DLL version, fix GetNextIV() bug in CTR and OFB modes
52
	typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
53
	typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
1 by weidai
Initial revision
54
};
55
56
typedef IDEA::Encryption IDEAEncryption;
57
typedef IDEA::Decryption IDEADecryption;
58
59
NAMESPACE_END
60
61
#endif