author | Mikael Berthe <mikael@lilotux.net> |
Mon, 13 Jun 2022 18:01:27 +0200 | |
changeset 745 | 7785b42dd7bc |
parent 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 |
#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) |
|
79 |
#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n)))) |
|
80 |
||
81 |
#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
|
82 |
#define F_20_39(x, y, z) ((x) ^ (y) ^ (z)) |
|
83 |
#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) |
|
84 |
#define F_60_79(x, y, z) ((x) ^ (y) ^ (z)) |
|
85 |
||
86 |
#define DO_ROUND(F, K) { \ |
|
87 |
temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \ |
|
88 |
e = d; \ |
|
89 |
d = c; \ |
|
90 |
c = ROTL(b, 30); \ |
|
91 |
b = a; \ |
|
92 |
a = temp; \ |
|
93 |
} |
|
94 |
||
95 |
#define K_0_19 0x5a827999L |
|
96 |
#define K_20_39 0x6ed9eba1L |
|
97 |
#define K_40_59 0x8f1bbcdcL |
|
98 |
#define K_60_79 0xca62c1d6L |
|
99 |
||
100 |
#ifndef RUNTIME_ENDIAN |
|
101 |
||
102 |
#ifdef WORDS_BIGENDIAN |
|
103 |
||
104 |
#define BYTESWAP(x) (x) |
|
105 |
#define BYTESWAP64(x) (x) |
|
106 |
||
107 |
#else /* WORDS_BIGENDIAN */ |
|
108 |
||
109 |
#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
|
110 |
(ROTL((x), 8) & 0x00ff00ffL)) |
1 | 111 |
#define BYTESWAP64(x) _byteswap64(x) |
112 |
||
113 |
static inline guint64 _byteswap64(guint64 x) |
|
114 |
{ |
|
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 |
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
|
116 |
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
|
117 |
return ((guint64) BYTESWAP(b) << 32) | (guint64) BYTESWAP(a); |
1 | 118 |
} |
119 |
||
120 |
#endif /* WORDS_BIGENDIAN */ |
|
121 |
||
122 |
#else /* !RUNTIME_ENDIAN */ |
|
123 |
||
124 |
static int littleEndian; |
|
125 |
||
126 |
#define BYTESWAP(x) _byteswap(x) |
|
127 |
#define BYTESWAP64(x) _byteswap64(x) |
|
128 |
||
129 |
#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
|
130 |
(ROTL((x), 8) & 0x00ff00ffL)) |
1 | 131 |
#define _BYTESWAP64(x) __byteswap64(x) |
132 |
||
133 |
static inline guint64 __byteswap64(guint64 x) |
|
134 |
{ |
|
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 |
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
|
136 |
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
|
137 |
return ((guint64) _BYTESWAP(b) << 32) | (guint64) _BYTESWAP(a); |
1 | 138 |
} |
139 |
||
140 |
static inline guint32 _byteswap(guint32 x) |
|
141 |
{ |
|
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
|
142 |
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
|
143 |
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
|
144 |
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
|
145 |
return _BYTESWAP(x); |
1 | 146 |
} |
147 |
||
148 |
static inline guint64 _byteswap64(guint64 x) |
|
149 |
{ |
|
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
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
return _BYTESWAP64(x); |
1 | 154 |
} |
155 |
||
156 |
static inline void setEndian(void) |
|
157 |
{ |
|
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
|
158 |
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
|
159 |
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
|
160 |
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
|
161 |
} endian; |
1 | 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 |
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
|
164 |
littleEndian = endian.b[0] != 0; |
1 | 165 |
} |
166 |
||
167 |
#endif /* !RUNTIME_ENDIAN */ |
|
168 |
||
169 |
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
|
170 |
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
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
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
|
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 |
1 | 178 |
}; |
179 |
||
162
16d29898f97b
2006-08-03 Richard Hult <richard@imendio.com>
hallski <hallski>
parents:
140
diff
changeset
|
180 |
static void |
1 | 181 |
SHA1Init (SHA1Context *sc) |
182 |
{ |
|
183 |
#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
|
184 |
setEndian (); |
1 | 185 |
#endif /* RUNTIME_ENDIAN */ |
186 |
||
140
103227122f45
2006-04-19 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
86
diff
changeset
|
187 |
#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
|
188 |
sc->totalLength = 0L; |
9
2e14e3ab411b
2003-06-24 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
1
diff
changeset
|
189 |
#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
|
190 |
sc->totalLength = 0LL; |
9
2e14e3ab411b
2003-06-24 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
1
diff
changeset
|
191 |
#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
|
192 |
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
|
193 |
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
|
194 |
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
|
195 |
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
|
196 |
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
|
197 |
sc->bufferLength = 0L; |
1 | 198 |
} |
199 |
||
200 |
static void |
|
201 |
burnStack (int size) |
|
202 |
{ |
|
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
|
203 |
char buf[128]; |
1 | 204 |
|
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
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
burnStack (size); |
1 | 209 |
} |
210 |
||
211 |
static void |
|
212 |
SHA1Guts (SHA1Context *sc, const guint32 *cbuf) |
|
213 |
{ |
|
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
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
int i; |
1 | 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 |
W = buf; |
1 | 220 |
|
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
|
221 |
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
|
222 |
*(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
|
223 |
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
|
224 |
} |
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 |
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
|
227 |
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
|
228 |
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
|
229 |
W3 = &buf[13]; |
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 |
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
|
232 |
*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
|
233 |
*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
|
234 |
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
|
235 |
} |
1 | 236 |
|
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
|
237 |
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
|
238 |
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
|
239 |
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
|
240 |
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
|
241 |
e = sc->hash[4]; |
1 | 242 |
|
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
|
243 |
W = buf; |
1 | 244 |
|
245 |
#ifndef SHA1_UNROLL |
|
246 |
#define SHA1_UNROLL 20 |
|
247 |
#endif /* !SHA1_UNROLL */ |
|
248 |
||
249 |
#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
|
250 |
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
|
251 |
DO_ROUND(F_0_19, K_0_19); |
1 | 252 |
|
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
|
253 |
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
|
254 |
DO_ROUND(F_20_39, K_20_39); |
1 | 255 |
|
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
|
256 |
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
|
257 |
DO_ROUND(F_40_59, K_40_59); |
1 | 258 |
|
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
|
259 |
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
|
260 |
DO_ROUND(F_60_79, K_60_79); |
1 | 261 |
#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
|
262 |
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
|
263 |
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
|
264 |
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
|
265 |
} |
1 | 266 |
|
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_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
|
269 |
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
|
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_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
|
274 |
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
|
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_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
|
279 |
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
|
280 |
} |
1 | 281 |
#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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
} |
1 | 288 |
|
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
|
289 |
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
|
290 |
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
|
291 |
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
|
292 |
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
|
293 |
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
|
294 |
} |
1 | 295 |
|
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
|
296 |
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
|
297 |
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
|
298 |
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
|
299 |
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
|
300 |
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
|
301 |
} |
1 | 302 |
|
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
} |
1 | 309 |
#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
|
310 |
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
|
311 |
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
|
312 |
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
|
313 |
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
|
314 |
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
|
315 |
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
|
316 |
} |
1 | 317 |
|
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
|
318 |
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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
} |
1 | 325 |
|
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
|
326 |
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
|
327 |
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
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
} |
1 | 333 |
|
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
|
334 |
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
|
335 |
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
|
336 |
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
|
337 |
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
|
338 |
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
|
339 |
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
|
340 |
} |
1 | 341 |
#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
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
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
|
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 |
} |
1 | 354 |
|
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
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
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
|
360 |
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
|
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 |
} |
1 | 367 |
|
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
|
368 |
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
|
369 |
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
|
370 |
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
|
371 |
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
|
372 |
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
|
373 |
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
|
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 |
} |
1 | 380 |
|
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
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
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
|
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 |
} |
1 | 393 |
#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
|
394 |
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
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
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
|
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); |
1 | 414 |
|
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
|
415 |
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
|
416 |
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
|
417 |
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
|
418 |
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
|
419 |
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
|
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); |
1 | 435 |
|
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
|
436 |
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
|
437 |
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
|
438 |
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
|
439 |
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
|
440 |
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
|
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); |
1 | 456 |
|
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
|
457 |
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
|
458 |
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
|
459 |
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
|
460 |
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
|
461 |
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
|
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); |
1 | 477 |
#else /* SHA1_UNROLL */ |
478 |
#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20! |
|
479 |
#endif |
|
480 |
||
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
|
481 |
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
|
482 |
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
|
483 |
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
|
484 |
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
|
485 |
sc->hash[4] += e; |
1 | 486 |
} |
487 |
||
162
16d29898f97b
2006-08-03 Richard Hult <richard@imendio.com>
hallski <hallski>
parents:
140
diff
changeset
|
488 |
static void |
84
7ae7b690aa89
2004-05-28 Mikael Hallendal <micke@imendio.com>
hallski <hallski>
parents:
9
diff
changeset
|
489 |
SHA1Update (SHA1Context *sc, const void *udata, guint32 len) |
1 | 490 |
{ |
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
|
491 |
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
|
492 |
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
|
493 |
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
|
494 |
guint8 *data = (guint8 *)udata; |
1 | 495 |
|
496 |
#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
|
497 |
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
|
498 |
bufferBytesLeft = 64L - sc->bufferLength; |
1 | 499 |
|
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
|
500 |
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
|
501 |
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
|
502 |
bytesToCopy = len; |
1 | 503 |
|
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
|
504 |
memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); |
1 | 505 |
|
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
|
506 |
sc->totalLength += bytesToCopy * 8L; |
1 | 507 |
|
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
|
508 |
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
|
509 |
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
|
510 |
len -= bytesToCopy; |
1 | 511 |
|
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
|
512 |
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
|
513 |
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
|
514 |
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
|
515 |
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
|
516 |
} |
cdd6a0c5b439
Went 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 |
} |
1 | 518 |
|
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
|
519 |
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
|
520 |
sc->totalLength += 512L; |
1 | 521 |
|
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
|
522 |
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
|
523 |
needBurn = 1; |
1 | 524 |
|
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
|
525 |
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
|
526 |
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
|
527 |
} |
1 | 528 |
|
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
|
529 |
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
|
530 |
memcpy (&sc->buffer.bytes[sc->bufferLength], data, len); |
1 | 531 |
|
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
|
532 |
sc->totalLength += len * 8L; |
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 |
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
|
535 |
} |
1 | 536 |
#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
|
537 |
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
|
538 |
bufferBytesLeft = 64L - sc->bufferLength; |
1 | 539 |
|
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
|
540 |
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
|
541 |
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
|
542 |
bytesToCopy = len; |
1 | 543 |
|
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
|
544 |
memcpy (&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy); |
1 | 545 |
|
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
|
546 |
sc->totalLength += bytesToCopy * 8L; |
1 | 547 |
|
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
|
548 |
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
|
549 |
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
|
550 |
len -= bytesToCopy; |
1 | 551 |
|
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
|
552 |
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
|
553 |
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
|
554 |
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
|
555 |
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
|
556 |
} |
cdd6a0c5b439
Went 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 |
} |
1 | 558 |
#endif /* SHA1_FAST_COPY */ |
559 |
||
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
|
560 |
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
|
561 |
burnStack (sizeof (guint32[86]) + sizeof (guint32 *[5]) + sizeof (int)); |
1 | 562 |
} |
563 |
||
162
16d29898f97b
2006-08-03 Richard Hult <richard@imendio.com>
hallski <hallski>
parents:
140
diff
changeset
|
564 |
static void |
1 | 565 |
SHA1Final (SHA1Context *sc, guint8 hash[SHA1_HASH_SIZE]) |
566 |
{ |
|
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
|
567 |
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
|
568 |
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
|
569 |
int i; |
1 | 570 |
|
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
|
571 |
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
|
572 |
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
|
573 |
bytesToPad -= 64L; |
1 | 574 |
|
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
|
575 |
lengthPad = BYTESWAP64(sc->totalLength); |
1 | 576 |
|
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
|
577 |
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
|
578 |
SHA1Update (sc, &lengthPad, 8L); |
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 |
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
|
581 |
for (i = 0; i < SHA1_HASH_WORDS; i++) { |
1 | 582 |
#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
|
583 |
*((guint32 *) hash) = BYTESWAP(sc->hash[i]); |
1 | 584 |
#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
|
585 |
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
|
586 |
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
|
587 |
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
|
588 |
hash[3] = (guint8) sc->hash[i]; |
1 | 589 |
#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
|
590 |
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
|
591 |
} |
cdd6a0c5b439
Went 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 |
} |
1 | 593 |
} |
594 |
||
497
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
595 |
/** |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
596 |
* lm_sha_hash: |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
597 |
* @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
|
598 |
* |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
599 |
* 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
|
600 |
* |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
601 |
* 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
|
602 |
**/ |
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
603 |
gchar * |
1 | 604 |
lm_sha_hash (const gchar *str) |
605 |
{ |
|
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
|
606 |
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
|
607 |
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
|
608 |
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
|
609 |
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
|
610 |
guint i; |
497
bb4157a604ec
Make lm_sha_hash thread safe. Fixes LM-64
Andreas Köhler <andi5.py@gmx.net>
parents:
162
diff
changeset
|
611 |
|
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
|
612 |
ret_val = g_malloc (SHA1_HASH_SIZE*2 + 1); |
1 | 613 |
|
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
|
614 |
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
|
615 |
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
|
616 |
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
|
617 |
|
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
|
618 |
ch = ret_val; |
1 | 619 |
|
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
|
620 |
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
|
621 |
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
|
622 |
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
|
623 |
} |
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 |
return ret_val; |
1 | 626 |
} |