VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/crypto/genasm-nasm/x25519-x86_64.S@ 94081

Last change on this file since 94081 was 83531, checked in by vboxsync, 5 years ago

setting svn:sync-process=export for openssl-1.1.1f, all files except tests

File size: 8.5 KB
Line 
1default rel
2%define XMMWORD
3%define YMMWORD
4%define ZMMWORD
5section .text code align=64
6
7
8global x25519_fe51_mul
9
10ALIGN 32
11x25519_fe51_mul:
12 mov QWORD[8+rsp],rdi ;WIN64 prologue
13 mov QWORD[16+rsp],rsi
14 mov rax,rsp
15$L$SEH_begin_x25519_fe51_mul:
16 mov rdi,rcx
17 mov rsi,rdx
18 mov rdx,r8
19
20
21
22 push rbp
23
24 push rbx
25
26 push r12
27
28 push r13
29
30 push r14
31
32 push r15
33
34 lea rsp,[((-40))+rsp]
35
36$L$fe51_mul_body:
37
38 mov rax,QWORD[rsi]
39 mov r11,QWORD[rdx]
40 mov r12,QWORD[8+rdx]
41 mov r13,QWORD[16+rdx]
42 mov rbp,QWORD[24+rdx]
43 mov r14,QWORD[32+rdx]
44
45 mov QWORD[32+rsp],rdi
46 mov rdi,rax
47 mul r11
48 mov QWORD[rsp],r11
49 mov rbx,rax
50 mov rax,rdi
51 mov rcx,rdx
52 mul r12
53 mov QWORD[8+rsp],r12
54 mov r8,rax
55 mov rax,rdi
56 lea r15,[r14*8+r14]
57 mov r9,rdx
58 mul r13
59 mov QWORD[16+rsp],r13
60 mov r10,rax
61 mov rax,rdi
62 lea rdi,[r15*2+r14]
63 mov r11,rdx
64 mul rbp
65 mov r12,rax
66 mov rax,QWORD[rsi]
67 mov r13,rdx
68 mul r14
69 mov r14,rax
70 mov rax,QWORD[8+rsi]
71 mov r15,rdx
72
73 mul rdi
74 add rbx,rax
75 mov rax,QWORD[16+rsi]
76 adc rcx,rdx
77 mul rdi
78 add r8,rax
79 mov rax,QWORD[24+rsi]
80 adc r9,rdx
81 mul rdi
82 add r10,rax
83 mov rax,QWORD[32+rsi]
84 adc r11,rdx
85 mul rdi
86 imul rdi,rbp,19
87 add r12,rax
88 mov rax,QWORD[8+rsi]
89 adc r13,rdx
90 mul rbp
91 mov rbp,QWORD[16+rsp]
92 add r14,rax
93 mov rax,QWORD[16+rsi]
94 adc r15,rdx
95
96 mul rdi
97 add rbx,rax
98 mov rax,QWORD[24+rsi]
99 adc rcx,rdx
100 mul rdi
101 add r8,rax
102 mov rax,QWORD[32+rsi]
103 adc r9,rdx
104 mul rdi
105 imul rdi,rbp,19
106 add r10,rax
107 mov rax,QWORD[8+rsi]
108 adc r11,rdx
109 mul rbp
110 add r12,rax
111 mov rax,QWORD[16+rsi]
112 adc r13,rdx
113 mul rbp
114 mov rbp,QWORD[8+rsp]
115 add r14,rax
116 mov rax,QWORD[24+rsi]
117 adc r15,rdx
118
119 mul rdi
120 add rbx,rax
121 mov rax,QWORD[32+rsi]
122 adc rcx,rdx
123 mul rdi
124 add r8,rax
125 mov rax,QWORD[8+rsi]
126 adc r9,rdx
127 mul rbp
128 imul rdi,rbp,19
129 add r10,rax
130 mov rax,QWORD[16+rsi]
131 adc r11,rdx
132 mul rbp
133 add r12,rax
134 mov rax,QWORD[24+rsi]
135 adc r13,rdx
136 mul rbp
137 mov rbp,QWORD[rsp]
138 add r14,rax
139 mov rax,QWORD[32+rsi]
140 adc r15,rdx
141
142 mul rdi
143 add rbx,rax
144 mov rax,QWORD[8+rsi]
145 adc rcx,rdx
146 mul rbp
147 add r8,rax
148 mov rax,QWORD[16+rsi]
149 adc r9,rdx
150 mul rbp
151 add r10,rax
152 mov rax,QWORD[24+rsi]
153 adc r11,rdx
154 mul rbp
155 add r12,rax
156 mov rax,QWORD[32+rsi]
157 adc r13,rdx
158 mul rbp
159 add r14,rax
160 adc r15,rdx
161
162 mov rdi,QWORD[32+rsp]
163 jmp NEAR $L$reduce51
164$L$fe51_mul_epilogue:
165
166$L$SEH_end_x25519_fe51_mul:
167
168global x25519_fe51_sqr
169
170ALIGN 32
171x25519_fe51_sqr:
172 mov QWORD[8+rsp],rdi ;WIN64 prologue
173 mov QWORD[16+rsp],rsi
174 mov rax,rsp
175$L$SEH_begin_x25519_fe51_sqr:
176 mov rdi,rcx
177 mov rsi,rdx
178
179
180
181 push rbp
182
183 push rbx
184
185 push r12
186
187 push r13
188
189 push r14
190
191 push r15
192
193 lea rsp,[((-40))+rsp]
194
195$L$fe51_sqr_body:
196
197 mov rax,QWORD[rsi]
198 mov r15,QWORD[16+rsi]
199 mov rbp,QWORD[32+rsi]
200
201 mov QWORD[32+rsp],rdi
202 lea r14,[rax*1+rax]
203 mul rax
204 mov rbx,rax
205 mov rax,QWORD[8+rsi]
206 mov rcx,rdx
207 mul r14
208 mov r8,rax
209 mov rax,r15
210 mov QWORD[rsp],r15
211 mov r9,rdx
212 mul r14
213 mov r10,rax
214 mov rax,QWORD[24+rsi]
215 mov r11,rdx
216 imul rdi,rbp,19
217 mul r14
218 mov r12,rax
219 mov rax,rbp
220 mov r13,rdx
221 mul r14
222 mov r14,rax
223 mov rax,rbp
224 mov r15,rdx
225
226 mul rdi
227 add r12,rax
228 mov rax,QWORD[8+rsi]
229 adc r13,rdx
230
231 mov rsi,QWORD[24+rsi]
232 lea rbp,[rax*1+rax]
233 mul rax
234 add r10,rax
235 mov rax,QWORD[rsp]
236 adc r11,rdx
237 mul rbp
238 add r12,rax
239 mov rax,rbp
240 adc r13,rdx
241 mul rsi
242 add r14,rax
243 mov rax,rbp
244 adc r15,rdx
245 imul rbp,rsi,19
246 mul rdi
247 add rbx,rax
248 lea rax,[rsi*1+rsi]
249 adc rcx,rdx
250
251 mul rdi
252 add r10,rax
253 mov rax,rsi
254 adc r11,rdx
255 mul rbp
256 add r8,rax
257 mov rax,QWORD[rsp]
258 adc r9,rdx
259
260 lea rsi,[rax*1+rax]
261 mul rax
262 add r14,rax
263 mov rax,rbp
264 adc r15,rdx
265 mul rsi
266 add rbx,rax
267 mov rax,rsi
268 adc rcx,rdx
269 mul rdi
270 add r8,rax
271 adc r9,rdx
272
273 mov rdi,QWORD[32+rsp]
274 jmp NEAR $L$reduce51
275
276ALIGN 32
277$L$reduce51:
278 mov rbp,0x7ffffffffffff
279
280 mov rdx,r10
281 shr r10,51
282 shl r11,13
283 and rdx,rbp
284 or r11,r10
285 add r12,r11
286 adc r13,0
287
288 mov rax,rbx
289 shr rbx,51
290 shl rcx,13
291 and rax,rbp
292 or rcx,rbx
293 add r8,rcx
294 adc r9,0
295
296 mov rbx,r12
297 shr r12,51
298 shl r13,13
299 and rbx,rbp
300 or r13,r12
301 add r14,r13
302 adc r15,0
303
304 mov rcx,r8
305 shr r8,51
306 shl r9,13
307 and rcx,rbp
308 or r9,r8
309 add rdx,r9
310
311 mov r10,r14
312 shr r14,51
313 shl r15,13
314 and r10,rbp
315 or r15,r14
316
317 lea r14,[r15*8+r15]
318 lea r15,[r14*2+r15]
319 add rax,r15
320
321 mov r8,rdx
322 and rdx,rbp
323 shr r8,51
324 add rbx,r8
325
326 mov r9,rax
327 and rax,rbp
328 shr r9,51
329 add rcx,r9
330
331 mov QWORD[rdi],rax
332 mov QWORD[8+rdi],rcx
333 mov QWORD[16+rdi],rdx
334 mov QWORD[24+rdi],rbx
335 mov QWORD[32+rdi],r10
336
337 mov r15,QWORD[40+rsp]
338
339 mov r14,QWORD[48+rsp]
340
341 mov r13,QWORD[56+rsp]
342
343 mov r12,QWORD[64+rsp]
344
345 mov rbx,QWORD[72+rsp]
346
347 mov rbp,QWORD[80+rsp]
348
349 lea rsp,[88+rsp]
350
351$L$fe51_sqr_epilogue:
352 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
353 mov rsi,QWORD[16+rsp]
354 DB 0F3h,0C3h ;repret
355
356$L$SEH_end_x25519_fe51_sqr:
357
358global x25519_fe51_mul121666
359
360ALIGN 32
361x25519_fe51_mul121666:
362 mov QWORD[8+rsp],rdi ;WIN64 prologue
363 mov QWORD[16+rsp],rsi
364 mov rax,rsp
365$L$SEH_begin_x25519_fe51_mul121666:
366 mov rdi,rcx
367 mov rsi,rdx
368
369
370
371 push rbp
372
373 push rbx
374
375 push r12
376
377 push r13
378
379 push r14
380
381 push r15
382
383 lea rsp,[((-40))+rsp]
384
385$L$fe51_mul121666_body:
386 mov eax,121666
387
388 mul QWORD[rsi]
389 mov rbx,rax
390 mov eax,121666
391 mov rcx,rdx
392 mul QWORD[8+rsi]
393 mov r8,rax
394 mov eax,121666
395 mov r9,rdx
396 mul QWORD[16+rsi]
397 mov r10,rax
398 mov eax,121666
399 mov r11,rdx
400 mul QWORD[24+rsi]
401 mov r12,rax
402 mov eax,121666
403 mov r13,rdx
404 mul QWORD[32+rsi]
405 mov r14,rax
406 mov r15,rdx
407
408 jmp NEAR $L$reduce51
409$L$fe51_mul121666_epilogue:
410
411$L$SEH_end_x25519_fe51_mul121666:
412global x25519_fe64_eligible
413
414ALIGN 32
415x25519_fe64_eligible:
416 xor eax,eax
417 DB 0F3h,0C3h ;repret
418
419
420global x25519_fe64_mul
421
422global x25519_fe64_sqr
423global x25519_fe64_mul121666
424global x25519_fe64_add
425global x25519_fe64_sub
426global x25519_fe64_tobytes
427x25519_fe64_mul:
428x25519_fe64_sqr:
429x25519_fe64_mul121666:
430x25519_fe64_add:
431x25519_fe64_sub:
432x25519_fe64_tobytes:
433DB 0x0f,0x0b
434 DB 0F3h,0C3h ;repret
435
436DB 88,50,53,53,49,57,32,112,114,105,109,105,116,105,118,101
437DB 115,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82
438DB 89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112
439DB 114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
440EXTERN __imp_RtlVirtualUnwind
441
442
443ALIGN 16
444short_handler:
445 push rsi
446 push rdi
447 push rbx
448 push rbp
449 push r12
450 push r13
451 push r14
452 push r15
453 pushfq
454 sub rsp,64
455
456 mov rax,QWORD[120+r8]
457 mov rbx,QWORD[248+r8]
458
459 mov rsi,QWORD[8+r9]
460 mov r11,QWORD[56+r9]
461
462 mov r10d,DWORD[r11]
463 lea r10,[r10*1+rsi]
464 cmp rbx,r10
465 jb NEAR $L$common_seh_tail
466
467 mov rax,QWORD[152+r8]
468 jmp NEAR $L$common_seh_tail
469
470
471
472ALIGN 16
473full_handler:
474 push rsi
475 push rdi
476 push rbx
477 push rbp
478 push r12
479 push r13
480 push r14
481 push r15
482 pushfq
483 sub rsp,64
484
485 mov rax,QWORD[120+r8]
486 mov rbx,QWORD[248+r8]
487
488 mov rsi,QWORD[8+r9]
489 mov r11,QWORD[56+r9]
490
491 mov r10d,DWORD[r11]
492 lea r10,[r10*1+rsi]
493 cmp rbx,r10
494 jb NEAR $L$common_seh_tail
495
496 mov rax,QWORD[152+r8]
497
498 mov r10d,DWORD[4+r11]
499 lea r10,[r10*1+rsi]
500 cmp rbx,r10
501 jae NEAR $L$common_seh_tail
502
503 mov r10d,DWORD[8+r11]
504 lea rax,[r10*1+rax]
505
506 mov rbp,QWORD[((-8))+rax]
507 mov rbx,QWORD[((-16))+rax]
508 mov r12,QWORD[((-24))+rax]
509 mov r13,QWORD[((-32))+rax]
510 mov r14,QWORD[((-40))+rax]
511 mov r15,QWORD[((-48))+rax]
512 mov QWORD[144+r8],rbx
513 mov QWORD[160+r8],rbp
514 mov QWORD[216+r8],r12
515 mov QWORD[224+r8],r13
516 mov QWORD[232+r8],r14
517 mov QWORD[240+r8],r15
518
519$L$common_seh_tail:
520 mov rdi,QWORD[8+rax]
521 mov rsi,QWORD[16+rax]
522 mov QWORD[152+r8],rax
523 mov QWORD[168+r8],rsi
524 mov QWORD[176+r8],rdi
525
526 mov rdi,QWORD[40+r9]
527 mov rsi,r8
528 mov ecx,154
529 DD 0xa548f3fc
530
531 mov rsi,r9
532 xor rcx,rcx
533 mov rdx,QWORD[8+rsi]
534 mov r8,QWORD[rsi]
535 mov r9,QWORD[16+rsi]
536 mov r10,QWORD[40+rsi]
537 lea r11,[56+rsi]
538 lea r12,[24+rsi]
539 mov QWORD[32+rsp],r10
540 mov QWORD[40+rsp],r11
541 mov QWORD[48+rsp],r12
542 mov QWORD[56+rsp],rcx
543 call QWORD[__imp_RtlVirtualUnwind]
544
545 mov eax,1
546 add rsp,64
547 popfq
548 pop r15
549 pop r14
550 pop r13
551 pop r12
552 pop rbp
553 pop rbx
554 pop rdi
555 pop rsi
556 DB 0F3h,0C3h ;repret
557
558
559section .pdata rdata align=4
560ALIGN 4
561 DD $L$SEH_begin_x25519_fe51_mul wrt ..imagebase
562 DD $L$SEH_end_x25519_fe51_mul wrt ..imagebase
563 DD $L$SEH_info_x25519_fe51_mul wrt ..imagebase
564
565 DD $L$SEH_begin_x25519_fe51_sqr wrt ..imagebase
566 DD $L$SEH_end_x25519_fe51_sqr wrt ..imagebase
567 DD $L$SEH_info_x25519_fe51_sqr wrt ..imagebase
568
569 DD $L$SEH_begin_x25519_fe51_mul121666 wrt ..imagebase
570 DD $L$SEH_end_x25519_fe51_mul121666 wrt ..imagebase
571 DD $L$SEH_info_x25519_fe51_mul121666 wrt ..imagebase
572section .xdata rdata align=8
573ALIGN 8
574$L$SEH_info_x25519_fe51_mul:
575DB 9,0,0,0
576 DD full_handler wrt ..imagebase
577 DD $L$fe51_mul_body wrt ..imagebase,$L$fe51_mul_epilogue wrt ..imagebase
578 DD 88,0
579$L$SEH_info_x25519_fe51_sqr:
580DB 9,0,0,0
581 DD full_handler wrt ..imagebase
582 DD $L$fe51_sqr_body wrt ..imagebase,$L$fe51_sqr_epilogue wrt ..imagebase
583 DD 88,0
584$L$SEH_info_x25519_fe51_mul121666:
585DB 9,0,0,0
586 DD full_handler wrt ..imagebase
587 DD $L$fe51_mul121666_body wrt ..imagebase,$L$fe51_mul121666_epilogue wrt ..imagebase
588 DD 88,0
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