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 | global _ChaCha20_ctr32
|
---|
9 | align 16
|
---|
10 | _ChaCha20_ctr32:
|
---|
11 | L$_ChaCha20_ctr32_begin:
|
---|
12 | push ebp
|
---|
13 | push ebx
|
---|
14 | push esi
|
---|
15 | push edi
|
---|
16 | xor eax,eax
|
---|
17 | cmp eax,DWORD [28+esp]
|
---|
18 | je NEAR L$000no_data
|
---|
19 | mov esi,DWORD [32+esp]
|
---|
20 | mov edi,DWORD [36+esp]
|
---|
21 | sub esp,132
|
---|
22 | mov eax,DWORD [esi]
|
---|
23 | mov ebx,DWORD [4+esi]
|
---|
24 | mov ecx,DWORD [8+esi]
|
---|
25 | mov edx,DWORD [12+esi]
|
---|
26 | mov DWORD [80+esp],eax
|
---|
27 | mov DWORD [84+esp],ebx
|
---|
28 | mov DWORD [88+esp],ecx
|
---|
29 | mov DWORD [92+esp],edx
|
---|
30 | mov eax,DWORD [16+esi]
|
---|
31 | mov ebx,DWORD [20+esi]
|
---|
32 | mov ecx,DWORD [24+esi]
|
---|
33 | mov edx,DWORD [28+esi]
|
---|
34 | mov DWORD [96+esp],eax
|
---|
35 | mov DWORD [100+esp],ebx
|
---|
36 | mov DWORD [104+esp],ecx
|
---|
37 | mov DWORD [108+esp],edx
|
---|
38 | mov eax,DWORD [edi]
|
---|
39 | mov ebx,DWORD [4+edi]
|
---|
40 | mov ecx,DWORD [8+edi]
|
---|
41 | mov edx,DWORD [12+edi]
|
---|
42 | sub eax,1
|
---|
43 | mov DWORD [112+esp],eax
|
---|
44 | mov DWORD [116+esp],ebx
|
---|
45 | mov DWORD [120+esp],ecx
|
---|
46 | mov DWORD [124+esp],edx
|
---|
47 | jmp NEAR L$001entry
|
---|
48 | align 16
|
---|
49 | L$002outer_loop:
|
---|
50 | mov DWORD [156+esp],ebx
|
---|
51 | mov DWORD [152+esp],eax
|
---|
52 | mov DWORD [160+esp],ecx
|
---|
53 | L$001entry:
|
---|
54 | mov eax,1634760805
|
---|
55 | mov DWORD [4+esp],857760878
|
---|
56 | mov DWORD [8+esp],2036477234
|
---|
57 | mov DWORD [12+esp],1797285236
|
---|
58 | mov ebx,DWORD [84+esp]
|
---|
59 | mov ebp,DWORD [88+esp]
|
---|
60 | mov ecx,DWORD [104+esp]
|
---|
61 | mov esi,DWORD [108+esp]
|
---|
62 | mov edx,DWORD [116+esp]
|
---|
63 | mov edi,DWORD [120+esp]
|
---|
64 | mov DWORD [20+esp],ebx
|
---|
65 | mov DWORD [24+esp],ebp
|
---|
66 | mov DWORD [40+esp],ecx
|
---|
67 | mov DWORD [44+esp],esi
|
---|
68 | mov DWORD [52+esp],edx
|
---|
69 | mov DWORD [56+esp],edi
|
---|
70 | mov ebx,DWORD [92+esp]
|
---|
71 | mov edi,DWORD [124+esp]
|
---|
72 | mov edx,DWORD [112+esp]
|
---|
73 | mov ebp,DWORD [80+esp]
|
---|
74 | mov ecx,DWORD [96+esp]
|
---|
75 | mov esi,DWORD [100+esp]
|
---|
76 | add edx,1
|
---|
77 | mov DWORD [28+esp],ebx
|
---|
78 | mov DWORD [60+esp],edi
|
---|
79 | mov DWORD [112+esp],edx
|
---|
80 | mov ebx,10
|
---|
81 | jmp NEAR L$003loop
|
---|
82 | align 16
|
---|
83 | L$003loop:
|
---|
84 | add eax,ebp
|
---|
85 | mov DWORD [128+esp],ebx
|
---|
86 | mov ebx,ebp
|
---|
87 | xor edx,eax
|
---|
88 | rol edx,16
|
---|
89 | add ecx,edx
|
---|
90 | xor ebx,ecx
|
---|
91 | mov edi,DWORD [52+esp]
|
---|
92 | rol ebx,12
|
---|
93 | mov ebp,DWORD [20+esp]
|
---|
94 | add eax,ebx
|
---|
95 | xor edx,eax
|
---|
96 | mov DWORD [esp],eax
|
---|
97 | rol edx,8
|
---|
98 | mov eax,DWORD [4+esp]
|
---|
99 | add ecx,edx
|
---|
100 | mov DWORD [48+esp],edx
|
---|
101 | xor ebx,ecx
|
---|
102 | add eax,ebp
|
---|
103 | rol ebx,7
|
---|
104 | xor edi,eax
|
---|
105 | mov DWORD [32+esp],ecx
|
---|
106 | rol edi,16
|
---|
107 | mov DWORD [16+esp],ebx
|
---|
108 | add esi,edi
|
---|
109 | mov ecx,DWORD [40+esp]
|
---|
110 | xor ebp,esi
|
---|
111 | mov edx,DWORD [56+esp]
|
---|
112 | rol ebp,12
|
---|
113 | mov ebx,DWORD [24+esp]
|
---|
114 | add eax,ebp
|
---|
115 | xor edi,eax
|
---|
116 | mov DWORD [4+esp],eax
|
---|
117 | rol edi,8
|
---|
118 | mov eax,DWORD [8+esp]
|
---|
119 | add esi,edi
|
---|
120 | mov DWORD [52+esp],edi
|
---|
121 | xor ebp,esi
|
---|
122 | add eax,ebx
|
---|
123 | rol ebp,7
|
---|
124 | xor edx,eax
|
---|
125 | mov DWORD [36+esp],esi
|
---|
126 | rol edx,16
|
---|
127 | mov DWORD [20+esp],ebp
|
---|
128 | add ecx,edx
|
---|
129 | mov esi,DWORD [44+esp]
|
---|
130 | xor ebx,ecx
|
---|
131 | mov edi,DWORD [60+esp]
|
---|
132 | rol ebx,12
|
---|
133 | mov ebp,DWORD [28+esp]
|
---|
134 | add eax,ebx
|
---|
135 | xor edx,eax
|
---|
136 | mov DWORD [8+esp],eax
|
---|
137 | rol edx,8
|
---|
138 | mov eax,DWORD [12+esp]
|
---|
139 | add ecx,edx
|
---|
140 | mov DWORD [56+esp],edx
|
---|
141 | xor ebx,ecx
|
---|
142 | add eax,ebp
|
---|
143 | rol ebx,7
|
---|
144 | xor edi,eax
|
---|
145 | rol edi,16
|
---|
146 | mov DWORD [24+esp],ebx
|
---|
147 | add esi,edi
|
---|
148 | xor ebp,esi
|
---|
149 | rol ebp,12
|
---|
150 | mov ebx,DWORD [20+esp]
|
---|
151 | add eax,ebp
|
---|
152 | xor edi,eax
|
---|
153 | mov DWORD [12+esp],eax
|
---|
154 | rol edi,8
|
---|
155 | mov eax,DWORD [esp]
|
---|
156 | add esi,edi
|
---|
157 | mov edx,edi
|
---|
158 | xor ebp,esi
|
---|
159 | add eax,ebx
|
---|
160 | rol ebp,7
|
---|
161 | xor edx,eax
|
---|
162 | rol edx,16
|
---|
163 | mov DWORD [28+esp],ebp
|
---|
164 | add ecx,edx
|
---|
165 | xor ebx,ecx
|
---|
166 | mov edi,DWORD [48+esp]
|
---|
167 | rol ebx,12
|
---|
168 | mov ebp,DWORD [24+esp]
|
---|
169 | add eax,ebx
|
---|
170 | xor edx,eax
|
---|
171 | mov DWORD [esp],eax
|
---|
172 | rol edx,8
|
---|
173 | mov eax,DWORD [4+esp]
|
---|
174 | add ecx,edx
|
---|
175 | mov DWORD [60+esp],edx
|
---|
176 | xor ebx,ecx
|
---|
177 | add eax,ebp
|
---|
178 | rol ebx,7
|
---|
179 | xor edi,eax
|
---|
180 | mov DWORD [40+esp],ecx
|
---|
181 | rol edi,16
|
---|
182 | mov DWORD [20+esp],ebx
|
---|
183 | add esi,edi
|
---|
184 | mov ecx,DWORD [32+esp]
|
---|
185 | xor ebp,esi
|
---|
186 | mov edx,DWORD [52+esp]
|
---|
187 | rol ebp,12
|
---|
188 | mov ebx,DWORD [28+esp]
|
---|
189 | add eax,ebp
|
---|
190 | xor edi,eax
|
---|
191 | mov DWORD [4+esp],eax
|
---|
192 | rol edi,8
|
---|
193 | mov eax,DWORD [8+esp]
|
---|
194 | add esi,edi
|
---|
195 | mov DWORD [48+esp],edi
|
---|
196 | xor ebp,esi
|
---|
197 | add eax,ebx
|
---|
198 | rol ebp,7
|
---|
199 | xor edx,eax
|
---|
200 | mov DWORD [44+esp],esi
|
---|
201 | rol edx,16
|
---|
202 | mov DWORD [24+esp],ebp
|
---|
203 | add ecx,edx
|
---|
204 | mov esi,DWORD [36+esp]
|
---|
205 | xor ebx,ecx
|
---|
206 | mov edi,DWORD [56+esp]
|
---|
207 | rol ebx,12
|
---|
208 | mov ebp,DWORD [16+esp]
|
---|
209 | add eax,ebx
|
---|
210 | xor edx,eax
|
---|
211 | mov DWORD [8+esp],eax
|
---|
212 | rol edx,8
|
---|
213 | mov eax,DWORD [12+esp]
|
---|
214 | add ecx,edx
|
---|
215 | mov DWORD [52+esp],edx
|
---|
216 | xor ebx,ecx
|
---|
217 | add eax,ebp
|
---|
218 | rol ebx,7
|
---|
219 | xor edi,eax
|
---|
220 | rol edi,16
|
---|
221 | mov DWORD [28+esp],ebx
|
---|
222 | add esi,edi
|
---|
223 | xor ebp,esi
|
---|
224 | mov edx,DWORD [48+esp]
|
---|
225 | rol ebp,12
|
---|
226 | mov ebx,DWORD [128+esp]
|
---|
227 | add eax,ebp
|
---|
228 | xor edi,eax
|
---|
229 | mov DWORD [12+esp],eax
|
---|
230 | rol edi,8
|
---|
231 | mov eax,DWORD [esp]
|
---|
232 | add esi,edi
|
---|
233 | mov DWORD [56+esp],edi
|
---|
234 | xor ebp,esi
|
---|
235 | rol ebp,7
|
---|
236 | dec ebx
|
---|
237 | jnz NEAR L$003loop
|
---|
238 | mov ebx,DWORD [160+esp]
|
---|
239 | add eax,1634760805
|
---|
240 | add ebp,DWORD [80+esp]
|
---|
241 | add ecx,DWORD [96+esp]
|
---|
242 | add esi,DWORD [100+esp]
|
---|
243 | cmp ebx,64
|
---|
244 | jb NEAR L$004tail
|
---|
245 | mov ebx,DWORD [156+esp]
|
---|
246 | add edx,DWORD [112+esp]
|
---|
247 | add edi,DWORD [120+esp]
|
---|
248 | xor eax,DWORD [ebx]
|
---|
249 | xor ebp,DWORD [16+ebx]
|
---|
250 | mov DWORD [esp],eax
|
---|
251 | mov eax,DWORD [152+esp]
|
---|
252 | xor ecx,DWORD [32+ebx]
|
---|
253 | xor esi,DWORD [36+ebx]
|
---|
254 | xor edx,DWORD [48+ebx]
|
---|
255 | xor edi,DWORD [56+ebx]
|
---|
256 | mov DWORD [16+eax],ebp
|
---|
257 | mov DWORD [32+eax],ecx
|
---|
258 | mov DWORD [36+eax],esi
|
---|
259 | mov DWORD [48+eax],edx
|
---|
260 | mov DWORD [56+eax],edi
|
---|
261 | mov ebp,DWORD [4+esp]
|
---|
262 | mov ecx,DWORD [8+esp]
|
---|
263 | mov esi,DWORD [12+esp]
|
---|
264 | mov edx,DWORD [20+esp]
|
---|
265 | mov edi,DWORD [24+esp]
|
---|
266 | add ebp,857760878
|
---|
267 | add ecx,2036477234
|
---|
268 | add esi,1797285236
|
---|
269 | add edx,DWORD [84+esp]
|
---|
270 | add edi,DWORD [88+esp]
|
---|
271 | xor ebp,DWORD [4+ebx]
|
---|
272 | xor ecx,DWORD [8+ebx]
|
---|
273 | xor esi,DWORD [12+ebx]
|
---|
274 | xor edx,DWORD [20+ebx]
|
---|
275 | xor edi,DWORD [24+ebx]
|
---|
276 | mov DWORD [4+eax],ebp
|
---|
277 | mov DWORD [8+eax],ecx
|
---|
278 | mov DWORD [12+eax],esi
|
---|
279 | mov DWORD [20+eax],edx
|
---|
280 | mov DWORD [24+eax],edi
|
---|
281 | mov ebp,DWORD [28+esp]
|
---|
282 | mov ecx,DWORD [40+esp]
|
---|
283 | mov esi,DWORD [44+esp]
|
---|
284 | mov edx,DWORD [52+esp]
|
---|
285 | mov edi,DWORD [60+esp]
|
---|
286 | add ebp,DWORD [92+esp]
|
---|
287 | add ecx,DWORD [104+esp]
|
---|
288 | add esi,DWORD [108+esp]
|
---|
289 | add edx,DWORD [116+esp]
|
---|
290 | add edi,DWORD [124+esp]
|
---|
291 | xor ebp,DWORD [28+ebx]
|
---|
292 | xor ecx,DWORD [40+ebx]
|
---|
293 | xor esi,DWORD [44+ebx]
|
---|
294 | xor edx,DWORD [52+ebx]
|
---|
295 | xor edi,DWORD [60+ebx]
|
---|
296 | lea ebx,[64+ebx]
|
---|
297 | mov DWORD [28+eax],ebp
|
---|
298 | mov ebp,DWORD [esp]
|
---|
299 | mov DWORD [40+eax],ecx
|
---|
300 | mov ecx,DWORD [160+esp]
|
---|
301 | mov DWORD [44+eax],esi
|
---|
302 | mov DWORD [52+eax],edx
|
---|
303 | mov DWORD [60+eax],edi
|
---|
304 | mov DWORD [eax],ebp
|
---|
305 | lea eax,[64+eax]
|
---|
306 | sub ecx,64
|
---|
307 | jnz NEAR L$002outer_loop
|
---|
308 | jmp NEAR L$005done
|
---|
309 | L$004tail:
|
---|
310 | add edx,DWORD [112+esp]
|
---|
311 | add edi,DWORD [120+esp]
|
---|
312 | mov DWORD [esp],eax
|
---|
313 | mov DWORD [16+esp],ebp
|
---|
314 | mov DWORD [32+esp],ecx
|
---|
315 | mov DWORD [36+esp],esi
|
---|
316 | mov DWORD [48+esp],edx
|
---|
317 | mov DWORD [56+esp],edi
|
---|
318 | mov ebp,DWORD [4+esp]
|
---|
319 | mov ecx,DWORD [8+esp]
|
---|
320 | mov esi,DWORD [12+esp]
|
---|
321 | mov edx,DWORD [20+esp]
|
---|
322 | mov edi,DWORD [24+esp]
|
---|
323 | add ebp,857760878
|
---|
324 | add ecx,2036477234
|
---|
325 | add esi,1797285236
|
---|
326 | add edx,DWORD [84+esp]
|
---|
327 | add edi,DWORD [88+esp]
|
---|
328 | mov DWORD [4+esp],ebp
|
---|
329 | mov DWORD [8+esp],ecx
|
---|
330 | mov DWORD [12+esp],esi
|
---|
331 | mov DWORD [20+esp],edx
|
---|
332 | mov DWORD [24+esp],edi
|
---|
333 | mov ebp,DWORD [28+esp]
|
---|
334 | mov ecx,DWORD [40+esp]
|
---|
335 | mov esi,DWORD [44+esp]
|
---|
336 | mov edx,DWORD [52+esp]
|
---|
337 | mov edi,DWORD [60+esp]
|
---|
338 | add ebp,DWORD [92+esp]
|
---|
339 | add ecx,DWORD [104+esp]
|
---|
340 | add esi,DWORD [108+esp]
|
---|
341 | add edx,DWORD [116+esp]
|
---|
342 | add edi,DWORD [124+esp]
|
---|
343 | mov DWORD [28+esp],ebp
|
---|
344 | mov ebp,DWORD [156+esp]
|
---|
345 | mov DWORD [40+esp],ecx
|
---|
346 | mov ecx,DWORD [152+esp]
|
---|
347 | mov DWORD [44+esp],esi
|
---|
348 | xor esi,esi
|
---|
349 | mov DWORD [52+esp],edx
|
---|
350 | mov DWORD [60+esp],edi
|
---|
351 | xor eax,eax
|
---|
352 | xor edx,edx
|
---|
353 | L$006tail_loop:
|
---|
354 | mov al,BYTE [ebp*1+esi]
|
---|
355 | mov dl,BYTE [esi*1+esp]
|
---|
356 | lea esi,[1+esi]
|
---|
357 | xor al,dl
|
---|
358 | mov BYTE [esi*1+ecx-1],al
|
---|
359 | dec ebx
|
---|
360 | jnz NEAR L$006tail_loop
|
---|
361 | L$005done:
|
---|
362 | add esp,132
|
---|
363 | L$000no_data:
|
---|
364 | pop edi
|
---|
365 | pop esi
|
---|
366 | pop ebx
|
---|
367 | pop ebp
|
---|
368 | ret
|
---|
369 | db 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54
|
---|
370 | db 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32
|
---|
371 | db 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111
|
---|
372 | db 114,103,62,0
|
---|