~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/CLucene/util/_MD5Digester.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////
 
2
// MD5.cpp
 
3
// Implementation file for MD5 class
 
4
//
 
5
// This C++ Class implementation of the original RSA Data Security, Inc.
 
6
// MD5 Message-Digest Algorithm is copyright (c) 2002, Gary McNickle.
 
7
// All rights reserved.  This software is a derivative of the "RSA Data
 
8
//  Security, Inc. MD5 Message-Digest Algorithm"
 
9
//
 
10
// You may use this software free of any charge, but without any
 
11
// warranty or implied warranty, provided that you follow the terms
 
12
// of the original RSA copyright, listed below.
 
13
//
 
14
// Original RSA Data Security, Inc. Copyright notice
 
15
/////////////////////////////////////////////////////////////////////////
 
16
//
 
17
// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
 
18
// rights reserved.
 
19
//
 
20
// License to copy and use this software is granted provided that it
 
21
// is identified as the "RSA Data Security, Inc. MD5 Message-Digest
 
22
// Algorithm" in all material mentioning or referencing this software
 
23
// or this function.
 
24
// License is also granted to make and use derivative works provided
 
25
// that such works are identified as "derived from the RSA Data
 
26
// Security, Inc. MD5 Message-Digest Algorithm" in all material
 
27
// mentioning or referencing the derived work.
 
28
// RSA Data Security, Inc. makes no representations concerning either
 
29
// the merchantability of this software or the suitability of this
 
30
// software for any particular purpose. It is provided "as is"
 
31
// without express or implied warranty of any kind.
 
32
// These notices must be retained in any copies of any part of this
 
33
// documentation and/or software.
 
34
/////////////////////////////////////////////////////////////////////////
 
35
 
 
36
/*------------------------------------------------------------------------------
 
37
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
 
38
 
39
* Distributable under the terms of either the Apache License (Version 2.0) or 
 
40
* the GNU Lesser General Public License, as specified in the COPYING file.
 
41
------------------------------------------------------------------------------*/
 
42
 
 
43
#ifndef _lucene_util_MD5Digester_H
 
44
#define _lucene_util_MD5Digester_H
 
45
 
 
46
 
 
47
CL_NS_DEF(util)
 
48
 
 
49
typedef unsigned short int uint2;
 
50
 
 
51
char* PrintMD5(uint8_t md5Digest[16]);
 
52
char* MD5String(char* szString);
 
53
char* MD5File(char* szFilename);
 
54
 
 
55
class md5
 
56
{
 
57
// Methods
 
58
public:
 
59
        md5() { Init(); }
 
60
        void    Init();
 
61
        void    Update(uint8_t* chInput, uint32_t nInputLen);
 
62
        void    Finalize();
 
63
        uint8_t*        Digest() { return m_Digest; }
 
64
 
 
65
private:
 
66
 
 
67
        void    Transform(uint8_t* block);
 
68
        void    Encode(uint8_t* dest, uint32_t* src, uint32_t nLength);
 
69
        void    Decode(uint32_t* dest, uint8_t* src, uint32_t nLength);
 
70
 
 
71
 
 
72
        inline  uint32_t        rotate_left(uint32_t x, uint32_t n)
 
73
                         { return ((x << n) | (x >> (32-n))); }
 
74
 
 
75
        inline  uint32_t        F(uint32_t x, uint32_t y, uint32_t z)
 
76
                         { return ((x & y) | (~x & z)); }
 
77
 
 
78
        inline  uint32_t        G(uint32_t x, uint32_t y, uint32_t z)
 
79
                         { return ((x & z) | (y & ~z)); }
 
80
 
 
81
        inline  uint32_t        H(uint32_t x, uint32_t y, uint32_t z)
 
82
                         { return (x ^ y ^ z); }
 
83
 
 
84
        inline  uint32_t        I(uint32_t x, uint32_t y, uint32_t z)
 
85
                         { return (y ^ (x | ~z)); }
 
86
 
 
87
        inline  void    FF(uint32_t& a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint32_t s, uint32_t ac)
 
88
                         { a += F(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 
89
 
 
90
        inline  void    GG(uint32_t& a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint32_t s, uint32_t ac)
 
91
                     { a += G(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 
92
 
 
93
        inline  void    HH(uint32_t& a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint32_t s, uint32_t ac)
 
94
                     { a += H(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 
95
 
 
96
        inline  void    II(uint32_t& a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint32_t s, uint32_t ac)
 
97
                     { a += I(b, c, d) + x + ac; a = rotate_left(a, s); a += b; }
 
98
 
 
99
// Data
 
100
private:
 
101
        uint32_t                m_State[4];
 
102
        uint32_t                m_Count[2];
 
103
        uint8_t         m_Buffer[64];
 
104
        uint8_t         m_Digest[16];
 
105
        uint8_t         m_Finalized;
 
106
 
 
107
};
 
108
 
 
109
CL_NS_END
 
110
#endif