hight.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // hight.h - written and placed in the public domain by Kim Sung Hee and Jeffrey Walton
  2. // Based on "HIGHT: A New Block Cipher Suitable for Low-Resource Device"
  3. // by Deukjo Hong, Jaechul Sung, Seokhie Hong, Jongin Lim, Sangjin Lee,
  4. // Bon-Seok Koo, Changhoon Lee, Donghoon Chang, Jesang Lee, Kitae Jeong,
  5. // Hyun Kim, Jongsung Kim, and Seongtaek Chee
  6. /// \file hight.h
  7. /// \brief Classes for the HIGHT block cipher
  8. /// \since Crypto++ 8.0
  9. #ifndef CRYPTOPP_HIGHT_H
  10. #define CRYPTOPP_HIGHT_H
  11. #include "config.h"
  12. #include "seckey.h"
  13. #include "secblock.h"
  14. #include "algparam.h"
  15. NAMESPACE_BEGIN(CryptoPP)
  16. /// \brief HIGHT block cipher information
  17. /// \since Crypto++ 8.0
  18. struct HIGHT_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
  19. {
  20. static const std::string StaticAlgorithmName()
  21. {
  22. // Format is Cipher-Blocksize
  23. return "HIGHT";
  24. }
  25. };
  26. /// \brief HIGHT 64-bit block cipher
  27. /// \details HIGHT provides 64-bit block size. The valid key size is 128-bits.
  28. /// \note Crypto++ provides a byte oriented implementation
  29. /// \sa <a href="http://www.cryptopp.com/wiki/HIGHT">HIGHT</a>,
  30. /// <a href="https://seed.kisa.or.kr/">Korea Internet &amp; Security
  31. /// Agency</a> website
  32. /// \since Crypto++ 8.0
  33. class CRYPTOPP_NO_VTABLE HIGHT : public HIGHT_Info, public BlockCipherDocumentation
  34. {
  35. public:
  36. /// \brief HIGHT block cipher transformation functions
  37. /// \details Provides implementation common to encryption and decryption
  38. /// \since Crypto++ 8.0
  39. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<HIGHT_Info>
  40. {
  41. protected:
  42. void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs &params);
  43. FixedSizeSecBlock<byte, 136> m_rkey;
  44. mutable FixedSizeSecBlock<word32, 8> m_xx;
  45. };
  46. /// \brief Encryption transformation
  47. /// \details Enc provides implementation for encryption transformation.
  48. /// \since Crypto++ 8.0
  49. class CRYPTOPP_NO_VTABLE Enc : public Base
  50. {
  51. public:
  52. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  53. };
  54. /// \brief Decryption transformation
  55. /// \details Dec provides implementation for decryption transformation.
  56. /// \since Crypto++ 8.0
  57. class CRYPTOPP_NO_VTABLE Dec : public Base
  58. {
  59. public:
  60. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  61. };
  62. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  63. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  64. };
  65. typedef HIGHT::Encryption HIGHTEncryption;
  66. typedef HIGHT::Decryption HIGHTDecryption;
  67. NAMESPACE_END
  68. #endif // CRYPTOPP_HIGHT_H