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