1 | default rel
|
---|
2 | %define XMMWORD
|
---|
3 | %define YMMWORD
|
---|
4 | %define ZMMWORD
|
---|
5 | section .text code align=64
|
---|
6 |
|
---|
7 |
|
---|
8 | global x25519_fe51_mul
|
---|
9 |
|
---|
10 | ALIGN 32
|
---|
11 | x25519_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 |
|
---|
168 | global x25519_fe51_sqr
|
---|
169 |
|
---|
170 | ALIGN 32
|
---|
171 | x25519_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 |
|
---|
276 | ALIGN 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 |
|
---|
358 | global x25519_fe51_mul121666
|
---|
359 |
|
---|
360 | ALIGN 32
|
---|
361 | x25519_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:
|
---|
412 | EXTERN OPENSSL_ia32cap_P
|
---|
413 | global x25519_fe64_eligible
|
---|
414 |
|
---|
415 | ALIGN 32
|
---|
416 | x25519_fe64_eligible:
|
---|
417 |
|
---|
418 | mov ecx,DWORD[((OPENSSL_ia32cap_P+8))]
|
---|
419 | xor eax,eax
|
---|
420 | and ecx,0x80100
|
---|
421 | cmp ecx,0x80100
|
---|
422 | cmove eax,ecx
|
---|
423 | DB 0F3h,0C3h ;repret
|
---|
424 |
|
---|
425 |
|
---|
426 |
|
---|
427 | global x25519_fe64_mul
|
---|
428 |
|
---|
429 | ALIGN 32
|
---|
430 | x25519_fe64_mul:
|
---|
431 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
432 | mov QWORD[16+rsp],rsi
|
---|
433 | mov rax,rsp
|
---|
434 | $L$SEH_begin_x25519_fe64_mul:
|
---|
435 | mov rdi,rcx
|
---|
436 | mov rsi,rdx
|
---|
437 | mov rdx,r8
|
---|
438 |
|
---|
439 |
|
---|
440 |
|
---|
441 | push rbp
|
---|
442 |
|
---|
443 | push rbx
|
---|
444 |
|
---|
445 | push r12
|
---|
446 |
|
---|
447 | push r13
|
---|
448 |
|
---|
449 | push r14
|
---|
450 |
|
---|
451 | push r15
|
---|
452 |
|
---|
453 | push rdi
|
---|
454 |
|
---|
455 | lea rsp,[((-16))+rsp]
|
---|
456 |
|
---|
457 | $L$fe64_mul_body:
|
---|
458 |
|
---|
459 | mov rax,rdx
|
---|
460 | mov rbp,QWORD[rdx]
|
---|
461 | mov rdx,QWORD[rsi]
|
---|
462 | mov rcx,QWORD[8+rax]
|
---|
463 | mov r14,QWORD[16+rax]
|
---|
464 | mov r15,QWORD[24+rax]
|
---|
465 |
|
---|
466 | mulx rax,r8,rbp
|
---|
467 | xor edi,edi
|
---|
468 | mulx rbx,r9,rcx
|
---|
469 | adcx r9,rax
|
---|
470 | mulx rax,r10,r14
|
---|
471 | adcx r10,rbx
|
---|
472 | mulx r12,r11,r15
|
---|
473 | mov rdx,QWORD[8+rsi]
|
---|
474 | adcx r11,rax
|
---|
475 | mov QWORD[rsp],r14
|
---|
476 | adcx r12,rdi
|
---|
477 |
|
---|
478 | mulx rbx,rax,rbp
|
---|
479 | adox r9,rax
|
---|
480 | adcx r10,rbx
|
---|
481 | mulx rbx,rax,rcx
|
---|
482 | adox r10,rax
|
---|
483 | adcx r11,rbx
|
---|
484 | mulx rbx,rax,r14
|
---|
485 | adox r11,rax
|
---|
486 | adcx r12,rbx
|
---|
487 | mulx r13,rax,r15
|
---|
488 | mov rdx,QWORD[16+rsi]
|
---|
489 | adox r12,rax
|
---|
490 | adcx r13,rdi
|
---|
491 | adox r13,rdi
|
---|
492 |
|
---|
493 | mulx rbx,rax,rbp
|
---|
494 | adcx r10,rax
|
---|
495 | adox r11,rbx
|
---|
496 | mulx rbx,rax,rcx
|
---|
497 | adcx r11,rax
|
---|
498 | adox r12,rbx
|
---|
499 | mulx rbx,rax,r14
|
---|
500 | adcx r12,rax
|
---|
501 | adox r13,rbx
|
---|
502 | mulx r14,rax,r15
|
---|
503 | mov rdx,QWORD[24+rsi]
|
---|
504 | adcx r13,rax
|
---|
505 | adox r14,rdi
|
---|
506 | adcx r14,rdi
|
---|
507 |
|
---|
508 | mulx rbx,rax,rbp
|
---|
509 | adox r11,rax
|
---|
510 | adcx r12,rbx
|
---|
511 | mulx rbx,rax,rcx
|
---|
512 | adox r12,rax
|
---|
513 | adcx r13,rbx
|
---|
514 | mulx rbx,rax,QWORD[rsp]
|
---|
515 | adox r13,rax
|
---|
516 | adcx r14,rbx
|
---|
517 | mulx r15,rax,r15
|
---|
518 | mov edx,38
|
---|
519 | adox r14,rax
|
---|
520 | adcx r15,rdi
|
---|
521 | adox r15,rdi
|
---|
522 |
|
---|
523 | jmp NEAR $L$reduce64
|
---|
524 | $L$fe64_mul_epilogue:
|
---|
525 |
|
---|
526 | $L$SEH_end_x25519_fe64_mul:
|
---|
527 |
|
---|
528 | global x25519_fe64_sqr
|
---|
529 |
|
---|
530 | ALIGN 32
|
---|
531 | x25519_fe64_sqr:
|
---|
532 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
533 | mov QWORD[16+rsp],rsi
|
---|
534 | mov rax,rsp
|
---|
535 | $L$SEH_begin_x25519_fe64_sqr:
|
---|
536 | mov rdi,rcx
|
---|
537 | mov rsi,rdx
|
---|
538 |
|
---|
539 |
|
---|
540 |
|
---|
541 | push rbp
|
---|
542 |
|
---|
543 | push rbx
|
---|
544 |
|
---|
545 | push r12
|
---|
546 |
|
---|
547 | push r13
|
---|
548 |
|
---|
549 | push r14
|
---|
550 |
|
---|
551 | push r15
|
---|
552 |
|
---|
553 | push rdi
|
---|
554 |
|
---|
555 | lea rsp,[((-16))+rsp]
|
---|
556 |
|
---|
557 | $L$fe64_sqr_body:
|
---|
558 |
|
---|
559 | mov rdx,QWORD[rsi]
|
---|
560 | mov rcx,QWORD[8+rsi]
|
---|
561 | mov rbp,QWORD[16+rsi]
|
---|
562 | mov rsi,QWORD[24+rsi]
|
---|
563 |
|
---|
564 |
|
---|
565 | mulx r15,r8,rdx
|
---|
566 | mulx rax,r9,rcx
|
---|
567 | xor edi,edi
|
---|
568 | mulx rbx,r10,rbp
|
---|
569 | adcx r10,rax
|
---|
570 | mulx r12,r11,rsi
|
---|
571 | mov rdx,rcx
|
---|
572 | adcx r11,rbx
|
---|
573 | adcx r12,rdi
|
---|
574 |
|
---|
575 |
|
---|
576 | mulx rbx,rax,rbp
|
---|
577 | adox r11,rax
|
---|
578 | adcx r12,rbx
|
---|
579 | mulx r13,rax,rsi
|
---|
580 | mov rdx,rbp
|
---|
581 | adox r12,rax
|
---|
582 | adcx r13,rdi
|
---|
583 |
|
---|
584 |
|
---|
585 | mulx r14,rax,rsi
|
---|
586 | mov rdx,rcx
|
---|
587 | adox r13,rax
|
---|
588 | adcx r14,rdi
|
---|
589 | adox r14,rdi
|
---|
590 |
|
---|
591 | adcx r9,r9
|
---|
592 | adox r9,r15
|
---|
593 | adcx r10,r10
|
---|
594 | mulx rbx,rax,rdx
|
---|
595 | mov rdx,rbp
|
---|
596 | adcx r11,r11
|
---|
597 | adox r10,rax
|
---|
598 | adcx r12,r12
|
---|
599 | adox r11,rbx
|
---|
600 | mulx rbx,rax,rdx
|
---|
601 | mov rdx,rsi
|
---|
602 | adcx r13,r13
|
---|
603 | adox r12,rax
|
---|
604 | adcx r14,r14
|
---|
605 | adox r13,rbx
|
---|
606 | mulx r15,rax,rdx
|
---|
607 | mov edx,38
|
---|
608 | adox r14,rax
|
---|
609 | adcx r15,rdi
|
---|
610 | adox r15,rdi
|
---|
611 | jmp NEAR $L$reduce64
|
---|
612 |
|
---|
613 | ALIGN 32
|
---|
614 | $L$reduce64:
|
---|
615 | mulx rbx,rax,r12
|
---|
616 | adcx r8,rax
|
---|
617 | adox r9,rbx
|
---|
618 | mulx rbx,rax,r13
|
---|
619 | adcx r9,rax
|
---|
620 | adox r10,rbx
|
---|
621 | mulx rbx,rax,r14
|
---|
622 | adcx r10,rax
|
---|
623 | adox r11,rbx
|
---|
624 | mulx r12,rax,r15
|
---|
625 | adcx r11,rax
|
---|
626 | adox r12,rdi
|
---|
627 | adcx r12,rdi
|
---|
628 |
|
---|
629 | mov rdi,QWORD[16+rsp]
|
---|
630 | imul r12,rdx
|
---|
631 |
|
---|
632 | add r8,r12
|
---|
633 | adc r9,0
|
---|
634 | adc r10,0
|
---|
635 | adc r11,0
|
---|
636 |
|
---|
637 | sbb rax,rax
|
---|
638 | and rax,38
|
---|
639 |
|
---|
640 | add r8,rax
|
---|
641 | mov QWORD[8+rdi],r9
|
---|
642 | mov QWORD[16+rdi],r10
|
---|
643 | mov QWORD[24+rdi],r11
|
---|
644 | mov QWORD[rdi],r8
|
---|
645 |
|
---|
646 | mov r15,QWORD[24+rsp]
|
---|
647 |
|
---|
648 | mov r14,QWORD[32+rsp]
|
---|
649 |
|
---|
650 | mov r13,QWORD[40+rsp]
|
---|
651 |
|
---|
652 | mov r12,QWORD[48+rsp]
|
---|
653 |
|
---|
654 | mov rbx,QWORD[56+rsp]
|
---|
655 |
|
---|
656 | mov rbp,QWORD[64+rsp]
|
---|
657 |
|
---|
658 | lea rsp,[72+rsp]
|
---|
659 |
|
---|
660 | $L$fe64_sqr_epilogue:
|
---|
661 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
662 | mov rsi,QWORD[16+rsp]
|
---|
663 | DB 0F3h,0C3h ;repret
|
---|
664 |
|
---|
665 | $L$SEH_end_x25519_fe64_sqr:
|
---|
666 |
|
---|
667 | global x25519_fe64_mul121666
|
---|
668 |
|
---|
669 | ALIGN 32
|
---|
670 | x25519_fe64_mul121666:
|
---|
671 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
672 | mov QWORD[16+rsp],rsi
|
---|
673 | mov rax,rsp
|
---|
674 | $L$SEH_begin_x25519_fe64_mul121666:
|
---|
675 | mov rdi,rcx
|
---|
676 | mov rsi,rdx
|
---|
677 |
|
---|
678 |
|
---|
679 | $L$fe64_mul121666_body:
|
---|
680 |
|
---|
681 | mov edx,121666
|
---|
682 | mulx rcx,r8,QWORD[rsi]
|
---|
683 | mulx rax,r9,QWORD[8+rsi]
|
---|
684 | add r9,rcx
|
---|
685 | mulx rcx,r10,QWORD[16+rsi]
|
---|
686 | adc r10,rax
|
---|
687 | mulx rax,r11,QWORD[24+rsi]
|
---|
688 | adc r11,rcx
|
---|
689 | adc rax,0
|
---|
690 |
|
---|
691 | imul rax,rax,38
|
---|
692 |
|
---|
693 | add r8,rax
|
---|
694 | adc r9,0
|
---|
695 | adc r10,0
|
---|
696 | adc r11,0
|
---|
697 |
|
---|
698 | sbb rax,rax
|
---|
699 | and rax,38
|
---|
700 |
|
---|
701 | add r8,rax
|
---|
702 | mov QWORD[8+rdi],r9
|
---|
703 | mov QWORD[16+rdi],r10
|
---|
704 | mov QWORD[24+rdi],r11
|
---|
705 | mov QWORD[rdi],r8
|
---|
706 |
|
---|
707 | $L$fe64_mul121666_epilogue:
|
---|
708 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
709 | mov rsi,QWORD[16+rsp]
|
---|
710 | DB 0F3h,0C3h ;repret
|
---|
711 |
|
---|
712 | $L$SEH_end_x25519_fe64_mul121666:
|
---|
713 |
|
---|
714 | global x25519_fe64_add
|
---|
715 |
|
---|
716 | ALIGN 32
|
---|
717 | x25519_fe64_add:
|
---|
718 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
719 | mov QWORD[16+rsp],rsi
|
---|
720 | mov rax,rsp
|
---|
721 | $L$SEH_begin_x25519_fe64_add:
|
---|
722 | mov rdi,rcx
|
---|
723 | mov rsi,rdx
|
---|
724 | mov rdx,r8
|
---|
725 |
|
---|
726 |
|
---|
727 | $L$fe64_add_body:
|
---|
728 |
|
---|
729 | mov r8,QWORD[rsi]
|
---|
730 | mov r9,QWORD[8+rsi]
|
---|
731 | mov r10,QWORD[16+rsi]
|
---|
732 | mov r11,QWORD[24+rsi]
|
---|
733 |
|
---|
734 | add r8,QWORD[rdx]
|
---|
735 | adc r9,QWORD[8+rdx]
|
---|
736 | adc r10,QWORD[16+rdx]
|
---|
737 | adc r11,QWORD[24+rdx]
|
---|
738 |
|
---|
739 | sbb rax,rax
|
---|
740 | and rax,38
|
---|
741 |
|
---|
742 | add r8,rax
|
---|
743 | adc r9,0
|
---|
744 | adc r10,0
|
---|
745 | mov QWORD[8+rdi],r9
|
---|
746 | adc r11,0
|
---|
747 | mov QWORD[16+rdi],r10
|
---|
748 | sbb rax,rax
|
---|
749 | mov QWORD[24+rdi],r11
|
---|
750 | and rax,38
|
---|
751 |
|
---|
752 | add r8,rax
|
---|
753 | mov QWORD[rdi],r8
|
---|
754 |
|
---|
755 | $L$fe64_add_epilogue:
|
---|
756 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
757 | mov rsi,QWORD[16+rsp]
|
---|
758 | DB 0F3h,0C3h ;repret
|
---|
759 |
|
---|
760 | $L$SEH_end_x25519_fe64_add:
|
---|
761 |
|
---|
762 | global x25519_fe64_sub
|
---|
763 |
|
---|
764 | ALIGN 32
|
---|
765 | x25519_fe64_sub:
|
---|
766 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
767 | mov QWORD[16+rsp],rsi
|
---|
768 | mov rax,rsp
|
---|
769 | $L$SEH_begin_x25519_fe64_sub:
|
---|
770 | mov rdi,rcx
|
---|
771 | mov rsi,rdx
|
---|
772 | mov rdx,r8
|
---|
773 |
|
---|
774 |
|
---|
775 | $L$fe64_sub_body:
|
---|
776 |
|
---|
777 | mov r8,QWORD[rsi]
|
---|
778 | mov r9,QWORD[8+rsi]
|
---|
779 | mov r10,QWORD[16+rsi]
|
---|
780 | mov r11,QWORD[24+rsi]
|
---|
781 |
|
---|
782 | sub r8,QWORD[rdx]
|
---|
783 | sbb r9,QWORD[8+rdx]
|
---|
784 | sbb r10,QWORD[16+rdx]
|
---|
785 | sbb r11,QWORD[24+rdx]
|
---|
786 |
|
---|
787 | sbb rax,rax
|
---|
788 | and rax,38
|
---|
789 |
|
---|
790 | sub r8,rax
|
---|
791 | sbb r9,0
|
---|
792 | sbb r10,0
|
---|
793 | mov QWORD[8+rdi],r9
|
---|
794 | sbb r11,0
|
---|
795 | mov QWORD[16+rdi],r10
|
---|
796 | sbb rax,rax
|
---|
797 | mov QWORD[24+rdi],r11
|
---|
798 | and rax,38
|
---|
799 |
|
---|
800 | sub r8,rax
|
---|
801 | mov QWORD[rdi],r8
|
---|
802 |
|
---|
803 | $L$fe64_sub_epilogue:
|
---|
804 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
805 | mov rsi,QWORD[16+rsp]
|
---|
806 | DB 0F3h,0C3h ;repret
|
---|
807 |
|
---|
808 | $L$SEH_end_x25519_fe64_sub:
|
---|
809 |
|
---|
810 | global x25519_fe64_tobytes
|
---|
811 |
|
---|
812 | ALIGN 32
|
---|
813 | x25519_fe64_tobytes:
|
---|
814 | mov QWORD[8+rsp],rdi ;WIN64 prologue
|
---|
815 | mov QWORD[16+rsp],rsi
|
---|
816 | mov rax,rsp
|
---|
817 | $L$SEH_begin_x25519_fe64_tobytes:
|
---|
818 | mov rdi,rcx
|
---|
819 | mov rsi,rdx
|
---|
820 |
|
---|
821 |
|
---|
822 | $L$fe64_to_body:
|
---|
823 |
|
---|
824 | mov r8,QWORD[rsi]
|
---|
825 | mov r9,QWORD[8+rsi]
|
---|
826 | mov r10,QWORD[16+rsi]
|
---|
827 | mov r11,QWORD[24+rsi]
|
---|
828 |
|
---|
829 |
|
---|
830 | lea rax,[r11*1+r11]
|
---|
831 | sar r11,63
|
---|
832 | shr rax,1
|
---|
833 | and r11,19
|
---|
834 | add r11,19
|
---|
835 |
|
---|
836 | add r8,r11
|
---|
837 | adc r9,0
|
---|
838 | adc r10,0
|
---|
839 | adc rax,0
|
---|
840 |
|
---|
841 | lea r11,[rax*1+rax]
|
---|
842 | sar rax,63
|
---|
843 | shr r11,1
|
---|
844 | not rax
|
---|
845 | and rax,19
|
---|
846 |
|
---|
847 | sub r8,rax
|
---|
848 | sbb r9,0
|
---|
849 | sbb r10,0
|
---|
850 | sbb r11,0
|
---|
851 |
|
---|
852 | mov QWORD[rdi],r8
|
---|
853 | mov QWORD[8+rdi],r9
|
---|
854 | mov QWORD[16+rdi],r10
|
---|
855 | mov QWORD[24+rdi],r11
|
---|
856 |
|
---|
857 | $L$fe64_to_epilogue:
|
---|
858 | mov rdi,QWORD[8+rsp] ;WIN64 epilogue
|
---|
859 | mov rsi,QWORD[16+rsp]
|
---|
860 | DB 0F3h,0C3h ;repret
|
---|
861 |
|
---|
862 | $L$SEH_end_x25519_fe64_tobytes:
|
---|
863 | DB 88,50,53,53,49,57,32,112,114,105,109,105,116,105,118,101
|
---|
864 | DB 115,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82
|
---|
865 | DB 89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112
|
---|
866 | DB 114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
|
---|
867 | EXTERN __imp_RtlVirtualUnwind
|
---|
868 |
|
---|
869 |
|
---|
870 | ALIGN 16
|
---|
871 | short_handler:
|
---|
872 | push rsi
|
---|
873 | push rdi
|
---|
874 | push rbx
|
---|
875 | push rbp
|
---|
876 | push r12
|
---|
877 | push r13
|
---|
878 | push r14
|
---|
879 | push r15
|
---|
880 | pushfq
|
---|
881 | sub rsp,64
|
---|
882 |
|
---|
883 | mov rax,QWORD[120+r8]
|
---|
884 | mov rbx,QWORD[248+r8]
|
---|
885 |
|
---|
886 | mov rsi,QWORD[8+r9]
|
---|
887 | mov r11,QWORD[56+r9]
|
---|
888 |
|
---|
889 | mov r10d,DWORD[r11]
|
---|
890 | lea r10,[r10*1+rsi]
|
---|
891 | cmp rbx,r10
|
---|
892 | jb NEAR $L$common_seh_tail
|
---|
893 |
|
---|
894 | mov rax,QWORD[152+r8]
|
---|
895 | jmp NEAR $L$common_seh_tail
|
---|
896 |
|
---|
897 |
|
---|
898 |
|
---|
899 | ALIGN 16
|
---|
900 | full_handler:
|
---|
901 | push rsi
|
---|
902 | push rdi
|
---|
903 | push rbx
|
---|
904 | push rbp
|
---|
905 | push r12
|
---|
906 | push r13
|
---|
907 | push r14
|
---|
908 | push r15
|
---|
909 | pushfq
|
---|
910 | sub rsp,64
|
---|
911 |
|
---|
912 | mov rax,QWORD[120+r8]
|
---|
913 | mov rbx,QWORD[248+r8]
|
---|
914 |
|
---|
915 | mov rsi,QWORD[8+r9]
|
---|
916 | mov r11,QWORD[56+r9]
|
---|
917 |
|
---|
918 | mov r10d,DWORD[r11]
|
---|
919 | lea r10,[r10*1+rsi]
|
---|
920 | cmp rbx,r10
|
---|
921 | jb NEAR $L$common_seh_tail
|
---|
922 |
|
---|
923 | mov rax,QWORD[152+r8]
|
---|
924 |
|
---|
925 | mov r10d,DWORD[4+r11]
|
---|
926 | lea r10,[r10*1+rsi]
|
---|
927 | cmp rbx,r10
|
---|
928 | jae NEAR $L$common_seh_tail
|
---|
929 |
|
---|
930 | mov r10d,DWORD[8+r11]
|
---|
931 | lea rax,[r10*1+rax]
|
---|
932 |
|
---|
933 | mov rbp,QWORD[((-8))+rax]
|
---|
934 | mov rbx,QWORD[((-16))+rax]
|
---|
935 | mov r12,QWORD[((-24))+rax]
|
---|
936 | mov r13,QWORD[((-32))+rax]
|
---|
937 | mov r14,QWORD[((-40))+rax]
|
---|
938 | mov r15,QWORD[((-48))+rax]
|
---|
939 | mov QWORD[144+r8],rbx
|
---|
940 | mov QWORD[160+r8],rbp
|
---|
941 | mov QWORD[216+r8],r12
|
---|
942 | mov QWORD[224+r8],r13
|
---|
943 | mov QWORD[232+r8],r14
|
---|
944 | mov QWORD[240+r8],r15
|
---|
945 |
|
---|
946 | $L$common_seh_tail:
|
---|
947 | mov rdi,QWORD[8+rax]
|
---|
948 | mov rsi,QWORD[16+rax]
|
---|
949 | mov QWORD[152+r8],rax
|
---|
950 | mov QWORD[168+r8],rsi
|
---|
951 | mov QWORD[176+r8],rdi
|
---|
952 |
|
---|
953 | mov rdi,QWORD[40+r9]
|
---|
954 | mov rsi,r8
|
---|
955 | mov ecx,154
|
---|
956 | DD 0xa548f3fc
|
---|
957 |
|
---|
958 | mov rsi,r9
|
---|
959 | xor rcx,rcx
|
---|
960 | mov rdx,QWORD[8+rsi]
|
---|
961 | mov r8,QWORD[rsi]
|
---|
962 | mov r9,QWORD[16+rsi]
|
---|
963 | mov r10,QWORD[40+rsi]
|
---|
964 | lea r11,[56+rsi]
|
---|
965 | lea r12,[24+rsi]
|
---|
966 | mov QWORD[32+rsp],r10
|
---|
967 | mov QWORD[40+rsp],r11
|
---|
968 | mov QWORD[48+rsp],r12
|
---|
969 | mov QWORD[56+rsp],rcx
|
---|
970 | call QWORD[__imp_RtlVirtualUnwind]
|
---|
971 |
|
---|
972 | mov eax,1
|
---|
973 | add rsp,64
|
---|
974 | popfq
|
---|
975 | pop r15
|
---|
976 | pop r14
|
---|
977 | pop r13
|
---|
978 | pop r12
|
---|
979 | pop rbp
|
---|
980 | pop rbx
|
---|
981 | pop rdi
|
---|
982 | pop rsi
|
---|
983 | DB 0F3h,0C3h ;repret
|
---|
984 |
|
---|
985 |
|
---|
986 | section .pdata rdata align=4
|
---|
987 | ALIGN 4
|
---|
988 | DD $L$SEH_begin_x25519_fe51_mul wrt ..imagebase
|
---|
989 | DD $L$SEH_end_x25519_fe51_mul wrt ..imagebase
|
---|
990 | DD $L$SEH_info_x25519_fe51_mul wrt ..imagebase
|
---|
991 |
|
---|
992 | DD $L$SEH_begin_x25519_fe51_sqr wrt ..imagebase
|
---|
993 | DD $L$SEH_end_x25519_fe51_sqr wrt ..imagebase
|
---|
994 | DD $L$SEH_info_x25519_fe51_sqr wrt ..imagebase
|
---|
995 |
|
---|
996 | DD $L$SEH_begin_x25519_fe51_mul121666 wrt ..imagebase
|
---|
997 | DD $L$SEH_end_x25519_fe51_mul121666 wrt ..imagebase
|
---|
998 | DD $L$SEH_info_x25519_fe51_mul121666 wrt ..imagebase
|
---|
999 | DD $L$SEH_begin_x25519_fe64_mul wrt ..imagebase
|
---|
1000 | DD $L$SEH_end_x25519_fe64_mul wrt ..imagebase
|
---|
1001 | DD $L$SEH_info_x25519_fe64_mul wrt ..imagebase
|
---|
1002 |
|
---|
1003 | DD $L$SEH_begin_x25519_fe64_sqr wrt ..imagebase
|
---|
1004 | DD $L$SEH_end_x25519_fe64_sqr wrt ..imagebase
|
---|
1005 | DD $L$SEH_info_x25519_fe64_sqr wrt ..imagebase
|
---|
1006 |
|
---|
1007 | DD $L$SEH_begin_x25519_fe64_mul121666 wrt ..imagebase
|
---|
1008 | DD $L$SEH_end_x25519_fe64_mul121666 wrt ..imagebase
|
---|
1009 | DD $L$SEH_info_x25519_fe64_mul121666 wrt ..imagebase
|
---|
1010 |
|
---|
1011 | DD $L$SEH_begin_x25519_fe64_add wrt ..imagebase
|
---|
1012 | DD $L$SEH_end_x25519_fe64_add wrt ..imagebase
|
---|
1013 | DD $L$SEH_info_x25519_fe64_add wrt ..imagebase
|
---|
1014 |
|
---|
1015 | DD $L$SEH_begin_x25519_fe64_sub wrt ..imagebase
|
---|
1016 | DD $L$SEH_end_x25519_fe64_sub wrt ..imagebase
|
---|
1017 | DD $L$SEH_info_x25519_fe64_sub wrt ..imagebase
|
---|
1018 |
|
---|
1019 | DD $L$SEH_begin_x25519_fe64_tobytes wrt ..imagebase
|
---|
1020 | DD $L$SEH_end_x25519_fe64_tobytes wrt ..imagebase
|
---|
1021 | DD $L$SEH_info_x25519_fe64_tobytes wrt ..imagebase
|
---|
1022 | section .xdata rdata align=8
|
---|
1023 | ALIGN 8
|
---|
1024 | $L$SEH_info_x25519_fe51_mul:
|
---|
1025 | DB 9,0,0,0
|
---|
1026 | DD full_handler wrt ..imagebase
|
---|
1027 | DD $L$fe51_mul_body wrt ..imagebase,$L$fe51_mul_epilogue wrt ..imagebase
|
---|
1028 | DD 88,0
|
---|
1029 | $L$SEH_info_x25519_fe51_sqr:
|
---|
1030 | DB 9,0,0,0
|
---|
1031 | DD full_handler wrt ..imagebase
|
---|
1032 | DD $L$fe51_sqr_body wrt ..imagebase,$L$fe51_sqr_epilogue wrt ..imagebase
|
---|
1033 | DD 88,0
|
---|
1034 | $L$SEH_info_x25519_fe51_mul121666:
|
---|
1035 | DB 9,0,0,0
|
---|
1036 | DD full_handler wrt ..imagebase
|
---|
1037 | DD $L$fe51_mul121666_body wrt ..imagebase,$L$fe51_mul121666_epilogue wrt ..imagebase
|
---|
1038 | DD 88,0
|
---|
1039 | $L$SEH_info_x25519_fe64_mul:
|
---|
1040 | DB 9,0,0,0
|
---|
1041 | DD full_handler wrt ..imagebase
|
---|
1042 | DD $L$fe64_mul_body wrt ..imagebase,$L$fe64_mul_epilogue wrt ..imagebase
|
---|
1043 | DD 72,0
|
---|
1044 | $L$SEH_info_x25519_fe64_sqr:
|
---|
1045 | DB 9,0,0,0
|
---|
1046 | DD full_handler wrt ..imagebase
|
---|
1047 | DD $L$fe64_sqr_body wrt ..imagebase,$L$fe64_sqr_epilogue wrt ..imagebase
|
---|
1048 | DD 72,0
|
---|
1049 | $L$SEH_info_x25519_fe64_mul121666:
|
---|
1050 | DB 9,0,0,0
|
---|
1051 | DD short_handler wrt ..imagebase
|
---|
1052 | DD $L$fe64_mul121666_body wrt ..imagebase,$L$fe64_mul121666_epilogue wrt ..imagebase
|
---|
1053 | $L$SEH_info_x25519_fe64_add:
|
---|
1054 | DB 9,0,0,0
|
---|
1055 | DD short_handler wrt ..imagebase
|
---|
1056 | DD $L$fe64_add_body wrt ..imagebase,$L$fe64_add_epilogue wrt ..imagebase
|
---|
1057 | $L$SEH_info_x25519_fe64_sub:
|
---|
1058 | DB 9,0,0,0
|
---|
1059 | DD short_handler wrt ..imagebase
|
---|
1060 | DD $L$fe64_sub_body wrt ..imagebase,$L$fe64_sub_epilogue wrt ..imagebase
|
---|
1061 | $L$SEH_info_x25519_fe64_tobytes:
|
---|
1062 | DB 9,0,0,0
|
---|
1063 | DD short_handler wrt ..imagebase
|
---|
1064 | DD $L$fe64_to_body wrt ..imagebase,$L$fe64_to_epilogue wrt ..imagebase
|
---|