1 | %ifidn __OUTPUT_FORMAT__,obj
|
---|
2 | section code use32 class=code align=64
|
---|
3 | %elifidn __OUTPUT_FORMAT__,win32
|
---|
4 | section .text code align=64
|
---|
5 | %else
|
---|
6 | section .text code
|
---|
7 | %endif
|
---|
8 | ;extern _OPENSSL_ia32cap_P
|
---|
9 | global _RC4
|
---|
10 | align 16
|
---|
11 | _RC4:
|
---|
12 | L$_RC4_begin:
|
---|
13 | push ebp
|
---|
14 | push ebx
|
---|
15 | push esi
|
---|
16 | push edi
|
---|
17 | mov edi,DWORD [20+esp]
|
---|
18 | mov edx,DWORD [24+esp]
|
---|
19 | mov esi,DWORD [28+esp]
|
---|
20 | mov ebp,DWORD [32+esp]
|
---|
21 | xor eax,eax
|
---|
22 | xor ebx,ebx
|
---|
23 | cmp edx,0
|
---|
24 | je NEAR L$000abort
|
---|
25 | mov al,BYTE [edi]
|
---|
26 | mov bl,BYTE [4+edi]
|
---|
27 | add edi,8
|
---|
28 | lea ecx,[edx*1+esi]
|
---|
29 | sub ebp,esi
|
---|
30 | mov DWORD [24+esp],ecx
|
---|
31 | inc al
|
---|
32 | cmp DWORD [256+edi],-1
|
---|
33 | je NEAR L$001RC4_CHAR
|
---|
34 | mov ecx,DWORD [eax*4+edi]
|
---|
35 | and edx,-4
|
---|
36 | jz NEAR L$002loop1
|
---|
37 | mov DWORD [32+esp],ebp
|
---|
38 | test edx,-8
|
---|
39 | jz NEAR L$003go4loop4
|
---|
40 | lea ebp,[_OPENSSL_ia32cap_P]
|
---|
41 | bt DWORD [ebp],26
|
---|
42 | jnc NEAR L$003go4loop4
|
---|
43 | mov ebp,DWORD [32+esp]
|
---|
44 | and edx,-8
|
---|
45 | lea edx,[edx*1+esi-8]
|
---|
46 | mov DWORD [edi-4],edx
|
---|
47 | add bl,cl
|
---|
48 | mov edx,DWORD [ebx*4+edi]
|
---|
49 | mov DWORD [ebx*4+edi],ecx
|
---|
50 | mov DWORD [eax*4+edi],edx
|
---|
51 | inc eax
|
---|
52 | add edx,ecx
|
---|
53 | movzx eax,al
|
---|
54 | movzx edx,dl
|
---|
55 | movq mm0,[esi]
|
---|
56 | mov ecx,DWORD [eax*4+edi]
|
---|
57 | movd mm2,DWORD [edx*4+edi]
|
---|
58 | jmp NEAR L$004loop_mmx_enter
|
---|
59 | align 16
|
---|
60 | L$005loop_mmx:
|
---|
61 | add bl,cl
|
---|
62 | psllq mm1,56
|
---|
63 | mov edx,DWORD [ebx*4+edi]
|
---|
64 | mov DWORD [ebx*4+edi],ecx
|
---|
65 | mov DWORD [eax*4+edi],edx
|
---|
66 | inc eax
|
---|
67 | add edx,ecx
|
---|
68 | movzx eax,al
|
---|
69 | movzx edx,dl
|
---|
70 | pxor mm2,mm1
|
---|
71 | movq mm0,[esi]
|
---|
72 | movq [esi*1+ebp-8],mm2
|
---|
73 | mov ecx,DWORD [eax*4+edi]
|
---|
74 | movd mm2,DWORD [edx*4+edi]
|
---|
75 | L$004loop_mmx_enter:
|
---|
76 | add bl,cl
|
---|
77 | mov edx,DWORD [ebx*4+edi]
|
---|
78 | mov DWORD [ebx*4+edi],ecx
|
---|
79 | mov DWORD [eax*4+edi],edx
|
---|
80 | inc eax
|
---|
81 | add edx,ecx
|
---|
82 | movzx eax,al
|
---|
83 | movzx edx,dl
|
---|
84 | pxor mm2,mm0
|
---|
85 | mov ecx,DWORD [eax*4+edi]
|
---|
86 | movd mm1,DWORD [edx*4+edi]
|
---|
87 | add bl,cl
|
---|
88 | psllq mm1,8
|
---|
89 | mov edx,DWORD [ebx*4+edi]
|
---|
90 | mov DWORD [ebx*4+edi],ecx
|
---|
91 | mov DWORD [eax*4+edi],edx
|
---|
92 | inc eax
|
---|
93 | add edx,ecx
|
---|
94 | movzx eax,al
|
---|
95 | movzx edx,dl
|
---|
96 | pxor mm2,mm1
|
---|
97 | mov ecx,DWORD [eax*4+edi]
|
---|
98 | movd mm1,DWORD [edx*4+edi]
|
---|
99 | add bl,cl
|
---|
100 | psllq mm1,16
|
---|
101 | mov edx,DWORD [ebx*4+edi]
|
---|
102 | mov DWORD [ebx*4+edi],ecx
|
---|
103 | mov DWORD [eax*4+edi],edx
|
---|
104 | inc eax
|
---|
105 | add edx,ecx
|
---|
106 | movzx eax,al
|
---|
107 | movzx edx,dl
|
---|
108 | pxor mm2,mm1
|
---|
109 | mov ecx,DWORD [eax*4+edi]
|
---|
110 | movd mm1,DWORD [edx*4+edi]
|
---|
111 | add bl,cl
|
---|
112 | psllq mm1,24
|
---|
113 | mov edx,DWORD [ebx*4+edi]
|
---|
114 | mov DWORD [ebx*4+edi],ecx
|
---|
115 | mov DWORD [eax*4+edi],edx
|
---|
116 | inc eax
|
---|
117 | add edx,ecx
|
---|
118 | movzx eax,al
|
---|
119 | movzx edx,dl
|
---|
120 | pxor mm2,mm1
|
---|
121 | mov ecx,DWORD [eax*4+edi]
|
---|
122 | movd mm1,DWORD [edx*4+edi]
|
---|
123 | add bl,cl
|
---|
124 | psllq mm1,32
|
---|
125 | mov edx,DWORD [ebx*4+edi]
|
---|
126 | mov DWORD [ebx*4+edi],ecx
|
---|
127 | mov DWORD [eax*4+edi],edx
|
---|
128 | inc eax
|
---|
129 | add edx,ecx
|
---|
130 | movzx eax,al
|
---|
131 | movzx edx,dl
|
---|
132 | pxor mm2,mm1
|
---|
133 | mov ecx,DWORD [eax*4+edi]
|
---|
134 | movd mm1,DWORD [edx*4+edi]
|
---|
135 | add bl,cl
|
---|
136 | psllq mm1,40
|
---|
137 | mov edx,DWORD [ebx*4+edi]
|
---|
138 | mov DWORD [ebx*4+edi],ecx
|
---|
139 | mov DWORD [eax*4+edi],edx
|
---|
140 | inc eax
|
---|
141 | add edx,ecx
|
---|
142 | movzx eax,al
|
---|
143 | movzx edx,dl
|
---|
144 | pxor mm2,mm1
|
---|
145 | mov ecx,DWORD [eax*4+edi]
|
---|
146 | movd mm1,DWORD [edx*4+edi]
|
---|
147 | add bl,cl
|
---|
148 | psllq mm1,48
|
---|
149 | mov edx,DWORD [ebx*4+edi]
|
---|
150 | mov DWORD [ebx*4+edi],ecx
|
---|
151 | mov DWORD [eax*4+edi],edx
|
---|
152 | inc eax
|
---|
153 | add edx,ecx
|
---|
154 | movzx eax,al
|
---|
155 | movzx edx,dl
|
---|
156 | pxor mm2,mm1
|
---|
157 | mov ecx,DWORD [eax*4+edi]
|
---|
158 | movd mm1,DWORD [edx*4+edi]
|
---|
159 | mov edx,ebx
|
---|
160 | xor ebx,ebx
|
---|
161 | mov bl,dl
|
---|
162 | cmp esi,DWORD [edi-4]
|
---|
163 | lea esi,[8+esi]
|
---|
164 | jb NEAR L$005loop_mmx
|
---|
165 | psllq mm1,56
|
---|
166 | pxor mm2,mm1
|
---|
167 | movq [esi*1+ebp-8],mm2
|
---|
168 | emms
|
---|
169 | cmp esi,DWORD [24+esp]
|
---|
170 | je NEAR L$006done
|
---|
171 | jmp NEAR L$002loop1
|
---|
172 | align 16
|
---|
173 | L$003go4loop4:
|
---|
174 | lea edx,[edx*1+esi-4]
|
---|
175 | mov DWORD [28+esp],edx
|
---|
176 | L$007loop4:
|
---|
177 | add bl,cl
|
---|
178 | mov edx,DWORD [ebx*4+edi]
|
---|
179 | mov DWORD [ebx*4+edi],ecx
|
---|
180 | mov DWORD [eax*4+edi],edx
|
---|
181 | add edx,ecx
|
---|
182 | inc al
|
---|
183 | and edx,255
|
---|
184 | mov ecx,DWORD [eax*4+edi]
|
---|
185 | mov ebp,DWORD [edx*4+edi]
|
---|
186 | add bl,cl
|
---|
187 | mov edx,DWORD [ebx*4+edi]
|
---|
188 | mov DWORD [ebx*4+edi],ecx
|
---|
189 | mov DWORD [eax*4+edi],edx
|
---|
190 | add edx,ecx
|
---|
191 | inc al
|
---|
192 | and edx,255
|
---|
193 | ror ebp,8
|
---|
194 | mov ecx,DWORD [eax*4+edi]
|
---|
195 | or ebp,DWORD [edx*4+edi]
|
---|
196 | add bl,cl
|
---|
197 | mov edx,DWORD [ebx*4+edi]
|
---|
198 | mov DWORD [ebx*4+edi],ecx
|
---|
199 | mov DWORD [eax*4+edi],edx
|
---|
200 | add edx,ecx
|
---|
201 | inc al
|
---|
202 | and edx,255
|
---|
203 | ror ebp,8
|
---|
204 | mov ecx,DWORD [eax*4+edi]
|
---|
205 | or ebp,DWORD [edx*4+edi]
|
---|
206 | add bl,cl
|
---|
207 | mov edx,DWORD [ebx*4+edi]
|
---|
208 | mov DWORD [ebx*4+edi],ecx
|
---|
209 | mov DWORD [eax*4+edi],edx
|
---|
210 | add edx,ecx
|
---|
211 | inc al
|
---|
212 | and edx,255
|
---|
213 | ror ebp,8
|
---|
214 | mov ecx,DWORD [32+esp]
|
---|
215 | or ebp,DWORD [edx*4+edi]
|
---|
216 | ror ebp,8
|
---|
217 | xor ebp,DWORD [esi]
|
---|
218 | cmp esi,DWORD [28+esp]
|
---|
219 | mov DWORD [esi*1+ecx],ebp
|
---|
220 | lea esi,[4+esi]
|
---|
221 | mov ecx,DWORD [eax*4+edi]
|
---|
222 | jb NEAR L$007loop4
|
---|
223 | cmp esi,DWORD [24+esp]
|
---|
224 | je NEAR L$006done
|
---|
225 | mov ebp,DWORD [32+esp]
|
---|
226 | align 16
|
---|
227 | L$002loop1:
|
---|
228 | add bl,cl
|
---|
229 | mov edx,DWORD [ebx*4+edi]
|
---|
230 | mov DWORD [ebx*4+edi],ecx
|
---|
231 | mov DWORD [eax*4+edi],edx
|
---|
232 | add edx,ecx
|
---|
233 | inc al
|
---|
234 | and edx,255
|
---|
235 | mov edx,DWORD [edx*4+edi]
|
---|
236 | xor dl,BYTE [esi]
|
---|
237 | lea esi,[1+esi]
|
---|
238 | mov ecx,DWORD [eax*4+edi]
|
---|
239 | cmp esi,DWORD [24+esp]
|
---|
240 | mov BYTE [esi*1+ebp-1],dl
|
---|
241 | jb NEAR L$002loop1
|
---|
242 | jmp NEAR L$006done
|
---|
243 | align 16
|
---|
244 | L$001RC4_CHAR:
|
---|
245 | movzx ecx,BYTE [eax*1+edi]
|
---|
246 | L$008cloop1:
|
---|
247 | add bl,cl
|
---|
248 | movzx edx,BYTE [ebx*1+edi]
|
---|
249 | mov BYTE [ebx*1+edi],cl
|
---|
250 | mov BYTE [eax*1+edi],dl
|
---|
251 | add dl,cl
|
---|
252 | movzx edx,BYTE [edx*1+edi]
|
---|
253 | add al,1
|
---|
254 | xor dl,BYTE [esi]
|
---|
255 | lea esi,[1+esi]
|
---|
256 | movzx ecx,BYTE [eax*1+edi]
|
---|
257 | cmp esi,DWORD [24+esp]
|
---|
258 | mov BYTE [esi*1+ebp-1],dl
|
---|
259 | jb NEAR L$008cloop1
|
---|
260 | L$006done:
|
---|
261 | dec al
|
---|
262 | mov DWORD [edi-4],ebx
|
---|
263 | mov BYTE [edi-8],al
|
---|
264 | L$000abort:
|
---|
265 | pop edi
|
---|
266 | pop esi
|
---|
267 | pop ebx
|
---|
268 | pop ebp
|
---|
269 | ret
|
---|
270 | global _RC4_set_key
|
---|
271 | align 16
|
---|
272 | _RC4_set_key:
|
---|
273 | L$_RC4_set_key_begin:
|
---|
274 | push ebp
|
---|
275 | push ebx
|
---|
276 | push esi
|
---|
277 | push edi
|
---|
278 | mov edi,DWORD [20+esp]
|
---|
279 | mov ebp,DWORD [24+esp]
|
---|
280 | mov esi,DWORD [28+esp]
|
---|
281 | lea edx,[_OPENSSL_ia32cap_P]
|
---|
282 | lea edi,[8+edi]
|
---|
283 | lea esi,[ebp*1+esi]
|
---|
284 | neg ebp
|
---|
285 | xor eax,eax
|
---|
286 | mov DWORD [edi-4],ebp
|
---|
287 | bt DWORD [edx],20
|
---|
288 | jc NEAR L$009c1stloop
|
---|
289 | align 16
|
---|
290 | L$010w1stloop:
|
---|
291 | mov DWORD [eax*4+edi],eax
|
---|
292 | add al,1
|
---|
293 | jnc NEAR L$010w1stloop
|
---|
294 | xor ecx,ecx
|
---|
295 | xor edx,edx
|
---|
296 | align 16
|
---|
297 | L$011w2ndloop:
|
---|
298 | mov eax,DWORD [ecx*4+edi]
|
---|
299 | add dl,BYTE [ebp*1+esi]
|
---|
300 | add dl,al
|
---|
301 | add ebp,1
|
---|
302 | mov ebx,DWORD [edx*4+edi]
|
---|
303 | jnz NEAR L$012wnowrap
|
---|
304 | mov ebp,DWORD [edi-4]
|
---|
305 | L$012wnowrap:
|
---|
306 | mov DWORD [edx*4+edi],eax
|
---|
307 | mov DWORD [ecx*4+edi],ebx
|
---|
308 | add cl,1
|
---|
309 | jnc NEAR L$011w2ndloop
|
---|
310 | jmp NEAR L$013exit
|
---|
311 | align 16
|
---|
312 | L$009c1stloop:
|
---|
313 | mov BYTE [eax*1+edi],al
|
---|
314 | add al,1
|
---|
315 | jnc NEAR L$009c1stloop
|
---|
316 | xor ecx,ecx
|
---|
317 | xor edx,edx
|
---|
318 | xor ebx,ebx
|
---|
319 | align 16
|
---|
320 | L$014c2ndloop:
|
---|
321 | mov al,BYTE [ecx*1+edi]
|
---|
322 | add dl,BYTE [ebp*1+esi]
|
---|
323 | add dl,al
|
---|
324 | add ebp,1
|
---|
325 | mov bl,BYTE [edx*1+edi]
|
---|
326 | jnz NEAR L$015cnowrap
|
---|
327 | mov ebp,DWORD [edi-4]
|
---|
328 | L$015cnowrap:
|
---|
329 | mov BYTE [edx*1+edi],al
|
---|
330 | mov BYTE [ecx*1+edi],bl
|
---|
331 | add cl,1
|
---|
332 | jnc NEAR L$014c2ndloop
|
---|
333 | mov DWORD [256+edi],-1
|
---|
334 | L$013exit:
|
---|
335 | xor eax,eax
|
---|
336 | mov DWORD [edi-8],eax
|
---|
337 | mov DWORD [edi-4],eax
|
---|
338 | pop edi
|
---|
339 | pop esi
|
---|
340 | pop ebx
|
---|
341 | pop ebp
|
---|
342 | ret
|
---|
343 | global _RC4_options
|
---|
344 | align 16
|
---|
345 | _RC4_options:
|
---|
346 | L$_RC4_options_begin:
|
---|
347 | call L$016pic_point
|
---|
348 | L$016pic_point:
|
---|
349 | pop eax
|
---|
350 | lea eax,[(L$017opts-L$016pic_point)+eax]
|
---|
351 | lea edx,[_OPENSSL_ia32cap_P]
|
---|
352 | mov edx,DWORD [edx]
|
---|
353 | bt edx,20
|
---|
354 | jc NEAR L$0181xchar
|
---|
355 | bt edx,26
|
---|
356 | jnc NEAR L$019ret
|
---|
357 | add eax,25
|
---|
358 | ret
|
---|
359 | L$0181xchar:
|
---|
360 | add eax,12
|
---|
361 | L$019ret:
|
---|
362 | ret
|
---|
363 | align 64
|
---|
364 | L$017opts:
|
---|
365 | db 114,99,52,40,52,120,44,105,110,116,41,0
|
---|
366 | db 114,99,52,40,49,120,44,99,104,97,114,41,0
|
---|
367 | db 114,99,52,40,56,120,44,109,109,120,41,0
|
---|
368 | db 82,67,52,32,102,111,114,32,120,56,54,44,32,67,82,89
|
---|
369 | db 80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114
|
---|
370 | db 111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
---|
371 | align 64
|
---|
372 | segment .bss
|
---|
373 | common _OPENSSL_ia32cap_P 16
|
---|