1#ifndef CRYPTOPP_IDEA_H 2#define CRYPTOPP_IDEA_H 3 4/** \file 5*/ 6 7#include "seckey.h" 8#include "secblock.h" 9 10NAMESPACE_BEGIN(CryptoPP) 11 12//! _ 13struct 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> 19class IDEA : public IDEA_Info, public BlockCipherDocumentation 20{ 21public: // made public for internal purposes 22#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE 23 typedef word Word; 24#else 25 typedef hword Word; 26#endif 27 28private: 29 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info> 30 { 31 public: 32 unsigned int OptimalDataAlignment() const {return 2;} 33 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; 34 35 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); 36 37 private: 38 void EnKey(const byte *); 39 void DeKey(); 40 FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key; 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 51public: 52 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption; 53 typedef BlockCipherFinal<DECRYPTION, Base> Decryption; 54}; 55 56typedef IDEA::Encryption IDEAEncryption; 57typedef IDEA::Decryption IDEADecryption; 58 59NAMESPACE_END 60 61#endif 62