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

Contents of /projs/trunk/shared_source/c_datd/esrg_sha512.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (show annotations) (download)
Sat Oct 29 01:53:01 2016 UTC (6 years, 3 months ago) by dashley
File MIME type: text/plain
File size: 5180 byte(s)
License and property (keyword) changes.
1 //$Header$
2 //-------------------------------------------------------------------------------------------------
3 //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 //-------------------------------------------------------------------------------------------------
6 //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 //
16 //The above copyright notice and this permission notice shall be included in all
17 //copies or substantial portions of the Software.
18 //
19 //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 //-------------------------------------------------------------------------------------------------
27 #ifndef ESRG_SHA512_H_INCLUDED
28 #define ESRG_SHA512_H_INCLUDED
29
30 #ifdef MODULE_ESRG_SHA512
31 #define DECMOD_ESRG_SHA512
32 #else
33 #define DECMOD_ESRG_SHA512 extern
34 #endif
35
36 //Fundamental state for forming
37 //SHA-512s. Conceptually private to this module.
38 struct ESRG_SHA512_Sha512StateStruct
39 {
40 unsigned __int64 H0, H1, H2, H3, H4, H5, H6, H7;
41 //Directly from FIPS 180-3. In retrospect, this might have
42 //been better implemented as an array.
43 unsigned __int64 bit_count;
44 //The count of bits processed thus far. The algorithm here
45 //works in bytes, not bits, so this is advanced by 8 on
46 //each byte processed. FIPS 180-3 calls for processing
47 //messages up to length 2^128, but for obvious reasons
48 //we don't do that. 2^64-1 bits is in excess of 2^61-1
49 //bytes, or somewhere around 2,000 terabytes. This
50 //isn't a practical limit with current computer technology.
51 unsigned __int64 M[16];
52 //These are the words corresponding to the chars (below). We don't
53 //dare union to extract them because of big-endian/little-endian concerns.
54 //The "M" nomenclature is from FIPS 180-3. At the time the
55 //SHA-512 rounds are done, the chars (below) are converted to words
56 //(this field) so that the rounds can be done using the words.
57 unsigned char buf[128];
58 //We can't proceed to execute a round unless we have the
59 //full 1024 bits = 16 words = 128 bytes of data. We must
60 //buffer it because we can't count on being called with data
61 //blocks that are a multiple of 128. We may have data hanging
62 //around between calls. We fill up this buffer from the low
63 //end, i.e. [0], then [1], then [2], etc.
64 };
65
66
67 //Result structure, used to hold result. Caller is allowed to
68 //pick it apart.
69 struct ESRG_SHA512_Sha512ResultStruct
70 {
71 unsigned __int64 sha512_words[8];
72 //Hash in binary form, as the 64-bit integers.
73 char sha512_chars[129];
74 //Zero terminated string containing MD5 formed.
75 };
76
77
78 //Initializes the SHA512 calculation structure.
79 DECMOD_ESRG_SHA512
80 void ESRG_SHA512_Sha512StateStructOpen(struct ESRG_SHA512_Sha512StateStruct *arg);
81
82 //Adds data to it. Zero length is OK.
83 DECMOD_ESRG_SHA512
84 void ESRG_SHA512_Sha512StateStructAddData(struct ESRG_SHA512_Sha512StateStruct *arg,
85 void *data,
86 unsigned len);
87
88 //Closes the structure and returns the SHA512. This is destructive--one cannot
89 //continue adding characters. All characters returned are lower-case.
90 DECMOD_ESRG_SHA512
91 void ESRG_SHA512_Sha512StateStructClose(struct ESRG_SHA512_Sha512StateStruct *state,
92 struct ESRG_SHA512_Sha512ResultStruct *result);
93
94 //Returns version control information.
95 DECMOD_ESRG_SHA512 const char *ESRG_SHA512_cvcinfo(void);
96 DECMOD_ESRG_SHA512 const char *ESRG_SHA512_hvcinfo(void);
97
98 //Definition of the version of the H file, used for providing version control
99 //information to external callers.
100 #define ESRG_SHA512_H_VERSION ("$Header$")
101
102 #endif
103
104 //End of esrg_sha512.h.

Properties

Name Value
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25