VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.3/crypto/genasm-nasm/poly1305-x86_64.S@ 95221

Last change on this file since 95221 was 95221, checked in by vboxsync, 3 years ago

libs/openssl-3.0.3: Recreated openssl assembler files, bugref:10128

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1default rel
2%define XMMWORD
3%define YMMWORD
4%define ZMMWORD
5section .text code align=64
6
7
8EXTERN OPENSSL_ia32cap_P
9
10global poly1305_init
11
12global poly1305_blocks
13
14global poly1305_emit
15
16
17
18ALIGN 32
19poly1305_init:
20 mov QWORD[8+rsp],rdi ;WIN64 prologue
21 mov QWORD[16+rsp],rsi
22 mov rax,rsp
23$L$SEH_begin_poly1305_init:
24 mov rdi,rcx
25 mov rsi,rdx
26 mov rdx,r8
27
28
29
30 xor rax,rax
31 mov QWORD[rdi],rax
32 mov QWORD[8+rdi],rax
33 mov QWORD[16+rdi],rax
34
35 cmp rsi,0
36 je NEAR $L$no_key
37
38 lea r10,[poly1305_blocks]
39 lea r11,[poly1305_emit]
40 mov rax,0x0ffffffc0fffffff
41 mov rcx,0x0ffffffc0ffffffc
42 and rax,QWORD[rsi]
43 and rcx,QWORD[8+rsi]
44 mov QWORD[24+rdi],rax
45 mov QWORD[32+rdi],rcx
46 mov QWORD[rdx],r10
47 mov QWORD[8+rdx],r11
48 mov eax,1
49$L$no_key:
50 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
51 mov rsi,QWORD[16+rsp]
52 DB 0F3h,0C3h ;repret
53
54$L$SEH_end_poly1305_init:
55
56
57ALIGN 32
58poly1305_blocks:
59 mov QWORD[8+rsp],rdi ;WIN64 prologue
60 mov QWORD[16+rsp],rsi
61 mov rax,rsp
62$L$SEH_begin_poly1305_blocks:
63 mov rdi,rcx
64 mov rsi,rdx
65 mov rdx,r8
66 mov rcx,r9
67
68
69
70$L$blocks:
71 shr rdx,4
72 jz NEAR $L$no_data
73
74 push rbx
75
76 push rbp
77
78 push r12
79
80 push r13
81
82 push r14
83
84 push r15
85
86$L$blocks_body:
87
88 mov r15,rdx
89
90 mov r11,QWORD[24+rdi]
91 mov r13,QWORD[32+rdi]
92
93 mov r14,QWORD[rdi]
94 mov rbx,QWORD[8+rdi]
95 mov rbp,QWORD[16+rdi]
96
97 mov r12,r13
98 shr r13,2
99 mov rax,r12
100 add r13,r12
101 jmp NEAR $L$oop
102
103ALIGN 32
104$L$oop:
105 add r14,QWORD[rsi]
106 adc rbx,QWORD[8+rsi]
107 lea rsi,[16+rsi]
108 adc rbp,rcx
109 mul r14
110 mov r9,rax
111 mov rax,r11
112 mov r10,rdx
113
114 mul r14
115 mov r14,rax
116 mov rax,r11
117 mov r8,rdx
118
119 mul rbx
120 add r9,rax
121 mov rax,r13
122 adc r10,rdx
123
124 mul rbx
125 mov rbx,rbp
126 add r14,rax
127 adc r8,rdx
128
129 imul rbx,r13
130 add r9,rbx
131 mov rbx,r8
132 adc r10,0
133
134 imul rbp,r11
135 add rbx,r9
136 mov rax,-4
137 adc r10,rbp
138
139 and rax,r10
140 mov rbp,r10
141 shr r10,2
142 and rbp,3
143 add rax,r10
144 add r14,rax
145 adc rbx,0
146 adc rbp,0
147 mov rax,r12
148 dec r15
149 jnz NEAR $L$oop
150
151 mov QWORD[rdi],r14
152 mov QWORD[8+rdi],rbx
153 mov QWORD[16+rdi],rbp
154
155 mov r15,QWORD[rsp]
156
157 mov r14,QWORD[8+rsp]
158
159 mov r13,QWORD[16+rsp]
160
161 mov r12,QWORD[24+rsp]
162
163 mov rbp,QWORD[32+rsp]
164
165 mov rbx,QWORD[40+rsp]
166
167 lea rsp,[48+rsp]
168
169$L$no_data:
170$L$blocks_epilogue:
171 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
172 mov rsi,QWORD[16+rsp]
173 DB 0F3h,0C3h ;repret
174
175$L$SEH_end_poly1305_blocks:
176
177
178ALIGN 32
179poly1305_emit:
180 mov QWORD[8+rsp],rdi ;WIN64 prologue
181 mov QWORD[16+rsp],rsi
182 mov rax,rsp
183$L$SEH_begin_poly1305_emit:
184 mov rdi,rcx
185 mov rsi,rdx
186 mov rdx,r8
187
188
189
190$L$emit:
191 mov r8,QWORD[rdi]
192 mov r9,QWORD[8+rdi]
193 mov r10,QWORD[16+rdi]
194
195 mov rax,r8
196 add r8,5
197 mov rcx,r9
198 adc r9,0
199 adc r10,0
200 shr r10,2
201 cmovnz rax,r8
202 cmovnz rcx,r9
203
204 add rax,QWORD[rdx]
205 adc rcx,QWORD[8+rdx]
206 mov QWORD[rsi],rax
207 mov QWORD[8+rsi],rcx
208
209 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
210 mov rsi,QWORD[16+rsp]
211 DB 0F3h,0C3h ;repret
212
213$L$SEH_end_poly1305_emit:
214DB 80,111,108,121,49,51,48,53,32,102,111,114,32,120,56,54
215DB 95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32
216DB 98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115
217DB 108,46,111,114,103,62,0
218ALIGN 16
219global xor128_encrypt_n_pad
220
221ALIGN 16
222xor128_encrypt_n_pad:
223
224 sub rdx,r8
225 sub rcx,r8
226 mov r10,r9
227 shr r9,4
228 jz NEAR $L$tail_enc
229 nop
230$L$oop_enc_xmm:
231 movdqu xmm0,XMMWORD[r8*1+rdx]
232 pxor xmm0,XMMWORD[r8]
233 movdqu XMMWORD[r8*1+rcx],xmm0
234 movdqa XMMWORD[r8],xmm0
235 lea r8,[16+r8]
236 dec r9
237 jnz NEAR $L$oop_enc_xmm
238
239 and r10,15
240 jz NEAR $L$done_enc
241
242$L$tail_enc:
243 mov r9,16
244 sub r9,r10
245 xor eax,eax
246$L$oop_enc_byte:
247 mov al,BYTE[r8*1+rdx]
248 xor al,BYTE[r8]
249 mov BYTE[r8*1+rcx],al
250 mov BYTE[r8],al
251 lea r8,[1+r8]
252 dec r10
253 jnz NEAR $L$oop_enc_byte
254
255 xor eax,eax
256$L$oop_enc_pad:
257 mov BYTE[r8],al
258 lea r8,[1+r8]
259 dec r9
260 jnz NEAR $L$oop_enc_pad
261
262$L$done_enc:
263 mov rax,r8
264 DB 0F3h,0C3h ;repret
265
266
267
268global xor128_decrypt_n_pad
269
270ALIGN 16
271xor128_decrypt_n_pad:
272
273 sub rdx,r8
274 sub rcx,r8
275 mov r10,r9
276 shr r9,4
277 jz NEAR $L$tail_dec
278 nop
279$L$oop_dec_xmm:
280 movdqu xmm0,XMMWORD[r8*1+rdx]
281 movdqa xmm1,XMMWORD[r8]
282 pxor xmm1,xmm0
283 movdqu XMMWORD[r8*1+rcx],xmm1
284 movdqa XMMWORD[r8],xmm0
285 lea r8,[16+r8]
286 dec r9
287 jnz NEAR $L$oop_dec_xmm
288
289 pxor xmm1,xmm1
290 and r10,15
291 jz NEAR $L$done_dec
292
293$L$tail_dec:
294 mov r9,16
295 sub r9,r10
296 xor eax,eax
297 xor r11,r11
298$L$oop_dec_byte:
299 mov r11b,BYTE[r8*1+rdx]
300 mov al,BYTE[r8]
301 xor al,r11b
302 mov BYTE[r8*1+rcx],al
303 mov BYTE[r8],r11b
304 lea r8,[1+r8]
305 dec r10
306 jnz NEAR $L$oop_dec_byte
307
308 xor eax,eax
309$L$oop_dec_pad:
310 mov BYTE[r8],al
311 lea r8,[1+r8]
312 dec r9
313 jnz NEAR $L$oop_dec_pad
314
315$L$done_dec:
316 mov rax,r8
317 DB 0F3h,0C3h ;repret
318
319
320EXTERN __imp_RtlVirtualUnwind
321
322ALIGN 16
323se_handler:
324 push rsi
325 push rdi
326 push rbx
327 push rbp
328 push r12
329 push r13
330 push r14
331 push r15
332 pushfq
333 sub rsp,64
334
335 mov rax,QWORD[120+r8]
336 mov rbx,QWORD[248+r8]
337
338 mov rsi,QWORD[8+r9]
339 mov r11,QWORD[56+r9]
340
341 mov r10d,DWORD[r11]
342 lea r10,[r10*1+rsi]
343 cmp rbx,r10
344 jb NEAR $L$common_seh_tail
345
346 mov rax,QWORD[152+r8]
347
348 mov r10d,DWORD[4+r11]
349 lea r10,[r10*1+rsi]
350 cmp rbx,r10
351 jae NEAR $L$common_seh_tail
352
353 lea rax,[48+rax]
354
355 mov rbx,QWORD[((-8))+rax]
356 mov rbp,QWORD[((-16))+rax]
357 mov r12,QWORD[((-24))+rax]
358 mov r13,QWORD[((-32))+rax]
359 mov r14,QWORD[((-40))+rax]
360 mov r15,QWORD[((-48))+rax]
361 mov QWORD[144+r8],rbx
362 mov QWORD[160+r8],rbp
363 mov QWORD[216+r8],r12
364 mov QWORD[224+r8],r13
365 mov QWORD[232+r8],r14
366 mov QWORD[240+r8],r15
367
368 jmp NEAR $L$common_seh_tail
369
370
371
372ALIGN 16
373avx_handler:
374 push rsi
375 push rdi
376 push rbx
377 push rbp
378 push r12
379 push r13
380 push r14
381 push r15
382 pushfq
383 sub rsp,64
384
385 mov rax,QWORD[120+r8]
386 mov rbx,QWORD[248+r8]
387
388 mov rsi,QWORD[8+r9]
389 mov r11,QWORD[56+r9]
390
391 mov r10d,DWORD[r11]
392 lea r10,[r10*1+rsi]
393 cmp rbx,r10
394 jb NEAR $L$common_seh_tail
395
396 mov rax,QWORD[152+r8]
397
398 mov r10d,DWORD[4+r11]
399 lea r10,[r10*1+rsi]
400 cmp rbx,r10
401 jae NEAR $L$common_seh_tail
402
403 mov rax,QWORD[208+r8]
404
405 lea rsi,[80+rax]
406 lea rax,[248+rax]
407 lea rdi,[512+r8]
408 mov ecx,20
409 DD 0xa548f3fc
410
411$L$common_seh_tail:
412 mov rdi,QWORD[8+rax]
413 mov rsi,QWORD[16+rax]
414 mov QWORD[152+r8],rax
415 mov QWORD[168+r8],rsi
416 mov QWORD[176+r8],rdi
417
418 mov rdi,QWORD[40+r9]
419 mov rsi,r8
420 mov ecx,154
421 DD 0xa548f3fc
422
423 mov rsi,r9
424 xor rcx,rcx
425 mov rdx,QWORD[8+rsi]
426 mov r8,QWORD[rsi]
427 mov r9,QWORD[16+rsi]
428 mov r10,QWORD[40+rsi]
429 lea r11,[56+rsi]
430 lea r12,[24+rsi]
431 mov QWORD[32+rsp],r10
432 mov QWORD[40+rsp],r11
433 mov QWORD[48+rsp],r12
434 mov QWORD[56+rsp],rcx
435 call QWORD[__imp_RtlVirtualUnwind]
436
437 mov eax,1
438 add rsp,64
439 popfq
440 pop r15
441 pop r14
442 pop r13
443 pop r12
444 pop rbp
445 pop rbx
446 pop rdi
447 pop rsi
448 DB 0F3h,0C3h ;repret
449
450
451section .pdata rdata align=4
452ALIGN 4
453 DD $L$SEH_begin_poly1305_init wrt ..imagebase
454 DD $L$SEH_end_poly1305_init wrt ..imagebase
455 DD $L$SEH_info_poly1305_init wrt ..imagebase
456
457 DD $L$SEH_begin_poly1305_blocks wrt ..imagebase
458 DD $L$SEH_end_poly1305_blocks wrt ..imagebase
459 DD $L$SEH_info_poly1305_blocks wrt ..imagebase
460
461 DD $L$SEH_begin_poly1305_emit wrt ..imagebase
462 DD $L$SEH_end_poly1305_emit wrt ..imagebase
463 DD $L$SEH_info_poly1305_emit wrt ..imagebase
464section .xdata rdata align=8
465ALIGN 8
466$L$SEH_info_poly1305_init:
467DB 9,0,0,0
468 DD se_handler wrt ..imagebase
469 DD $L$SEH_begin_poly1305_init wrt ..imagebase,$L$SEH_begin_poly1305_init wrt ..imagebase
470
471$L$SEH_info_poly1305_blocks:
472DB 9,0,0,0
473 DD se_handler wrt ..imagebase
474 DD $L$blocks_body wrt ..imagebase,$L$blocks_epilogue wrt ..imagebase
475
476$L$SEH_info_poly1305_emit:
477DB 9,0,0,0
478 DD se_handler wrt ..imagebase
479 DD $L$SEH_begin_poly1305_emit wrt ..imagebase,$L$SEH_begin_poly1305_emit wrt ..imagebase
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette