Line | Count | Source |
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 | | |
7 | | /// \file hight.h |
8 | | /// \brief Classes for the HIGHT block cipher |
9 | | /// \since Crypto++ 8.0 |
10 | | |
11 | | #ifndef CRYPTOPP_HIGHT_H |
12 | | #define CRYPTOPP_HIGHT_H |
13 | | |
14 | | #include "config.h" |
15 | | #include "seckey.h" |
16 | | #include "secblock.h" |
17 | | #include "algparam.h" |
18 | | |
19 | | NAMESPACE_BEGIN(CryptoPP) |
20 | | |
21 | | /// \brief HIGHT block cipher information |
22 | | /// \since Crypto++ 8.0 |
23 | | struct HIGHT_Info : public FixedBlockSize<8>, public FixedKeyLength<16> |
24 | | { |
25 | | static const std::string StaticAlgorithmName() |
26 | 10 | { |
27 | | // Format is Cipher-Blocksize |
28 | 10 | return "HIGHT"; |
29 | 10 | } |
30 | | }; |
31 | | |
32 | | /// \brief HIGHT 64-bit block cipher |
33 | | /// \details HIGHT provides 64-bit block size. The valid key size is 128-bits. |
34 | | /// \note Crypto++ provides a byte oriented implementation |
35 | | /// \sa <a href="http://www.cryptopp.com/wiki/HIGHT">HIGHT</a>, |
36 | | /// <a href="https://seed.kisa.or.kr/">Korea Internet & Security |
37 | | /// Agency</a> website |
38 | | /// \since Crypto++ 8.0 |
39 | | class CRYPTOPP_NO_VTABLE HIGHT : public HIGHT_Info, public BlockCipherDocumentation |
40 | | { |
41 | | public: |
42 | | /// \brief HIGHT block cipher transformation functions |
43 | | /// \details Provides implementation common to encryption and decryption |
44 | | /// \since Crypto++ 8.0 |
45 | | class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<HIGHT_Info> |
46 | | { |
47 | | protected: |
48 | | void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms); |
49 | | |
50 | | FixedSizeSecBlock<byte, 136> m_rkey; |
51 | | mutable FixedSizeSecBlock<word32, 8> m_xx; |
52 | | }; |
53 | | |
54 | | /// \brief Encryption transformation |
55 | | /// \details Enc provides implementation for encryption transformation. |
56 | | /// \since Crypto++ 8.0 |
57 | | class CRYPTOPP_NO_VTABLE Enc : public Base |
58 | | { |
59 | | public: |
60 | | void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
61 | | }; |
62 | | |
63 | | /// \brief Decryption transformation |
64 | | /// \details Dec provides implementation for decryption transformation. |
65 | | /// \since Crypto++ 8.0 |
66 | | class CRYPTOPP_NO_VTABLE Dec : public Base |
67 | | { |
68 | | public: |
69 | | void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
70 | | }; |
71 | | |
72 | | typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption; |
73 | | typedef BlockCipherFinal<DECRYPTION, Dec> Decryption; |
74 | | }; |
75 | | |
76 | | typedef HIGHT::Encryption HIGHTEncryption; |
77 | | typedef HIGHT::Decryption HIGHTDecryption; |
78 | | |
79 | | NAMESPACE_END |
80 | | |
81 | | #endif // CRYPTOPP_HIGHT_H |