mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / extra / yassl / taocrypt / include / ripemd.hpp
bloba63f92ceadd5de6d5e0898e1fb82d47198ac4b5e
1 /*
2 Copyright (C) 2000-2007 MySQL AB
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.
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.
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.
19 /* ripemd.hpp provides RIPEMD digest support
22 #ifndef TAO_CRYPT_RIPEMD_HPP
23 #define TAO_CRYPT_RIPEMD_HPP
25 #include "hash.hpp"
28 #if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
29 #define DO_RIPEMD_ASM
30 #endif
32 namespace TaoCrypt {
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; }
47 RIPEMD160(const RIPEMD160&);
48 RIPEMD160& operator= (const RIPEMD160&);
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);
60 inline void swap(RIPEMD160& a, RIPEMD160& b)
62 a.Swap(b);
66 } // namespace
68 #endif // TAO_CRYPT_RIPEMD_HPP