1 |
dashley |
56 |
//$Header$
|
2 |
dashley |
25 |
//-------------------------------------------------------------------------------------------------
|
3 |
dashley |
56 |
//This file is part of "David T. Ashley's Shared Source Code", a set of shared components
|
4 |
|
|
//integrated into many of David T. Ashley's projects.
|
5 |
dashley |
25 |
//-------------------------------------------------------------------------------------------------
|
6 |
dashley |
56 |
//This source code and any program in which it is compiled/used is provided under the MIT License,
|
7 |
|
|
//reproduced below.
|
8 |
|
|
//-------------------------------------------------------------------------------------------------
|
9 |
|
|
//Permission is hereby granted, free of charge, to any person obtaining a copy of
|
10 |
|
|
//this software and associated documentation files(the "Software"), to deal in the
|
11 |
|
|
//Software without restriction, including without limitation the rights to use,
|
12 |
|
|
//copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
|
13 |
|
|
//Software, and to permit persons to whom the Software is furnished to do so,
|
14 |
|
|
//subject to the following conditions :
|
15 |
dashley |
25 |
//
|
16 |
dashley |
56 |
//The above copyright notice and this permission notice shall be included in all
|
17 |
|
|
//copies or substantial portions of the Software.
|
18 |
dashley |
25 |
//
|
19 |
dashley |
56 |
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20 |
|
|
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21 |
|
|
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
22 |
|
|
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23 |
|
|
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24 |
|
|
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
25 |
|
|
//SOFTWARE.
|
26 |
dashley |
25 |
//-------------------------------------------------------------------------------------------------
|
27 |
|
|
#ifndef ESRG_MD5_H_INCLUDED
|
28 |
|
|
#define ESRG_MD5_H_INCLUDED
|
29 |
|
|
|
30 |
|
|
#ifdef MODULE_ESRG_MD5
|
31 |
|
|
#define DECMOD_ESRG_MD5
|
32 |
|
|
#else
|
33 |
|
|
#define DECMOD_ESRG_MD5 extern
|
34 |
|
|
#endif
|
35 |
|
|
|
36 |
|
|
//Fundamental state (or RFC 1321 calls it context) for forming
|
37 |
|
|
//MD5s. Conceptually private to this module.
|
38 |
|
|
struct ESRG_MD5_Md5StateStruct
|
39 |
|
|
{
|
40 |
|
|
unsigned A, B, C, D;
|
41 |
|
|
//Directly from RFC 1321.
|
42 |
|
|
unsigned __int64 bit_count;
|
43 |
|
|
//The count of bits processed thus far. The algorithm here
|
44 |
|
|
//works in bytes, not bits, so this is advanced by 8 on
|
45 |
|
|
//each byte processed.
|
46 |
|
|
unsigned X[16];
|
47 |
|
|
//These are the words corresponding to the chars. We don't
|
48 |
|
|
//dare union them because of big-endian/little-endian concerns.
|
49 |
|
|
//The name "X" comes directly from RFC 1321 nomenclature.
|
50 |
|
|
unsigned char buf[64];
|
51 |
|
|
//We can't proceed to execute a round unless we have the
|
52 |
|
|
//full 512 bits = 16 words = 64 bytes of data. We must
|
53 |
|
|
//buffer it because we can't count on being called with data
|
54 |
|
|
//blocks that are a multiple of 64. We may have data hanging
|
55 |
|
|
//around between calls. We fill up this buffer from the low
|
56 |
|
|
//end, i.e. [0], then [1], then [2], etc.
|
57 |
|
|
};
|
58 |
|
|
|
59 |
|
|
//Result structure, used to hold result. Caller is allowed to
|
60 |
|
|
//pick it apart.
|
61 |
|
|
struct ESRG_MD5_Md5ResultStruct
|
62 |
|
|
{
|
63 |
|
|
unsigned md5_words[4];
|
64 |
|
|
char md5_chars[33];
|
65 |
|
|
//Zero terminated string containing MD5 formed.
|
66 |
|
|
};
|
67 |
|
|
|
68 |
|
|
//Initializes the MD5 calculation structure.
|
69 |
|
|
DECMOD_ESRG_MD5
|
70 |
|
|
void ESRG_MD5_Md5StateStructOpen(struct ESRG_MD5_Md5StateStruct *arg);
|
71 |
|
|
|
72 |
|
|
//Adds data to it. Zero length is OK.
|
73 |
|
|
DECMOD_ESRG_MD5
|
74 |
|
|
void ESRG_MD5_Md5StateStructAddData(struct ESRG_MD5_Md5StateStruct *arg,
|
75 |
|
|
void *data,
|
76 |
|
|
unsigned len);
|
77 |
|
|
|
78 |
|
|
//Closes the structure and returns the MD5. This is destructive--one cannot
|
79 |
|
|
//continue adding characters. All characters returned are lower-case.
|
80 |
|
|
DECMOD_ESRG_MD5
|
81 |
|
|
void ESRG_MD5_Md5StateStructClose(struct ESRG_MD5_Md5StateStruct *state,
|
82 |
|
|
struct ESRG_MD5_Md5ResultStruct *result);
|
83 |
|
|
|
84 |
|
|
//Returns version control information.
|
85 |
|
|
DECMOD_ESRG_MD5 const char *ESRG_MD5_cvcinfo(void);
|
86 |
|
|
DECMOD_ESRG_MD5 const char *ESRG_MD5_hvcinfo(void);
|
87 |
|
|
|
88 |
|
|
//Definition of the version of the H file, used for providing version control
|
89 |
|
|
//information to external callers.
|
90 |
dashley |
56 |
#define ESRG_MD5_H_VERSION ("$Header$")
|
91 |
dashley |
25 |
|
92 |
|
|
#endif
|
93 |
|
|
|
94 |
dashley |
56 |
//End of esrg_md5.h.
|