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
73typedef void* POINTER;
74
75//----------------------------------------------------------------------
76
84class MD5 {
85 private:
91 void MD5Transform(unsigned long int state[4], unsigned char block[64]);
92
100 void Encode(unsigned char* output, unsigned long int* input, unsigned int len);
101
109 void Decode(unsigned long int* output, unsigned char* input, unsigned int len);
110
118 void MD5_memcpy(POINTER output, POINTER input, unsigned int len);
119
128 void MD5_memset(POINTER output, int value, unsigned int len);
129
131 unsigned long int state[4];
132
134 unsigned long int count[2];
135
137 unsigned char buffer[64];
138
139 public:
144 void Reset();
145
153 void Input(unsigned char* input, unsigned int inputLen);
154
162 void Result(unsigned char digest[16]);
163
167 MD5() {
168 Reset();
169 };
170};
171
172//----------------------------------------------------------------------
173// End of include protection
174#endif
175
176//----------------------------------------------------------------------
177// EOF
This class represents the implementation of the md5 message digest algorithm.
void MD5_memset(POINTER output, int value, unsigned int len)
internal memory management
Definition md5.cc:289
void MD5_memcpy(POINTER output, POINTER input, unsigned int len)
internal memory management
Definition md5.cc:277
void MD5Transform(unsigned long int state[4], unsigned char block[64])
Basic transformation. Transforms state based on block.
Definition md5.cc:147
void Reset()
Initialization begins an operation, writing a new context.
Definition md5.cc:300
void Decode(unsigned long int *output, unsigned char *input, unsigned int len)
Decodes input data into output.
Definition md5.cc:261
void Input(unsigned char *input, unsigned int inputLen)
Block update operation. Continues an md5 message-digest operation, processing another message block,...
Definition md5.cc:315
void Encode(unsigned char *output, unsigned long int *input, unsigned int len)
Encodes input data.
Definition md5.cc:243