1 | default rel
|
---|
2 | %define XMMWORD
|
---|
3 | %define YMMWORD
|
---|
4 | %define ZMMWORD
|
---|
5 | section .text code align=64
|
---|
6 |
|
---|
7 | EXTERN OPENSSL_ia32cap_P
|
---|
8 |
|
---|
9 | global RC4
|
---|
10 |
|
---|
11 | ALIGN 16
|
---|
12 | RC4:
|
---|
13 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
14 | mov QWORD[16+rsp],rsi
|
---|
15 | mov rax,rsp
|
---|
16 | $L$SEH_begin_RC4:
|
---|
17 | mov rdi,rcx
|
---|
18 | mov rsi,rdx
|
---|
19 | mov rdx,r8
|
---|
20 | mov rcx,r9
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | DB 243,15,30,250
|
---|
25 | or rsi,rsi
|
---|
26 | jne NEAR $L$entry
|
---|
27 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
28 | mov rsi,QWORD[16+rsp]
|
---|
29 | DB 0F3h,0C3h ;repret
|
---|
30 | $L$entry:
|
---|
31 | push rbx
|
---|
32 |
|
---|
33 | push r12
|
---|
34 |
|
---|
35 | push r13
|
---|
36 |
|
---|
37 | $L$prologue:
|
---|
38 | mov r11,rsi
|
---|
39 | mov r12,rdx
|
---|
40 | mov r13,rcx
|
---|
41 | xor r10,r10
|
---|
42 | xor rcx,rcx
|
---|
43 |
|
---|
44 | lea rdi,[8+rdi]
|
---|
45 | mov r10b,BYTE[((-8))+rdi]
|
---|
46 | mov cl,BYTE[((-4))+rdi]
|
---|
47 | cmp DWORD[256+rdi],-1
|
---|
48 | je NEAR $L$RC4_CHAR
|
---|
49 | mov r8d,DWORD[OPENSSL_ia32cap_P]
|
---|
50 | xor rbx,rbx
|
---|
51 | inc r10b
|
---|
52 | sub rbx,r10
|
---|
53 | sub r13,r12
|
---|
54 | mov eax,DWORD[r10*4+rdi]
|
---|
55 | test r11,-16
|
---|
56 | jz NEAR $L$loop1
|
---|
57 | bt r8d,30
|
---|
58 | jc NEAR $L$intel
|
---|
59 | and rbx,7
|
---|
60 | lea rsi,[1+r10]
|
---|
61 | jz NEAR $L$oop8
|
---|
62 | sub r11,rbx
|
---|
63 | $L$oop8_warmup:
|
---|
64 | add cl,al
|
---|
65 | mov edx,DWORD[rcx*4+rdi]
|
---|
66 | mov DWORD[rcx*4+rdi],eax
|
---|
67 | mov DWORD[r10*4+rdi],edx
|
---|
68 | add al,dl
|
---|
69 | inc r10b
|
---|
70 | mov edx,DWORD[rax*4+rdi]
|
---|
71 | mov eax,DWORD[r10*4+rdi]
|
---|
72 | xor dl,BYTE[r12]
|
---|
73 | mov BYTE[r13*1+r12],dl
|
---|
74 | lea r12,[1+r12]
|
---|
75 | dec rbx
|
---|
76 | jnz NEAR $L$oop8_warmup
|
---|
77 |
|
---|
78 | lea rsi,[1+r10]
|
---|
79 | jmp NEAR $L$oop8
|
---|
80 | ALIGN 16
|
---|
81 | $L$oop8:
|
---|
82 | add cl,al
|
---|
83 | mov edx,DWORD[rcx*4+rdi]
|
---|
84 | mov DWORD[rcx*4+rdi],eax
|
---|
85 | mov ebx,DWORD[rsi*4+rdi]
|
---|
86 | ror r8,8
|
---|
87 | mov DWORD[r10*4+rdi],edx
|
---|
88 | add dl,al
|
---|
89 | mov r8b,BYTE[rdx*4+rdi]
|
---|
90 | add cl,bl
|
---|
91 | mov edx,DWORD[rcx*4+rdi]
|
---|
92 | mov DWORD[rcx*4+rdi],ebx
|
---|
93 | mov eax,DWORD[4+rsi*4+rdi]
|
---|
94 | ror r8,8
|
---|
95 | mov DWORD[4+r10*4+rdi],edx
|
---|
96 | add dl,bl
|
---|
97 | mov r8b,BYTE[rdx*4+rdi]
|
---|
98 | add cl,al
|
---|
99 | mov edx,DWORD[rcx*4+rdi]
|
---|
100 | mov DWORD[rcx*4+rdi],eax
|
---|
101 | mov ebx,DWORD[8+rsi*4+rdi]
|
---|
102 | ror r8,8
|
---|
103 | mov DWORD[8+r10*4+rdi],edx
|
---|
104 | add dl,al
|
---|
105 | mov r8b,BYTE[rdx*4+rdi]
|
---|
106 | add cl,bl
|
---|
107 | mov edx,DWORD[rcx*4+rdi]
|
---|
108 | mov DWORD[rcx*4+rdi],ebx
|
---|
109 | mov eax,DWORD[12+rsi*4+rdi]
|
---|
110 | ror r8,8
|
---|
111 | mov DWORD[12+r10*4+rdi],edx
|
---|
112 | add dl,bl
|
---|
113 | mov r8b,BYTE[rdx*4+rdi]
|
---|
114 | add cl,al
|
---|
115 | mov edx,DWORD[rcx*4+rdi]
|
---|
116 | mov DWORD[rcx*4+rdi],eax
|
---|
117 | mov ebx,DWORD[16+rsi*4+rdi]
|
---|
118 | ror r8,8
|
---|
119 | mov DWORD[16+r10*4+rdi],edx
|
---|
120 | add dl,al
|
---|
121 | mov r8b,BYTE[rdx*4+rdi]
|
---|
122 | add cl,bl
|
---|
123 | mov edx,DWORD[rcx*4+rdi]
|
---|
124 | mov DWORD[rcx*4+rdi],ebx
|
---|
125 | mov eax,DWORD[20+rsi*4+rdi]
|
---|
126 | ror r8,8
|
---|
127 | mov DWORD[20+r10*4+rdi],edx
|
---|
128 | add dl,bl
|
---|
129 | mov r8b,BYTE[rdx*4+rdi]
|
---|
130 | add cl,al
|
---|
131 | mov edx,DWORD[rcx*4+rdi]
|
---|
132 | mov DWORD[rcx*4+rdi],eax
|
---|
133 | mov ebx,DWORD[24+rsi*4+rdi]
|
---|
134 | ror r8,8
|
---|
135 | mov DWORD[24+r10*4+rdi],edx
|
---|
136 | add dl,al
|
---|
137 | mov r8b,BYTE[rdx*4+rdi]
|
---|
138 | add sil,8
|
---|
139 | add cl,bl
|
---|
140 | mov edx,DWORD[rcx*4+rdi]
|
---|
141 | mov DWORD[rcx*4+rdi],ebx
|
---|
142 | mov eax,DWORD[((-4))+rsi*4+rdi]
|
---|
143 | ror r8,8
|
---|
144 | mov DWORD[28+r10*4+rdi],edx
|
---|
145 | add dl,bl
|
---|
146 | mov r8b,BYTE[rdx*4+rdi]
|
---|
147 | add r10b,8
|
---|
148 | ror r8,8
|
---|
149 | sub r11,8
|
---|
150 |
|
---|
151 | xor r8,QWORD[r12]
|
---|
152 | mov QWORD[r13*1+r12],r8
|
---|
153 | lea r12,[8+r12]
|
---|
154 |
|
---|
155 | test r11,-8
|
---|
156 | jnz NEAR $L$oop8
|
---|
157 | cmp r11,0
|
---|
158 | jne NEAR $L$loop1
|
---|
159 | jmp NEAR $L$exit
|
---|
160 |
|
---|
161 | ALIGN 16
|
---|
162 | $L$intel:
|
---|
163 | test r11,-32
|
---|
164 | jz NEAR $L$loop1
|
---|
165 | and rbx,15
|
---|
166 | jz NEAR $L$oop16_is_hot
|
---|
167 | sub r11,rbx
|
---|
168 | $L$oop16_warmup:
|
---|
169 | add cl,al
|
---|
170 | mov edx,DWORD[rcx*4+rdi]
|
---|
171 | mov DWORD[rcx*4+rdi],eax
|
---|
172 | mov DWORD[r10*4+rdi],edx
|
---|
173 | add al,dl
|
---|
174 | inc r10b
|
---|
175 | mov edx,DWORD[rax*4+rdi]
|
---|
176 | mov eax,DWORD[r10*4+rdi]
|
---|
177 | xor dl,BYTE[r12]
|
---|
178 | mov BYTE[r13*1+r12],dl
|
---|
179 | lea r12,[1+r12]
|
---|
180 | dec rbx
|
---|
181 | jnz NEAR $L$oop16_warmup
|
---|
182 |
|
---|
183 | mov rbx,rcx
|
---|
184 | xor rcx,rcx
|
---|
185 | mov cl,bl
|
---|
186 |
|
---|
187 | $L$oop16_is_hot:
|
---|
188 | lea rsi,[r10*4+rdi]
|
---|
189 | add cl,al
|
---|
190 | mov edx,DWORD[rcx*4+rdi]
|
---|
191 | pxor xmm0,xmm0
|
---|
192 | mov DWORD[rcx*4+rdi],eax
|
---|
193 | add al,dl
|
---|
194 | mov ebx,DWORD[4+rsi]
|
---|
195 | movzx eax,al
|
---|
196 | mov DWORD[rsi],edx
|
---|
197 | add cl,bl
|
---|
198 | pinsrw xmm0,WORD[rax*4+rdi],0
|
---|
199 | jmp NEAR $L$oop16_enter
|
---|
200 | ALIGN 16
|
---|
201 | $L$oop16:
|
---|
202 | add cl,al
|
---|
203 | mov edx,DWORD[rcx*4+rdi]
|
---|
204 | pxor xmm2,xmm0
|
---|
205 | psllq xmm1,8
|
---|
206 | pxor xmm0,xmm0
|
---|
207 | mov DWORD[rcx*4+rdi],eax
|
---|
208 | add al,dl
|
---|
209 | mov ebx,DWORD[4+rsi]
|
---|
210 | movzx eax,al
|
---|
211 | mov DWORD[rsi],edx
|
---|
212 | pxor xmm2,xmm1
|
---|
213 | add cl,bl
|
---|
214 | pinsrw xmm0,WORD[rax*4+rdi],0
|
---|
215 | movdqu XMMWORD[r13*1+r12],xmm2
|
---|
216 | lea r12,[16+r12]
|
---|
217 | $L$oop16_enter:
|
---|
218 | mov edx,DWORD[rcx*4+rdi]
|
---|
219 | pxor xmm1,xmm1
|
---|
220 | mov DWORD[rcx*4+rdi],ebx
|
---|
221 | add bl,dl
|
---|
222 | mov eax,DWORD[8+rsi]
|
---|
223 | movzx ebx,bl
|
---|
224 | mov DWORD[4+rsi],edx
|
---|
225 | add cl,al
|
---|
226 | pinsrw xmm1,WORD[rbx*4+rdi],0
|
---|
227 | mov edx,DWORD[rcx*4+rdi]
|
---|
228 | mov DWORD[rcx*4+rdi],eax
|
---|
229 | add al,dl
|
---|
230 | mov ebx,DWORD[12+rsi]
|
---|
231 | movzx eax,al
|
---|
232 | mov DWORD[8+rsi],edx
|
---|
233 | add cl,bl
|
---|
234 | pinsrw xmm0,WORD[rax*4+rdi],1
|
---|
235 | mov edx,DWORD[rcx*4+rdi]
|
---|
236 | mov DWORD[rcx*4+rdi],ebx
|
---|
237 | add bl,dl
|
---|
238 | mov eax,DWORD[16+rsi]
|
---|
239 | movzx ebx,bl
|
---|
240 | mov DWORD[12+rsi],edx
|
---|
241 | add cl,al
|
---|
242 | pinsrw xmm1,WORD[rbx*4+rdi],1
|
---|
243 | mov edx,DWORD[rcx*4+rdi]
|
---|
244 | mov DWORD[rcx*4+rdi],eax
|
---|
245 | add al,dl
|
---|
246 | mov ebx,DWORD[20+rsi]
|
---|
247 | movzx eax,al
|
---|
248 | mov DWORD[16+rsi],edx
|
---|
249 | add cl,bl
|
---|
250 | pinsrw xmm0,WORD[rax*4+rdi],2
|
---|
251 | mov edx,DWORD[rcx*4+rdi]
|
---|
252 | mov DWORD[rcx*4+rdi],ebx
|
---|
253 | add bl,dl
|
---|
254 | mov eax,DWORD[24+rsi]
|
---|
255 | movzx ebx,bl
|
---|
256 | mov DWORD[20+rsi],edx
|
---|
257 | add cl,al
|
---|
258 | pinsrw xmm1,WORD[rbx*4+rdi],2
|
---|
259 | mov edx,DWORD[rcx*4+rdi]
|
---|
260 | mov DWORD[rcx*4+rdi],eax
|
---|
261 | add al,dl
|
---|
262 | mov ebx,DWORD[28+rsi]
|
---|
263 | movzx eax,al
|
---|
264 | mov DWORD[24+rsi],edx
|
---|
265 | add cl,bl
|
---|
266 | pinsrw xmm0,WORD[rax*4+rdi],3
|
---|
267 | mov edx,DWORD[rcx*4+rdi]
|
---|
268 | mov DWORD[rcx*4+rdi],ebx
|
---|
269 | add bl,dl
|
---|
270 | mov eax,DWORD[32+rsi]
|
---|
271 | movzx ebx,bl
|
---|
272 | mov DWORD[28+rsi],edx
|
---|
273 | add cl,al
|
---|
274 | pinsrw xmm1,WORD[rbx*4+rdi],3
|
---|
275 | mov edx,DWORD[rcx*4+rdi]
|
---|
276 | mov DWORD[rcx*4+rdi],eax
|
---|
277 | add al,dl
|
---|
278 | mov ebx,DWORD[36+rsi]
|
---|
279 | movzx eax,al
|
---|
280 | mov DWORD[32+rsi],edx
|
---|
281 | add cl,bl
|
---|
282 | pinsrw xmm0,WORD[rax*4+rdi],4
|
---|
283 | mov edx,DWORD[rcx*4+rdi]
|
---|
284 | mov DWORD[rcx*4+rdi],ebx
|
---|
285 | add bl,dl
|
---|
286 | mov eax,DWORD[40+rsi]
|
---|
287 | movzx ebx,bl
|
---|
288 | mov DWORD[36+rsi],edx
|
---|
289 | add cl,al
|
---|
290 | pinsrw xmm1,WORD[rbx*4+rdi],4
|
---|
291 | mov edx,DWORD[rcx*4+rdi]
|
---|
292 | mov DWORD[rcx*4+rdi],eax
|
---|
293 | add al,dl
|
---|
294 | mov ebx,DWORD[44+rsi]
|
---|
295 | movzx eax,al
|
---|
296 | mov DWORD[40+rsi],edx
|
---|
297 | add cl,bl
|
---|
298 | pinsrw xmm0,WORD[rax*4+rdi],5
|
---|
299 | mov edx,DWORD[rcx*4+rdi]
|
---|
300 | mov DWORD[rcx*4+rdi],ebx
|
---|
301 | add bl,dl
|
---|
302 | mov eax,DWORD[48+rsi]
|
---|
303 | movzx ebx,bl
|
---|
304 | mov DWORD[44+rsi],edx
|
---|
305 | add cl,al
|
---|
306 | pinsrw xmm1,WORD[rbx*4+rdi],5
|
---|
307 | mov edx,DWORD[rcx*4+rdi]
|
---|
308 | mov DWORD[rcx*4+rdi],eax
|
---|
309 | add al,dl
|
---|
310 | mov ebx,DWORD[52+rsi]
|
---|
311 | movzx eax,al
|
---|
312 | mov DWORD[48+rsi],edx
|
---|
313 | add cl,bl
|
---|
314 | pinsrw xmm0,WORD[rax*4+rdi],6
|
---|
315 | mov edx,DWORD[rcx*4+rdi]
|
---|
316 | mov DWORD[rcx*4+rdi],ebx
|
---|
317 | add bl,dl
|
---|
318 | mov eax,DWORD[56+rsi]
|
---|
319 | movzx ebx,bl
|
---|
320 | mov DWORD[52+rsi],edx
|
---|
321 | add cl,al
|
---|
322 | pinsrw xmm1,WORD[rbx*4+rdi],6
|
---|
323 | mov edx,DWORD[rcx*4+rdi]
|
---|
324 | mov DWORD[rcx*4+rdi],eax
|
---|
325 | add al,dl
|
---|
326 | mov ebx,DWORD[60+rsi]
|
---|
327 | movzx eax,al
|
---|
328 | mov DWORD[56+rsi],edx
|
---|
329 | add cl,bl
|
---|
330 | pinsrw xmm0,WORD[rax*4+rdi],7
|
---|
331 | add r10b,16
|
---|
332 | movdqu xmm2,XMMWORD[r12]
|
---|
333 | mov edx,DWORD[rcx*4+rdi]
|
---|
334 | mov DWORD[rcx*4+rdi],ebx
|
---|
335 | add bl,dl
|
---|
336 | movzx ebx,bl
|
---|
337 | mov DWORD[60+rsi],edx
|
---|
338 | lea rsi,[r10*4+rdi]
|
---|
339 | pinsrw xmm1,WORD[rbx*4+rdi],7
|
---|
340 | mov eax,DWORD[rsi]
|
---|
341 | mov rbx,rcx
|
---|
342 | xor rcx,rcx
|
---|
343 | sub r11,16
|
---|
344 | mov cl,bl
|
---|
345 | test r11,-16
|
---|
346 | jnz NEAR $L$oop16
|
---|
347 |
|
---|
348 | psllq xmm1,8
|
---|
349 | pxor xmm2,xmm0
|
---|
350 | pxor xmm2,xmm1
|
---|
351 | movdqu XMMWORD[r13*1+r12],xmm2
|
---|
352 | lea r12,[16+r12]
|
---|
353 |
|
---|
354 | cmp r11,0
|
---|
355 | jne NEAR $L$loop1
|
---|
356 | jmp NEAR $L$exit
|
---|
357 |
|
---|
358 | ALIGN 16
|
---|
359 | $L$loop1:
|
---|
360 | add cl,al
|
---|
361 | mov edx,DWORD[rcx*4+rdi]
|
---|
362 | mov DWORD[rcx*4+rdi],eax
|
---|
363 | mov DWORD[r10*4+rdi],edx
|
---|
364 | add al,dl
|
---|
365 | inc r10b
|
---|
366 | mov edx,DWORD[rax*4+rdi]
|
---|
367 | mov eax,DWORD[r10*4+rdi]
|
---|
368 | xor dl,BYTE[r12]
|
---|
369 | mov BYTE[r13*1+r12],dl
|
---|
370 | lea r12,[1+r12]
|
---|
371 | dec r11
|
---|
372 | jnz NEAR $L$loop1
|
---|
373 | jmp NEAR $L$exit
|
---|
374 |
|
---|
375 | ALIGN 16
|
---|
376 | $L$RC4_CHAR:
|
---|
377 | add r10b,1
|
---|
378 | movzx eax,BYTE[r10*1+rdi]
|
---|
379 | test r11,-8
|
---|
380 | jz NEAR $L$cloop1
|
---|
381 | jmp NEAR $L$cloop8
|
---|
382 | ALIGN 16
|
---|
383 | $L$cloop8:
|
---|
384 | mov r8d,DWORD[r12]
|
---|
385 | mov r9d,DWORD[4+r12]
|
---|
386 | add cl,al
|
---|
387 | lea rsi,[1+r10]
|
---|
388 | movzx edx,BYTE[rcx*1+rdi]
|
---|
389 | movzx esi,sil
|
---|
390 | movzx ebx,BYTE[rsi*1+rdi]
|
---|
391 | mov BYTE[rcx*1+rdi],al
|
---|
392 | cmp rcx,rsi
|
---|
393 | mov BYTE[r10*1+rdi],dl
|
---|
394 | jne NEAR $L$cmov0
|
---|
395 | mov rbx,rax
|
---|
396 | $L$cmov0:
|
---|
397 | add dl,al
|
---|
398 | xor r8b,BYTE[rdx*1+rdi]
|
---|
399 | ror r8d,8
|
---|
400 | add cl,bl
|
---|
401 | lea r10,[1+rsi]
|
---|
402 | movzx edx,BYTE[rcx*1+rdi]
|
---|
403 | movzx r10d,r10b
|
---|
404 | movzx eax,BYTE[r10*1+rdi]
|
---|
405 | mov BYTE[rcx*1+rdi],bl
|
---|
406 | cmp rcx,r10
|
---|
407 | mov BYTE[rsi*1+rdi],dl
|
---|
408 | jne NEAR $L$cmov1
|
---|
409 | mov rax,rbx
|
---|
410 | $L$cmov1:
|
---|
411 | add dl,bl
|
---|
412 | xor r8b,BYTE[rdx*1+rdi]
|
---|
413 | ror r8d,8
|
---|
414 | add cl,al
|
---|
415 | lea rsi,[1+r10]
|
---|
416 | movzx edx,BYTE[rcx*1+rdi]
|
---|
417 | movzx esi,sil
|
---|
418 | movzx ebx,BYTE[rsi*1+rdi]
|
---|
419 | mov BYTE[rcx*1+rdi],al
|
---|
420 | cmp rcx,rsi
|
---|
421 | mov BYTE[r10*1+rdi],dl
|
---|
422 | jne NEAR $L$cmov2
|
---|
423 | mov rbx,rax
|
---|
424 | $L$cmov2:
|
---|
425 | add dl,al
|
---|
426 | xor r8b,BYTE[rdx*1+rdi]
|
---|
427 | ror r8d,8
|
---|
428 | add cl,bl
|
---|
429 | lea r10,[1+rsi]
|
---|
430 | movzx edx,BYTE[rcx*1+rdi]
|
---|
431 | movzx r10d,r10b
|
---|
432 | movzx eax,BYTE[r10*1+rdi]
|
---|
433 | mov BYTE[rcx*1+rdi],bl
|
---|
434 | cmp rcx,r10
|
---|
435 | mov BYTE[rsi*1+rdi],dl
|
---|
436 | jne NEAR $L$cmov3
|
---|
437 | mov rax,rbx
|
---|
438 | $L$cmov3:
|
---|
439 | add dl,bl
|
---|
440 | xor r8b,BYTE[rdx*1+rdi]
|
---|
441 | ror r8d,8
|
---|
442 | add cl,al
|
---|
443 | lea rsi,[1+r10]
|
---|
444 | movzx edx,BYTE[rcx*1+rdi]
|
---|
445 | movzx esi,sil
|
---|
446 | movzx ebx,BYTE[rsi*1+rdi]
|
---|
447 | mov BYTE[rcx*1+rdi],al
|
---|
448 | cmp rcx,rsi
|
---|
449 | mov BYTE[r10*1+rdi],dl
|
---|
450 | jne NEAR $L$cmov4
|
---|
451 | mov rbx,rax
|
---|
452 | $L$cmov4:
|
---|
453 | add dl,al
|
---|
454 | xor r9b,BYTE[rdx*1+rdi]
|
---|
455 | ror r9d,8
|
---|
456 | add cl,bl
|
---|
457 | lea r10,[1+rsi]
|
---|
458 | movzx edx,BYTE[rcx*1+rdi]
|
---|
459 | movzx r10d,r10b
|
---|
460 | movzx eax,BYTE[r10*1+rdi]
|
---|
461 | mov BYTE[rcx*1+rdi],bl
|
---|
462 | cmp rcx,r10
|
---|
463 | mov BYTE[rsi*1+rdi],dl
|
---|
464 | jne NEAR $L$cmov5
|
---|
465 | mov rax,rbx
|
---|
466 | $L$cmov5:
|
---|
467 | add dl,bl
|
---|
468 | xor r9b,BYTE[rdx*1+rdi]
|
---|
469 | ror r9d,8
|
---|
470 | add cl,al
|
---|
471 | lea rsi,[1+r10]
|
---|
472 | movzx edx,BYTE[rcx*1+rdi]
|
---|
473 | movzx esi,sil
|
---|
474 | movzx ebx,BYTE[rsi*1+rdi]
|
---|
475 | mov BYTE[rcx*1+rdi],al
|
---|
476 | cmp rcx,rsi
|
---|
477 | mov BYTE[r10*1+rdi],dl
|
---|
478 | jne NEAR $L$cmov6
|
---|
479 | mov rbx,rax
|
---|
480 | $L$cmov6:
|
---|
481 | add dl,al
|
---|
482 | xor r9b,BYTE[rdx*1+rdi]
|
---|
483 | ror r9d,8
|
---|
484 | add cl,bl
|
---|
485 | lea r10,[1+rsi]
|
---|
486 | movzx edx,BYTE[rcx*1+rdi]
|
---|
487 | movzx r10d,r10b
|
---|
488 | movzx eax,BYTE[r10*1+rdi]
|
---|
489 | mov BYTE[rcx*1+rdi],bl
|
---|
490 | cmp rcx,r10
|
---|
491 | mov BYTE[rsi*1+rdi],dl
|
---|
492 | jne NEAR $L$cmov7
|
---|
493 | mov rax,rbx
|
---|
494 | $L$cmov7:
|
---|
495 | add dl,bl
|
---|
496 | xor r9b,BYTE[rdx*1+rdi]
|
---|
497 | ror r9d,8
|
---|
498 | lea r11,[((-8))+r11]
|
---|
499 | mov DWORD[r13],r8d
|
---|
500 | lea r12,[8+r12]
|
---|
501 | mov DWORD[4+r13],r9d
|
---|
502 | lea r13,[8+r13]
|
---|
503 |
|
---|
504 | test r11,-8
|
---|
505 | jnz NEAR $L$cloop8
|
---|
506 | cmp r11,0
|
---|
507 | jne NEAR $L$cloop1
|
---|
508 | jmp NEAR $L$exit
|
---|
509 | ALIGN 16
|
---|
510 | $L$cloop1:
|
---|
511 | add cl,al
|
---|
512 | movzx ecx,cl
|
---|
513 | movzx edx,BYTE[rcx*1+rdi]
|
---|
514 | mov BYTE[rcx*1+rdi],al
|
---|
515 | mov BYTE[r10*1+rdi],dl
|
---|
516 | add dl,al
|
---|
517 | add r10b,1
|
---|
518 | movzx edx,dl
|
---|
519 | movzx r10d,r10b
|
---|
520 | movzx edx,BYTE[rdx*1+rdi]
|
---|
521 | movzx eax,BYTE[r10*1+rdi]
|
---|
522 | xor dl,BYTE[r12]
|
---|
523 | lea r12,[1+r12]
|
---|
524 | mov BYTE[r13],dl
|
---|
525 | lea r13,[1+r13]
|
---|
526 | sub r11,1
|
---|
527 | jnz NEAR $L$cloop1
|
---|
528 | jmp NEAR $L$exit
|
---|
529 |
|
---|
530 | ALIGN 16
|
---|
531 | $L$exit:
|
---|
532 | sub r10b,1
|
---|
533 | mov DWORD[((-8))+rdi],r10d
|
---|
534 | mov DWORD[((-4))+rdi],ecx
|
---|
535 |
|
---|
536 | mov r13,QWORD[rsp]
|
---|
537 |
|
---|
538 | mov r12,QWORD[8+rsp]
|
---|
539 |
|
---|
540 | mov rbx,QWORD[16+rsp]
|
---|
541 |
|
---|
542 | add rsp,24
|
---|
543 |
|
---|
544 | $L$epilogue:
|
---|
545 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
546 | mov rsi,QWORD[16+rsp]
|
---|
547 | DB 0F3h,0C3h ;repret
|
---|
548 |
|
---|
549 | $L$SEH_end_RC4:
|
---|
550 | global RC4_set_key
|
---|
551 |
|
---|
552 | ALIGN 16
|
---|
553 | RC4_set_key:
|
---|
554 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
555 | mov QWORD[16+rsp],rsi
|
---|
556 | mov rax,rsp
|
---|
557 | $L$SEH_begin_RC4_set_key:
|
---|
558 | mov rdi,rcx
|
---|
559 | mov rsi,rdx
|
---|
560 | mov rdx,r8
|
---|
561 |
|
---|
562 |
|
---|
563 |
|
---|
564 | DB 243,15,30,250
|
---|
565 | lea rdi,[8+rdi]
|
---|
566 | lea rdx,[rsi*1+rdx]
|
---|
567 | neg rsi
|
---|
568 | mov rcx,rsi
|
---|
569 | xor eax,eax
|
---|
570 | xor r9,r9
|
---|
571 | xor r10,r10
|
---|
572 | xor r11,r11
|
---|
573 |
|
---|
574 | mov r8d,DWORD[OPENSSL_ia32cap_P]
|
---|
575 | bt r8d,20
|
---|
576 | jc NEAR $L$c1stloop
|
---|
577 | jmp NEAR $L$w1stloop
|
---|
578 |
|
---|
579 | ALIGN 16
|
---|
580 | $L$w1stloop:
|
---|
581 | mov DWORD[rax*4+rdi],eax
|
---|
582 | add al,1
|
---|
583 | jnc NEAR $L$w1stloop
|
---|
584 |
|
---|
585 | xor r9,r9
|
---|
586 | xor r8,r8
|
---|
587 | ALIGN 16
|
---|
588 | $L$w2ndloop:
|
---|
589 | mov r10d,DWORD[r9*4+rdi]
|
---|
590 | add r8b,BYTE[rsi*1+rdx]
|
---|
591 | add r8b,r10b
|
---|
592 | add rsi,1
|
---|
593 | mov r11d,DWORD[r8*4+rdi]
|
---|
594 | cmovz rsi,rcx
|
---|
595 | mov DWORD[r8*4+rdi],r10d
|
---|
596 | mov DWORD[r9*4+rdi],r11d
|
---|
597 | add r9b,1
|
---|
598 | jnc NEAR $L$w2ndloop
|
---|
599 | jmp NEAR $L$exit_key
|
---|
600 |
|
---|
601 | ALIGN 16
|
---|
602 | $L$c1stloop:
|
---|
603 | mov BYTE[rax*1+rdi],al
|
---|
604 | add al,1
|
---|
605 | jnc NEAR $L$c1stloop
|
---|
606 |
|
---|
607 | xor r9,r9
|
---|
608 | xor r8,r8
|
---|
609 | ALIGN 16
|
---|
610 | $L$c2ndloop:
|
---|
611 | mov r10b,BYTE[r9*1+rdi]
|
---|
612 | add r8b,BYTE[rsi*1+rdx]
|
---|
613 | add r8b,r10b
|
---|
614 | add rsi,1
|
---|
615 | mov r11b,BYTE[r8*1+rdi]
|
---|
616 | jnz NEAR $L$cnowrap
|
---|
617 | mov rsi,rcx
|
---|
618 | $L$cnowrap:
|
---|
619 | mov BYTE[r8*1+rdi],r10b
|
---|
620 | mov BYTE[r9*1+rdi],r11b
|
---|
621 | add r9b,1
|
---|
622 | jnc NEAR $L$c2ndloop
|
---|
623 | mov DWORD[256+rdi],-1
|
---|
624 |
|
---|
625 | ALIGN 16
|
---|
626 | $L$exit_key:
|
---|
627 | xor eax,eax
|
---|
628 | mov DWORD[((-8))+rdi],eax
|
---|
629 | mov DWORD[((-4))+rdi],eax
|
---|
630 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
631 | mov rsi,QWORD[16+rsp]
|
---|
632 | DB 0F3h,0C3h ;repret
|
---|
633 |
|
---|
634 | $L$SEH_end_RC4_set_key:
|
---|
635 |
|
---|
636 | global RC4_options
|
---|
637 |
|
---|
638 | ALIGN 16
|
---|
639 | RC4_options:
|
---|
640 |
|
---|
641 | DB 243,15,30,250
|
---|
642 | lea rax,[$L$opts]
|
---|
643 | mov edx,DWORD[OPENSSL_ia32cap_P]
|
---|
644 | bt edx,20
|
---|
645 | jc NEAR $L$8xchar
|
---|
646 | bt edx,30
|
---|
647 | jnc NEAR $L$done
|
---|
648 | add rax,25
|
---|
649 | DB 0F3h,0C3h ;repret
|
---|
650 | $L$8xchar:
|
---|
651 | add rax,12
|
---|
652 | $L$done:
|
---|
653 | DB 0F3h,0C3h ;repret
|
---|
654 |
|
---|
655 | ALIGN 64
|
---|
656 | $L$opts:
|
---|
657 | DB 114,99,52,40,56,120,44,105,110,116,41,0
|
---|
658 | DB 114,99,52,40,56,120,44,99,104,97,114,41,0
|
---|
659 | DB 114,99,52,40,49,54,120,44,105,110,116,41,0
|
---|
660 | DB 82,67,52,32,102,111,114,32,120,56,54,95,54,52,44,32
|
---|
661 | DB 67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97
|
---|
662 | DB 112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103
|
---|
663 | DB 62,0
|
---|
664 | ALIGN 64
|
---|
665 |
|
---|
666 | EXTERN __imp_RtlVirtualUnwind
|
---|
667 |
|
---|
668 | ALIGN 16
|
---|
669 | stream_se_handler:
|
---|
670 | push rsi
|
---|
671 | push rdi
|
---|
672 | push rbx
|
---|
673 | push rbp
|
---|
674 | push r12
|
---|
675 | push r13
|
---|
676 | push r14
|
---|
677 | push r15
|
---|
678 | pushfq
|
---|
679 | sub rsp,64
|
---|
680 |
|
---|
681 | mov rax,QWORD[120+r8]
|
---|
682 | mov rbx,QWORD[248+r8]
|
---|
683 |
|
---|
684 | lea r10,[$L$prologue]
|
---|
685 | cmp rbx,r10
|
---|
686 | jb NEAR $L$in_prologue
|
---|
687 |
|
---|
688 | mov rax,QWORD[152+r8]
|
---|
689 |
|
---|
690 | lea r10,[$L$epilogue]
|
---|
691 | cmp rbx,r10
|
---|
692 | jae NEAR $L$in_prologue
|
---|
693 |
|
---|
694 | lea rax,[24+rax]
|
---|
695 |
|
---|
696 | mov rbx,QWORD[((-8))+rax]
|
---|
697 | mov r12,QWORD[((-16))+rax]
|
---|
698 | mov r13,QWORD[((-24))+rax]
|
---|
699 | mov QWORD[144+r8],rbx
|
---|
700 | mov QWORD[216+r8],r12
|
---|
701 | mov QWORD[224+r8],r13
|
---|
702 |
|
---|
703 | $L$in_prologue:
|
---|
704 | mov rdi,QWORD[8+rax]
|
---|
705 | mov rsi,QWORD[16+rax]
|
---|
706 | mov QWORD[152+r8],rax
|
---|
707 | mov QWORD[168+r8],rsi
|
---|
708 | mov QWORD[176+r8],rdi
|
---|
709 |
|
---|
710 | jmp NEAR $L$common_seh_exit
|
---|
711 |
|
---|
712 |
|
---|
713 |
|
---|
714 | ALIGN 16
|
---|
715 | key_se_handler:
|
---|
716 | push rsi
|
---|
717 | push rdi
|
---|
718 | push rbx
|
---|
719 | push rbp
|
---|
720 | push r12
|
---|
721 | push r13
|
---|
722 | push r14
|
---|
723 | push r15
|
---|
724 | pushfq
|
---|
725 | sub rsp,64
|
---|
726 |
|
---|
727 | mov rax,QWORD[152+r8]
|
---|
728 | mov rdi,QWORD[8+rax]
|
---|
729 | mov rsi,QWORD[16+rax]
|
---|
730 | mov QWORD[168+r8],rsi
|
---|
731 | mov QWORD[176+r8],rdi
|
---|
732 |
|
---|
733 | $L$common_seh_exit:
|
---|
734 |
|
---|
735 | mov rdi,QWORD[40+r9]
|
---|
736 | mov rsi,r8
|
---|
737 | mov ecx,154
|
---|
738 | DD 0xa548f3fc
|
---|
739 |
|
---|
740 | mov rsi,r9
|
---|
741 | xor rcx,rcx
|
---|
742 | mov rdx,QWORD[8+rsi]
|
---|
743 | mov r8,QWORD[rsi]
|
---|
744 | mov r9,QWORD[16+rsi]
|
---|
745 | mov r10,QWORD[40+rsi]
|
---|
746 | lea r11,[56+rsi]
|
---|
747 | lea r12,[24+rsi]
|
---|
748 | mov QWORD[32+rsp],r10
|
---|
749 | mov QWORD[40+rsp],r11
|
---|
750 | mov QWORD[48+rsp],r12
|
---|
751 | mov QWORD[56+rsp],rcx
|
---|
752 | call QWORD[__imp_RtlVirtualUnwind]
|
---|
753 |
|
---|
754 | mov eax,1
|
---|
755 | add rsp,64
|
---|
756 | popfq
|
---|
757 | pop r15
|
---|
758 | pop r14
|
---|
759 | pop r13
|
---|
760 | pop r12
|
---|
761 | pop rbp
|
---|
762 | pop rbx
|
---|
763 | pop rdi
|
---|
764 | pop rsi
|
---|
765 | DB 0F3h,0C3h ;repret
|
---|
766 |
|
---|
767 |
|
---|
768 | section .pdata rdata align=4
|
---|
769 | ALIGN 4
|
---|
770 | DD $L$SEH_begin_RC4 wrt ..imagebase
|
---|
771 | DD $L$SEH_end_RC4 wrt ..imagebase
|
---|
772 | DD $L$SEH_info_RC4 wrt ..imagebase
|
---|
773 |
|
---|
774 | DD $L$SEH_begin_RC4_set_key wrt ..imagebase
|
---|
775 | DD $L$SEH_end_RC4_set_key wrt ..imagebase
|
---|
776 | DD $L$SEH_info_RC4_set_key wrt ..imagebase
|
---|
777 |
|
---|
778 | section .xdata rdata align=8
|
---|
779 | ALIGN 8
|
---|
780 | $L$SEH_info_RC4:
|
---|
781 | DB 9,0,0,0
|
---|
782 | DD stream_se_handler wrt ..imagebase
|
---|
783 | $L$SEH_info_RC4_set_key:
|
---|
784 | DB 9,0,0,0
|
---|
785 | DD key_se_handler wrt ..imagebase
|
---|