Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

  1. #ifndef CRYPTOPP_IDEA_H
  2. #define CRYPTOPP_IDEA_H
  3. /** \file
  4. */
  5. #include "seckey.h"
  6. #include "secblock.h"
  7. NAMESPACE_BEGIN(CryptoPP)
  8. //! _
  9. struct IDEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public FixedRounds<8>
  10. {
  11. static const char *StaticAlgorithmName() {return "IDEA";}
  12. };
  13. /// <a href="http://www.weidai.com/scan-mirror/cs.html#IDEA">IDEA</a>
  14. class IDEA : public IDEA_Info, public BlockCipherDocumentation
  15. {
  16. public: // made public for internal purposes
  17. #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
  18. typedef word Word;
  19. #else
  20. typedef hword Word;
  21. #endif
  22. private:
  23. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<IDEA_Info>
  24. {
  25. public:
  26. unsigned int OptimalDataAlignment() const {return 2;}
  27. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  28. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  29. private:
  30. void EnKey(const byte *);
  31. void DeKey();
  32. FixedSizeSecBlock<Word, 6*ROUNDS+4> m_key;
  33. #ifdef IDEA_LARGECACHE
  34. static inline void LookupMUL(word &a, word b);
  35. void LookupKeyLogs();
  36. static void BuildLogTables();
  37. static volatile bool tablesBuilt;
  38. static word16 log[0x10000], antilog[0x10000];
  39. #endif
  40. };
  41. public:
  42. typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
  43. typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
  44. };
  45. typedef IDEA::Encryption IDEAEncryption;
  46. typedef IDEA::Decryption IDEADecryption;
  47. NAMESPACE_END
  48. #endif