Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:03

0001 // hight.h - written and placed in the public domain by Kim Sung Hee and Jeffrey Walton

0002 //           Based on "HIGHT: A New Block Cipher Suitable for Low-Resource Device"

0003 //           by Deukjo Hong, Jaechul Sung, Seokhie Hong, Jongin Lim, Sangjin Lee,

0004 //           Bon-Seok Koo, Changhoon Lee, Donghoon Chang, Jesang Lee, Kitae Jeong,

0005 //           Hyun Kim, Jongsung Kim, and Seongtaek Chee

0006 
0007 /// \file hight.h

0008 /// \brief Classes for the HIGHT block cipher

0009 /// \since Crypto++ 8.0

0010 
0011 #ifndef CRYPTOPP_HIGHT_H
0012 #define CRYPTOPP_HIGHT_H
0013 
0014 #include "config.h"
0015 #include "seckey.h"
0016 #include "secblock.h"
0017 #include "algparam.h"
0018 
0019 NAMESPACE_BEGIN(CryptoPP)
0020 
0021 /// \brief HIGHT block cipher information

0022 /// \since Crypto++ 8.0

0023 struct HIGHT_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
0024 {
0025     static const std::string StaticAlgorithmName()
0026     {
0027         // Format is Cipher-Blocksize

0028         return "HIGHT";
0029     }
0030 };
0031 
0032 /// \brief HIGHT 64-bit block cipher

0033 /// \details HIGHT provides 64-bit block size. The valid key size is 128-bits.

0034 /// \note Crypto++ provides a byte oriented implementation

0035 /// \sa <a href="http://www.cryptopp.com/wiki/HIGHT">HIGHT</a>,

0036 ///   <a href="https://seed.kisa.or.kr/">Korea Internet &amp; Security

0037 ///   Agency</a> website

0038 /// \since Crypto++ 8.0

0039 class CRYPTOPP_NO_VTABLE HIGHT : public HIGHT_Info, public BlockCipherDocumentation
0040 {
0041 public:
0042     /// \brief HIGHT block cipher transformation functions

0043     /// \details Provides implementation common to encryption and decryption

0044     /// \since Crypto++ 8.0

0045     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<HIGHT_Info>
0046     {
0047     protected:
0048         void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs &params);
0049 
0050         FixedSizeSecBlock<byte, 136> m_rkey;
0051         mutable FixedSizeSecBlock<word32, 8> m_xx;
0052     };
0053 
0054     /// \brief Encryption transformation

0055     /// \details Enc provides implementation for encryption transformation.

0056     /// \since Crypto++ 8.0

0057     class CRYPTOPP_NO_VTABLE Enc : public Base
0058     {
0059     public:
0060         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0061     };
0062 
0063     /// \brief Decryption transformation

0064     /// \details Dec provides implementation for decryption transformation.

0065     /// \since Crypto++ 8.0

0066     class CRYPTOPP_NO_VTABLE Dec : public Base
0067     {
0068     public:
0069         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0070     };
0071 
0072     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0073     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0074 };
0075 
0076 typedef HIGHT::Encryption HIGHTEncryption;
0077 typedef HIGHT::Decryption HIGHTDecryption;
0078 
0079 NAMESPACE_END
0080 
0081 #endif  // CRYPTOPP_HIGHT_H