camellia.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // camellia.h - originally written and placed in the public domain by Wei Dai
  2. /// \file camellia.h
  3. /// \brief Classes for the Camellia block cipher
  4. #ifndef CRYPTOPP_CAMELLIA_H
  5. #define CRYPTOPP_CAMELLIA_H
  6. #include "config.h"
  7. #include "seckey.h"
  8. #include "secblock.h"
  9. NAMESPACE_BEGIN(CryptoPP)
  10. /// \brief Camellia block cipher information
  11. struct Camellia_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
  12. {
  13. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Camellia";}
  14. };
  15. /// \brief Camellia block cipher
  16. /// \sa <a href="http://www.cryptopp.com/wiki/Camellia">Camellia</a>
  17. class Camellia : public Camellia_Info, public BlockCipherDocumentation
  18. {
  19. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Camellia_Info>
  20. {
  21. public:
  22. void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &params);
  23. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  24. protected:
  25. CRYPTOPP_ALIGN_DATA(4) static const byte s1[256];
  26. static const word32 SP[4][256];
  27. unsigned int m_rounds;
  28. SecBlock<word32> m_key;
  29. };
  30. public:
  31. typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
  32. typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
  33. };
  34. typedef Camellia::Encryption CamelliaEncryption;
  35. typedef Camellia::Decryption CamelliaDecryption;
  36. NAMESPACE_END
  37. #endif