/[dtapublic]/projs/trunk/shared_source/c_datd/esrg_md5.h
ViewVC logotype

Diff of /projs/trunk/shared_source/c_datd/esrg_md5.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.70  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25