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.

58 lines
1.3 KiB

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