mars.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // mars.h - originally 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. /// \since Crypto++ 3.0
  5. #ifndef CRYPTOPP_MARS_H
  6. #define CRYPTOPP_MARS_H
  7. #include "seckey.h"
  8. #include "secblock.h"
  9. NAMESPACE_BEGIN(CryptoPP)
  10. /// \brief MARS block cipher information
  11. /// \since Crypto++ 3.0
  12. struct MARS_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 56, 8>
  13. {
  14. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "MARS";}
  15. };
  16. /// \brief MARS block cipher
  17. /// \sa <a href="http://www.cryptopp.com/wiki/MARS">MARS</a>
  18. /// \since Crypto++ 3.0
  19. class MARS : public MARS_Info, public BlockCipherDocumentation
  20. {
  21. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<MARS_Info>
  22. {
  23. public:
  24. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  25. protected:
  26. static const word32 Sbox[512];
  27. FixedSizeSecBlock<word32, 40> m_k;
  28. };
  29. class CRYPTOPP_NO_VTABLE Enc : public Base
  30. {
  31. public:
  32. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  33. };
  34. class CRYPTOPP_NO_VTABLE Dec : public Base
  35. {
  36. public:
  37. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  38. };
  39. public:
  40. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  41. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  42. };
  43. typedef MARS::Encryption MARSEncryption;
  44. typedef MARS::Decryption MARSDecryption;
  45. NAMESPACE_END
  46. #endif