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