00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_IDEA_H
00007 #define CRYPTOPP_IDEA_H
00008
00009 #include "seckey.h"
00010 #include "secblock.h"
00011
00012 NAMESPACE_BEGIN(CryptoPP)
00013
00014
00015 struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
00016 {
00017 static const char *StaticAlgorithmName() {return "IDEA";}
00018 };
00019
00020
00021 class IDEA : public IDEA_Info, public BlockCipherDocumentation
00022 {
00023 public:
00024 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
00025 typedef word Word;
00026 #else
00027 typedef hword Word;
00028 #endif
00029
00030 private:
00031 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info>
00032 {
00033 public:
00034 unsigned int OptimalDataAlignment() const {return 2;}
00035 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00036
00037 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
00038
00039 private:
00040 void EnKey(const byte *);
00041 void DeKey();
00042 FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key;
00043
00044 #ifdef IDEA_LARGECACHE
00045 static inline void LookupMUL(word &a, word b);
00046 void LookupKeyLogs();
00047 static void BuildLogTables();
00048 static volatile bool tablesBuilt;
00049 static word16 log[0x10000], antilog[0x10000];
00050 #endif
00051 };
00052
00053 public:
00054 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
00055 typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
00056 };
00057
00058 typedef IDEA::Encryption IDEAEncryption;
00059 typedef IDEA::Decryption IDEADecryption;
00060
00061 NAMESPACE_END
00062
00063 #endif