File indexing completed on 2025-01-18 09:55:04
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_IDEA_H
0007 #define CRYPTOPP_IDEA_H
0008
0009 #include "seckey.h"
0010 #include "secblock.h"
0011
0012 NAMESPACE_BEGIN(CryptoPP)
0013
0014
0015
0016 struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
0017 {
0018 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "IDEA";}
0019 };
0020
0021
0022
0023
0024 class IDEA : public IDEA_Info, public BlockCipherDocumentation
0025 {
0026 public:
0027 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
0028 typedef word Word;
0029 #else
0030 typedef hword Word;
0031 #endif
0032
0033 private:
0034 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info>
0035 {
0036 public:
0037 unsigned int OptimalDataAlignment() const {return 2;}
0038 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0039
0040 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
0041
0042 private:
0043 void EnKey(const byte *);
0044 void DeKey();
0045 FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key;
0046
0047 #ifdef IDEA_LARGECACHE
0048 static inline void LookupMUL(word &a, word b);
0049 void LookupKeyLogs();
0050 static void BuildLogTables();
0051 static volatile bool tablesBuilt;
0052 static word16 log[0x10000], antilog[0x10000];
0053 #endif
0054 };
0055
0056 public:
0057 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
0058 typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
0059 };
0060
0061 typedef IDEA::Encryption IDEAEncryption;
0062 typedef IDEA::Decryption IDEADecryption;
0063
0064 NAMESPACE_END
0065
0066 #endif