Team Fortress 2 Source Code as on 22/4/2020
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.

56 lines
1.3 KiB

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