MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
md2.hpp
1 /*
2  Copyright (c) 2000, 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 /* md2.hpp provides MD2 digest support, see RFC 1319
20 */
21 
22 #ifndef TAO_CRYPT_MD2_HPP
23 #define TAO_CRYPT_MD2_HPP
24 
25 
26 #include "hash.hpp"
27 #include "block.hpp"
28 
29 
30 namespace TaoCrypt {
31 
32 
33 // MD2 digest
34 class MD2 : public HASH {
35 public:
36  enum { BLOCK_SIZE = 16, DIGEST_SIZE = 16, PAD_SIZE = 16, X_SIZE = 48 };
37  MD2();
38 
39  word32 getBlockSize() const { return BLOCK_SIZE; }
40  word32 getDigestSize() const { return DIGEST_SIZE; }
41 
42  void Update(const byte*, word32);
43  void Final(byte*);
44 
45  void Init();
46  void Swap(MD2&);
47 private:
48  ByteBlock X_, C_, buffer_;
49  word32 count_; // bytes % PAD_SIZE
50 
51  MD2(const MD2&);
52  MD2& operator=(const MD2&);
53 };
54 
55 inline void swap(MD2& a, MD2& b)
56 {
57  a.Swap(b);
58 }
59 
60 
61 } // namespace
62 
63 #endif // TAO_CRYPT_MD2_HPP
64