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.

65 lines
1.4 KiB

  1. #ifndef CRYPTOPP_SHARK_H
  2. #define CRYPTOPP_SHARK_H
  3. /** \file
  4. */
  5. #include "config.h"
  6. #include "seckey.h"
  7. #include "secblock.h"
  8. NAMESPACE_BEGIN(CryptoPP)
  9. //! _
  10. struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>, public VariableRounds<6, 2>
  11. {
  12. static const char *StaticAlgorithmName() {return "SHARK-E";}
  13. };
  14. /// <a href="http://www.weidai.com/scan-mirror/cs.html#SHARK-E">SHARK-E</a>
  15. class SHARK : public SHARK_Info, public BlockCipherDocumentation
  16. {
  17. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
  18. {
  19. public:
  20. void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &param);
  21. protected:
  22. unsigned int m_rounds;
  23. SecBlock<word64> m_roundKeys;
  24. };
  25. class CRYPTOPP_NO_VTABLE Enc : public Base
  26. {
  27. public:
  28. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  29. // used by Base to do key setup
  30. void InitForKeySetup();
  31. private:
  32. static const byte sbox[256];
  33. static const word64 cbox[8][256];
  34. };
  35. class CRYPTOPP_NO_VTABLE Dec : public Base
  36. {
  37. public:
  38. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  39. private:
  40. static const byte sbox[256];
  41. static const word64 cbox[8][256];
  42. };
  43. public:
  44. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  45. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  46. };
  47. typedef SHARK::Encryption SHARKEncryption;
  48. typedef SHARK::Decryption SHARKDecryption;
  49. NAMESPACE_END
  50. #endif