The Pedigree Project  0.1
system/include/pedigree/kernel/utilities/md5/md5.h
1 /*
2  * hashlib++ - a simple hash library for C++
3  *
4  * Copyright (c) 2007-2010 Benjamin Grüdelbach
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1) Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2) Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 //----------------------------------------------------------------------
31 
32 /*
33  * The hashlib++ MD5 implementation is derivative from the sourcecode
34  * published in RFC 1321
35  *
36  * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
37  * rights reserved.
38  *
39  * License to copy and use this software is granted provided that it
40  * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
41  * Algorithm" in all material mentioning or referencing this software
42  * or this function.
43  *
44  * License is also granted to make and use derivative works provided
45  * that such works are identified as "derived from the RSA Data
46  * Security, Inc. MD5 Message-Digest Algorithm" in all material
47  * mentioning or referencing the derived work.
48  *
49  * RSA Data Security, Inc. makes no representations concerning either
50  * the merchantability of this software or the suitability of this
51  * software for any particular purpose. It is provided "as is"
52  * without express or implied warranty of any kind.
53  *
54  * These notices must be retained in any copies of any part of this
55  * documentation and/or software.
56  */
57 
58 //----------------------------------------------------------------------
59 
66 //----------------------------------------------------------------------
67 // include protection
68 #ifndef MD5_H
69 #define MD5_H
70 
71 //----------------------------------------------------------------------
72 // typedefs
73 typedef void *POINTER;
74 
75 //----------------------------------------------------------------------
76 
84 class MD5
85 {
86  private:
92  void MD5Transform(unsigned long int state[4], unsigned char block[64]);
93 
101  void
102  Encode(unsigned char *output, unsigned long int *input, unsigned int len);
103 
111  void
112  Decode(unsigned long int *output, unsigned char *input, unsigned int len);
113 
121  void MD5_memcpy(POINTER output, POINTER input, unsigned int len);
122 
131  void MD5_memset(POINTER output, int value, unsigned int len);
132 
134  unsigned long int state[4];
135 
137  unsigned long int count[2];
138 
140  unsigned char buffer[64];
141 
142  public:
147  void Reset();
148 
156  void Input(unsigned char *input, unsigned int inputLen);
157 
165  void Result(unsigned char digest[16]);
166 
170  MD5()
171  {
172  Reset();
173  };
174 };
175 
176 //----------------------------------------------------------------------
177 // End of include protection
178 #endif
179 
180 //----------------------------------------------------------------------
181 // EOF
void Input(unsigned char *input, unsigned int inputLen)
Block update operation. Continues an md5 message-digest operation, processing another message block...
Definition: md5.cc:326
void Decode(unsigned long int *output, unsigned char *input, unsigned int len)
Decodes input data into output.
Definition: md5.cc:266
void Encode(unsigned char *output, unsigned long int *input, unsigned int len)
Encodes input data.
Definition: md5.cc:245
This class represents the implementation of the md5 message digest algorithm.
void MD5Transform(unsigned long int state[4], unsigned char block[64])
Basic transformation. Transforms state based on block.
Definition: md5.cc:147
void MD5_memcpy(POINTER output, POINTER input, unsigned int len)
internal memory management
Definition: md5.cc:285
void MD5_memset(POINTER output, int value, unsigned int len)
internal memory management
Definition: md5.cc:298
void Result(unsigned char digest[16])
Finalization ends the md5 message-digest operation, writing the the message digest and zeroizing the ...
Definition: md5.cc:368
void Reset()
Initialization begins an operation, writing a new context.
Definition: md5.cc:310