1 |
//----------------------------------------------------------------------------------------------------
|
2 |
//$Header: /home/dashley/cvsrep/e3ft_gpl01/e3ft_gpl01/dtaipubs/cron/2010/blackjack_201010/source/bjcceval/sha512.h,v 1.7 2012/03/30 00:20:15 dashley Exp $
|
3 |
//----------------------------------------------------------------------------------------------------
|
4 |
//Copyright (C) 2012, David T. Ashley.
|
5 |
//
|
6 |
//This file is part of BJCCEVAL, a program that evaluates by simulation
|
7 |
//the best basic strategy, card-counting, and other playing strategies
|
8 |
//for several variants of the game of Blackjack.
|
9 |
//
|
10 |
//BJCCEVAL is free software: you can redistribute it and/or modify
|
11 |
//it under the terms of the GNU General Public License as published by
|
12 |
//the Free Software Foundation, either version 3 of the License, or
|
13 |
//(at your option) any later version.
|
14 |
//
|
15 |
//BJCCEVAL is distributed in the hope that it will be useful,
|
16 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
//GNU General Public License for more details.
|
19 |
//
|
20 |
//You should have received a copy of the GNU General Public License
|
21 |
//along with this program. If not, see <http://www.gnu.org/licenses/>.
|
22 |
//(A copy of the GNU General Public License, Version 3 is provided in
|
23 |
//the file "COPYING" distributed with BJCCEVAL.)
|
24 |
//
|
25 |
//David T. Ashley can be contacted at DASHLEY@GMAIL.COM and/or at
|
26 |
//P.O. Box 918, Marshall MI 49068.
|
27 |
//----------------------------------------------------------------------------------------------------
|
28 |
#ifndef SHA512_H_INCLUDED
|
29 |
#define SHA512_H_INCLUDED
|
30 |
|
31 |
#ifdef MODULE_SHA512
|
32 |
#define DECMOD_SHA512
|
33 |
#else
|
34 |
#define DECMOD_SHA512 extern
|
35 |
#endif
|
36 |
|
37 |
|
38 |
//Fundamental state for forming SHA-512s. Conceptually private to this module.
|
39 |
//
|
40 |
struct SHA512_Sha512StateStruct
|
41 |
{
|
42 |
unsigned long long H0, H1, H2, H3, H4, H5, H6, H7;
|
43 |
//Directly from FIPS 180-3. In retrospect, this might have
|
44 |
//been better implemented as an array.
|
45 |
unsigned long long bit_count;
|
46 |
//The count of bits processed thus far. The algorithm here
|
47 |
//works in bytes, not bits, so this is advanced by 8 on
|
48 |
//each byte processed. FIPS 180-3 calls for processing
|
49 |
//messages up to length 2^128, but for obvious reasons
|
50 |
//we don't do that. 2^64-1 bits is in excess of 2^61-1
|
51 |
//bytes, or somewhere around 2,000 terabytes. This
|
52 |
//isn't a practical limit with current computer technology.
|
53 |
unsigned long long M[16];
|
54 |
//These are the words corresponding to the chars (below). We don't
|
55 |
//dare union to extract them because of big-endian/little-endian concerns.
|
56 |
//The "M" nomenclature is from FIPS 180-3. At the time the
|
57 |
//SHA-512 rounds are done, the chars (below) are converted to words
|
58 |
//(this field) so that the rounds can be done using the words.
|
59 |
unsigned char buf[128];
|
60 |
//We can't proceed to execute a round unless we have the
|
61 |
//full 1024 bits = 16 words = 128 bytes of data. We must
|
62 |
//buffer it because we can't count on being called with data
|
63 |
//blocks that are a multiple of 128. We may have data hanging
|
64 |
//around between calls. We fill up this buffer from the low
|
65 |
//end, i.e. [0], then [1], then [2], etc.
|
66 |
};
|
67 |
|
68 |
|
69 |
//Result structure, used to hold result. Caller is allowed to
|
70 |
//pick it apart.
|
71 |
//
|
72 |
struct SHA512_Sha512ResultStruct
|
73 |
{
|
74 |
unsigned long long sha512_words[8];
|
75 |
//Hash in binary form, as the 64-bit integers.
|
76 |
char sha512_chars[129];
|
77 |
//Zero-terminated string containing character representation
|
78 |
//of SHA-512 formed.
|
79 |
};
|
80 |
|
81 |
|
82 |
DECMOD_SHA512 void SHA512_Sha512StateStructOpen(struct SHA512_Sha512StateStruct *arg);
|
83 |
DECMOD_SHA512 void SHA512_Sha512StateStructAddData(struct SHA512_Sha512StateStruct *arg,
|
84 |
void *pointer_in,
|
85 |
unsigned len);
|
86 |
DECMOD_SHA512 void SHA512_Sha512StateStructClose(struct SHA512_Sha512StateStruct *state,
|
87 |
struct SHA512_Sha512ResultStruct *result);
|
88 |
|
89 |
DECMOD_SHA512 const char *SHA512_Vcinfo_C(void);
|
90 |
DECMOD_SHA512 const char *SHA512_Vcinfo_H(void);
|
91 |
|
92 |
#define SHA512_VCINFO_H "$Revision: 1.7 $"
|
93 |
|
94 |
#if defined(P_TEST) || defined(P_TEST_SHA512)
|
95 |
DECMOD_SHA512 int SHA512_Test(void);
|
96 |
#endif
|
97 |
|
98 |
#endif
|
99 |
|
100 |
//----------------------------------------------------------------------------------------------------
|
101 |
//$Log: sha512.h,v $
|
102 |
//Revision 1.7 2012/03/30 00:20:15 dashley
|
103 |
//Edits.
|
104 |
//
|
105 |
//Revision 1.6 2012/03/29 23:44:01 dashley
|
106 |
//Edits.
|
107 |
//
|
108 |
//Revision 1.5 2012/03/15 23:38:08 dashley
|
109 |
//License text enhanced.
|
110 |
//
|
111 |
//Revision 1.4 2012/03/14 02:44:49 dashley
|
112 |
//Edits.
|
113 |
//
|
114 |
//Revision 1.3 2012/03/14 01:57:52 dashley
|
115 |
//Edits.
|
116 |
//
|
117 |
//Revision 1.2 2012/03/12 02:54:01 dashley
|
118 |
//Edits.
|
119 |
//
|
120 |
//Revision 1.1 2012/03/11 21:01:46 dashley
|
121 |
//Initial checkin.
|
122 |
//----------------------------------------------------------------------------------------------------
|
123 |
// End of $RCSfile: sha512.h,v $.
|
124 |
//----------------------------------------------------------------------------------------------------
|