author | Mikael Berthe <mikael@lilotux.net> |
Thu, 05 Nov 2015 21:47:40 +0100 | |
changeset 672 | 71f60c55efb3 |
parent 518 | cdd6a0c5b439 |
child 681 | e3370fbe0a25 |
permissions | -rw-r--r-- |
1 | 1 |
/*- |
2 |
* Copyright (c) 2001, 2002 Allan Saddi <allan@saddi.com> |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* Redistribution and use in source and binary forms, with or without |
|
6 |
* modification, are permitted provided that the following conditions |
|
7 |
* are met: |
|
8 |
* 1. Redistributions of source code must retain the above copyright |
|
9 |
* notice, this list of conditions and the following disclaimer. |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer in the |
|
12 |
* documentation and/or other materials provided with the distribution. |
|
13 |
* |
|
14 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
|
15 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
16 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
17 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
|
18 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
19 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
20 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
21 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
22 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
23 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
24 |
* SUCH DAMAGE. |
|
25 |
* |
|
26 |
*/ |
|
27 |
||
28 |
/* |
|
29 |
* Define WORDS_BIGENDIAN if compiling on a big-endian architecture. |
|
30 |
* |
|
31 |
* Define SHA1_TEST to test the implementation using the NIST's |
|
32 |
* sample messages. The output should be: |
|
33 |
* |
|
34 |
* a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d |
|
35 |
* 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1 |
|
36 |
* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f |
|
37 |
*/ |
|
38 |
||
39 |
#ifdef HAVE_CONFIG_H |
|
40 |
#include <config.h> |
|
41 |
#endif /* HAVE_CONFIG_H */ |
|
42 |
||
43 |
#include <string.h> |
|
44 |
#include <stdio.h> |
|
45 |
#include <glib.h> |
|
46 |
||
47 |
#include "lm-sha.h" |
|
48 |
||
49 |
#define SHA1_HASH_SIZE 20 |
|
50 |
||
51 |
/* Hash size in 32-bit words */ |
|
52 |
#define SHA1_HASH_WORDS 5 |
|
53 |
||
54 |
struct _SHA1Context { |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
55 |
guint64 totalLength; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
56 |
guint32 hash[SHA1_HASH_WORDS]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
57 |
guint32 bufferLength; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
58 |
union { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
59 |
guint32 words[16]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
60 |
guint8 bytes[64]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
61 |
} buffer; |
1 | 62 |
}; |
63 |
||
64 |
typedef struct _SHA1Context SHA1Context; |
|
65 |
||
66 |
#ifdef __cplusplus |
|
67 |
extern "C" { |
|
68 |
#endif |
|
69 |
||
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
70 |
static void SHA1Init (SHA1Context *sc); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
71 |
static void SHA1Update (SHA1Context *sc, const void *udata, guint32 len); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
72 |
static void SHA1Final (SHA1Context *sc, guint8 hash[SHA1_HASH_SIZE]); |
1 | 73 |
|
74 |
#ifdef __cplusplus |
|
75 |
} |
|
76 |
#endif |
|
77 |
||
78 |
#ifndef lint |
|
79 |
static const char rcsid[] = |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
80 |
"$Id$"; |
1 | 81 |
#endif /* !lint */ |
82 |
||
83 |
#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) |
|
84 |
#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) |
|
85 |
||
86 |
#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
|
87 |
#define F_20_39(x, y, z) ((x) ^ (y) ^ (z)) |
|
88 |
#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) |
|
89 |
#define F_60_79(x, y, z) ((x) ^ (y) ^ (z)) |
|
90 |
||
91 |
#define DO_ROUND(F, K) { \ |
|
92 |
temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \ |
|
93 |
e = d; \ |
|
94 |
d = c; \ |
|
95 |
c = ROTL(b, 30); \ |
|
96 |
b = a; \ |
|
97 |
a = temp; \ |
|
98 |
} |
|
99 |
||
100 |
#define K_0_19 0x5a827999L |
|
101 |
#define K_20_39 0x6ed9eba1L |
|
102 |
#define K_40_59 0x8f1bbcdcL |
|
103 |
#define K_60_79 0xca62c1d6L |
|
104 |
||
105 |
#ifndef RUNTIME_ENDIAN |
|
106 |
||
107 |
#ifdef WORDS_BIGENDIAN |
|
108 |
||
109 |
#define BYTESWAP(x) (x) |
|
110 |
#define BYTESWAP64(x) (x) |
|
111 |
||
112 |
#else /* WORDS_BIGENDIAN */ |
|
113 |
||
114 |
#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
115 |
(ROTL((x), 8) & 0x00ff00ffL)) |
1 | 116 |
#define BYTESWAP64(x) _byteswap64(x) |
117 |
||
118 |
static inline guint64 _byteswap64(guint64 x) |
|
119 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
120 |
guint32 a = x >> 32; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
121 |
guint32 b = (guint32) x; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
122 |
return ((guint64) BYTESWAP(b) << 32) | (guint64) BYTESWAP(a); |
1 | 123 |
} |
124 |
||
125 |
#endif /* WORDS_BIGENDIAN */ |
|
126 |
||
127 |
#else /* !RUNTIME_ENDIAN */ |
|
128 |
||
129 |
static int littleEndian; |
|
130 |
||
131 |
#define BYTESWAP(x) _byteswap(x) |
|
132 |
#define BYTESWAP64(x) _byteswap64(x) |
|
133 |
||
134 |
#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
135 |
(ROTL((x), 8) & 0x00ff00ffL)) |
1 | 136 |
#define _BYTESWAP64(x) __byteswap64(x) |
137 |
||
138 |
static inline guint64 __byteswap64(guint64 x) |
|
139 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
140 |
guint32 a = x >> 32; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
141 |
guint32 b = (guint32) x; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
142 |
return ((guint64) _BYTESWAP(b) << 32) | (guint64) _BYTESWAP(a); |
1 | 143 |
} |
144 |
||
145 |
static inline guint32 _byteswap(guint32 x) |
|
146 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
147 |
if (!littleEndian) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
148 |
return x; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
149 |
else |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
150 |
return _BYTESWAP(x); |
1 | 151 |
} |
152 |
||
153 |
static inline guint64 _byteswap64(guint64 x) |
|
154 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
155 |
if (!littleEndian) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
156 |
return x; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
157 |
else |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
158 |
return _BYTESWAP64(x); |
1 | 159 |
} |
160 |
||
161 |
static inline void setEndian(void) |
|
162 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
163 |
union { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
164 |
guint32 w; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
165 |
guint8 b[4]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
166 |
} endian; |
1 | 167 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
168 |
endian.w = 1L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
169 |
littleEndian = endian.b[0] != 0; |
1 | 170 |
} |
171 |
||
172 |
#endif /* !RUNTIME_ENDIAN */ |
|
173 |
||
174 |
static const guint8 padding[64] = { |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
175 |
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
176 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
177 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
178 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
179 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
180 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
181 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
182 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
1 | 183 |
}; |
184 |
||
162
16d29898f97b
2006-08-03 Richard Hult <richard@imendio.com>
hallski <hallski>
parents:
140
diff
changeset
|
185 |
static void |
1 | 186 |
SHA1Init (SHA1Context *sc) |
187 |
{ |
|
188 |
#ifdef RUNTIME_ENDIAN |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
189 |
setEndian (); |
1 | 190 |
#endif /* RUNTIME_ENDIAN */ |
191 |
||
140
103227122f45
2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
86
diff
changeset
|
192 |
#ifdef G_OS_WIN32 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
193 |
sc->totalLength = 0L; |
9
2e14e3ab411b
2003-06-24 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
1
diff
changeset
|
194 |
#else |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
195 |
sc->totalLength = 0LL; |
9
2e14e3ab411b
2003-06-24 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
1
diff
changeset
|
196 |
#endif |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
197 |
sc->hash[0] = 0x67452301L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
198 |
sc->hash[1] = 0xefcdab89L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
199 |
sc->hash[2] = 0x98badcfeL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
200 |
sc->hash[3] = 0x10325476L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
201 |
sc->hash[4] = 0xc3d2e1f0L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
202 |
sc->bufferLength = 0L; |
1 | 203 |
} |
204 |
||
205 |
static void |
|
206 |
burnStack (int size) |
|
207 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
208 |
char buf[128]; |
1 | 209 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
210 |
memset (buf, 0, sizeof (buf)); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
211 |
size -= sizeof (buf); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
212 |
if (size > 0) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
213 |
burnStack (size); |
1 | 214 |
} |
215 |
||
216 |
static void |
|
217 |
SHA1Guts (SHA1Context *sc, const guint32 *cbuf) |
|
218 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
219 |
guint32 buf[80]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
220 |
guint32 *W, *W3, *W8, *W14, *W16; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
221 |
guint32 a, b, c, d, e, temp; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
222 |
int i; |
1 | 223 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
224 |
W = buf; |
1 | 225 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
226 |
for (i = 15; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
227 |
*(W++) = BYTESWAP(*cbuf); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
228 |
cbuf++; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
229 |
} |
1 | 230 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
231 |
W16 = &buf[0]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
232 |
W14 = &buf[2]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
233 |
W8 = &buf[8]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
234 |
W3 = &buf[13]; |
1 | 235 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
236 |
for (i = 63; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
237 |
*W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
238 |
*W = ROTL(*W, 1); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
239 |
W++; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
240 |
} |
1 | 241 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
242 |
a = sc->hash[0]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
243 |
b = sc->hash[1]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
244 |
c = sc->hash[2]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
245 |
d = sc->hash[3]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
246 |
e = sc->hash[4]; |
1 | 247 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
248 |
W = buf; |
1 | 249 |
|
250 |
#ifndef SHA1_UNROLL |
|
251 |
#define SHA1_UNROLL 20 |
|
252 |
#endif /* !SHA1_UNROLL */ |
|
253 |
||
254 |
#if SHA1_UNROLL == 1 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
255 |
for (i = 19; i >= 0; i--) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
256 |
DO_ROUND(F_0_19, K_0_19); |
1 | 257 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
258 |
for (i = 19; i >= 0; i--) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
259 |
DO_ROUND(F_20_39, K_20_39); |
1 | 260 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
261 |
for (i = 19; i >= 0; i--) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
262 |
DO_ROUND(F_40_59, K_40_59); |
1 | 263 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
264 |
for (i = 19; i >= 0; i--) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
265 |
DO_ROUND(F_60_79, K_60_79); |
1 | 266 |
#elif SHA1_UNROLL == 2 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
267 |
for (i = 9; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
268 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
269 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
270 |
} |
1 | 271 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
272 |
for (i = 9; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
273 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
274 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
275 |
} |
1 | 276 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
277 |
for (i = 9; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
278 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
279 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
280 |
} |
1 | 281 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
282 |
for (i = 9; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
283 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
284 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
285 |
} |
1 | 286 |
#elif SHA1_UNROLL == 4 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
287 |
for (i = 4; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
288 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
289 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
290 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
291 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
292 |
} |
1 | 293 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
294 |
for (i = 4; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
295 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
296 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
297 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
298 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
299 |
} |
1 | 300 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
301 |
for (i = 4; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
302 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
303 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
304 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
305 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
306 |
} |
1 | 307 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
308 |
for (i = 4; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
309 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
310 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
311 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
312 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
313 |
} |
1 | 314 |
#elif SHA1_UNROLL == 5 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
315 |
for (i = 3; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
316 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
317 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
318 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
319 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
320 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
321 |
} |
1 | 322 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
323 |
for (i = 3; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
324 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
325 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
326 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
327 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
328 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
329 |
} |
1 | 330 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
331 |
for (i = 3; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
332 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
333 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
334 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
335 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
336 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
337 |
} |
1 | 338 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
339 |
for (i = 3; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
340 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
341 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
342 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
343 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
344 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
345 |
} |
1 | 346 |
#elif SHA1_UNROLL == 10 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
347 |
for (i = 1; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
348 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
349 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
350 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
351 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
352 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
353 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
354 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
355 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
356 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
357 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
358 |
} |
1 | 359 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
360 |
for (i = 1; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
361 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
362 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
363 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
364 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
365 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
366 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
367 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
368 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
369 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
370 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
371 |
} |
1 | 372 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
373 |
for (i = 1; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
374 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
375 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
376 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
377 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
378 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
379 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
380 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
381 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
382 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
383 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
384 |
} |
1 | 385 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
386 |
for (i = 1; i >= 0; i--) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
387 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
388 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
389 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
390 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
391 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
392 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
393 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
394 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
395 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
396 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
397 |
} |
1 | 398 |
#elif SHA1_UNROLL == 20 |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
399 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
400 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
401 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
402 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
403 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
404 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
405 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
406 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
407 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
408 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
409 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
410 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
411 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
412 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
413 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
414 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
415 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
416 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
417 |
DO_ROUND(F_0_19, K_0_19); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
418 |
DO_ROUND(F_0_19, K_0_19); |
1 | 419 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
420 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
421 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
422 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
423 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
424 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
425 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
426 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
427 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
428 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
429 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
430 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
431 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
432 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
433 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
434 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
435 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
436 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
437 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
438 |
DO_ROUND(F_20_39, K_20_39); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
439 |
DO_ROUND(F_20_39, K_20_39); |
1 | 440 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
441 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
442 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
443 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
444 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
445 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
446 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
447 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
448 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
449 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
450 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
451 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
452 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
453 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
454 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
455 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
456 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
457 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
458 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
459 |
DO_ROUND(F_40_59, K_40_59); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
460 |
DO_ROUND(F_40_59, K_40_59); |
1 | 461 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
462 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
463 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
464 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
465 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
466 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
467 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
468 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
469 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
470 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
471 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
472 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
473 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
474 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
475 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
476 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
477 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
478 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
479 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
480 |
DO_ROUND(F_60_79, K_60_79); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
481 |
DO_ROUND(F_60_79, K_60_79); |
1 | 482 |
#else /* SHA1_UNROLL */ |
483 |
#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20! |
|
484 |
#endif |
|
485 |
||
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
486 |
sc->hash[0] += a; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
487 |
sc->hash[1] += b; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
488 |
sc->hash[2] += c; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
489 |
sc->hash[3] += d; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
490 |
sc->hash[4] += e; |
1 | 491 |
} |
492 |
||
162
16d29898f97b
2006-08-03 Richard Hult <richard@imendio.com>
hallski <hallski>
parents:
140
diff
changeset
|
493 |
static void |
84
7ae7b690aa89
2004-05-28 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
9
diff
changeset
|
494 |
SHA1Update (SHA1Context *sc, const void *udata, guint32 len) |
1 | 495 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
496 |
guint32 bufferBytesLeft; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
497 |
guint32 bytesToCopy; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
498 |
int needBurn = 0; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
499 |
guint8 *data = (guint8 *)udata; |
1 | 500 |
|
501 |
#ifdef SHA1_FAST_COPY |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
502 |
if (sc->bufferLength) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
503 |
bufferBytesLeft = 64L - sc->bufferLength; |
1 | 504 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
505 |
bytesToCopy = bufferBytesLeft; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
506 |
if (bytesToCopy > len) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
507 |
bytesToCopy = len; |
1 | 508 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
509 |
memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); |
1 | 510 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
511 |
sc->totalLength += bytesToCopy * 8L; |
1 | 512 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
513 |
sc->bufferLength += bytesToCopy; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
514 |
data += bytesToCopy; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
515 |
len -= bytesToCopy; |
1 | 516 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
517 |
if (sc->bufferLength == 64L) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
518 |
SHA1Guts (sc, sc->buffer.words); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
519 |
needBurn = 1; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
520 |
sc->bufferLength = 0L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
521 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
522 |
} |
1 | 523 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
524 |
while (len > 63) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
525 |
sc->totalLength += 512L; |
1 | 526 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
527 |
SHA1Guts (sc, data); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
528 |
needBurn = 1; |
1 | 529 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
530 |
data += 64L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
531 |
len -= 64L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
532 |
} |
1 | 533 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
534 |
if (len) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
535 |
memcpy (&sc->buffer.bytes[sc->bufferLength], data, len); |
1 | 536 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
537 |
sc->totalLength += len * 8L; |
1 | 538 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
539 |
sc->bufferLength += len; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
540 |
} |
1 | 541 |
#else /* SHA1_FAST_COPY */ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
542 |
while (len) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
543 |
bufferBytesLeft = 64L - sc->bufferLength; |
1 | 544 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
545 |
bytesToCopy = bufferBytesLeft; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
546 |
if (bytesToCopy > len) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
547 |
bytesToCopy = len; |
1 | 548 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
549 |
memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); |
1 | 550 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
551 |
sc->totalLength += bytesToCopy * 8L; |
1 | 552 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
553 |
sc->bufferLength += bytesToCopy; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
554 |
data += bytesToCopy; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
555 |
len -= bytesToCopy; |
1 | 556 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
557 |
if (sc->bufferLength == 64L) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
558 |
SHA1Guts (sc, sc->buffer.words); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
559 |
needBurn = 1; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
560 |
sc->bufferLength = 0L; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
561 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
562 |
} |
1 | 563 |
#endif /* SHA1_FAST_COPY */ |
564 |
||
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
565 |
if (needBurn) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
566 |
burnStack (sizeof (guint32[86]) + sizeof (guint32 *[5]) + sizeof (int)); |
1 | 567 |
} |
568 |
||
162
16d29898f97b
2006-08-03 Richard Hult <richard@imendio.com>
hallski <hallski>
parents:
140
diff
changeset
|
569 |
static void |
1 | 570 |
SHA1Final (SHA1Context *sc, guint8 hash[SHA1_HASH_SIZE]) |
571 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
572 |
guint32 bytesToPad; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
573 |
guint64 lengthPad; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
574 |
int i; |
1 | 575 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
576 |
bytesToPad = 120L - sc->bufferLength; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
577 |
if (bytesToPad > 64L) |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
578 |
bytesToPad -= 64L; |
1 | 579 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
580 |
lengthPad = BYTESWAP64(sc->totalLength); |
1 | 581 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
582 |
SHA1Update (sc, padding, bytesToPad); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
583 |
SHA1Update (sc, &lengthPad, 8L); |
1 | 584 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
585 |
if (hash) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
586 |
for (i = 0; i < SHA1_HASH_WORDS; i++) { |
1 | 587 |
#ifdef SHA1_FAST_COPY |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
588 |
*((guint32 *) hash) = BYTESWAP(sc->hash[i]); |
1 | 589 |
#else /* SHA1_FAST_COPY */ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
590 |
hash[0] = (guint8) (sc->hash[i] >> 24); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
591 |
hash[1] = (guint8) (sc->hash[i] >> 16); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
592 |
hash[2] = (guint8) (sc->hash[i] >> 8); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
593 |
hash[3] = (guint8) sc->hash[i]; |
1 | 594 |
#endif /* SHA1_FAST_COPY */ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
595 |
hash += 4; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
596 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
597 |
} |
1 | 598 |
} |
599 |
||
497
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
600 |
/** |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
601 |
* lm_sha_hash: |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
602 |
* @str: the input string |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
603 |
* |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
604 |
* Computes the SHA1 checksum of @str and prints it in text mode. |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
605 |
* |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
606 |
* Return value: A newly allocated string. |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
607 |
**/ |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
608 |
gchar * |
1 | 609 |
lm_sha_hash (const gchar *str) |
610 |
{ |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
611 |
gchar *ret_val; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
612 |
SHA1Context ctx; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
613 |
guint8 hash[SHA1_HASH_SIZE]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
614 |
gchar *ch; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
615 |
guint i; |
497
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
616 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
617 |
ret_val = g_malloc (SHA1_HASH_SIZE*2 + 1); |
1 | 618 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
619 |
SHA1Init (&ctx); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
620 |
SHA1Update (&ctx, str, strlen (str)); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
621 |
SHA1Final (&ctx, hash); |
497
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
622 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
623 |
ch = ret_val; |
1 | 624 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
625 |
for (i = 0; i < SHA1_HASH_SIZE; ++i) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
626 |
g_snprintf (ch, 3, "%02x", hash[i]); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
627 |
ch += 2; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
628 |
} |
1 | 629 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
497
diff
changeset
|
630 |
return ret_val; |
1 | 631 |
} |