shacal2.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // shacal.h - originally written and placed in the public domain by Wei Dai
  2. /// \file shacal2.h
  3. /// \brief Classes for the SHACAL-2 block cipher
  4. /// \since Crypto++ 5.2, Intel SHA since Crypto++ 6.0
  5. #ifndef CRYPTOPP_SHACAL2_H
  6. #define CRYPTOPP_SHACAL2_H
  7. #include "seckey.h"
  8. #include "secblock.h"
  9. NAMESPACE_BEGIN(CryptoPP)
  10. /// \brief SHACAL2 block cipher information
  11. struct SHACAL2_Info : public FixedBlockSize<32>, public VariableKeyLength<16, 16, 64>
  12. {
  13. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SHACAL-2";}
  14. };
  15. /// \brief SHACAL2 block cipher
  16. /// \since Crypto++ 5.2, Intel SHA since Crypto++ 6.0
  17. /// \sa <a href="http://www.cryptopp.com/wiki/SHACAL-2">SHACAL-2</a>
  18. class SHACAL2 : public SHACAL2_Info, public BlockCipherDocumentation
  19. {
  20. /// \brief SHACAL2 block cipher transformation functions
  21. /// \details Provides implementation common to encryption and decryption
  22. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHACAL2_Info>
  23. {
  24. public:
  25. std::string AlgorithmProvider() const;
  26. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  27. protected:
  28. FixedSizeAlignedSecBlock<word32, 64> m_key;
  29. static const word32 K[64];
  30. };
  31. /// \brief SHACAL2 block cipher transformation functions
  32. /// \details Encryption transformation
  33. class CRYPTOPP_NO_VTABLE Enc : public Base
  34. {
  35. public:
  36. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  37. };
  38. /// \brief SHACAL2 block cipher transformation functions
  39. /// \details Decryption transformation
  40. class CRYPTOPP_NO_VTABLE Dec : public Base
  41. {
  42. public:
  43. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  44. };
  45. public:
  46. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  47. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  48. };
  49. typedef SHACAL2::Encryption SHACAL2Encryption;
  50. typedef SHACAL2::Decryption SHACAL2Decryption;
  51. NAMESPACE_END
  52. #endif