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.

59 lines
1.4 KiB

  1. #ifndef CRYPTOPP_TWOFISH_H
  2. #define CRYPTOPP_TWOFISH_H
  3. /** \file
  4. */
  5. #include "seckey.h"
  6. #include "secblock.h"
  7. NAMESPACE_BEGIN(CryptoPP)
  8. //! _
  9. struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, FixedRounds<16>
  10. {
  11. static const char *StaticAlgorithmName() {return "Twofish";}
  12. };
  13. /// <a href="http://www.weidai.com/scan-mirror/cs.html#Twofish">Twofish</a>
  14. class Twofish : public Twofish_Info, public BlockCipherDocumentation
  15. {
  16. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Twofish_Info>
  17. {
  18. public:
  19. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  20. protected:
  21. static word32 h0(word32 x, const word32 *key, unsigned int kLen);
  22. static word32 h(word32 x, const word32 *key, unsigned int kLen);
  23. static const byte q[2][256];
  24. static const word32 mds[4][256];
  25. FixedSizeSecBlock<word32, 40> m_k;
  26. FixedSizeSecBlock<word32, 4*256> m_s;
  27. };
  28. class CRYPTOPP_NO_VTABLE Enc : public Base
  29. {
  30. public:
  31. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  32. };
  33. class CRYPTOPP_NO_VTABLE Dec : public Base
  34. {
  35. public:
  36. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  37. };
  38. public:
  39. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  40. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  41. };
  42. typedef Twofish::Encryption TwofishEncryption;
  43. typedef Twofish::Decryption TwofishDecryption;
  44. NAMESPACE_END
  45. #endif