diff options
author | ryker <> | 1998-10-05 20:13:14 +0000 |
---|---|---|
committer | ryker <> | 1998-10-05 20:13:14 +0000 |
commit | aeeae06a79815dc190061534d47236cec09f9e32 (patch) | |
tree | 851692b9c2f9c04f077666855641900f19fdb217 /src/lib/libcrypto/ripemd | |
parent | a4f79641824cbf9f60ca9d1168d1fcc46717a82a (diff) | |
download | openbsd-aeeae06a79815dc190061534d47236cec09f9e32.tar.gz openbsd-aeeae06a79815dc190061534d47236cec09f9e32.tar.bz2 openbsd-aeeae06a79815dc190061534d47236cec09f9e32.zip |
Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD build
functionality for shared libs.
Note that routines such as sslv2_init and friends that use RSA will
not work due to lack of RSA in this library.
Needs documentation and help from ports for easy upgrade to full
functionality where legally possible.
Diffstat (limited to 'src/lib/libcrypto/ripemd')
-rw-r--r-- | src/lib/libcrypto/ripemd/README | 15 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/asm/rmd-586.pl | 582 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/ripemd.h | 99 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmd_dgst.c | 535 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmd_locl.h | 226 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmd_one.c | 77 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/rmdconst.h | 399 |
7 files changed, 1933 insertions, 0 deletions
diff --git a/src/lib/libcrypto/ripemd/README b/src/lib/libcrypto/ripemd/README new file mode 100644 index 0000000000..7097707264 --- /dev/null +++ b/src/lib/libcrypto/ripemd/README | |||
@@ -0,0 +1,15 @@ | |||
1 | RIPEMD-160 | ||
2 | http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html | ||
3 | |||
4 | This is my implementation of RIPEMD-160. The pentium assember is a little | ||
5 | off the pace since I only get 1050 cycles, while the best is 1013. | ||
6 | I have a few ideas for how to get another 20 or so cycles, but at | ||
7 | this point I will not bother right now. I belive the trick will be | ||
8 | to remove my 'copy X array onto stack' until inside the RIP1() finctions the | ||
9 | first time round. To do this I need another register and will only have one | ||
10 | temporary one. A bit tricky.... I can also cleanup the saving of the 5 words | ||
11 | after the first half of the calculation. I should read the origional | ||
12 | value, add then write. Currently I just save the new and read the origioal. | ||
13 | I then read both at the end. Bad. | ||
14 | |||
15 | eric (20-Jan-1998) | ||
diff --git a/src/lib/libcrypto/ripemd/asm/rmd-586.pl b/src/lib/libcrypto/ripemd/asm/rmd-586.pl new file mode 100644 index 0000000000..dc3f6c792e --- /dev/null +++ b/src/lib/libcrypto/ripemd/asm/rmd-586.pl | |||
@@ -0,0 +1,582 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | # Normal is the | ||
4 | # ripemd160_block_x86(MD5_CTX *c, ULONG *X); | ||
5 | # version, non-normal is the | ||
6 | # ripemd160_block_x86(MD5_CTX *c, ULONG *X,int blocks); | ||
7 | |||
8 | $normal=0; | ||
9 | |||
10 | push(@INC,"perlasm","../../perlasm"); | ||
11 | require "x86asm.pl"; | ||
12 | |||
13 | &asm_init($ARGV[0],$0); | ||
14 | |||
15 | $A="eax"; | ||
16 | $B="ebx"; | ||
17 | $C="ecx"; | ||
18 | $D="edx"; | ||
19 | $E="ebp"; | ||
20 | $tmp1="esi"; | ||
21 | $tmp2="edi"; | ||
22 | |||
23 | $KL1=0x5A827999; | ||
24 | $KL2=0x6ED9EBA1; | ||
25 | $KL3=0x8F1BBCDC; | ||
26 | $KL4=0xA953FD4E; | ||
27 | $KR0=0x50A28BE6; | ||
28 | $KR1=0x5C4DD124; | ||
29 | $KR2=0x6D703EF3; | ||
30 | $KR3=0x7A6D76E9; | ||
31 | |||
32 | |||
33 | @wl=( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15, | ||
34 | 7, 4,13, 1,10, 6,15, 3,12, 0, 9, 5, 2,14,11, 8, | ||
35 | 3,10,14, 4, 9,15, 8, 1, 2, 7, 0, 6,13,11, 5,12, | ||
36 | 1, 9,11,10, 0, 8,12, 4,13, 3, 7,15,14, 5, 6, 2, | ||
37 | 4, 0, 5, 9, 7,12, 2,10,14, 1, 3, 8,11, 6,15,13, | ||
38 | ); | ||
39 | |||
40 | @wr=( 5,14, 7, 0, 9, 2,11, 4,13, 6,15, 8, 1,10, 3,12, | ||
41 | 6,11, 3, 7, 0,13, 5,10,14,15, 8,12, 4, 9, 1, 2, | ||
42 | 15, 5, 1, 3, 7,14, 6, 9,11, 8,12, 2,10, 0, 4,13, | ||
43 | 8, 6, 4, 1, 3,11,15, 0, 5,12, 2,13, 9, 7,10,14, | ||
44 | 12,15,10, 4, 1, 5, 8, 7, 6, 2,13,14, 0, 3, 9,11, | ||
45 | ); | ||
46 | |||
47 | @sl=( 11,14,15,12, 5, 8, 7, 9,11,13,14,15, 6, 7, 9, 8, | ||
48 | 7, 6, 8,13,11, 9, 7,15, 7,12,15, 9,11, 7,13,12, | ||
49 | 11,13, 6, 7,14, 9,13,15,14, 8,13, 6, 5,12, 7, 5, | ||
50 | 11,12,14,15,14,15, 9, 8, 9,14, 5, 6, 8, 6, 5,12, | ||
51 | 9,15, 5,11, 6, 8,13,12, 5,12,13,14,11, 8, 5, 6, | ||
52 | ); | ||
53 | |||
54 | @sr=( 8, 9, 9,11,13,15,15, 5, 7, 7, 8,11,14,14,12, 6, | ||
55 | 9,13,15, 7,12, 8, 9,11, 7, 7,12, 7, 6,15,13,11, | ||
56 | 9, 7,15,11, 8, 6, 6,14,12,13, 5,14,13,13, 7, 5, | ||
57 | 15, 5, 8,11,14,14, 6,14, 6, 9,12, 9,12, 5,15, 8, | ||
58 | 8, 5,12, 9,12, 5,14, 6, 8,13, 6, 5,15,13,11,11, | ||
59 | ); | ||
60 | |||
61 | &ripemd160_block("ripemd160_block_x86"); | ||
62 | &asm_finish(); | ||
63 | |||
64 | sub Xv | ||
65 | { | ||
66 | local($n)=@_; | ||
67 | return(&swtmp($n+1)); | ||
68 | # tmp on stack | ||
69 | } | ||
70 | |||
71 | sub Np | ||
72 | { | ||
73 | local($p)=@_; | ||
74 | local(%n)=($A,$E,$B,$A,$C,$B,$D,$C,$E,$D); | ||
75 | return($n{$p}); | ||
76 | } | ||
77 | |||
78 | sub RIP1 | ||
79 | { | ||
80 | local($a,$b,$c,$d,$e,$pos,$s,$o,$pos2)=@_; | ||
81 | |||
82 | &comment($p++); | ||
83 | if ($p & 1) | ||
84 | { | ||
85 | &mov($tmp1, $c) if $o == -1; | ||
86 | &xor($tmp1, $d) if $o == -1; | ||
87 | &mov($tmp2, &Xv($pos)); | ||
88 | &xor($tmp1, $b); | ||
89 | &add($a, $tmp2); | ||
90 | &rotl($c, 10); | ||
91 | &add($a, $tmp1); | ||
92 | &mov($tmp1, &Np($c)); # NEXT | ||
93 | # XXX | ||
94 | &rotl($a, $s); | ||
95 | &add($a, $e); | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | &xor($tmp1, $d); | ||
100 | &mov($tmp2, &Xv($pos)); | ||
101 | &xor($tmp1, $b); | ||
102 | &add($a, $tmp1); | ||
103 | &mov($tmp1, &Np($c)) if $o <= 0; | ||
104 | &mov($tmp1, -1) if $o == 1; | ||
105 | # XXX if $o == 2; | ||
106 | &rotl($c, 10); | ||
107 | &add($a, $tmp2); | ||
108 | &xor($tmp1, &Np($d)) if $o <= 0; | ||
109 | &mov($tmp2, &Xv($pos2)) if $o == 1; | ||
110 | &mov($tmp2, &wparam(0)) if $o == 2; | ||
111 | &rotl($a, $s); | ||
112 | &add($a, $e); | ||
113 | } | ||
114 | } | ||
115 | |||
116 | sub RIP2 | ||
117 | { | ||
118 | local($a,$b,$c,$d,$e,$pos,$pos2,$s,$K,$o)=@_; | ||
119 | |||
120 | # XXXXXX | ||
121 | &comment($p++); | ||
122 | if ($p & 1) | ||
123 | { | ||
124 | # &mov($tmp2, &Xv($pos)) if $o < -1; | ||
125 | # &mov($tmp1, -1) if $o < -1; | ||
126 | |||
127 | &add($a, $tmp2); | ||
128 | &mov($tmp2, $c); | ||
129 | &sub($tmp1, $b); | ||
130 | &and($tmp2, $b); | ||
131 | &and($tmp1, $d); | ||
132 | &or($tmp2, $tmp1); | ||
133 | &mov($tmp1, &Xv($pos2)) if $o <= 0; # XXXXXXXXXXXXXX | ||
134 | # XXX | ||
135 | &rotl($c, 10); | ||
136 | &lea($a, &DWP($K,$a,$tmp2,1)); | ||
137 | &mov($tmp2, -1) if $o <= 0; | ||
138 | # XXX | ||
139 | &rotl($a, $s); | ||
140 | &add($a, $e); | ||
141 | } | ||
142 | else | ||
143 | { | ||
144 | # XXX | ||
145 | &add($a, $tmp1); | ||
146 | &mov($tmp1, $c); | ||
147 | &sub($tmp2, $b); | ||
148 | &and($tmp1, $b); | ||
149 | &and($tmp2, $d); | ||
150 | if ($o != 2) | ||
151 | { | ||
152 | &or($tmp1, $tmp2); | ||
153 | &mov($tmp2, &Xv($pos2)) if $o <= 0; | ||
154 | &mov($tmp2, -1) if $o == 1; | ||
155 | &rotl($c, 10); | ||
156 | &lea($a, &DWP($K,$a,$tmp1,1)); | ||
157 | &mov($tmp1, -1) if $o <= 0; | ||
158 | &sub($tmp2, &Np($c)) if $o == 1; | ||
159 | } else { | ||
160 | &or($tmp2, $tmp1); | ||
161 | &mov($tmp1, &Np($c)); | ||
162 | &rotl($c, 10); | ||
163 | &lea($a, &DWP($K,$a,$tmp2,1)); | ||
164 | &xor($tmp1, &Np($d)); | ||
165 | } | ||
166 | &rotl($a, $s); | ||
167 | &add($a, $e); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | sub RIP3 | ||
172 | { | ||
173 | local($a,$b,$c,$d,$e,$pos,$s,$K,$o,$pos2)=@_; | ||
174 | |||
175 | &comment($p++); | ||
176 | if ($p & 1) | ||
177 | { | ||
178 | # &mov($tmp2, -1) if $o < -1; | ||
179 | # &sub($tmp2, $c) if $o < -1; | ||
180 | &mov($tmp1, &Xv($pos)); | ||
181 | &or($tmp2, $b); | ||
182 | &add($a, $tmp1); | ||
183 | &xor($tmp2, $d); | ||
184 | &mov($tmp1, -1) if $o <= 0; # NEXT | ||
185 | # XXX | ||
186 | &rotl($c, 10); | ||
187 | &lea($a, &DWP($K,$a,$tmp2,1)); | ||
188 | &sub($tmp1, &Np($c)) if $o <= 0; # NEXT | ||
189 | # XXX | ||
190 | &rotl($a, $s); | ||
191 | &add($a, $e); | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | &mov($tmp2, &Xv($pos)); | ||
196 | &or($tmp1, $b); | ||
197 | &add($a, $tmp2); | ||
198 | &xor($tmp1, $d); | ||
199 | &mov($tmp2, -1) if $o <= 0; # NEXT | ||
200 | &mov($tmp2, -1) if $o == 1; | ||
201 | &mov($tmp2, &Xv($pos2)) if $o == 2; | ||
202 | &rotl($c, 10); | ||
203 | &lea($a, &DWP($K,$a,$tmp1,1)); | ||
204 | &sub($tmp2, &Np($c)) if $o <= 0; # NEXT | ||
205 | &mov($tmp1, &Np($d)) if $o == 1; | ||
206 | &mov($tmp1, -1) if $o == 2; | ||
207 | &rotl($a, $s); | ||
208 | &add($a, $e); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | sub RIP4 | ||
213 | { | ||
214 | local($a,$b,$c,$d,$e,$pos,$s,$K,$o)=@_; | ||
215 | |||
216 | &comment($p++); | ||
217 | if ($p & 1) | ||
218 | { | ||
219 | # &mov($tmp2, -1) if $o == -2; | ||
220 | # &mov($tmp1, $d) if $o == -2; | ||
221 | &sub($tmp2, $d); | ||
222 | &and($tmp1, $b); | ||
223 | &and($tmp2, $c); | ||
224 | &or($tmp2, $tmp1); | ||
225 | &mov($tmp1, &Xv($pos)); | ||
226 | &rotl($c, 10); | ||
227 | &lea($a, &DWP($K,$a,$tmp2)); | ||
228 | &mov($tmp2, -1) unless $o > 0; # NEXT | ||
229 | # XXX | ||
230 | &add($a, $tmp1); | ||
231 | &mov($tmp1, &Np($d)) unless $o > 0; # NEXT | ||
232 | # XXX | ||
233 | &rotl($a, $s); | ||
234 | &add($a, $e); | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | &sub($tmp2, $d); | ||
239 | &and($tmp1, $b); | ||
240 | &and($tmp2, $c); | ||
241 | &or($tmp2, $tmp1); | ||
242 | &mov($tmp1, &Xv($pos)); | ||
243 | &rotl($c, 10); | ||
244 | &lea($a, &DWP($K,$a,$tmp2)); | ||
245 | &mov($tmp2, -1) if $o == 0; # NEXT | ||
246 | &mov($tmp2, -1) if $o == 1; | ||
247 | &mov($tmp2, -1) if $o == 2; | ||
248 | # XXX | ||
249 | &add($a, $tmp1); | ||
250 | &mov($tmp1, &Np($d)) if $o == 0; # NEXT | ||
251 | &sub($tmp2, &Np($d)) if $o == 1; | ||
252 | &sub($tmp2, &Np($c)) if $o == 2; | ||
253 | # XXX | ||
254 | &rotl($a, $s); | ||
255 | &add($a, $e); | ||
256 | } | ||
257 | } | ||
258 | |||
259 | sub RIP5 | ||
260 | { | ||
261 | local($a,$b,$c,$d,$e,$pos,$s,$K,$o)=@_; | ||
262 | |||
263 | &comment($p++); | ||
264 | if ($p & 1) | ||
265 | { | ||
266 | &mov($tmp2, -1) if $o == -2; | ||
267 | &sub($tmp2, $d) if $o == -2; | ||
268 | &mov($tmp1, &Xv($pos)); | ||
269 | &or($tmp2, $c); | ||
270 | &add($a, $tmp1); | ||
271 | &xor($tmp2, $b); | ||
272 | &mov($tmp1, -1) if $o <= 0; | ||
273 | # XXX | ||
274 | &rotl($c, 10); | ||
275 | &lea($a, &DWP($K,$a,$tmp2,1)); | ||
276 | &sub($tmp1, &Np($d)) if $o <= 0; | ||
277 | # XXX | ||
278 | &rotl($a, $s); | ||
279 | &add($a, $e); | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | &mov($tmp2, &Xv($pos)); | ||
284 | &or($tmp1, $c); | ||
285 | &add($a, $tmp2); | ||
286 | &xor($tmp1, $b); | ||
287 | &mov($tmp2, -1) if $o <= 0; | ||
288 | &mov($tmp2, &wparam(0)) if $o == 1; # Middle code | ||
289 | &mov($tmp2, -1) if $o == 2; | ||
290 | &rotl($c, 10); | ||
291 | &lea($a, &DWP($K,$a,$tmp1,1)); | ||
292 | &sub($tmp2, &Np($d)) if $o <= 0; | ||
293 | &mov(&swtmp(1+16), $A) if $o == 1; | ||
294 | &mov($tmp1, &Np($d)) if $o == 2; | ||
295 | &rotl($a, $s); | ||
296 | &add($a, $e); | ||
297 | } | ||
298 | } | ||
299 | |||
300 | sub ripemd160_block | ||
301 | { | ||
302 | local($name)=@_; | ||
303 | |||
304 | &function_begin_B($name,"",3); | ||
305 | |||
306 | # parameter 1 is the RIPEMD160_CTX structure. | ||
307 | # A 0 | ||
308 | # B 4 | ||
309 | # C 8 | ||
310 | # D 12 | ||
311 | # E 16 | ||
312 | |||
313 | &push("esi"); | ||
314 | &mov($C, &wparam(2)); | ||
315 | &push("edi"); | ||
316 | &mov($tmp1, &wparam(1)); # edi | ||
317 | &push("ebp"); | ||
318 | &add($C, $tmp1); # offset we end at | ||
319 | &push("ebx"); | ||
320 | &sub($C, 64); | ||
321 | &stack_push(16+5+1); | ||
322 | # XXX | ||
323 | |||
324 | &mov(&swtmp(0), $C); | ||
325 | &mov($tmp2, &wparam(0)); # Done at end of loop | ||
326 | |||
327 | &set_label("start") unless $normal; | ||
328 | &comment(""); | ||
329 | |||
330 | # &mov($tmp1, &wparam(1)); # Done at end of loop | ||
331 | # &mov($tmp2, &wparam(0)); # Done at end of loop | ||
332 | |||
333 | for ($z=0; $z<16; $z+=2) | ||
334 | { | ||
335 | &mov($A, &DWP( $z*4,$tmp1,"",0)); | ||
336 | &mov($B, &DWP( ($z+1)*4,$tmp1,"",0)); | ||
337 | &mov(&swtmp(1+$z), $A); | ||
338 | &mov(&swtmp(1+$z+1), $B); | ||
339 | } | ||
340 | &add($tmp1, 64); | ||
341 | &mov($A, &DWP( 0,$tmp2,"",0)); | ||
342 | &mov(&wparam(1),$tmp1); | ||
343 | &mov($B, &DWP( 4,$tmp2,"",0)); | ||
344 | &mov($C, &DWP( 8,$tmp2,"",0)); | ||
345 | &mov($D, &DWP(12,$tmp2,"",0)); | ||
346 | &mov($E, &DWP(16,$tmp2,"",0)); | ||
347 | |||
348 | &RIP1($A,$B,$C,$D,$E,$wl[ 0],$sl[ 0],-1); | ||
349 | &RIP1($E,$A,$B,$C,$D,$wl[ 1],$sl[ 1],0); | ||
350 | &RIP1($D,$E,$A,$B,$C,$wl[ 2],$sl[ 2],0); | ||
351 | &RIP1($C,$D,$E,$A,$B,$wl[ 3],$sl[ 3],0); | ||
352 | &RIP1($B,$C,$D,$E,$A,$wl[ 4],$sl[ 4],0); | ||
353 | &RIP1($A,$B,$C,$D,$E,$wl[ 5],$sl[ 5],0); | ||
354 | &RIP1($E,$A,$B,$C,$D,$wl[ 6],$sl[ 6],0); | ||
355 | &RIP1($D,$E,$A,$B,$C,$wl[ 7],$sl[ 7],0); | ||
356 | &RIP1($C,$D,$E,$A,$B,$wl[ 8],$sl[ 8],0); | ||
357 | &RIP1($B,$C,$D,$E,$A,$wl[ 9],$sl[ 9],0); | ||
358 | &RIP1($A,$B,$C,$D,$E,$wl[10],$sl[10],0); | ||
359 | &RIP1($E,$A,$B,$C,$D,$wl[11],$sl[11],0); | ||
360 | &RIP1($D,$E,$A,$B,$C,$wl[12],$sl[12],0); | ||
361 | &RIP1($C,$D,$E,$A,$B,$wl[13],$sl[13],0); | ||
362 | &RIP1($B,$C,$D,$E,$A,$wl[14],$sl[14],0); | ||
363 | &RIP1($A,$B,$C,$D,$E,$wl[15],$sl[15],1,$wl[16]); | ||
364 | |||
365 | &RIP2($E,$A,$B,$C,$D,$wl[16],$wl[17],$sl[16],$KL1,-1); | ||
366 | &RIP2($D,$E,$A,$B,$C,$wl[17],$wl[18],$sl[17],$KL1,0); | ||
367 | &RIP2($C,$D,$E,$A,$B,$wl[18],$wl[19],$sl[18],$KL1,0); | ||
368 | &RIP2($B,$C,$D,$E,$A,$wl[19],$wl[20],$sl[19],$KL1,0); | ||
369 | &RIP2($A,$B,$C,$D,$E,$wl[20],$wl[21],$sl[20],$KL1,0); | ||
370 | &RIP2($E,$A,$B,$C,$D,$wl[21],$wl[22],$sl[21],$KL1,0); | ||
371 | &RIP2($D,$E,$A,$B,$C,$wl[22],$wl[23],$sl[22],$KL1,0); | ||
372 | &RIP2($C,$D,$E,$A,$B,$wl[23],$wl[24],$sl[23],$KL1,0); | ||
373 | &RIP2($B,$C,$D,$E,$A,$wl[24],$wl[25],$sl[24],$KL1,0); | ||
374 | &RIP2($A,$B,$C,$D,$E,$wl[25],$wl[26],$sl[25],$KL1,0); | ||
375 | &RIP2($E,$A,$B,$C,$D,$wl[26],$wl[27],$sl[26],$KL1,0); | ||
376 | &RIP2($D,$E,$A,$B,$C,$wl[27],$wl[28],$sl[27],$KL1,0); | ||
377 | &RIP2($C,$D,$E,$A,$B,$wl[28],$wl[29],$sl[28],$KL1,0); | ||
378 | &RIP2($B,$C,$D,$E,$A,$wl[29],$wl[30],$sl[29],$KL1,0); | ||
379 | &RIP2($A,$B,$C,$D,$E,$wl[30],$wl[31],$sl[30],$KL1,0); | ||
380 | &RIP2($E,$A,$B,$C,$D,$wl[31],$wl[32],$sl[31],$KL1,1); | ||
381 | |||
382 | &RIP3($D,$E,$A,$B,$C,$wl[32],$sl[32],$KL2,-1); | ||
383 | &RIP3($C,$D,$E,$A,$B,$wl[33],$sl[33],$KL2,0); | ||
384 | &RIP3($B,$C,$D,$E,$A,$wl[34],$sl[34],$KL2,0); | ||
385 | &RIP3($A,$B,$C,$D,$E,$wl[35],$sl[35],$KL2,0); | ||
386 | &RIP3($E,$A,$B,$C,$D,$wl[36],$sl[36],$KL2,0); | ||
387 | &RIP3($D,$E,$A,$B,$C,$wl[37],$sl[37],$KL2,0); | ||
388 | &RIP3($C,$D,$E,$A,$B,$wl[38],$sl[38],$KL2,0); | ||
389 | &RIP3($B,$C,$D,$E,$A,$wl[39],$sl[39],$KL2,0); | ||
390 | &RIP3($A,$B,$C,$D,$E,$wl[40],$sl[40],$KL2,0); | ||
391 | &RIP3($E,$A,$B,$C,$D,$wl[41],$sl[41],$KL2,0); | ||
392 | &RIP3($D,$E,$A,$B,$C,$wl[42],$sl[42],$KL2,0); | ||
393 | &RIP3($C,$D,$E,$A,$B,$wl[43],$sl[43],$KL2,0); | ||
394 | &RIP3($B,$C,$D,$E,$A,$wl[44],$sl[44],$KL2,0); | ||
395 | &RIP3($A,$B,$C,$D,$E,$wl[45],$sl[45],$KL2,0); | ||
396 | &RIP3($E,$A,$B,$C,$D,$wl[46],$sl[46],$KL2,0); | ||
397 | &RIP3($D,$E,$A,$B,$C,$wl[47],$sl[47],$KL2,1); | ||
398 | |||
399 | &RIP4($C,$D,$E,$A,$B,$wl[48],$sl[48],$KL3,-1); | ||
400 | &RIP4($B,$C,$D,$E,$A,$wl[49],$sl[49],$KL3,0); | ||
401 | &RIP4($A,$B,$C,$D,$E,$wl[50],$sl[50],$KL3,0); | ||
402 | &RIP4($E,$A,$B,$C,$D,$wl[51],$sl[51],$KL3,0); | ||
403 | &RIP4($D,$E,$A,$B,$C,$wl[52],$sl[52],$KL3,0); | ||
404 | &RIP4($C,$D,$E,$A,$B,$wl[53],$sl[53],$KL3,0); | ||
405 | &RIP4($B,$C,$D,$E,$A,$wl[54],$sl[54],$KL3,0); | ||
406 | &RIP4($A,$B,$C,$D,$E,$wl[55],$sl[55],$KL3,0); | ||
407 | &RIP4($E,$A,$B,$C,$D,$wl[56],$sl[56],$KL3,0); | ||
408 | &RIP4($D,$E,$A,$B,$C,$wl[57],$sl[57],$KL3,0); | ||
409 | &RIP4($C,$D,$E,$A,$B,$wl[58],$sl[58],$KL3,0); | ||
410 | &RIP4($B,$C,$D,$E,$A,$wl[59],$sl[59],$KL3,0); | ||
411 | &RIP4($A,$B,$C,$D,$E,$wl[60],$sl[60],$KL3,0); | ||
412 | &RIP4($E,$A,$B,$C,$D,$wl[61],$sl[61],$KL3,0); | ||
413 | &RIP4($D,$E,$A,$B,$C,$wl[62],$sl[62],$KL3,0); | ||
414 | &RIP4($C,$D,$E,$A,$B,$wl[63],$sl[63],$KL3,1); | ||
415 | |||
416 | &RIP5($B,$C,$D,$E,$A,$wl[64],$sl[64],$KL4,-1); | ||
417 | &RIP5($A,$B,$C,$D,$E,$wl[65],$sl[65],$KL4,0); | ||
418 | &RIP5($E,$A,$B,$C,$D,$wl[66],$sl[66],$KL4,0); | ||
419 | &RIP5($D,$E,$A,$B,$C,$wl[67],$sl[67],$KL4,0); | ||
420 | &RIP5($C,$D,$E,$A,$B,$wl[68],$sl[68],$KL4,0); | ||
421 | &RIP5($B,$C,$D,$E,$A,$wl[69],$sl[69],$KL4,0); | ||
422 | &RIP5($A,$B,$C,$D,$E,$wl[70],$sl[70],$KL4,0); | ||
423 | &RIP5($E,$A,$B,$C,$D,$wl[71],$sl[71],$KL4,0); | ||
424 | &RIP5($D,$E,$A,$B,$C,$wl[72],$sl[72],$KL4,0); | ||
425 | &RIP5($C,$D,$E,$A,$B,$wl[73],$sl[73],$KL4,0); | ||
426 | &RIP5($B,$C,$D,$E,$A,$wl[74],$sl[74],$KL4,0); | ||
427 | &RIP5($A,$B,$C,$D,$E,$wl[75],$sl[75],$KL4,0); | ||
428 | &RIP5($E,$A,$B,$C,$D,$wl[76],$sl[76],$KL4,0); | ||
429 | &RIP5($D,$E,$A,$B,$C,$wl[77],$sl[77],$KL4,0); | ||
430 | &RIP5($C,$D,$E,$A,$B,$wl[78],$sl[78],$KL4,0); | ||
431 | &RIP5($B,$C,$D,$E,$A,$wl[79],$sl[79],$KL4,1); | ||
432 | |||
433 | # &mov($tmp2, &wparam(0)); # moved into last RIP5 | ||
434 | # &mov(&swtmp(1+16), $A); | ||
435 | &mov($A, &DWP( 0,$tmp2,"",0)); | ||
436 | &mov(&swtmp(1+17), $B); | ||
437 | &mov(&swtmp(1+18), $C); | ||
438 | &mov($B, &DWP( 4,$tmp2,"",0)); | ||
439 | &mov(&swtmp(1+19), $D); | ||
440 | &mov($C, &DWP( 8,$tmp2,"",0)); | ||
441 | &mov(&swtmp(1+20), $E); | ||
442 | &mov($D, &DWP(12,$tmp2,"",0)); | ||
443 | &mov($E, &DWP(16,$tmp2,"",0)); | ||
444 | |||
445 | &RIP5($A,$B,$C,$D,$E,$wr[ 0],$sr[ 0],$KR0,-2); | ||
446 | &RIP5($E,$A,$B,$C,$D,$wr[ 1],$sr[ 1],$KR0,0); | ||
447 | &RIP5($D,$E,$A,$B,$C,$wr[ 2],$sr[ 2],$KR0,0); | ||
448 | &RIP5($C,$D,$E,$A,$B,$wr[ 3],$sr[ 3],$KR0,0); | ||
449 | &RIP5($B,$C,$D,$E,$A,$wr[ 4],$sr[ 4],$KR0,0); | ||
450 | &RIP5($A,$B,$C,$D,$E,$wr[ 5],$sr[ 5],$KR0,0); | ||
451 | &RIP5($E,$A,$B,$C,$D,$wr[ 6],$sr[ 6],$KR0,0); | ||
452 | &RIP5($D,$E,$A,$B,$C,$wr[ 7],$sr[ 7],$KR0,0); | ||
453 | &RIP5($C,$D,$E,$A,$B,$wr[ 8],$sr[ 8],$KR0,0); | ||
454 | &RIP5($B,$C,$D,$E,$A,$wr[ 9],$sr[ 9],$KR0,0); | ||
455 | &RIP5($A,$B,$C,$D,$E,$wr[10],$sr[10],$KR0,0); | ||
456 | &RIP5($E,$A,$B,$C,$D,$wr[11],$sr[11],$KR0,0); | ||
457 | &RIP5($D,$E,$A,$B,$C,$wr[12],$sr[12],$KR0,0); | ||
458 | &RIP5($C,$D,$E,$A,$B,$wr[13],$sr[13],$KR0,0); | ||
459 | &RIP5($B,$C,$D,$E,$A,$wr[14],$sr[14],$KR0,0); | ||
460 | &RIP5($A,$B,$C,$D,$E,$wr[15],$sr[15],$KR0,2); | ||
461 | |||
462 | &RIP4($E,$A,$B,$C,$D,$wr[16],$sr[16],$KR1,-2); | ||
463 | &RIP4($D,$E,$A,$B,$C,$wr[17],$sr[17],$KR1,0); | ||
464 | &RIP4($C,$D,$E,$A,$B,$wr[18],$sr[18],$KR1,0); | ||
465 | &RIP4($B,$C,$D,$E,$A,$wr[19],$sr[19],$KR1,0); | ||
466 | &RIP4($A,$B,$C,$D,$E,$wr[20],$sr[20],$KR1,0); | ||
467 | &RIP4($E,$A,$B,$C,$D,$wr[21],$sr[21],$KR1,0); | ||
468 | &RIP4($D,$E,$A,$B,$C,$wr[22],$sr[22],$KR1,0); | ||
469 | &RIP4($C,$D,$E,$A,$B,$wr[23],$sr[23],$KR1,0); | ||
470 | &RIP4($B,$C,$D,$E,$A,$wr[24],$sr[24],$KR1,0); | ||
471 | &RIP4($A,$B,$C,$D,$E,$wr[25],$sr[25],$KR1,0); | ||
472 | &RIP4($E,$A,$B,$C,$D,$wr[26],$sr[26],$KR1,0); | ||
473 | &RIP4($D,$E,$A,$B,$C,$wr[27],$sr[27],$KR1,0); | ||
474 | &RIP4($C,$D,$E,$A,$B,$wr[28],$sr[28],$KR1,0); | ||
475 | &RIP4($B,$C,$D,$E,$A,$wr[29],$sr[29],$KR1,0); | ||
476 | &RIP4($A,$B,$C,$D,$E,$wr[30],$sr[30],$KR1,0); | ||
477 | &RIP4($E,$A,$B,$C,$D,$wr[31],$sr[31],$KR1,2); | ||
478 | |||
479 | &RIP3($D,$E,$A,$B,$C,$wr[32],$sr[32],$KR2,-2); | ||
480 | &RIP3($C,$D,$E,$A,$B,$wr[33],$sr[33],$KR2,0); | ||
481 | &RIP3($B,$C,$D,$E,$A,$wr[34],$sr[34],$KR2,0); | ||
482 | &RIP3($A,$B,$C,$D,$E,$wr[35],$sr[35],$KR2,0); | ||
483 | &RIP3($E,$A,$B,$C,$D,$wr[36],$sr[36],$KR2,0); | ||
484 | &RIP3($D,$E,$A,$B,$C,$wr[37],$sr[37],$KR2,0); | ||
485 | &RIP3($C,$D,$E,$A,$B,$wr[38],$sr[38],$KR2,0); | ||
486 | &RIP3($B,$C,$D,$E,$A,$wr[39],$sr[39],$KR2,0); | ||
487 | &RIP3($A,$B,$C,$D,$E,$wr[40],$sr[40],$KR2,0); | ||
488 | &RIP3($E,$A,$B,$C,$D,$wr[41],$sr[41],$KR2,0); | ||
489 | &RIP3($D,$E,$A,$B,$C,$wr[42],$sr[42],$KR2,0); | ||
490 | &RIP3($C,$D,$E,$A,$B,$wr[43],$sr[43],$KR2,0); | ||
491 | &RIP3($B,$C,$D,$E,$A,$wr[44],$sr[44],$KR2,0); | ||
492 | &RIP3($A,$B,$C,$D,$E,$wr[45],$sr[45],$KR2,0); | ||
493 | &RIP3($E,$A,$B,$C,$D,$wr[46],$sr[46],$KR2,0); | ||
494 | &RIP3($D,$E,$A,$B,$C,$wr[47],$sr[47],$KR2,2,$wr[48]); | ||
495 | |||
496 | &RIP2($C,$D,$E,$A,$B,$wr[48],$wr[49],$sr[48],$KR3,-2); | ||
497 | &RIP2($B,$C,$D,$E,$A,$wr[49],$wr[50],$sr[49],$KR3,0); | ||
498 | &RIP2($A,$B,$C,$D,$E,$wr[50],$wr[51],$sr[50],$KR3,0); | ||
499 | &RIP2($E,$A,$B,$C,$D,$wr[51],$wr[52],$sr[51],$KR3,0); | ||
500 | &RIP2($D,$E,$A,$B,$C,$wr[52],$wr[53],$sr[52],$KR3,0); | ||
501 | &RIP2($C,$D,$E,$A,$B,$wr[53],$wr[54],$sr[53],$KR3,0); | ||
502 | &RIP2($B,$C,$D,$E,$A,$wr[54],$wr[55],$sr[54],$KR3,0); | ||
503 | &RIP2($A,$B,$C,$D,$E,$wr[55],$wr[56],$sr[55],$KR3,0); | ||
504 | &RIP2($E,$A,$B,$C,$D,$wr[56],$wr[57],$sr[56],$KR3,0); | ||
505 | &RIP2($D,$E,$A,$B,$C,$wr[57],$wr[58],$sr[57],$KR3,0); | ||
506 | &RIP2($C,$D,$E,$A,$B,$wr[58],$wr[59],$sr[58],$KR3,0); | ||
507 | &RIP2($B,$C,$D,$E,$A,$wr[59],$wr[60],$sr[59],$KR3,0); | ||
508 | &RIP2($A,$B,$C,$D,$E,$wr[60],$wr[61],$sr[60],$KR3,0); | ||
509 | &RIP2($E,$A,$B,$C,$D,$wr[61],$wr[62],$sr[61],$KR3,0); | ||
510 | &RIP2($D,$E,$A,$B,$C,$wr[62],$wr[63],$sr[62],$KR3,0); | ||
511 | &RIP2($C,$D,$E,$A,$B,$wr[63],$wr[64],$sr[63],$KR3,2); | ||
512 | |||
513 | &RIP1($B,$C,$D,$E,$A,$wr[64],$sr[64],-2); | ||
514 | &RIP1($A,$B,$C,$D,$E,$wr[65],$sr[65],0); | ||
515 | &RIP1($E,$A,$B,$C,$D,$wr[66],$sr[66],0); | ||
516 | &RIP1($D,$E,$A,$B,$C,$wr[67],$sr[67],0); | ||
517 | &RIP1($C,$D,$E,$A,$B,$wr[68],$sr[68],0); | ||
518 | &RIP1($B,$C,$D,$E,$A,$wr[69],$sr[69],0); | ||
519 | &RIP1($A,$B,$C,$D,$E,$wr[70],$sr[70],0); | ||
520 | &RIP1($E,$A,$B,$C,$D,$wr[71],$sr[71],0); | ||
521 | &RIP1($D,$E,$A,$B,$C,$wr[72],$sr[72],0); | ||
522 | &RIP1($C,$D,$E,$A,$B,$wr[73],$sr[73],0); | ||
523 | &RIP1($B,$C,$D,$E,$A,$wr[74],$sr[74],0); | ||
524 | &RIP1($A,$B,$C,$D,$E,$wr[75],$sr[75],0); | ||
525 | &RIP1($E,$A,$B,$C,$D,$wr[76],$sr[76],0); | ||
526 | &RIP1($D,$E,$A,$B,$C,$wr[77],$sr[77],0); | ||
527 | &RIP1($C,$D,$E,$A,$B,$wr[78],$sr[78],0); | ||
528 | &RIP1($B,$C,$D,$E,$A,$wr[79],$sr[79],2); | ||
529 | |||
530 | # &mov($tmp2, &wparam(0)); # Moved into last round | ||
531 | |||
532 | &mov($tmp1, &DWP( 4,$tmp2,"",0)); # ctx->B | ||
533 | &add($D, $tmp1); | ||
534 | &mov($tmp1, &swtmp(1+18)); # $c | ||
535 | &add($D, $tmp1); | ||
536 | |||
537 | &mov($tmp1, &DWP( 8,$tmp2,"",0)); # ctx->C | ||
538 | &add($E, $tmp1); | ||
539 | &mov($tmp1, &swtmp(1+19)); # $d | ||
540 | &add($E, $tmp1); | ||
541 | |||
542 | &mov($tmp1, &DWP(12,$tmp2,"",0)); # ctx->D | ||
543 | &add($A, $tmp1); | ||
544 | &mov($tmp1, &swtmp(1+20)); # $e | ||
545 | &add($A, $tmp1); | ||
546 | |||
547 | |||
548 | &mov($tmp1, &DWP(16,$tmp2,"",0)); # ctx->E | ||
549 | &add($B, $tmp1); | ||
550 | &mov($tmp1, &swtmp(1+16)); # $a | ||
551 | &add($B, $tmp1); | ||
552 | |||
553 | &mov($tmp1, &DWP( 0,$tmp2,"",0)); # ctx->A | ||
554 | &add($C, $tmp1); | ||
555 | &mov($tmp1, &swtmp(1+17)); # $b | ||
556 | &add($C, $tmp1); | ||
557 | |||
558 | &mov(&DWP( 0,$tmp2,"",0), $D); | ||
559 | &mov(&DWP( 4,$tmp2,"",0), $E); | ||
560 | &mov(&DWP( 8,$tmp2,"",0), $A); | ||
561 | &mov(&DWP(12,$tmp2,"",0), $B); | ||
562 | &mov(&DWP(16,$tmp2,"",0), $C); | ||
563 | |||
564 | &mov($tmp2, &swtmp(0)); | ||
565 | &mov($tmp1, &wparam(1)); | ||
566 | |||
567 | &cmp($tmp2,$tmp1); | ||
568 | &mov($tmp2, &wparam(0)); | ||
569 | |||
570 | # XXX | ||
571 | &jge(&label("start")); | ||
572 | |||
573 | &stack_pop(16+5+1); | ||
574 | |||
575 | &pop("ebx"); | ||
576 | &pop("ebp"); | ||
577 | &pop("edi"); | ||
578 | &pop("esi"); | ||
579 | &ret(); | ||
580 | &function_end_B($name); | ||
581 | } | ||
582 | |||
diff --git a/src/lib/libcrypto/ripemd/ripemd.h b/src/lib/libcrypto/ripemd/ripemd.h new file mode 100644 index 0000000000..a3bc6e3ab2 --- /dev/null +++ b/src/lib/libcrypto/ripemd/ripemd.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /* crypto/ripemd/ripemd.h */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #ifndef HEADER_RIPEMD_H | ||
60 | #define HEADER_RIPEMD_H | ||
61 | |||
62 | #ifdef __cplusplus | ||
63 | extern "C" { | ||
64 | #endif | ||
65 | |||
66 | #define RIPEMD160_CBLOCK 64 | ||
67 | #define RIPEMD160_LBLOCK 16 | ||
68 | #define RIPEMD160_BLOCK 16 | ||
69 | #define RIPEMD160_LAST_BLOCK 56 | ||
70 | #define RIPEMD160_LENGTH_BLOCK 8 | ||
71 | #define RIPEMD160_DIGEST_LENGTH 20 | ||
72 | |||
73 | typedef struct RIPEMD160state_st | ||
74 | { | ||
75 | unsigned long A,B,C,D,E; | ||
76 | unsigned long Nl,Nh; | ||
77 | unsigned long data[RIPEMD160_LBLOCK]; | ||
78 | int num; | ||
79 | } RIPEMD160_CTX; | ||
80 | |||
81 | #ifndef NOPROTO | ||
82 | void RIPEMD160_Init(RIPEMD160_CTX *c); | ||
83 | void RIPEMD160_Update(RIPEMD160_CTX *c, unsigned char *data, unsigned long len); | ||
84 | void RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); | ||
85 | unsigned char *RIPEMD160(unsigned char *d, unsigned long n, unsigned char *md); | ||
86 | void RIPEMD160_Transform(RIPEMD160_CTX *c, unsigned char *b); | ||
87 | #else | ||
88 | void RIPEMD160_Init(); | ||
89 | void RIPEMD160_Update(); | ||
90 | void RIPEMD160_Final(); | ||
91 | unsigned char *RIPEMD160(); | ||
92 | void RIPEMD160_Transform(); | ||
93 | #endif | ||
94 | |||
95 | #ifdef __cplusplus | ||
96 | } | ||
97 | #endif | ||
98 | |||
99 | #endif | ||
diff --git a/src/lib/libcrypto/ripemd/rmd_dgst.c b/src/lib/libcrypto/ripemd/rmd_dgst.c new file mode 100644 index 0000000000..210de1977d --- /dev/null +++ b/src/lib/libcrypto/ripemd/rmd_dgst.c | |||
@@ -0,0 +1,535 @@ | |||
1 | /* crypto/ripemd/rmd_dgst.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include "rmd_locl.h" | ||
61 | |||
62 | char *RMD160_version="RIPEMD160 part of SSLeay 0.9.0b 29-Jun-1998"; | ||
63 | |||
64 | #ifndef NOPROTO | ||
65 | # ifdef RMD160_ASM | ||
66 | void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p,int num); | ||
67 | # define ripemd160_block ripemd160_block_x86 | ||
68 | # else | ||
69 | void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p,int num); | ||
70 | # endif | ||
71 | #else | ||
72 | # ifdef RMD160_ASM | ||
73 | void ripemd160_block_x86(); | ||
74 | # define ripemd160_block ripemd160_block_x86 | ||
75 | # else | ||
76 | static void ripemd160_block(); | ||
77 | # endif | ||
78 | #endif | ||
79 | |||
80 | void RIPEMD160_Init(c) | ||
81 | RIPEMD160_CTX *c; | ||
82 | { | ||
83 | c->A=RIPEMD160_A; | ||
84 | c->B=RIPEMD160_B; | ||
85 | c->C=RIPEMD160_C; | ||
86 | c->D=RIPEMD160_D; | ||
87 | c->E=RIPEMD160_E; | ||
88 | c->Nl=0; | ||
89 | c->Nh=0; | ||
90 | c->num=0; | ||
91 | } | ||
92 | |||
93 | void RIPEMD160_Update(c, data, len) | ||
94 | RIPEMD160_CTX *c; | ||
95 | register unsigned char *data; | ||
96 | unsigned long len; | ||
97 | { | ||
98 | register ULONG *p; | ||
99 | int sw,sc; | ||
100 | ULONG l; | ||
101 | |||
102 | if (len == 0) return; | ||
103 | |||
104 | l=(c->Nl+(len<<3))&0xffffffffL; | ||
105 | if (l < c->Nl) /* overflow */ | ||
106 | c->Nh++; | ||
107 | c->Nh+=(len>>29); | ||
108 | c->Nl=l; | ||
109 | |||
110 | if (c->num != 0) | ||
111 | { | ||
112 | p=c->data; | ||
113 | sw=c->num>>2; | ||
114 | sc=c->num&0x03; | ||
115 | |||
116 | if ((c->num+len) >= RIPEMD160_CBLOCK) | ||
117 | { | ||
118 | l= p[sw]; | ||
119 | p_c2l(data,l,sc); | ||
120 | p[sw++]=l; | ||
121 | for (; sw<RIPEMD160_LBLOCK; sw++) | ||
122 | { | ||
123 | c2l(data,l); | ||
124 | p[sw]=l; | ||
125 | } | ||
126 | len-=(RIPEMD160_CBLOCK-c->num); | ||
127 | |||
128 | ripemd160_block(c,p,64); | ||
129 | c->num=0; | ||
130 | /* drop through and do the rest */ | ||
131 | } | ||
132 | else | ||
133 | { | ||
134 | int ew,ec; | ||
135 | |||
136 | c->num+=(int)len; | ||
137 | if ((sc+len) < 4) /* ugly, add char's to a word */ | ||
138 | { | ||
139 | l= p[sw]; | ||
140 | p_c2l_p(data,l,sc,len); | ||
141 | p[sw]=l; | ||
142 | } | ||
143 | else | ||
144 | { | ||
145 | ew=(c->num>>2); | ||
146 | ec=(c->num&0x03); | ||
147 | l= p[sw]; | ||
148 | p_c2l(data,l,sc); | ||
149 | p[sw++]=l; | ||
150 | for (; sw < ew; sw++) | ||
151 | { c2l(data,l); p[sw]=l; } | ||
152 | if (ec) | ||
153 | { | ||
154 | c2l_p(data,l,ec); | ||
155 | p[sw]=l; | ||
156 | } | ||
157 | } | ||
158 | return; | ||
159 | } | ||
160 | } | ||
161 | /* we now can process the input data in blocks of RIPEMD160_CBLOCK | ||
162 | * chars and save the leftovers to c->data. */ | ||
163 | #ifdef L_ENDIAN | ||
164 | if ((((unsigned long)data)%sizeof(ULONG)) == 0) | ||
165 | { | ||
166 | sw=(int)len/RIPEMD160_CBLOCK; | ||
167 | if (sw > 0) | ||
168 | { | ||
169 | sw*=RIPEMD160_CBLOCK; | ||
170 | ripemd160_block(c,(ULONG *)data,sw); | ||
171 | data+=sw; | ||
172 | len-=sw; | ||
173 | } | ||
174 | } | ||
175 | #endif | ||
176 | p=c->data; | ||
177 | while (len >= RIPEMD160_CBLOCK) | ||
178 | { | ||
179 | #if defined(L_ENDIAN) || defined(B_ENDIAN) | ||
180 | if (p != (unsigned long *)data) | ||
181 | memcpy(p,data,RIPEMD160_CBLOCK); | ||
182 | data+=RIPEMD160_CBLOCK; | ||
183 | #ifdef B_ENDIAN | ||
184 | for (sw=(RIPEMD160_LBLOCK/4); sw; sw--) | ||
185 | { | ||
186 | Endian_Reverse32(p[0]); | ||
187 | Endian_Reverse32(p[1]); | ||
188 | Endian_Reverse32(p[2]); | ||
189 | Endian_Reverse32(p[3]); | ||
190 | p+=4; | ||
191 | } | ||
192 | #endif | ||
193 | #else | ||
194 | for (sw=(RIPEMD160_LBLOCK/4); sw; sw--) | ||
195 | { | ||
196 | c2l(data,l); *(p++)=l; | ||
197 | c2l(data,l); *(p++)=l; | ||
198 | c2l(data,l); *(p++)=l; | ||
199 | c2l(data,l); *(p++)=l; | ||
200 | } | ||
201 | #endif | ||
202 | p=c->data; | ||
203 | ripemd160_block(c,p,64); | ||
204 | len-=RIPEMD160_CBLOCK; | ||
205 | } | ||
206 | sc=(int)len; | ||
207 | c->num=sc; | ||
208 | if (sc) | ||
209 | { | ||
210 | sw=sc>>2; /* words to copy */ | ||
211 | #ifdef L_ENDIAN | ||
212 | p[sw]=0; | ||
213 | memcpy(p,data,sc); | ||
214 | #else | ||
215 | sc&=0x03; | ||
216 | for ( ; sw; sw--) | ||
217 | { c2l(data,l); *(p++)=l; } | ||
218 | c2l_p(data,l,sc); | ||
219 | *p=l; | ||
220 | #endif | ||
221 | } | ||
222 | } | ||
223 | |||
224 | void RIPEMD160_Transform(c,b) | ||
225 | RIPEMD160_CTX *c; | ||
226 | unsigned char *b; | ||
227 | { | ||
228 | ULONG p[16]; | ||
229 | #if !defined(L_ENDIAN) | ||
230 | ULONG *q; | ||
231 | int i; | ||
232 | #endif | ||
233 | |||
234 | #if defined(B_ENDIAN) || defined(L_ENDIAN) | ||
235 | memcpy(p,b,64); | ||
236 | #ifdef B_ENDIAN | ||
237 | q=p; | ||
238 | for (i=(RIPEMD160_LBLOCK/4); i; i--) | ||
239 | { | ||
240 | Endian_Reverse32(q[0]); | ||
241 | Endian_Reverse32(q[1]); | ||
242 | Endian_Reverse32(q[2]); | ||
243 | Endian_Reverse32(q[3]); | ||
244 | q+=4; | ||
245 | } | ||
246 | #endif | ||
247 | #else | ||
248 | q=p; | ||
249 | for (i=(RIPEMD160_LBLOCK/4); i; i--) | ||
250 | { | ||
251 | ULONG l; | ||
252 | c2l(b,l); *(q++)=l; | ||
253 | c2l(b,l); *(q++)=l; | ||
254 | c2l(b,l); *(q++)=l; | ||
255 | c2l(b,l); *(q++)=l; | ||
256 | } | ||
257 | #endif | ||
258 | ripemd160_block(c,p,64); | ||
259 | } | ||
260 | |||
261 | #ifndef RMD160_ASM | ||
262 | |||
263 | void ripemd160_block(ctx, X, num) | ||
264 | RIPEMD160_CTX *ctx; | ||
265 | register ULONG *X; | ||
266 | int num; | ||
267 | { | ||
268 | register ULONG A,B,C,D,E; | ||
269 | ULONG a,b,c,d,e; | ||
270 | |||
271 | for (;;) | ||
272 | { | ||
273 | A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; | ||
274 | |||
275 | RIP1(A,B,C,D,E,WL00,SL00); | ||
276 | RIP1(E,A,B,C,D,WL01,SL01); | ||
277 | RIP1(D,E,A,B,C,WL02,SL02); | ||
278 | RIP1(C,D,E,A,B,WL03,SL03); | ||
279 | RIP1(B,C,D,E,A,WL04,SL04); | ||
280 | RIP1(A,B,C,D,E,WL05,SL05); | ||
281 | RIP1(E,A,B,C,D,WL06,SL06); | ||
282 | RIP1(D,E,A,B,C,WL07,SL07); | ||
283 | RIP1(C,D,E,A,B,WL08,SL08); | ||
284 | RIP1(B,C,D,E,A,WL09,SL09); | ||
285 | RIP1(A,B,C,D,E,WL10,SL10); | ||
286 | RIP1(E,A,B,C,D,WL11,SL11); | ||
287 | RIP1(D,E,A,B,C,WL12,SL12); | ||
288 | RIP1(C,D,E,A,B,WL13,SL13); | ||
289 | RIP1(B,C,D,E,A,WL14,SL14); | ||
290 | RIP1(A,B,C,D,E,WL15,SL15); | ||
291 | |||
292 | RIP2(E,A,B,C,D,WL16,SL16,KL1); | ||
293 | RIP2(D,E,A,B,C,WL17,SL17,KL1); | ||
294 | RIP2(C,D,E,A,B,WL18,SL18,KL1); | ||
295 | RIP2(B,C,D,E,A,WL19,SL19,KL1); | ||
296 | RIP2(A,B,C,D,E,WL20,SL20,KL1); | ||
297 | RIP2(E,A,B,C,D,WL21,SL21,KL1); | ||
298 | RIP2(D,E,A,B,C,WL22,SL22,KL1); | ||
299 | RIP2(C,D,E,A,B,WL23,SL23,KL1); | ||
300 | RIP2(B,C,D,E,A,WL24,SL24,KL1); | ||
301 | RIP2(A,B,C,D,E,WL25,SL25,KL1); | ||
302 | RIP2(E,A,B,C,D,WL26,SL26,KL1); | ||
303 | RIP2(D,E,A,B,C,WL27,SL27,KL1); | ||
304 | RIP2(C,D,E,A,B,WL28,SL28,KL1); | ||
305 | RIP2(B,C,D,E,A,WL29,SL29,KL1); | ||
306 | RIP2(A,B,C,D,E,WL30,SL30,KL1); | ||
307 | RIP2(E,A,B,C,D,WL31,SL31,KL1); | ||
308 | |||
309 | RIP3(D,E,A,B,C,WL32,SL32,KL2); | ||
310 | RIP3(C,D,E,A,B,WL33,SL33,KL2); | ||
311 | RIP3(B,C,D,E,A,WL34,SL34,KL2); | ||
312 | RIP3(A,B,C,D,E,WL35,SL35,KL2); | ||
313 | RIP3(E,A,B,C,D,WL36,SL36,KL2); | ||
314 | RIP3(D,E,A,B,C,WL37,SL37,KL2); | ||
315 | RIP3(C,D,E,A,B,WL38,SL38,KL2); | ||
316 | RIP3(B,C,D,E,A,WL39,SL39,KL2); | ||
317 | RIP3(A,B,C,D,E,WL40,SL40,KL2); | ||
318 | RIP3(E,A,B,C,D,WL41,SL41,KL2); | ||
319 | RIP3(D,E,A,B,C,WL42,SL42,KL2); | ||
320 | RIP3(C,D,E,A,B,WL43,SL43,KL2); | ||
321 | RIP3(B,C,D,E,A,WL44,SL44,KL2); | ||
322 | RIP3(A,B,C,D,E,WL45,SL45,KL2); | ||
323 | RIP3(E,A,B,C,D,WL46,SL46,KL2); | ||
324 | RIP3(D,E,A,B,C,WL47,SL47,KL2); | ||
325 | |||
326 | RIP4(C,D,E,A,B,WL48,SL48,KL3); | ||
327 | RIP4(B,C,D,E,A,WL49,SL49,KL3); | ||
328 | RIP4(A,B,C,D,E,WL50,SL50,KL3); | ||
329 | RIP4(E,A,B,C,D,WL51,SL51,KL3); | ||
330 | RIP4(D,E,A,B,C,WL52,SL52,KL3); | ||
331 | RIP4(C,D,E,A,B,WL53,SL53,KL3); | ||
332 | RIP4(B,C,D,E,A,WL54,SL54,KL3); | ||
333 | RIP4(A,B,C,D,E,WL55,SL55,KL3); | ||
334 | RIP4(E,A,B,C,D,WL56,SL56,KL3); | ||
335 | RIP4(D,E,A,B,C,WL57,SL57,KL3); | ||
336 | RIP4(C,D,E,A,B,WL58,SL58,KL3); | ||
337 | RIP4(B,C,D,E,A,WL59,SL59,KL3); | ||
338 | RIP4(A,B,C,D,E,WL60,SL60,KL3); | ||
339 | RIP4(E,A,B,C,D,WL61,SL61,KL3); | ||
340 | RIP4(D,E,A,B,C,WL62,SL62,KL3); | ||
341 | RIP4(C,D,E,A,B,WL63,SL63,KL3); | ||
342 | |||
343 | RIP5(B,C,D,E,A,WL64,SL64,KL4); | ||
344 | RIP5(A,B,C,D,E,WL65,SL65,KL4); | ||
345 | RIP5(E,A,B,C,D,WL66,SL66,KL4); | ||
346 | RIP5(D,E,A,B,C,WL67,SL67,KL4); | ||
347 | RIP5(C,D,E,A,B,WL68,SL68,KL4); | ||
348 | RIP5(B,C,D,E,A,WL69,SL69,KL4); | ||
349 | RIP5(A,B,C,D,E,WL70,SL70,KL4); | ||
350 | RIP5(E,A,B,C,D,WL71,SL71,KL4); | ||
351 | RIP5(D,E,A,B,C,WL72,SL72,KL4); | ||
352 | RIP5(C,D,E,A,B,WL73,SL73,KL4); | ||
353 | RIP5(B,C,D,E,A,WL74,SL74,KL4); | ||
354 | RIP5(A,B,C,D,E,WL75,SL75,KL4); | ||
355 | RIP5(E,A,B,C,D,WL76,SL76,KL4); | ||
356 | RIP5(D,E,A,B,C,WL77,SL77,KL4); | ||
357 | RIP5(C,D,E,A,B,WL78,SL78,KL4); | ||
358 | RIP5(B,C,D,E,A,WL79,SL79,KL4); | ||
359 | |||
360 | a=A; b=B; c=C; d=D; e=E; | ||
361 | /* Do other half */ | ||
362 | A=ctx->A; B=ctx->B; C=ctx->C; D=ctx->D; E=ctx->E; | ||
363 | |||
364 | RIP5(A,B,C,D,E,WR00,SR00,KR0); | ||
365 | RIP5(E,A,B,C,D,WR01,SR01,KR0); | ||
366 | RIP5(D,E,A,B,C,WR02,SR02,KR0); | ||
367 | RIP5(C,D,E,A,B,WR03,SR03,KR0); | ||
368 | RIP5(B,C,D,E,A,WR04,SR04,KR0); | ||
369 | RIP5(A,B,C,D,E,WR05,SR05,KR0); | ||
370 | RIP5(E,A,B,C,D,WR06,SR06,KR0); | ||
371 | RIP5(D,E,A,B,C,WR07,SR07,KR0); | ||
372 | RIP5(C,D,E,A,B,WR08,SR08,KR0); | ||
373 | RIP5(B,C,D,E,A,WR09,SR09,KR0); | ||
374 | RIP5(A,B,C,D,E,WR10,SR10,KR0); | ||
375 | RIP5(E,A,B,C,D,WR11,SR11,KR0); | ||
376 | RIP5(D,E,A,B,C,WR12,SR12,KR0); | ||
377 | RIP5(C,D,E,A,B,WR13,SR13,KR0); | ||
378 | RIP5(B,C,D,E,A,WR14,SR14,KR0); | ||
379 | RIP5(A,B,C,D,E,WR15,SR15,KR0); | ||
380 | |||
381 | RIP4(E,A,B,C,D,WR16,SR16,KR1); | ||
382 | RIP4(D,E,A,B,C,WR17,SR17,KR1); | ||
383 | RIP4(C,D,E,A,B,WR18,SR18,KR1); | ||
384 | RIP4(B,C,D,E,A,WR19,SR19,KR1); | ||
385 | RIP4(A,B,C,D,E,WR20,SR20,KR1); | ||
386 | RIP4(E,A,B,C,D,WR21,SR21,KR1); | ||
387 | RIP4(D,E,A,B,C,WR22,SR22,KR1); | ||
388 | RIP4(C,D,E,A,B,WR23,SR23,KR1); | ||
389 | RIP4(B,C,D,E,A,WR24,SR24,KR1); | ||
390 | RIP4(A,B,C,D,E,WR25,SR25,KR1); | ||
391 | RIP4(E,A,B,C,D,WR26,SR26,KR1); | ||
392 | RIP4(D,E,A,B,C,WR27,SR27,KR1); | ||
393 | RIP4(C,D,E,A,B,WR28,SR28,KR1); | ||
394 | RIP4(B,C,D,E,A,WR29,SR29,KR1); | ||
395 | RIP4(A,B,C,D,E,WR30,SR30,KR1); | ||
396 | RIP4(E,A,B,C,D,WR31,SR31,KR1); | ||
397 | |||
398 | RIP3(D,E,A,B,C,WR32,SR32,KR2); | ||
399 | RIP3(C,D,E,A,B,WR33,SR33,KR2); | ||
400 | RIP3(B,C,D,E,A,WR34,SR34,KR2); | ||
401 | RIP3(A,B,C,D,E,WR35,SR35,KR2); | ||
402 | RIP3(E,A,B,C,D,WR36,SR36,KR2); | ||
403 | RIP3(D,E,A,B,C,WR37,SR37,KR2); | ||
404 | RIP3(C,D,E,A,B,WR38,SR38,KR2); | ||
405 | RIP3(B,C,D,E,A,WR39,SR39,KR2); | ||
406 | RIP3(A,B,C,D,E,WR40,SR40,KR2); | ||
407 | RIP3(E,A,B,C,D,WR41,SR41,KR2); | ||
408 | RIP3(D,E,A,B,C,WR42,SR42,KR2); | ||
409 | RIP3(C,D,E,A,B,WR43,SR43,KR2); | ||
410 | RIP3(B,C,D,E,A,WR44,SR44,KR2); | ||
411 | RIP3(A,B,C,D,E,WR45,SR45,KR2); | ||
412 | RIP3(E,A,B,C,D,WR46,SR46,KR2); | ||
413 | RIP3(D,E,A,B,C,WR47,SR47,KR2); | ||
414 | |||
415 | RIP2(C,D,E,A,B,WR48,SR48,KR3); | ||
416 | RIP2(B,C,D,E,A,WR49,SR49,KR3); | ||
417 | RIP2(A,B,C,D,E,WR50,SR50,KR3); | ||
418 | RIP2(E,A,B,C,D,WR51,SR51,KR3); | ||
419 | RIP2(D,E,A,B,C,WR52,SR52,KR3); | ||
420 | RIP2(C,D,E,A,B,WR53,SR53,KR3); | ||
421 | RIP2(B,C,D,E,A,WR54,SR54,KR3); | ||
422 | RIP2(A,B,C,D,E,WR55,SR55,KR3); | ||
423 | RIP2(E,A,B,C,D,WR56,SR56,KR3); | ||
424 | RIP2(D,E,A,B,C,WR57,SR57,KR3); | ||
425 | RIP2(C,D,E,A,B,WR58,SR58,KR3); | ||
426 | RIP2(B,C,D,E,A,WR59,SR59,KR3); | ||
427 | RIP2(A,B,C,D,E,WR60,SR60,KR3); | ||
428 | RIP2(E,A,B,C,D,WR61,SR61,KR3); | ||
429 | RIP2(D,E,A,B,C,WR62,SR62,KR3); | ||
430 | RIP2(C,D,E,A,B,WR63,SR63,KR3); | ||
431 | |||
432 | RIP1(B,C,D,E,A,WR64,SR64); | ||
433 | RIP1(A,B,C,D,E,WR65,SR65); | ||
434 | RIP1(E,A,B,C,D,WR66,SR66); | ||
435 | RIP1(D,E,A,B,C,WR67,SR67); | ||
436 | RIP1(C,D,E,A,B,WR68,SR68); | ||
437 | RIP1(B,C,D,E,A,WR69,SR69); | ||
438 | RIP1(A,B,C,D,E,WR70,SR70); | ||
439 | RIP1(E,A,B,C,D,WR71,SR71); | ||
440 | RIP1(D,E,A,B,C,WR72,SR72); | ||
441 | RIP1(C,D,E,A,B,WR73,SR73); | ||
442 | RIP1(B,C,D,E,A,WR74,SR74); | ||
443 | RIP1(A,B,C,D,E,WR75,SR75); | ||
444 | RIP1(E,A,B,C,D,WR76,SR76); | ||
445 | RIP1(D,E,A,B,C,WR77,SR77); | ||
446 | RIP1(C,D,E,A,B,WR78,SR78); | ||
447 | RIP1(B,C,D,E,A,WR79,SR79); | ||
448 | |||
449 | D =ctx->B+c+D; | ||
450 | ctx->B=ctx->C+d+E; | ||
451 | ctx->C=ctx->D+e+A; | ||
452 | ctx->D=ctx->E+a+B; | ||
453 | ctx->E=ctx->A+b+C; | ||
454 | ctx->A=D; | ||
455 | |||
456 | X+=16; | ||
457 | num-=64; | ||
458 | if (num <= 0) break; | ||
459 | } | ||
460 | } | ||
461 | #endif | ||
462 | |||
463 | void RIPEMD160_Final(md, c) | ||
464 | unsigned char *md; | ||
465 | RIPEMD160_CTX *c; | ||
466 | { | ||
467 | register int i,j; | ||
468 | register ULONG l; | ||
469 | register ULONG *p; | ||
470 | static unsigned char end[4]={0x80,0x00,0x00,0x00}; | ||
471 | unsigned char *cp=end; | ||
472 | |||
473 | /* c->num should definitly have room for at least one more byte. */ | ||
474 | p=c->data; | ||
475 | j=c->num; | ||
476 | i=j>>2; | ||
477 | |||
478 | /* purify often complains about the following line as an | ||
479 | * Uninitialized Memory Read. While this can be true, the | ||
480 | * following p_c2l macro will reset l when that case is true. | ||
481 | * This is because j&0x03 contains the number of 'valid' bytes | ||
482 | * already in p[i]. If and only if j&0x03 == 0, the UMR will | ||
483 | * occur but this is also the only time p_c2l will do | ||
484 | * l= *(cp++) instead of l|= *(cp++) | ||
485 | * Many thanks to Alex Tang <altitude@cic.net> for pickup this | ||
486 | * 'potential bug' */ | ||
487 | #ifdef PURIFY | ||
488 | if ((j&0x03) == 0) p[i]=0; | ||
489 | #endif | ||
490 | l=p[i]; | ||
491 | p_c2l(cp,l,j&0x03); | ||
492 | p[i]=l; | ||
493 | i++; | ||
494 | /* i is the next 'undefined word' */ | ||
495 | if (c->num >= RIPEMD160_LAST_BLOCK) | ||
496 | { | ||
497 | for (; i<RIPEMD160_LBLOCK; i++) | ||
498 | p[i]=0; | ||
499 | ripemd160_block(c,p,64); | ||
500 | i=0; | ||
501 | } | ||
502 | for (; i<(RIPEMD160_LBLOCK-2); i++) | ||
503 | p[i]=0; | ||
504 | p[RIPEMD160_LBLOCK-2]=c->Nl; | ||
505 | p[RIPEMD160_LBLOCK-1]=c->Nh; | ||
506 | ripemd160_block(c,p,64); | ||
507 | cp=md; | ||
508 | l=c->A; l2c(l,cp); | ||
509 | l=c->B; l2c(l,cp); | ||
510 | l=c->C; l2c(l,cp); | ||
511 | l=c->D; l2c(l,cp); | ||
512 | l=c->E; l2c(l,cp); | ||
513 | |||
514 | /* clear stuff, ripemd160_block may be leaving some stuff on the stack | ||
515 | * but I'm not worried :-) */ | ||
516 | c->num=0; | ||
517 | /* memset((char *)&c,0,sizeof(c));*/ | ||
518 | } | ||
519 | |||
520 | #ifdef undef | ||
521 | int printit(l) | ||
522 | unsigned long *l; | ||
523 | { | ||
524 | int i,ii; | ||
525 | |||
526 | for (i=0; i<2; i++) | ||
527 | { | ||
528 | for (ii=0; ii<8; ii++) | ||
529 | { | ||
530 | fprintf(stderr,"%08lx ",l[i*8+ii]); | ||
531 | } | ||
532 | fprintf(stderr,"\n"); | ||
533 | } | ||
534 | } | ||
535 | #endif | ||
diff --git a/src/lib/libcrypto/ripemd/rmd_locl.h b/src/lib/libcrypto/ripemd/rmd_locl.h new file mode 100644 index 0000000000..a1feccf7c1 --- /dev/null +++ b/src/lib/libcrypto/ripemd/rmd_locl.h | |||
@@ -0,0 +1,226 @@ | |||
1 | /* crypto/ripemd/rmd_locl.h */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdlib.h> | ||
60 | #include <string.h> | ||
61 | #include "ripemd.h" | ||
62 | |||
63 | #define ULONG unsigned long | ||
64 | #define UCHAR unsigned char | ||
65 | #define UINT unsigned int | ||
66 | |||
67 | #ifdef NOCONST | ||
68 | #define const | ||
69 | #endif | ||
70 | |||
71 | #undef c2nl | ||
72 | #define c2nl(c,l) (l =(((unsigned long)(*((c)++)))<<24), \ | ||
73 | l|=(((unsigned long)(*((c)++)))<<16), \ | ||
74 | l|=(((unsigned long)(*((c)++)))<< 8), \ | ||
75 | l|=(((unsigned long)(*((c)++))) )) | ||
76 | |||
77 | #undef p_c2nl | ||
78 | #define p_c2nl(c,l,n) { \ | ||
79 | switch (n) { \ | ||
80 | case 0: l =((unsigned long)(*((c)++)))<<24; \ | ||
81 | case 1: l|=((unsigned long)(*((c)++)))<<16; \ | ||
82 | case 2: l|=((unsigned long)(*((c)++)))<< 8; \ | ||
83 | case 3: l|=((unsigned long)(*((c)++))); \ | ||
84 | } \ | ||
85 | } | ||
86 | |||
87 | #undef c2nl_p | ||
88 | /* NOTE the pointer is not incremented at the end of this */ | ||
89 | #define c2nl_p(c,l,n) { \ | ||
90 | l=0; \ | ||
91 | (c)+=n; \ | ||
92 | switch (n) { \ | ||
93 | case 3: l =((unsigned long)(*(--(c))))<< 8; \ | ||
94 | case 2: l|=((unsigned long)(*(--(c))))<<16; \ | ||
95 | case 1: l|=((unsigned long)(*(--(c))))<<24; \ | ||
96 | } \ | ||
97 | } | ||
98 | |||
99 | #undef p_c2nl_p | ||
100 | #define p_c2nl_p(c,l,sc,len) { \ | ||
101 | switch (sc) \ | ||
102 | { \ | ||
103 | case 0: l =((unsigned long)(*((c)++)))<<24; \ | ||
104 | if (--len == 0) break; \ | ||
105 | case 1: l|=((unsigned long)(*((c)++)))<<16; \ | ||
106 | if (--len == 0) break; \ | ||
107 | case 2: l|=((unsigned long)(*((c)++)))<< 8; \ | ||
108 | } \ | ||
109 | } | ||
110 | |||
111 | #undef nl2c | ||
112 | #define nl2c(l,c) (*((c)++)=(unsigned char)(((l)>>24)&0xff), \ | ||
113 | *((c)++)=(unsigned char)(((l)>>16)&0xff), \ | ||
114 | *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ | ||
115 | *((c)++)=(unsigned char)(((l) )&0xff)) | ||
116 | |||
117 | #undef c2l | ||
118 | #define c2l(c,l) (l =(((unsigned long)(*((c)++))) ), \ | ||
119 | l|=(((unsigned long)(*((c)++)))<< 8), \ | ||
120 | l|=(((unsigned long)(*((c)++)))<<16), \ | ||
121 | l|=(((unsigned long)(*((c)++)))<<24)) | ||
122 | |||
123 | #undef p_c2l | ||
124 | #define p_c2l(c,l,n) { \ | ||
125 | switch (n) { \ | ||
126 | case 0: l =((unsigned long)(*((c)++))); \ | ||
127 | case 1: l|=((unsigned long)(*((c)++)))<< 8; \ | ||
128 | case 2: l|=((unsigned long)(*((c)++)))<<16; \ | ||
129 | case 3: l|=((unsigned long)(*((c)++)))<<24; \ | ||
130 | } \ | ||
131 | } | ||
132 | |||
133 | #undef c2l_p | ||
134 | /* NOTE the pointer is not incremented at the end of this */ | ||
135 | #define c2l_p(c,l,n) { \ | ||
136 | l=0; \ | ||
137 | (c)+=n; \ | ||
138 | switch (n) { \ | ||
139 | case 3: l =((unsigned long)(*(--(c))))<<16; \ | ||
140 | case 2: l|=((unsigned long)(*(--(c))))<< 8; \ | ||
141 | case 1: l|=((unsigned long)(*(--(c)))); \ | ||
142 | } \ | ||
143 | } | ||
144 | |||
145 | #undef p_c2l_p | ||
146 | #define p_c2l_p(c,l,sc,len) { \ | ||
147 | switch (sc) \ | ||
148 | { \ | ||
149 | case 0: l =((unsigned long)(*((c)++))); \ | ||
150 | if (--len == 0) break; \ | ||
151 | case 1: l|=((unsigned long)(*((c)++)))<< 8; \ | ||
152 | if (--len == 0) break; \ | ||
153 | case 2: l|=((unsigned long)(*((c)++)))<<16; \ | ||
154 | } \ | ||
155 | } | ||
156 | |||
157 | #undef l2c | ||
158 | #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ | ||
159 | *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ | ||
160 | *((c)++)=(unsigned char)(((l)>>16)&0xff), \ | ||
161 | *((c)++)=(unsigned char)(((l)>>24)&0xff)) | ||
162 | |||
163 | #undef ROTATE | ||
164 | #if defined(WIN32) | ||
165 | #define ROTATE(a,n) _lrotl(a,n) | ||
166 | #else | ||
167 | #define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n)))) | ||
168 | #endif | ||
169 | |||
170 | /* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */ | ||
171 | #if defined(WIN32) | ||
172 | /* 5 instructions with rotate instruction, else 9 */ | ||
173 | #define Endian_Reverse32(a) \ | ||
174 | { \ | ||
175 | unsigned long l=(a); \ | ||
176 | (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \ | ||
177 | } | ||
178 | #else | ||
179 | /* 6 instructions with rotate instruction, else 8 */ | ||
180 | #define Endian_Reverse32(a) \ | ||
181 | { \ | ||
182 | unsigned long l=(a); \ | ||
183 | l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \ | ||
184 | (a)=ROTATE(l,16L); \ | ||
185 | } | ||
186 | #endif | ||
187 | |||
188 | #define F1(x,y,z) ((x)^(y)^(z)) | ||
189 | #define F2(x,y,z) (((x)&(y))|((~x)&z)) | ||
190 | #define F3(x,y,z) (((x)|(~y))^(z)) | ||
191 | #define F4(x,y,z) (((x)&(z))|((y)&(~(z)))) | ||
192 | #define F5(x,y,z) ((x)^((y)|(~(z)))) | ||
193 | |||
194 | #define RIPEMD160_A 0x67452301L | ||
195 | #define RIPEMD160_B 0xEFCDAB89L | ||
196 | #define RIPEMD160_C 0x98BADCFEL | ||
197 | #define RIPEMD160_D 0x10325476L | ||
198 | #define RIPEMD160_E 0xC3D2E1F0L | ||
199 | |||
200 | #include "rmdconst.h" | ||
201 | |||
202 | #define RIP1(a,b,c,d,e,w,s) { \ | ||
203 | a+=F1(b,c,d)+X[w]; \ | ||
204 | a=ROTATE(a,s)+e; \ | ||
205 | c=ROTATE(c,10); } | ||
206 | |||
207 | #define RIP2(a,b,c,d,e,w,s,K) { \ | ||
208 | a+=F2(b,c,d)+X[w]+K; \ | ||
209 | a=ROTATE(a,s)+e; \ | ||
210 | c=ROTATE(c,10); } | ||
211 | |||
212 | #define RIP3(a,b,c,d,e,w,s,K) { \ | ||
213 | a+=F3(b,c,d)+X[w]+K; \ | ||
214 | a=ROTATE(a,s)+e; \ | ||
215 | c=ROTATE(c,10); } | ||
216 | |||
217 | #define RIP4(a,b,c,d,e,w,s,K) { \ | ||
218 | a+=F4(b,c,d)+X[w]+K; \ | ||
219 | a=ROTATE(a,s)+e; \ | ||
220 | c=ROTATE(c,10); } | ||
221 | |||
222 | #define RIP5(a,b,c,d,e,w,s,K) { \ | ||
223 | a+=F5(b,c,d)+X[w]+K; \ | ||
224 | a=ROTATE(a,s)+e; \ | ||
225 | c=ROTATE(c,10); } | ||
226 | |||
diff --git a/src/lib/libcrypto/ripemd/rmd_one.c b/src/lib/libcrypto/ripemd/rmd_one.c new file mode 100644 index 0000000000..a7626dbcda --- /dev/null +++ b/src/lib/libcrypto/ripemd/rmd_one.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /* crypto/ripemd/rmd_one.c */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | |||
59 | #include <stdio.h> | ||
60 | #include "rmd_locl.h" | ||
61 | |||
62 | unsigned char *RIPEMD160(d, n, md) | ||
63 | unsigned char *d; | ||
64 | unsigned long n; | ||
65 | unsigned char *md; | ||
66 | { | ||
67 | RIPEMD160_CTX c; | ||
68 | static unsigned char m[RIPEMD160_DIGEST_LENGTH]; | ||
69 | |||
70 | if (md == NULL) md=m; | ||
71 | RIPEMD160_Init(&c); | ||
72 | RIPEMD160_Update(&c,d,n); | ||
73 | RIPEMD160_Final(md,&c); | ||
74 | memset(&c,0,sizeof(c)); /* security consideration */ | ||
75 | return(md); | ||
76 | } | ||
77 | |||
diff --git a/src/lib/libcrypto/ripemd/rmdconst.h b/src/lib/libcrypto/ripemd/rmdconst.h new file mode 100644 index 0000000000..59c48dead1 --- /dev/null +++ b/src/lib/libcrypto/ripemd/rmdconst.h | |||
@@ -0,0 +1,399 @@ | |||
1 | /* crypto/ripemd/rmdconst.h */ | ||
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * This package is an SSL implementation written | ||
6 | * by Eric Young (eay@cryptsoft.com). | ||
7 | * The implementation was written so as to conform with Netscapes SSL. | ||
8 | * | ||
9 | * This library is free for commercial and non-commercial use as long as | ||
10 | * the following conditions are aheared to. The following conditions | ||
11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
13 | * included with this distribution is covered by the same copyright terms | ||
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
15 | * | ||
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
17 | * the code are not to be removed. | ||
18 | * If this package is used in a product, Eric Young should be given attribution | ||
19 | * as the author of the parts of the library used. | ||
20 | * This can be in the form of a textual message at program startup or | ||
21 | * in documentation (online or textual) provided with the package. | ||
22 | * | ||
23 | * Redistribution and use in source and binary forms, with or without | ||
24 | * modification, are permitted provided that the following conditions | ||
25 | * are met: | ||
26 | * 1. Redistributions of source code must retain the copyright | ||
27 | * notice, this list of conditions and the following disclaimer. | ||
28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
29 | * notice, this list of conditions and the following disclaimer in the | ||
30 | * documentation and/or other materials provided with the distribution. | ||
31 | * 3. All advertising materials mentioning features or use of this software | ||
32 | * must display the following acknowledgement: | ||
33 | * "This product includes cryptographic software written by | ||
34 | * Eric Young (eay@cryptsoft.com)" | ||
35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
36 | * being used are not cryptographic related :-). | ||
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
38 | * the apps directory (application code) you must include an acknowledgement: | ||
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
40 | * | ||
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
51 | * SUCH DAMAGE. | ||
52 | * | ||
53 | * The licence and distribution terms for any publically available version or | ||
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
55 | * copied and put under another distribution licence | ||
56 | * [including the GNU Public Licence.] | ||
57 | */ | ||
58 | #define KL0 0x00000000L | ||
59 | #define KL1 0x5A827999L | ||
60 | #define KL2 0x6ED9EBA1L | ||
61 | #define KL3 0x8F1BBCDCL | ||
62 | #define KL4 0xA953FD4EL | ||
63 | |||
64 | #define KR0 0x50A28BE6L | ||
65 | #define KR1 0x5C4DD124L | ||
66 | #define KR2 0x6D703EF3L | ||
67 | #define KR3 0x7A6D76E9L | ||
68 | #define KR4 0x00000000L | ||
69 | |||
70 | #define WL00 0 | ||
71 | #define SL00 11 | ||
72 | #define WL01 1 | ||
73 | #define SL01 14 | ||
74 | #define WL02 2 | ||
75 | #define SL02 15 | ||
76 | #define WL03 3 | ||
77 | #define SL03 12 | ||
78 | #define WL04 4 | ||
79 | #define SL04 5 | ||
80 | #define WL05 5 | ||
81 | #define SL05 8 | ||
82 | #define WL06 6 | ||
83 | #define SL06 7 | ||
84 | #define WL07 7 | ||
85 | #define SL07 9 | ||
86 | #define WL08 8 | ||
87 | #define SL08 11 | ||
88 | #define WL09 9 | ||
89 | #define SL09 13 | ||
90 | #define WL10 10 | ||
91 | #define SL10 14 | ||
92 | #define WL11 11 | ||
93 | #define SL11 15 | ||
94 | #define WL12 12 | ||
95 | #define SL12 6 | ||
96 | #define WL13 13 | ||
97 | #define SL13 7 | ||
98 | #define WL14 14 | ||
99 | #define SL14 9 | ||
100 | #define WL15 15 | ||
101 | #define SL15 8 | ||
102 | |||
103 | #define WL16 7 | ||
104 | #define SL16 7 | ||
105 | #define WL17 4 | ||
106 | #define SL17 6 | ||
107 | #define WL18 13 | ||
108 | #define SL18 8 | ||
109 | #define WL19 1 | ||
110 | #define SL19 13 | ||
111 | #define WL20 10 | ||
112 | #define SL20 11 | ||
113 | #define WL21 6 | ||
114 | #define SL21 9 | ||
115 | #define WL22 15 | ||
116 | #define SL22 7 | ||
117 | #define WL23 3 | ||
118 | #define SL23 15 | ||
119 | #define WL24 12 | ||
120 | #define SL24 7 | ||
121 | #define WL25 0 | ||
122 | #define SL25 12 | ||
123 | #define WL26 9 | ||
124 | #define SL26 15 | ||
125 | #define WL27 5 | ||
126 | #define SL27 9 | ||
127 | #define WL28 2 | ||
128 | #define SL28 11 | ||
129 | #define WL29 14 | ||
130 | #define SL29 7 | ||
131 | #define WL30 11 | ||
132 | #define SL30 13 | ||
133 | #define WL31 8 | ||
134 | #define SL31 12 | ||
135 | |||
136 | #define WL32 3 | ||
137 | #define SL32 11 | ||
138 | #define WL33 10 | ||
139 | #define SL33 13 | ||
140 | #define WL34 14 | ||
141 | #define SL34 6 | ||
142 | #define WL35 4 | ||
143 | #define SL35 7 | ||
144 | #define WL36 9 | ||
145 | #define SL36 14 | ||
146 | #define WL37 15 | ||
147 | #define SL37 9 | ||
148 | #define WL38 8 | ||
149 | #define SL38 13 | ||
150 | #define WL39 1 | ||
151 | #define SL39 15 | ||
152 | #define WL40 2 | ||
153 | #define SL40 14 | ||
154 | #define WL41 7 | ||
155 | #define SL41 8 | ||
156 | #define WL42 0 | ||
157 | #define SL42 13 | ||
158 | #define WL43 6 | ||
159 | #define SL43 6 | ||
160 | #define WL44 13 | ||
161 | #define SL44 5 | ||
162 | #define WL45 11 | ||
163 | #define SL45 12 | ||
164 | #define WL46 5 | ||
165 | #define SL46 7 | ||
166 | #define WL47 12 | ||
167 | #define SL47 5 | ||
168 | |||
169 | #define WL48 1 | ||
170 | #define SL48 11 | ||
171 | #define WL49 9 | ||
172 | #define SL49 12 | ||
173 | #define WL50 11 | ||
174 | #define SL50 14 | ||
175 | #define WL51 10 | ||
176 | #define SL51 15 | ||
177 | #define WL52 0 | ||
178 | #define SL52 14 | ||
179 | #define WL53 8 | ||
180 | #define SL53 15 | ||
181 | #define WL54 12 | ||
182 | #define SL54 9 | ||
183 | #define WL55 4 | ||
184 | #define SL55 8 | ||
185 | #define WL56 13 | ||
186 | #define SL56 9 | ||
187 | #define WL57 3 | ||
188 | #define SL57 14 | ||
189 | #define WL58 7 | ||
190 | #define SL58 5 | ||
191 | #define WL59 15 | ||
192 | #define SL59 6 | ||
193 | #define WL60 14 | ||
194 | #define SL60 8 | ||
195 | #define WL61 5 | ||
196 | #define SL61 6 | ||
197 | #define WL62 6 | ||
198 | #define SL62 5 | ||
199 | #define WL63 2 | ||
200 | #define SL63 12 | ||
201 | |||
202 | #define WL64 4 | ||
203 | #define SL64 9 | ||
204 | #define WL65 0 | ||
205 | #define SL65 15 | ||
206 | #define WL66 5 | ||
207 | #define SL66 5 | ||
208 | #define WL67 9 | ||
209 | #define SL67 11 | ||
210 | #define WL68 7 | ||
211 | #define SL68 6 | ||
212 | #define WL69 12 | ||
213 | #define SL69 8 | ||
214 | #define WL70 2 | ||
215 | #define SL70 13 | ||
216 | #define WL71 10 | ||
217 | #define SL71 12 | ||
218 | #define WL72 14 | ||
219 | #define SL72 5 | ||
220 | #define WL73 1 | ||
221 | #define SL73 12 | ||
222 | #define WL74 3 | ||
223 | #define SL74 13 | ||
224 | #define WL75 8 | ||
225 | #define SL75 14 | ||
226 | #define WL76 11 | ||
227 | #define SL76 11 | ||
228 | #define WL77 6 | ||
229 | #define SL77 8 | ||
230 | #define WL78 15 | ||
231 | #define SL78 5 | ||
232 | #define WL79 13 | ||
233 | #define SL79 6 | ||
234 | |||
235 | #define WR00 5 | ||
236 | #define SR00 8 | ||
237 | #define WR01 14 | ||
238 | #define SR01 9 | ||
239 | #define WR02 7 | ||
240 | #define SR02 9 | ||
241 | #define WR03 0 | ||
242 | #define SR03 11 | ||
243 | #define WR04 9 | ||
244 | #define SR04 13 | ||
245 | #define WR05 2 | ||
246 | #define SR05 15 | ||
247 | #define WR06 11 | ||
248 | #define SR06 15 | ||
249 | #define WR07 4 | ||
250 | #define SR07 5 | ||
251 | #define WR08 13 | ||
252 | #define SR08 7 | ||
253 | #define WR09 6 | ||
254 | #define SR09 7 | ||
255 | #define WR10 15 | ||
256 | #define SR10 8 | ||
257 | #define WR11 8 | ||
258 | #define SR11 11 | ||
259 | #define WR12 1 | ||
260 | #define SR12 14 | ||
261 | #define WR13 10 | ||
262 | #define SR13 14 | ||
263 | #define WR14 3 | ||
264 | #define SR14 12 | ||
265 | #define WR15 12 | ||
266 | #define SR15 6 | ||
267 | |||
268 | #define WR16 6 | ||
269 | #define SR16 9 | ||
270 | #define WR17 11 | ||
271 | #define SR17 13 | ||
272 | #define WR18 3 | ||
273 | #define SR18 15 | ||
274 | #define WR19 7 | ||
275 | #define SR19 7 | ||
276 | #define WR20 0 | ||
277 | #define SR20 12 | ||
278 | #define WR21 13 | ||
279 | #define SR21 8 | ||
280 | #define WR22 5 | ||
281 | #define SR22 9 | ||
282 | #define WR23 10 | ||
283 | #define SR23 11 | ||
284 | #define WR24 14 | ||
285 | #define SR24 7 | ||
286 | #define WR25 15 | ||
287 | #define SR25 7 | ||
288 | #define WR26 8 | ||
289 | #define SR26 12 | ||
290 | #define WR27 12 | ||
291 | #define SR27 7 | ||
292 | #define WR28 4 | ||
293 | #define SR28 6 | ||
294 | #define WR29 9 | ||
295 | #define SR29 15 | ||
296 | #define WR30 1 | ||
297 | #define SR30 13 | ||
298 | #define WR31 2 | ||
299 | #define SR31 11 | ||
300 | |||
301 | #define WR32 15 | ||
302 | #define SR32 9 | ||
303 | #define WR33 5 | ||
304 | #define SR33 7 | ||
305 | #define WR34 1 | ||
306 | #define SR34 15 | ||
307 | #define WR35 3 | ||
308 | #define SR35 11 | ||
309 | #define WR36 7 | ||
310 | #define SR36 8 | ||
311 | #define WR37 14 | ||
312 | #define SR37 6 | ||
313 | #define WR38 6 | ||
314 | #define SR38 6 | ||
315 | #define WR39 9 | ||
316 | #define SR39 14 | ||
317 | #define WR40 11 | ||
318 | #define SR40 12 | ||
319 | #define WR41 8 | ||
320 | #define SR41 13 | ||
321 | #define WR42 12 | ||
322 | #define SR42 5 | ||
323 | #define WR43 2 | ||
324 | #define SR43 14 | ||
325 | #define WR44 10 | ||
326 | #define SR44 13 | ||
327 | #define WR45 0 | ||
328 | #define SR45 13 | ||
329 | #define WR46 4 | ||
330 | #define SR46 7 | ||
331 | #define WR47 13 | ||
332 | #define SR47 5 | ||
333 | |||
334 | #define WR48 8 | ||
335 | #define SR48 15 | ||
336 | #define WR49 6 | ||
337 | #define SR49 5 | ||
338 | #define WR50 4 | ||
339 | #define SR50 8 | ||
340 | #define WR51 1 | ||
341 | #define SR51 11 | ||
342 | #define WR52 3 | ||
343 | #define SR52 14 | ||
344 | #define WR53 11 | ||
345 | #define SR53 14 | ||
346 | #define WR54 15 | ||
347 | #define SR54 6 | ||
348 | #define WR55 0 | ||
349 | #define SR55 14 | ||
350 | #define WR56 5 | ||
351 | #define SR56 6 | ||
352 | #define WR57 12 | ||
353 | #define SR57 9 | ||
354 | #define WR58 2 | ||
355 | #define SR58 12 | ||
356 | #define WR59 13 | ||
357 | #define SR59 9 | ||
358 | #define WR60 9 | ||
359 | #define SR60 12 | ||
360 | #define WR61 7 | ||
361 | #define SR61 5 | ||
362 | #define WR62 10 | ||
363 | #define SR62 15 | ||
364 | #define WR63 14 | ||
365 | #define SR63 8 | ||
366 | |||
367 | #define WR64 12 | ||
368 | #define SR64 8 | ||
369 | #define WR65 15 | ||
370 | #define SR65 5 | ||
371 | #define WR66 10 | ||
372 | #define SR66 12 | ||
373 | #define WR67 4 | ||
374 | #define SR67 9 | ||
375 | #define WR68 1 | ||
376 | #define SR68 12 | ||
377 | #define WR69 5 | ||
378 | #define SR69 5 | ||
379 | #define WR70 8 | ||
380 | #define SR70 14 | ||
381 | #define WR71 7 | ||
382 | #define SR71 6 | ||
383 | #define WR72 6 | ||
384 | #define SR72 8 | ||
385 | #define WR73 2 | ||
386 | #define SR73 13 | ||
387 | #define WR74 13 | ||
388 | #define SR74 6 | ||
389 | #define WR75 14 | ||
390 | #define SR75 5 | ||
391 | #define WR76 0 | ||
392 | #define SR76 15 | ||
393 | #define WR77 3 | ||
394 | #define SR77 13 | ||
395 | #define WR78 9 | ||
396 | #define SR78 11 | ||
397 | #define WR79 11 | ||
398 | #define SR79 11 | ||
399 | |||