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.

54 lines
1.2 KiB

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