diff options
Diffstat (limited to 'src/lib/libcrypto/cast/asm/c-win32.asm')
-rw-r--r-- | src/lib/libcrypto/cast/asm/c-win32.asm | 953 |
1 files changed, 0 insertions, 953 deletions
diff --git a/src/lib/libcrypto/cast/asm/c-win32.asm b/src/lib/libcrypto/cast/asm/c-win32.asm index ba78a3c69c..e69de29bb2 100644 --- a/src/lib/libcrypto/cast/asm/c-win32.asm +++ b/src/lib/libcrypto/cast/asm/c-win32.asm | |||
@@ -1,953 +0,0 @@ | |||
1 | ; Don't even think of reading this code | ||
2 | ; It was automatically generated by cast-586.pl | ||
3 | ; Which is a perl program used to generate the x86 assember for | ||
4 | ; any of elf, a.out, BSDI,Win32, or Solaris | ||
5 | ; eric <eay@cryptsoft.com> | ||
6 | ; | ||
7 | TITLE cast-586.asm | ||
8 | .486 | ||
9 | .model FLAT | ||
10 | _TEXT SEGMENT | ||
11 | PUBLIC _CAST_encrypt | ||
12 | EXTERN _CAST_S_table0:DWORD | ||
13 | EXTERN _CAST_S_table1:DWORD | ||
14 | EXTERN _CAST_S_table2:DWORD | ||
15 | EXTERN _CAST_S_table3:DWORD | ||
16 | |||
17 | _CAST_encrypt PROC NEAR | ||
18 | ; | ||
19 | push ebp | ||
20 | push ebx | ||
21 | mov ebx, DWORD PTR 12[esp] | ||
22 | mov ebp, DWORD PTR 16[esp] | ||
23 | push esi | ||
24 | push edi | ||
25 | ; Load the 2 words | ||
26 | mov edi, DWORD PTR [ebx] | ||
27 | mov esi, DWORD PTR 4[ebx] | ||
28 | ; Get short key flag | ||
29 | mov eax, DWORD PTR 128[ebp] | ||
30 | push eax | ||
31 | xor eax, eax | ||
32 | ; round 0 | ||
33 | mov edx, DWORD PTR [ebp] | ||
34 | mov ecx, DWORD PTR 4[ebp] | ||
35 | add edx, esi | ||
36 | rol edx, cl | ||
37 | mov ebx, edx | ||
38 | xor ecx, ecx | ||
39 | mov cl, dh | ||
40 | and ebx, 255 | ||
41 | shr edx, 16 | ||
42 | xor eax, eax | ||
43 | mov al, dh | ||
44 | and edx, 255 | ||
45 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
46 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
47 | xor ecx, ebx | ||
48 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
49 | sub ecx, ebx | ||
50 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
51 | add ecx, ebx | ||
52 | xor edi, ecx | ||
53 | ; round 1 | ||
54 | mov edx, DWORD PTR 8[ebp] | ||
55 | mov ecx, DWORD PTR 12[ebp] | ||
56 | xor edx, edi | ||
57 | rol edx, cl | ||
58 | mov ebx, edx | ||
59 | xor ecx, ecx | ||
60 | mov cl, dh | ||
61 | and ebx, 255 | ||
62 | shr edx, 16 | ||
63 | xor eax, eax | ||
64 | mov al, dh | ||
65 | and edx, 255 | ||
66 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
67 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
68 | sub ecx, ebx | ||
69 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
70 | add ecx, ebx | ||
71 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
72 | xor ecx, ebx | ||
73 | xor esi, ecx | ||
74 | ; round 2 | ||
75 | mov edx, DWORD PTR 16[ebp] | ||
76 | mov ecx, DWORD PTR 20[ebp] | ||
77 | sub edx, esi | ||
78 | rol edx, cl | ||
79 | mov ebx, edx | ||
80 | xor ecx, ecx | ||
81 | mov cl, dh | ||
82 | and ebx, 255 | ||
83 | shr edx, 16 | ||
84 | xor eax, eax | ||
85 | mov al, dh | ||
86 | and edx, 255 | ||
87 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
88 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
89 | add ecx, ebx | ||
90 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
91 | xor ecx, ebx | ||
92 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
93 | sub ecx, ebx | ||
94 | xor edi, ecx | ||
95 | ; round 3 | ||
96 | mov edx, DWORD PTR 24[ebp] | ||
97 | mov ecx, DWORD PTR 28[ebp] | ||
98 | add edx, edi | ||
99 | rol edx, cl | ||
100 | mov ebx, edx | ||
101 | xor ecx, ecx | ||
102 | mov cl, dh | ||
103 | and ebx, 255 | ||
104 | shr edx, 16 | ||
105 | xor eax, eax | ||
106 | mov al, dh | ||
107 | and edx, 255 | ||
108 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
109 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
110 | xor ecx, ebx | ||
111 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
112 | sub ecx, ebx | ||
113 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
114 | add ecx, ebx | ||
115 | xor esi, ecx | ||
116 | ; round 4 | ||
117 | mov edx, DWORD PTR 32[ebp] | ||
118 | mov ecx, DWORD PTR 36[ebp] | ||
119 | xor edx, esi | ||
120 | rol edx, cl | ||
121 | mov ebx, edx | ||
122 | xor ecx, ecx | ||
123 | mov cl, dh | ||
124 | and ebx, 255 | ||
125 | shr edx, 16 | ||
126 | xor eax, eax | ||
127 | mov al, dh | ||
128 | and edx, 255 | ||
129 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
130 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
131 | sub ecx, ebx | ||
132 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
133 | add ecx, ebx | ||
134 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
135 | xor ecx, ebx | ||
136 | xor edi, ecx | ||
137 | ; round 5 | ||
138 | mov edx, DWORD PTR 40[ebp] | ||
139 | mov ecx, DWORD PTR 44[ebp] | ||
140 | sub edx, edi | ||
141 | rol edx, cl | ||
142 | mov ebx, edx | ||
143 | xor ecx, ecx | ||
144 | mov cl, dh | ||
145 | and ebx, 255 | ||
146 | shr edx, 16 | ||
147 | xor eax, eax | ||
148 | mov al, dh | ||
149 | and edx, 255 | ||
150 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
151 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
152 | add ecx, ebx | ||
153 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
154 | xor ecx, ebx | ||
155 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
156 | sub ecx, ebx | ||
157 | xor esi, ecx | ||
158 | ; round 6 | ||
159 | mov edx, DWORD PTR 48[ebp] | ||
160 | mov ecx, DWORD PTR 52[ebp] | ||
161 | add edx, esi | ||
162 | rol edx, cl | ||
163 | mov ebx, edx | ||
164 | xor ecx, ecx | ||
165 | mov cl, dh | ||
166 | and ebx, 255 | ||
167 | shr edx, 16 | ||
168 | xor eax, eax | ||
169 | mov al, dh | ||
170 | and edx, 255 | ||
171 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
172 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
173 | xor ecx, ebx | ||
174 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
175 | sub ecx, ebx | ||
176 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
177 | add ecx, ebx | ||
178 | xor edi, ecx | ||
179 | ; round 7 | ||
180 | mov edx, DWORD PTR 56[ebp] | ||
181 | mov ecx, DWORD PTR 60[ebp] | ||
182 | xor edx, edi | ||
183 | rol edx, cl | ||
184 | mov ebx, edx | ||
185 | xor ecx, ecx | ||
186 | mov cl, dh | ||
187 | and ebx, 255 | ||
188 | shr edx, 16 | ||
189 | xor eax, eax | ||
190 | mov al, dh | ||
191 | and edx, 255 | ||
192 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
193 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
194 | sub ecx, ebx | ||
195 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
196 | add ecx, ebx | ||
197 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
198 | xor ecx, ebx | ||
199 | xor esi, ecx | ||
200 | ; round 8 | ||
201 | mov edx, DWORD PTR 64[ebp] | ||
202 | mov ecx, DWORD PTR 68[ebp] | ||
203 | sub edx, esi | ||
204 | rol edx, cl | ||
205 | mov ebx, edx | ||
206 | xor ecx, ecx | ||
207 | mov cl, dh | ||
208 | and ebx, 255 | ||
209 | shr edx, 16 | ||
210 | xor eax, eax | ||
211 | mov al, dh | ||
212 | and edx, 255 | ||
213 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
214 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
215 | add ecx, ebx | ||
216 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
217 | xor ecx, ebx | ||
218 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
219 | sub ecx, ebx | ||
220 | xor edi, ecx | ||
221 | ; round 9 | ||
222 | mov edx, DWORD PTR 72[ebp] | ||
223 | mov ecx, DWORD PTR 76[ebp] | ||
224 | add edx, edi | ||
225 | rol edx, cl | ||
226 | mov ebx, edx | ||
227 | xor ecx, ecx | ||
228 | mov cl, dh | ||
229 | and ebx, 255 | ||
230 | shr edx, 16 | ||
231 | xor eax, eax | ||
232 | mov al, dh | ||
233 | and edx, 255 | ||
234 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
235 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
236 | xor ecx, ebx | ||
237 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
238 | sub ecx, ebx | ||
239 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
240 | add ecx, ebx | ||
241 | xor esi, ecx | ||
242 | ; round 10 | ||
243 | mov edx, DWORD PTR 80[ebp] | ||
244 | mov ecx, DWORD PTR 84[ebp] | ||
245 | xor edx, esi | ||
246 | rol edx, cl | ||
247 | mov ebx, edx | ||
248 | xor ecx, ecx | ||
249 | mov cl, dh | ||
250 | and ebx, 255 | ||
251 | shr edx, 16 | ||
252 | xor eax, eax | ||
253 | mov al, dh | ||
254 | and edx, 255 | ||
255 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
256 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
257 | sub ecx, ebx | ||
258 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
259 | add ecx, ebx | ||
260 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
261 | xor ecx, ebx | ||
262 | xor edi, ecx | ||
263 | ; round 11 | ||
264 | mov edx, DWORD PTR 88[ebp] | ||
265 | mov ecx, DWORD PTR 92[ebp] | ||
266 | sub edx, edi | ||
267 | rol edx, cl | ||
268 | mov ebx, edx | ||
269 | xor ecx, ecx | ||
270 | mov cl, dh | ||
271 | and ebx, 255 | ||
272 | shr edx, 16 | ||
273 | xor eax, eax | ||
274 | mov al, dh | ||
275 | and edx, 255 | ||
276 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
277 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
278 | add ecx, ebx | ||
279 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
280 | xor ecx, ebx | ||
281 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
282 | sub ecx, ebx | ||
283 | xor esi, ecx | ||
284 | ; test short key flag | ||
285 | pop edx | ||
286 | or edx, edx | ||
287 | jnz $L000cast_enc_done | ||
288 | ; round 12 | ||
289 | mov edx, DWORD PTR 96[ebp] | ||
290 | mov ecx, DWORD PTR 100[ebp] | ||
291 | add edx, esi | ||
292 | rol edx, cl | ||
293 | mov ebx, edx | ||
294 | xor ecx, ecx | ||
295 | mov cl, dh | ||
296 | and ebx, 255 | ||
297 | shr edx, 16 | ||
298 | xor eax, eax | ||
299 | mov al, dh | ||
300 | and edx, 255 | ||
301 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
302 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
303 | xor ecx, ebx | ||
304 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
305 | sub ecx, ebx | ||
306 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
307 | add ecx, ebx | ||
308 | xor edi, ecx | ||
309 | ; round 13 | ||
310 | mov edx, DWORD PTR 104[ebp] | ||
311 | mov ecx, DWORD PTR 108[ebp] | ||
312 | xor edx, edi | ||
313 | rol edx, cl | ||
314 | mov ebx, edx | ||
315 | xor ecx, ecx | ||
316 | mov cl, dh | ||
317 | and ebx, 255 | ||
318 | shr edx, 16 | ||
319 | xor eax, eax | ||
320 | mov al, dh | ||
321 | and edx, 255 | ||
322 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
323 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
324 | sub ecx, ebx | ||
325 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
326 | add ecx, ebx | ||
327 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
328 | xor ecx, ebx | ||
329 | xor esi, ecx | ||
330 | ; round 14 | ||
331 | mov edx, DWORD PTR 112[ebp] | ||
332 | mov ecx, DWORD PTR 116[ebp] | ||
333 | sub edx, esi | ||
334 | rol edx, cl | ||
335 | mov ebx, edx | ||
336 | xor ecx, ecx | ||
337 | mov cl, dh | ||
338 | and ebx, 255 | ||
339 | shr edx, 16 | ||
340 | xor eax, eax | ||
341 | mov al, dh | ||
342 | and edx, 255 | ||
343 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
344 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
345 | add ecx, ebx | ||
346 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
347 | xor ecx, ebx | ||
348 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
349 | sub ecx, ebx | ||
350 | xor edi, ecx | ||
351 | ; round 15 | ||
352 | mov edx, DWORD PTR 120[ebp] | ||
353 | mov ecx, DWORD PTR 124[ebp] | ||
354 | add edx, edi | ||
355 | rol edx, cl | ||
356 | mov ebx, edx | ||
357 | xor ecx, ecx | ||
358 | mov cl, dh | ||
359 | and ebx, 255 | ||
360 | shr edx, 16 | ||
361 | xor eax, eax | ||
362 | mov al, dh | ||
363 | and edx, 255 | ||
364 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
365 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
366 | xor ecx, ebx | ||
367 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
368 | sub ecx, ebx | ||
369 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
370 | add ecx, ebx | ||
371 | xor esi, ecx | ||
372 | $L000cast_enc_done: | ||
373 | nop | ||
374 | mov eax, DWORD PTR 20[esp] | ||
375 | mov DWORD PTR 4[eax],edi | ||
376 | mov DWORD PTR [eax],esi | ||
377 | pop edi | ||
378 | pop esi | ||
379 | pop ebx | ||
380 | pop ebp | ||
381 | ret | ||
382 | _CAST_encrypt ENDP | ||
383 | _TEXT ENDS | ||
384 | _TEXT SEGMENT | ||
385 | PUBLIC _CAST_decrypt | ||
386 | EXTERN _CAST_S_table0:DWORD | ||
387 | EXTERN _CAST_S_table1:DWORD | ||
388 | EXTERN _CAST_S_table2:DWORD | ||
389 | EXTERN _CAST_S_table3:DWORD | ||
390 | |||
391 | _CAST_decrypt PROC NEAR | ||
392 | ; | ||
393 | push ebp | ||
394 | push ebx | ||
395 | mov ebx, DWORD PTR 12[esp] | ||
396 | mov ebp, DWORD PTR 16[esp] | ||
397 | push esi | ||
398 | push edi | ||
399 | ; Load the 2 words | ||
400 | mov edi, DWORD PTR [ebx] | ||
401 | mov esi, DWORD PTR 4[ebx] | ||
402 | ; Get short key flag | ||
403 | mov eax, DWORD PTR 128[ebp] | ||
404 | or eax, eax | ||
405 | jnz $L001cast_dec_skip | ||
406 | xor eax, eax | ||
407 | ; round 15 | ||
408 | mov edx, DWORD PTR 120[ebp] | ||
409 | mov ecx, DWORD PTR 124[ebp] | ||
410 | add edx, esi | ||
411 | rol edx, cl | ||
412 | mov ebx, edx | ||
413 | xor ecx, ecx | ||
414 | mov cl, dh | ||
415 | and ebx, 255 | ||
416 | shr edx, 16 | ||
417 | xor eax, eax | ||
418 | mov al, dh | ||
419 | and edx, 255 | ||
420 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
421 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
422 | xor ecx, ebx | ||
423 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
424 | sub ecx, ebx | ||
425 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
426 | add ecx, ebx | ||
427 | xor edi, ecx | ||
428 | ; round 14 | ||
429 | mov edx, DWORD PTR 112[ebp] | ||
430 | mov ecx, DWORD PTR 116[ebp] | ||
431 | sub edx, edi | ||
432 | rol edx, cl | ||
433 | mov ebx, edx | ||
434 | xor ecx, ecx | ||
435 | mov cl, dh | ||
436 | and ebx, 255 | ||
437 | shr edx, 16 | ||
438 | xor eax, eax | ||
439 | mov al, dh | ||
440 | and edx, 255 | ||
441 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
442 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
443 | add ecx, ebx | ||
444 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
445 | xor ecx, ebx | ||
446 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
447 | sub ecx, ebx | ||
448 | xor esi, ecx | ||
449 | ; round 13 | ||
450 | mov edx, DWORD PTR 104[ebp] | ||
451 | mov ecx, DWORD PTR 108[ebp] | ||
452 | xor edx, esi | ||
453 | rol edx, cl | ||
454 | mov ebx, edx | ||
455 | xor ecx, ecx | ||
456 | mov cl, dh | ||
457 | and ebx, 255 | ||
458 | shr edx, 16 | ||
459 | xor eax, eax | ||
460 | mov al, dh | ||
461 | and edx, 255 | ||
462 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
463 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
464 | sub ecx, ebx | ||
465 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
466 | add ecx, ebx | ||
467 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
468 | xor ecx, ebx | ||
469 | xor edi, ecx | ||
470 | ; round 12 | ||
471 | mov edx, DWORD PTR 96[ebp] | ||
472 | mov ecx, DWORD PTR 100[ebp] | ||
473 | add edx, edi | ||
474 | rol edx, cl | ||
475 | mov ebx, edx | ||
476 | xor ecx, ecx | ||
477 | mov cl, dh | ||
478 | and ebx, 255 | ||
479 | shr edx, 16 | ||
480 | xor eax, eax | ||
481 | mov al, dh | ||
482 | and edx, 255 | ||
483 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
484 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
485 | xor ecx, ebx | ||
486 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
487 | sub ecx, ebx | ||
488 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
489 | add ecx, ebx | ||
490 | xor esi, ecx | ||
491 | $L001cast_dec_skip: | ||
492 | ; round 11 | ||
493 | mov edx, DWORD PTR 88[ebp] | ||
494 | mov ecx, DWORD PTR 92[ebp] | ||
495 | sub edx, esi | ||
496 | rol edx, cl | ||
497 | mov ebx, edx | ||
498 | xor ecx, ecx | ||
499 | mov cl, dh | ||
500 | and ebx, 255 | ||
501 | shr edx, 16 | ||
502 | xor eax, eax | ||
503 | mov al, dh | ||
504 | and edx, 255 | ||
505 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
506 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
507 | add ecx, ebx | ||
508 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
509 | xor ecx, ebx | ||
510 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
511 | sub ecx, ebx | ||
512 | xor edi, ecx | ||
513 | ; round 10 | ||
514 | mov edx, DWORD PTR 80[ebp] | ||
515 | mov ecx, DWORD PTR 84[ebp] | ||
516 | xor edx, edi | ||
517 | rol edx, cl | ||
518 | mov ebx, edx | ||
519 | xor ecx, ecx | ||
520 | mov cl, dh | ||
521 | and ebx, 255 | ||
522 | shr edx, 16 | ||
523 | xor eax, eax | ||
524 | mov al, dh | ||
525 | and edx, 255 | ||
526 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
527 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
528 | sub ecx, ebx | ||
529 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
530 | add ecx, ebx | ||
531 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
532 | xor ecx, ebx | ||
533 | xor esi, ecx | ||
534 | ; round 9 | ||
535 | mov edx, DWORD PTR 72[ebp] | ||
536 | mov ecx, DWORD PTR 76[ebp] | ||
537 | add edx, esi | ||
538 | rol edx, cl | ||
539 | mov ebx, edx | ||
540 | xor ecx, ecx | ||
541 | mov cl, dh | ||
542 | and ebx, 255 | ||
543 | shr edx, 16 | ||
544 | xor eax, eax | ||
545 | mov al, dh | ||
546 | and edx, 255 | ||
547 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
548 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
549 | xor ecx, ebx | ||
550 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
551 | sub ecx, ebx | ||
552 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
553 | add ecx, ebx | ||
554 | xor edi, ecx | ||
555 | ; round 8 | ||
556 | mov edx, DWORD PTR 64[ebp] | ||
557 | mov ecx, DWORD PTR 68[ebp] | ||
558 | sub edx, edi | ||
559 | rol edx, cl | ||
560 | mov ebx, edx | ||
561 | xor ecx, ecx | ||
562 | mov cl, dh | ||
563 | and ebx, 255 | ||
564 | shr edx, 16 | ||
565 | xor eax, eax | ||
566 | mov al, dh | ||
567 | and edx, 255 | ||
568 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
569 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
570 | add ecx, ebx | ||
571 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
572 | xor ecx, ebx | ||
573 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
574 | sub ecx, ebx | ||
575 | xor esi, ecx | ||
576 | ; round 7 | ||
577 | mov edx, DWORD PTR 56[ebp] | ||
578 | mov ecx, DWORD PTR 60[ebp] | ||
579 | xor edx, esi | ||
580 | rol edx, cl | ||
581 | mov ebx, edx | ||
582 | xor ecx, ecx | ||
583 | mov cl, dh | ||
584 | and ebx, 255 | ||
585 | shr edx, 16 | ||
586 | xor eax, eax | ||
587 | mov al, dh | ||
588 | and edx, 255 | ||
589 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
590 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
591 | sub ecx, ebx | ||
592 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
593 | add ecx, ebx | ||
594 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
595 | xor ecx, ebx | ||
596 | xor edi, ecx | ||
597 | ; round 6 | ||
598 | mov edx, DWORD PTR 48[ebp] | ||
599 | mov ecx, DWORD PTR 52[ebp] | ||
600 | add edx, edi | ||
601 | rol edx, cl | ||
602 | mov ebx, edx | ||
603 | xor ecx, ecx | ||
604 | mov cl, dh | ||
605 | and ebx, 255 | ||
606 | shr edx, 16 | ||
607 | xor eax, eax | ||
608 | mov al, dh | ||
609 | and edx, 255 | ||
610 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
611 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
612 | xor ecx, ebx | ||
613 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
614 | sub ecx, ebx | ||
615 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
616 | add ecx, ebx | ||
617 | xor esi, ecx | ||
618 | ; round 5 | ||
619 | mov edx, DWORD PTR 40[ebp] | ||
620 | mov ecx, DWORD PTR 44[ebp] | ||
621 | sub edx, esi | ||
622 | rol edx, cl | ||
623 | mov ebx, edx | ||
624 | xor ecx, ecx | ||
625 | mov cl, dh | ||
626 | and ebx, 255 | ||
627 | shr edx, 16 | ||
628 | xor eax, eax | ||
629 | mov al, dh | ||
630 | and edx, 255 | ||
631 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
632 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
633 | add ecx, ebx | ||
634 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
635 | xor ecx, ebx | ||
636 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
637 | sub ecx, ebx | ||
638 | xor edi, ecx | ||
639 | ; round 4 | ||
640 | mov edx, DWORD PTR 32[ebp] | ||
641 | mov ecx, DWORD PTR 36[ebp] | ||
642 | xor edx, edi | ||
643 | rol edx, cl | ||
644 | mov ebx, edx | ||
645 | xor ecx, ecx | ||
646 | mov cl, dh | ||
647 | and ebx, 255 | ||
648 | shr edx, 16 | ||
649 | xor eax, eax | ||
650 | mov al, dh | ||
651 | and edx, 255 | ||
652 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
653 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
654 | sub ecx, ebx | ||
655 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
656 | add ecx, ebx | ||
657 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
658 | xor ecx, ebx | ||
659 | xor esi, ecx | ||
660 | ; round 3 | ||
661 | mov edx, DWORD PTR 24[ebp] | ||
662 | mov ecx, DWORD PTR 28[ebp] | ||
663 | add edx, esi | ||
664 | rol edx, cl | ||
665 | mov ebx, edx | ||
666 | xor ecx, ecx | ||
667 | mov cl, dh | ||
668 | and ebx, 255 | ||
669 | shr edx, 16 | ||
670 | xor eax, eax | ||
671 | mov al, dh | ||
672 | and edx, 255 | ||
673 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
674 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
675 | xor ecx, ebx | ||
676 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
677 | sub ecx, ebx | ||
678 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
679 | add ecx, ebx | ||
680 | xor edi, ecx | ||
681 | ; round 2 | ||
682 | mov edx, DWORD PTR 16[ebp] | ||
683 | mov ecx, DWORD PTR 20[ebp] | ||
684 | sub edx, edi | ||
685 | rol edx, cl | ||
686 | mov ebx, edx | ||
687 | xor ecx, ecx | ||
688 | mov cl, dh | ||
689 | and ebx, 255 | ||
690 | shr edx, 16 | ||
691 | xor eax, eax | ||
692 | mov al, dh | ||
693 | and edx, 255 | ||
694 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
695 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
696 | add ecx, ebx | ||
697 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
698 | xor ecx, ebx | ||
699 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
700 | sub ecx, ebx | ||
701 | xor esi, ecx | ||
702 | ; round 1 | ||
703 | mov edx, DWORD PTR 8[ebp] | ||
704 | mov ecx, DWORD PTR 12[ebp] | ||
705 | xor edx, esi | ||
706 | rol edx, cl | ||
707 | mov ebx, edx | ||
708 | xor ecx, ecx | ||
709 | mov cl, dh | ||
710 | and ebx, 255 | ||
711 | shr edx, 16 | ||
712 | xor eax, eax | ||
713 | mov al, dh | ||
714 | and edx, 255 | ||
715 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
716 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
717 | sub ecx, ebx | ||
718 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
719 | add ecx, ebx | ||
720 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
721 | xor ecx, ebx | ||
722 | xor edi, ecx | ||
723 | ; round 0 | ||
724 | mov edx, DWORD PTR [ebp] | ||
725 | mov ecx, DWORD PTR 4[ebp] | ||
726 | add edx, edi | ||
727 | rol edx, cl | ||
728 | mov ebx, edx | ||
729 | xor ecx, ecx | ||
730 | mov cl, dh | ||
731 | and ebx, 255 | ||
732 | shr edx, 16 | ||
733 | xor eax, eax | ||
734 | mov al, dh | ||
735 | and edx, 255 | ||
736 | mov ecx, DWORD PTR _CAST_S_table0[ecx*4] | ||
737 | mov ebx, DWORD PTR _CAST_S_table1[ebx*4] | ||
738 | xor ecx, ebx | ||
739 | mov ebx, DWORD PTR _CAST_S_table2[eax*4] | ||
740 | sub ecx, ebx | ||
741 | mov ebx, DWORD PTR _CAST_S_table3[edx*4] | ||
742 | add ecx, ebx | ||
743 | xor esi, ecx | ||
744 | nop | ||
745 | mov eax, DWORD PTR 20[esp] | ||
746 | mov DWORD PTR 4[eax],edi | ||
747 | mov DWORD PTR [eax],esi | ||
748 | pop edi | ||
749 | pop esi | ||
750 | pop ebx | ||
751 | pop ebp | ||
752 | ret | ||
753 | _CAST_decrypt ENDP | ||
754 | _TEXT ENDS | ||
755 | _TEXT SEGMENT | ||
756 | PUBLIC _CAST_cbc_encrypt | ||
757 | |||
758 | _CAST_cbc_encrypt PROC NEAR | ||
759 | ; | ||
760 | push ebp | ||
761 | push ebx | ||
762 | push esi | ||
763 | push edi | ||
764 | mov ebp, DWORD PTR 28[esp] | ||
765 | ; getting iv ptr from parameter 4 | ||
766 | mov ebx, DWORD PTR 36[esp] | ||
767 | mov esi, DWORD PTR [ebx] | ||
768 | mov edi, DWORD PTR 4[ebx] | ||
769 | push edi | ||
770 | push esi | ||
771 | push edi | ||
772 | push esi | ||
773 | mov ebx, esp | ||
774 | mov esi, DWORD PTR 36[esp] | ||
775 | mov edi, DWORD PTR 40[esp] | ||
776 | ; getting encrypt flag from parameter 5 | ||
777 | mov ecx, DWORD PTR 56[esp] | ||
778 | ; get and push parameter 3 | ||
779 | mov eax, DWORD PTR 48[esp] | ||
780 | push eax | ||
781 | push ebx | ||
782 | cmp ecx, 0 | ||
783 | jz $L002decrypt | ||
784 | and ebp, 4294967288 | ||
785 | mov eax, DWORD PTR 8[esp] | ||
786 | mov ebx, DWORD PTR 12[esp] | ||
787 | jz $L003encrypt_finish | ||
788 | L004encrypt_loop: | ||
789 | mov ecx, DWORD PTR [esi] | ||
790 | mov edx, DWORD PTR 4[esi] | ||
791 | xor eax, ecx | ||
792 | xor ebx, edx | ||
793 | bswap eax | ||
794 | bswap ebx | ||
795 | mov DWORD PTR 8[esp],eax | ||
796 | mov DWORD PTR 12[esp],ebx | ||
797 | call _CAST_encrypt | ||
798 | mov eax, DWORD PTR 8[esp] | ||
799 | mov ebx, DWORD PTR 12[esp] | ||
800 | bswap eax | ||
801 | bswap ebx | ||
802 | mov DWORD PTR [edi],eax | ||
803 | mov DWORD PTR 4[edi],ebx | ||
804 | add esi, 8 | ||
805 | add edi, 8 | ||
806 | sub ebp, 8 | ||
807 | jnz L004encrypt_loop | ||
808 | $L003encrypt_finish: | ||
809 | mov ebp, DWORD PTR 52[esp] | ||
810 | and ebp, 7 | ||
811 | jz $L005finish | ||
812 | xor ecx, ecx | ||
813 | xor edx, edx | ||
814 | mov ebp, DWORD PTR $L006cbc_enc_jmp_table[ebp*4] | ||
815 | jmp ebp | ||
816 | L007ej7: | ||
817 | xor edx, edx | ||
818 | mov dh, BYTE PTR 6[esi] | ||
819 | shl edx, 8 | ||
820 | L008ej6: | ||
821 | mov dh, BYTE PTR 5[esi] | ||
822 | L009ej5: | ||
823 | mov dl, BYTE PTR 4[esi] | ||
824 | L010ej4: | ||
825 | mov ecx, DWORD PTR [esi] | ||
826 | jmp $L011ejend | ||
827 | L012ej3: | ||
828 | mov ch, BYTE PTR 2[esi] | ||
829 | xor ecx, ecx | ||
830 | shl ecx, 8 | ||
831 | L013ej2: | ||
832 | mov ch, BYTE PTR 1[esi] | ||
833 | L014ej1: | ||
834 | mov cl, BYTE PTR [esi] | ||
835 | $L011ejend: | ||
836 | xor eax, ecx | ||
837 | xor ebx, edx | ||
838 | bswap eax | ||
839 | bswap ebx | ||
840 | mov DWORD PTR 8[esp],eax | ||
841 | mov DWORD PTR 12[esp],ebx | ||
842 | call _CAST_encrypt | ||
843 | mov eax, DWORD PTR 8[esp] | ||
844 | mov ebx, DWORD PTR 12[esp] | ||
845 | bswap eax | ||
846 | bswap ebx | ||
847 | mov DWORD PTR [edi],eax | ||
848 | mov DWORD PTR 4[edi],ebx | ||
849 | jmp $L005finish | ||
850 | $L002decrypt: | ||
851 | and ebp, 4294967288 | ||
852 | mov eax, DWORD PTR 16[esp] | ||
853 | mov ebx, DWORD PTR 20[esp] | ||
854 | jz $L015decrypt_finish | ||
855 | L016decrypt_loop: | ||
856 | mov eax, DWORD PTR [esi] | ||
857 | mov ebx, DWORD PTR 4[esi] | ||
858 | bswap eax | ||
859 | bswap ebx | ||
860 | mov DWORD PTR 8[esp],eax | ||
861 | mov DWORD PTR 12[esp],ebx | ||
862 | call _CAST_decrypt | ||
863 | mov eax, DWORD PTR 8[esp] | ||
864 | mov ebx, DWORD PTR 12[esp] | ||
865 | bswap eax | ||
866 | bswap ebx | ||
867 | mov ecx, DWORD PTR 16[esp] | ||
868 | mov edx, DWORD PTR 20[esp] | ||
869 | xor ecx, eax | ||
870 | xor edx, ebx | ||
871 | mov eax, DWORD PTR [esi] | ||
872 | mov ebx, DWORD PTR 4[esi] | ||
873 | mov DWORD PTR [edi],ecx | ||
874 | mov DWORD PTR 4[edi],edx | ||
875 | mov DWORD PTR 16[esp],eax | ||
876 | mov DWORD PTR 20[esp],ebx | ||
877 | add esi, 8 | ||
878 | add edi, 8 | ||
879 | sub ebp, 8 | ||
880 | jnz L016decrypt_loop | ||
881 | $L015decrypt_finish: | ||
882 | mov ebp, DWORD PTR 52[esp] | ||
883 | and ebp, 7 | ||
884 | jz $L005finish | ||
885 | mov eax, DWORD PTR [esi] | ||
886 | mov ebx, DWORD PTR 4[esi] | ||
887 | bswap eax | ||
888 | bswap ebx | ||
889 | mov DWORD PTR 8[esp],eax | ||
890 | mov DWORD PTR 12[esp],ebx | ||
891 | call _CAST_decrypt | ||
892 | mov eax, DWORD PTR 8[esp] | ||
893 | mov ebx, DWORD PTR 12[esp] | ||
894 | bswap eax | ||
895 | bswap ebx | ||
896 | mov ecx, DWORD PTR 16[esp] | ||
897 | mov edx, DWORD PTR 20[esp] | ||
898 | xor ecx, eax | ||
899 | xor edx, ebx | ||
900 | mov eax, DWORD PTR [esi] | ||
901 | mov ebx, DWORD PTR 4[esi] | ||
902 | L017dj7: | ||
903 | ror edx, 16 | ||
904 | mov BYTE PTR 6[edi],dl | ||
905 | shr edx, 16 | ||
906 | L018dj6: | ||
907 | mov BYTE PTR 5[edi],dh | ||
908 | L019dj5: | ||
909 | mov BYTE PTR 4[edi],dl | ||
910 | L020dj4: | ||
911 | mov DWORD PTR [edi],ecx | ||
912 | jmp $L021djend | ||
913 | L022dj3: | ||
914 | ror ecx, 16 | ||
915 | mov BYTE PTR 2[edi],cl | ||
916 | shl ecx, 16 | ||
917 | L023dj2: | ||
918 | mov BYTE PTR 1[esi],ch | ||
919 | L024dj1: | ||
920 | mov BYTE PTR [esi], cl | ||
921 | $L021djend: | ||
922 | jmp $L005finish | ||
923 | $L005finish: | ||
924 | mov ecx, DWORD PTR 60[esp] | ||
925 | add esp, 24 | ||
926 | mov DWORD PTR [ecx],eax | ||
927 | mov DWORD PTR 4[ecx],ebx | ||
928 | pop edi | ||
929 | pop esi | ||
930 | pop ebx | ||
931 | pop ebp | ||
932 | ret | ||
933 | $L006cbc_enc_jmp_table: | ||
934 | DD 0 | ||
935 | DD L014ej1 | ||
936 | DD L013ej2 | ||
937 | DD L012ej3 | ||
938 | DD L010ej4 | ||
939 | DD L009ej5 | ||
940 | DD L008ej6 | ||
941 | DD L007ej7 | ||
942 | L025cbc_dec_jmp_table: | ||
943 | DD 0 | ||
944 | DD L024dj1 | ||
945 | DD L023dj2 | ||
946 | DD L022dj3 | ||
947 | DD L020dj4 | ||
948 | DD L019dj5 | ||
949 | DD L018dj6 | ||
950 | DD L017dj7 | ||
951 | _CAST_cbc_encrypt ENDP | ||
952 | _TEXT ENDS | ||
953 | END | ||