MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
md5.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 /* md5.hpp provides MD5 digest support, see RFC 1321
20 */
21 
22 #ifndef TAO_CRYPT_MD5_HPP
23 #define TAO_CRYPT_MD5_HPP
24 
25 #include "hash.hpp"
26 
27 
28 #if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
29  #define DO_MD5_ASM
30 #endif
31 
32 namespace TaoCrypt {
33 
34 
35 // MD5 digest
36 class MD5 : public HASHwithTransform {
37 public:
38  enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56,
39  TAO_BYTE_ORDER = LittleEndianOrder }; // in Bytes
40  MD5() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE)
41  { Init(); }
42  ByteOrder getByteOrder() const { return ByteOrder(TAO_BYTE_ORDER); }
43  word32 getBlockSize() const { return BLOCK_SIZE; }
44  word32 getDigestSize() const { return DIGEST_SIZE; }
45  word32 getPadSize() const { return PAD_SIZE; }
46 
47  MD5(const MD5&);
48  MD5& operator= (const MD5&);
49 
50 #ifdef DO_MD5_ASM
51  void Update(const byte*, word32);
52 #endif
53 
54  void Init();
55  void Swap(MD5&);
56 private:
57  void Transform();
58  void AsmTransform(const byte* data, word32 times);
59 };
60 
61 inline void swap(MD5& a, MD5& b)
62 {
63  a.Swap(b);
64 }
65 
66 
67 } // namespace
68 
69 #endif // TAO_CRYPT_MD5_HPP
70