MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hc128.hpp
1 /*
2  Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to the
15  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16  MA 02110-1301 USA.
17 */
18 
19 /* hc128.hpp defines HC128
20 */
21 
22 
23 #ifndef TAO_CRYPT_HC128_HPP
24 #define TAO_CRYPT_HC128_HPP
25 
26 #include "misc.hpp"
27 
28 namespace TaoCrypt {
29 
30 
31 // HC128 encryption and decryption
32 class HC128 {
33 public:
34 
35  typedef HC128 Encryption;
36  typedef HC128 Decryption;
37 
38 
39  HC128() {}
40 
41  void Process(byte*, const byte*, word32);
42  void SetKey(const byte*, const byte*);
43 private:
44  word32 T_[1024]; /* P[i] = T[i]; Q[i] = T[1024 + i ]; */
45  word32 X_[16];
46  word32 Y_[16];
47  word32 counter1024_; /* counter1024 = i mod 1024 at the ith step */
48  word32 key_[8];
49  word32 iv_[8];
50 
51  void SetIV(const byte*);
52  void GenerateKeystream(word32*);
53  void SetupUpdate();
54 
55  HC128(const HC128&); // hide copy
56  const HC128 operator=(const HC128&); // and assign
57 };
58 
59 } // namespace
60 
61 
62 #endif // TAO_CRYPT_HC128_HPP
63