Debian Codegraph @

win-x86_64/crypto/fipsmodule/aesni-x86_64-win.asm

raw
1 ; This file is generated from a similarly-named Perl script in the BoringSSL
2 ; source tree. Do not edit by hand.
3
4 %ifidn __OUTPUT_FORMAT__, win64
5 default rel
6 %define XMMWORD
7 %define YMMWORD
8 %define ZMMWORD
9
10 %ifdef BORINGSSL_PREFIX
11 %include "boringssl_prefix_symbols_nasm.inc"
12 %endif
13 section .text code align=64
14
15 EXTERN OPENSSL_ia32cap_P
16 global aes_hw_encrypt
17
18 ALIGN 16
19 aes_hw_encrypt:
20
21 %ifdef BORINGSSL_DISPATCH_TEST
22 EXTERN BORINGSSL_function_hit
23 mov BYTE[((BORINGSSL_function_hit+1))],1
24 %endif
25 movups xmm2,XMMWORD[rcx]
26 mov eax,DWORD[240+r8]
27 movups xmm0,XMMWORD[r8]
28 movups xmm1,XMMWORD[16+r8]
29 lea r8,[32+r8]
30 xorps xmm2,xmm0
31 $L$oop_enc1_1:
32 DB 102,15,56,220,209
33 dec eax
34 movups xmm1,XMMWORD[r8]
35 lea r8,[16+r8]
36 jnz NEAR $L$oop_enc1_1
37 DB 102,15,56,221,209
38 pxor xmm0,xmm0
39 pxor xmm1,xmm1
40 movups XMMWORD[rdx],xmm2
41 pxor xmm2,xmm2
42 DB 0F3h,0C3h ;repret
43
44
45
46 global aes_hw_decrypt
47
48 ALIGN 16
49 aes_hw_decrypt:
50
51 movups xmm2,XMMWORD[rcx]
52 mov eax,DWORD[240+r8]
53 movups xmm0,XMMWORD[r8]
54 movups xmm1,XMMWORD[16+r8]
55 lea r8,[32+r8]
56 xorps xmm2,xmm0
57 $L$oop_dec1_2:
58 DB 102,15,56,222,209
59 dec eax
60 movups xmm1,XMMWORD[r8]
61 lea r8,[16+r8]
62 jnz NEAR $L$oop_dec1_2
63 DB 102,15,56,223,209
64 pxor xmm0,xmm0
65 pxor xmm1,xmm1
66 movups XMMWORD[rdx],xmm2
67 pxor xmm2,xmm2
68 DB 0F3h,0C3h ;repret
69
70
71
72 ALIGN 16
73 _aesni_encrypt2:
74
75 movups xmm0,XMMWORD[rcx]
76 shl eax,4
77 movups xmm1,XMMWORD[16+rcx]
78 xorps xmm2,xmm0
79 xorps xmm3,xmm0
80 movups xmm0,XMMWORD[32+rcx]
81 lea rcx,[32+rax*1+rcx]
82 neg rax
83 add rax,16
84
85 $L$enc_loop2:
86 DB 102,15,56,220,209
87 DB 102,15,56,220,217
88 movups xmm1,XMMWORD[rax*1+rcx]
89 add rax,32
90 DB 102,15,56,220,208
91 DB 102,15,56,220,216
92 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
93 jnz NEAR $L$enc_loop2
94
95 DB 102,15,56,220,209
96 DB 102,15,56,220,217
97 DB 102,15,56,221,208
98 DB 102,15,56,221,216
99 DB 0F3h,0C3h ;repret
100
101
102
103 ALIGN 16
104 _aesni_decrypt2:
105
106 movups xmm0,XMMWORD[rcx]
107 shl eax,4
108 movups xmm1,XMMWORD[16+rcx]
109 xorps xmm2,xmm0
110 xorps xmm3,xmm0
111 movups xmm0,XMMWORD[32+rcx]
112 lea rcx,[32+rax*1+rcx]
113 neg rax
114 add rax,16
115
116 $L$dec_loop2:
117 DB 102,15,56,222,209
118 DB 102,15,56,222,217
119 movups xmm1,XMMWORD[rax*1+rcx]
120 add rax,32
121 DB 102,15,56,222,208
122 DB 102,15,56,222,216
123 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
124 jnz NEAR $L$dec_loop2
125
126 DB 102,15,56,222,209
127 DB 102,15,56,222,217
128 DB 102,15,56,223,208
129 DB 102,15,56,223,216
130 DB 0F3h,0C3h ;repret
131
132
133
134 ALIGN 16
135 _aesni_encrypt3:
136
137 movups xmm0,XMMWORD[rcx]
138 shl eax,4
139 movups xmm1,XMMWORD[16+rcx]
140 xorps xmm2,xmm0
141 xorps xmm3,xmm0
142 xorps xmm4,xmm0
143 movups xmm0,XMMWORD[32+rcx]
144 lea rcx,[32+rax*1+rcx]
145 neg rax
146 add rax,16
147
148 $L$enc_loop3:
149 DB 102,15,56,220,209
150 DB 102,15,56,220,217
151 DB 102,15,56,220,225
152 movups xmm1,XMMWORD[rax*1+rcx]
153 add rax,32
154 DB 102,15,56,220,208
155 DB 102,15,56,220,216
156 DB 102,15,56,220,224
157 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
158 jnz NEAR $L$enc_loop3
159
160 DB 102,15,56,220,209
161 DB 102,15,56,220,217
162 DB 102,15,56,220,225
163 DB 102,15,56,221,208
164 DB 102,15,56,221,216
165 DB 102,15,56,221,224
166 DB 0F3h,0C3h ;repret
167
168
169
170 ALIGN 16
171 _aesni_decrypt3:
172
173 movups xmm0,XMMWORD[rcx]
174 shl eax,4
175 movups xmm1,XMMWORD[16+rcx]
176 xorps xmm2,xmm0
177 xorps xmm3,xmm0
178 xorps xmm4,xmm0
179 movups xmm0,XMMWORD[32+rcx]
180 lea rcx,[32+rax*1+rcx]
181 neg rax
182 add rax,16
183
184 $L$dec_loop3:
185 DB 102,15,56,222,209
186 DB 102,15,56,222,217
187 DB 102,15,56,222,225
188 movups xmm1,XMMWORD[rax*1+rcx]
189 add rax,32
190 DB 102,15,56,222,208
191 DB 102,15,56,222,216
192 DB 102,15,56,222,224
193 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
194 jnz NEAR $L$dec_loop3
195
196 DB 102,15,56,222,209
197 DB 102,15,56,222,217
198 DB 102,15,56,222,225
199 DB 102,15,56,223,208
200 DB 102,15,56,223,216
201 DB 102,15,56,223,224
202 DB 0F3h,0C3h ;repret
203
204
205
206 ALIGN 16
207 _aesni_encrypt4:
208
209 movups xmm0,XMMWORD[rcx]
210 shl eax,4
211 movups xmm1,XMMWORD[16+rcx]
212 xorps xmm2,xmm0
213 xorps xmm3,xmm0
214 xorps xmm4,xmm0
215 xorps xmm5,xmm0
216 movups xmm0,XMMWORD[32+rcx]
217 lea rcx,[32+rax*1+rcx]
218 neg rax
219 DB 0x0f,0x1f,0x00
220 add rax,16
221
222 $L$enc_loop4:
223 DB 102,15,56,220,209
224 DB 102,15,56,220,217
225 DB 102,15,56,220,225
226 DB 102,15,56,220,233
227 movups xmm1,XMMWORD[rax*1+rcx]
228 add rax,32
229 DB 102,15,56,220,208
230 DB 102,15,56,220,216
231 DB 102,15,56,220,224
232 DB 102,15,56,220,232
233 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
234 jnz NEAR $L$enc_loop4
235
236 DB 102,15,56,220,209
237 DB 102,15,56,220,217
238 DB 102,15,56,220,225
239 DB 102,15,56,220,233
240 DB 102,15,56,221,208
241 DB 102,15,56,221,216
242 DB 102,15,56,221,224
243 DB 102,15,56,221,232
244 DB 0F3h,0C3h ;repret
245
246
247
248 ALIGN 16
249 _aesni_decrypt4:
250
251 movups xmm0,XMMWORD[rcx]
252 shl eax,4
253 movups xmm1,XMMWORD[16+rcx]
254 xorps xmm2,xmm0
255 xorps xmm3,xmm0
256 xorps xmm4,xmm0
257 xorps xmm5,xmm0
258 movups xmm0,XMMWORD[32+rcx]
259 lea rcx,[32+rax*1+rcx]
260 neg rax
261 DB 0x0f,0x1f,0x00
262 add rax,16
263
264 $L$dec_loop4:
265 DB 102,15,56,222,209
266 DB 102,15,56,222,217
267 DB 102,15,56,222,225
268 DB 102,15,56,222,233
269 movups xmm1,XMMWORD[rax*1+rcx]
270 add rax,32
271 DB 102,15,56,222,208
272 DB 102,15,56,222,216
273 DB 102,15,56,222,224
274 DB 102,15,56,222,232
275 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
276 jnz NEAR $L$dec_loop4
277
278 DB 102,15,56,222,209
279 DB 102,15,56,222,217
280 DB 102,15,56,222,225
281 DB 102,15,56,222,233
282 DB 102,15,56,223,208
283 DB 102,15,56,223,216
284 DB 102,15,56,223,224
285 DB 102,15,56,223,232
286 DB 0F3h,0C3h ;repret
287
288
289
290 ALIGN 16
291 _aesni_encrypt6:
292
293 movups xmm0,XMMWORD[rcx]
294 shl eax,4
295 movups xmm1,XMMWORD[16+rcx]
296 xorps xmm2,xmm0
297 pxor xmm3,xmm0
298 pxor xmm4,xmm0
299 DB 102,15,56,220,209
300 lea rcx,[32+rax*1+rcx]
301 neg rax
302 DB 102,15,56,220,217
303 pxor xmm5,xmm0
304 pxor xmm6,xmm0
305 DB 102,15,56,220,225
306 pxor xmm7,xmm0
307 movups xmm0,XMMWORD[rax*1+rcx]
308 add rax,16
309 jmp NEAR $L$enc_loop6_enter
310 ALIGN 16
311 $L$enc_loop6:
312 DB 102,15,56,220,209
313 DB 102,15,56,220,217
314 DB 102,15,56,220,225
315 $L$enc_loop6_enter:
316 DB 102,15,56,220,233
317 DB 102,15,56,220,241
318 DB 102,15,56,220,249
319 movups xmm1,XMMWORD[rax*1+rcx]
320 add rax,32
321 DB 102,15,56,220,208
322 DB 102,15,56,220,216
323 DB 102,15,56,220,224
324 DB 102,15,56,220,232
325 DB 102,15,56,220,240
326 DB 102,15,56,220,248
327 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
328 jnz NEAR $L$enc_loop6
329
330 DB 102,15,56,220,209
331 DB 102,15,56,220,217
332 DB 102,15,56,220,225
333 DB 102,15,56,220,233
334 DB 102,15,56,220,241
335 DB 102,15,56,220,249
336 DB 102,15,56,221,208
337 DB 102,15,56,221,216
338 DB 102,15,56,221,224
339 DB 102,15,56,221,232
340 DB 102,15,56,221,240
341 DB 102,15,56,221,248
342 DB 0F3h,0C3h ;repret
343
344
345
346 ALIGN 16
347 _aesni_decrypt6:
348
349 movups xmm0,XMMWORD[rcx]
350 shl eax,4
351 movups xmm1,XMMWORD[16+rcx]
352 xorps xmm2,xmm0
353 pxor xmm3,xmm0
354 pxor xmm4,xmm0
355 DB 102,15,56,222,209
356 lea rcx,[32+rax*1+rcx]
357 neg rax
358 DB 102,15,56,222,217
359 pxor xmm5,xmm0
360 pxor xmm6,xmm0
361 DB 102,15,56,222,225
362 pxor xmm7,xmm0
363 movups xmm0,XMMWORD[rax*1+rcx]
364 add rax,16
365 jmp NEAR $L$dec_loop6_enter
366 ALIGN 16
367 $L$dec_loop6:
368 DB 102,15,56,222,209
369 DB 102,15,56,222,217
370 DB 102,15,56,222,225
371 $L$dec_loop6_enter:
372 DB 102,15,56,222,233
373 DB 102,15,56,222,241
374 DB 102,15,56,222,249
375 movups xmm1,XMMWORD[rax*1+rcx]
376 add rax,32
377 DB 102,15,56,222,208
378 DB 102,15,56,222,216
379 DB 102,15,56,222,224
380 DB 102,15,56,222,232
381 DB 102,15,56,222,240
382 DB 102,15,56,222,248
383 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
384 jnz NEAR $L$dec_loop6
385
386 DB 102,15,56,222,209
387 DB 102,15,56,222,217
388 DB 102,15,56,222,225
389 DB 102,15,56,222,233
390 DB 102,15,56,222,241
391 DB 102,15,56,222,249
392 DB 102,15,56,223,208
393 DB 102,15,56,223,216
394 DB 102,15,56,223,224
395 DB 102,15,56,223,232
396 DB 102,15,56,223,240
397 DB 102,15,56,223,248
398 DB 0F3h,0C3h ;repret
399
400
401
402 ALIGN 16
403 _aesni_encrypt8:
404
405 movups xmm0,XMMWORD[rcx]
406 shl eax,4
407 movups xmm1,XMMWORD[16+rcx]
408 xorps xmm2,xmm0
409 xorps xmm3,xmm0
410 pxor xmm4,xmm0
411 pxor xmm5,xmm0
412 pxor xmm6,xmm0
413 lea rcx,[32+rax*1+rcx]
414 neg rax
415 DB 102,15,56,220,209
416 pxor xmm7,xmm0
417 pxor xmm8,xmm0
418 DB 102,15,56,220,217
419 pxor xmm9,xmm0
420 movups xmm0,XMMWORD[rax*1+rcx]
421 add rax,16
422 jmp NEAR $L$enc_loop8_inner
423 ALIGN 16
424 $L$enc_loop8:
425 DB 102,15,56,220,209
426 DB 102,15,56,220,217
427 $L$enc_loop8_inner:
428 DB 102,15,56,220,225
429 DB 102,15,56,220,233
430 DB 102,15,56,220,241
431 DB 102,15,56,220,249
432 DB 102,68,15,56,220,193
433 DB 102,68,15,56,220,201
434 $L$enc_loop8_enter:
435 movups xmm1,XMMWORD[rax*1+rcx]
436 add rax,32
437 DB 102,15,56,220,208
438 DB 102,15,56,220,216
439 DB 102,15,56,220,224
440 DB 102,15,56,220,232
441 DB 102,15,56,220,240
442 DB 102,15,56,220,248
443 DB 102,68,15,56,220,192
444 DB 102,68,15,56,220,200
445 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
446 jnz NEAR $L$enc_loop8
447
448 DB 102,15,56,220,209
449 DB 102,15,56,220,217
450 DB 102,15,56,220,225
451 DB 102,15,56,220,233
452 DB 102,15,56,220,241
453 DB 102,15,56,220,249
454 DB 102,68,15,56,220,193
455 DB 102,68,15,56,220,201
456 DB 102,15,56,221,208
457 DB 102,15,56,221,216
458 DB 102,15,56,221,224
459 DB 102,15,56,221,232
460 DB 102,15,56,221,240
461 DB 102,15,56,221,248
462 DB 102,68,15,56,221,192
463 DB 102,68,15,56,221,200
464 DB 0F3h,0C3h ;repret
465
466
467
468 ALIGN 16
469 _aesni_decrypt8:
470
471 movups xmm0,XMMWORD[rcx]
472 shl eax,4
473 movups xmm1,XMMWORD[16+rcx]
474 xorps xmm2,xmm0
475 xorps xmm3,xmm0
476 pxor xmm4,xmm0
477 pxor xmm5,xmm0
478 pxor xmm6,xmm0
479 lea rcx,[32+rax*1+rcx]
480 neg rax
481 DB 102,15,56,222,209
482 pxor xmm7,xmm0
483 pxor xmm8,xmm0
484 DB 102,15,56,222,217
485 pxor xmm9,xmm0
486 movups xmm0,XMMWORD[rax*1+rcx]
487 add rax,16
488 jmp NEAR $L$dec_loop8_inner
489 ALIGN 16
490 $L$dec_loop8:
491 DB 102,15,56,222,209
492 DB 102,15,56,222,217
493 $L$dec_loop8_inner:
494 DB 102,15,56,222,225
495 DB 102,15,56,222,233
496 DB 102,15,56,222,241
497 DB 102,15,56,222,249
498 DB 102,68,15,56,222,193
499 DB 102,68,15,56,222,201
500 $L$dec_loop8_enter:
501 movups xmm1,XMMWORD[rax*1+rcx]
502 add rax,32
503 DB 102,15,56,222,208
504 DB 102,15,56,222,216
505 DB 102,15,56,222,224
506 DB 102,15,56,222,232
507 DB 102,15,56,222,240
508 DB 102,15,56,222,248
509 DB 102,68,15,56,222,192
510 DB 102,68,15,56,222,200
511 movups xmm0,XMMWORD[((-16))+rax*1+rcx]
512 jnz NEAR $L$dec_loop8
513
514 DB 102,15,56,222,209
515 DB 102,15,56,222,217
516 DB 102,15,56,222,225
517 DB 102,15,56,222,233
518 DB 102,15,56,222,241
519 DB 102,15,56,222,249
520 DB 102,68,15,56,222,193
521 DB 102,68,15,56,222,201
522 DB 102,15,56,223,208
523 DB 102,15,56,223,216
524 DB 102,15,56,223,224
525 DB 102,15,56,223,232
526 DB 102,15,56,223,240
527 DB 102,15,56,223,248
528 DB 102,68,15,56,223,192
529 DB 102,68,15,56,223,200
530 DB 0F3h,0C3h ;repret
531
532
533 global aes_hw_ecb_encrypt
534
535 ALIGN 16
536 aes_hw_ecb_encrypt:
537 mov QWORD[8+rsp],rdi ;WIN64 prologue
538 mov QWORD[16+rsp],rsi
539 mov rax,rsp
540 $L$SEH_begin_aes_hw_ecb_encrypt:
541 mov rdi,rcx
542 mov rsi,rdx
543 mov rdx,r8
544 mov rcx,r9
545 mov r8,QWORD[40+rsp]
546
547
548
549 lea rsp,[((-88))+rsp]
550 movaps XMMWORD[rsp],xmm6
551 movaps XMMWORD[16+rsp],xmm7
552 movaps XMMWORD[32+rsp],xmm8
553 movaps XMMWORD[48+rsp],xmm9
554 $L$ecb_enc_body:
555 and rdx,-16
556 jz NEAR $L$ecb_ret
557
558 mov eax,DWORD[240+rcx]
559 movups xmm0,XMMWORD[rcx]
560 mov r11,rcx
561 mov r10d,eax
562 test r8d,r8d
563 jz NEAR $L$ecb_decrypt
564
565 cmp rdx,0x80
566 jb NEAR $L$ecb_enc_tail
567
568 movdqu xmm2,XMMWORD[rdi]
569 movdqu xmm3,XMMWORD[16+rdi]
570 movdqu xmm4,XMMWORD[32+rdi]
571 movdqu xmm5,XMMWORD[48+rdi]
572 movdqu xmm6,XMMWORD[64+rdi]
573 movdqu xmm7,XMMWORD[80+rdi]
574 movdqu xmm8,XMMWORD[96+rdi]
575 movdqu xmm9,XMMWORD[112+rdi]
576 lea rdi,[128+rdi]
577 sub rdx,0x80
578 jmp NEAR $L$ecb_enc_loop8_enter
579 ALIGN 16
580 $L$ecb_enc_loop8:
581 movups XMMWORD[rsi],xmm2
582 mov rcx,r11
583 movdqu xmm2,XMMWORD[rdi]
584 mov eax,r10d
585 movups XMMWORD[16+rsi],xmm3
586 movdqu xmm3,XMMWORD[16+rdi]
587 movups XMMWORD[32+rsi],xmm4
588 movdqu xmm4,XMMWORD[32+rdi]
589 movups XMMWORD[48+rsi],xmm5
590 movdqu xmm5,XMMWORD[48+rdi]
591 movups XMMWORD[64+rsi],xmm6
592 movdqu xmm6,XMMWORD[64+rdi]
593 movups XMMWORD[80+rsi],xmm7
594 movdqu xmm7,XMMWORD[80+rdi]
595 movups XMMWORD[96+rsi],xmm8
596 movdqu xmm8,XMMWORD[96+rdi]
597 movups XMMWORD[112+rsi],xmm9
598 lea rsi,[128+rsi]
599 movdqu xmm9,XMMWORD[112+rdi]
600 lea rdi,[128+rdi]
601 $L$ecb_enc_loop8_enter:
602
603 call _aesni_encrypt8
604
605 sub rdx,0x80
606 jnc NEAR $L$ecb_enc_loop8
607
608 movups XMMWORD[rsi],xmm2
609 mov rcx,r11
610 movups XMMWORD[16+rsi],xmm3
611 mov eax,r10d
612 movups XMMWORD[32+rsi],xmm4
613 movups XMMWORD[48+rsi],xmm5
614 movups XMMWORD[64+rsi],xmm6
615 movups XMMWORD[80+rsi],xmm7
616 movups XMMWORD[96+rsi],xmm8
617 movups XMMWORD[112+rsi],xmm9
618 lea rsi,[128+rsi]
619 add rdx,0x80
620 jz NEAR $L$ecb_ret
621
622 $L$ecb_enc_tail:
623 movups xmm2,XMMWORD[rdi]
624 cmp rdx,0x20
625 jb NEAR $L$ecb_enc_one
626 movups xmm3,XMMWORD[16+rdi]
627 je NEAR $L$ecb_enc_two
628 movups xmm4,XMMWORD[32+rdi]
629 cmp rdx,0x40
630 jb NEAR $L$ecb_enc_three
631 movups xmm5,XMMWORD[48+rdi]
632 je NEAR $L$ecb_enc_four
633 movups xmm6,XMMWORD[64+rdi]
634 cmp rdx,0x60
635 jb NEAR $L$ecb_enc_five
636 movups xmm7,XMMWORD[80+rdi]
637 je NEAR $L$ecb_enc_six
638 movdqu xmm8,XMMWORD[96+rdi]
639 xorps xmm9,xmm9
640 call _aesni_encrypt8
641 movups XMMWORD[rsi],xmm2
642 movups XMMWORD[16+rsi],xmm3
643 movups XMMWORD[32+rsi],xmm4
644 movups XMMWORD[48+rsi],xmm5
645 movups XMMWORD[64+rsi],xmm6
646 movups XMMWORD[80+rsi],xmm7
647 movups XMMWORD[96+rsi],xmm8
648 jmp NEAR $L$ecb_ret
649 ALIGN 16
650 $L$ecb_enc_one:
651 movups xmm0,XMMWORD[rcx]
652 movups xmm1,XMMWORD[16+rcx]
653 lea rcx,[32+rcx]
654 xorps xmm2,xmm0
655 $L$oop_enc1_3:
656 DB 102,15,56,220,209
657 dec eax
658 movups xmm1,XMMWORD[rcx]
659 lea rcx,[16+rcx]
660 jnz NEAR $L$oop_enc1_3
661 DB 102,15,56,221,209
662 movups XMMWORD[rsi],xmm2
663 jmp NEAR $L$ecb_ret
664 ALIGN 16
665 $L$ecb_enc_two:
666 call _aesni_encrypt2
667 movups XMMWORD[rsi],xmm2
668 movups XMMWORD[16+rsi],xmm3
669 jmp NEAR $L$ecb_ret
670 ALIGN 16
671 $L$ecb_enc_three:
672 call _aesni_encrypt3
673 movups XMMWORD[rsi],xmm2
674 movups XMMWORD[16+rsi],xmm3
675 movups XMMWORD[32+rsi],xmm4
676 jmp NEAR $L$ecb_ret
677 ALIGN 16
678 $L$ecb_enc_four:
679 call _aesni_encrypt4
680 movups XMMWORD[rsi],xmm2
681 movups XMMWORD[16+rsi],xmm3
682 movups XMMWORD[32+rsi],xmm4
683 movups XMMWORD[48+rsi],xmm5
684 jmp NEAR $L$ecb_ret
685 ALIGN 16
686 $L$ecb_enc_five:
687 xorps xmm7,xmm7
688 call _aesni_encrypt6
689 movups XMMWORD[rsi],xmm2
690 movups XMMWORD[16+rsi],xmm3
691 movups XMMWORD[32+rsi],xmm4
692 movups XMMWORD[48+rsi],xmm5
693 movups XMMWORD[64+rsi],xmm6
694 jmp NEAR $L$ecb_ret
695 ALIGN 16
696 $L$ecb_enc_six:
697 call _aesni_encrypt6
698 movups XMMWORD[rsi],xmm2
699 movups XMMWORD[16+rsi],xmm3
700 movups XMMWORD[32+rsi],xmm4
701 movups XMMWORD[48+rsi],xmm5
702 movups XMMWORD[64+rsi],xmm6
703 movups XMMWORD[80+rsi],xmm7
704 jmp NEAR $L$ecb_ret
705
706 ALIGN 16
707 $L$ecb_decrypt:
708 cmp rdx,0x80
709 jb NEAR $L$ecb_dec_tail
710
711 movdqu xmm2,XMMWORD[rdi]
712 movdqu xmm3,XMMWORD[16+rdi]
713 movdqu xmm4,XMMWORD[32+rdi]
714 movdqu xmm5,XMMWORD[48+rdi]
715 movdqu xmm6,XMMWORD[64+rdi]
716 movdqu xmm7,XMMWORD[80+rdi]
717 movdqu xmm8,XMMWORD[96+rdi]
718 movdqu xmm9,XMMWORD[112+rdi]
719 lea rdi,[128+rdi]
720 sub rdx,0x80
721 jmp NEAR $L$ecb_dec_loop8_enter
722 ALIGN 16
723 $L$ecb_dec_loop8:
724 movups XMMWORD[rsi],xmm2
725 mov rcx,r11
726 movdqu xmm2,XMMWORD[rdi]
727 mov eax,r10d
728 movups XMMWORD[16+rsi],xmm3
729 movdqu xmm3,XMMWORD[16+rdi]
730 movups XMMWORD[32+rsi],xmm4
731 movdqu xmm4,XMMWORD[32+rdi]
732 movups XMMWORD[48+rsi],xmm5
733 movdqu xmm5,XMMWORD[48+rdi]
734 movups XMMWORD[64+rsi],xmm6
735 movdqu xmm6,XMMWORD[64+rdi]
736 movups XMMWORD[80+rsi],xmm7
737 movdqu xmm7,XMMWORD[80+rdi]
738 movups XMMWORD[96+rsi],xmm8
739 movdqu xmm8,XMMWORD[96+rdi]
740 movups XMMWORD[112+rsi],xmm9
741 lea rsi,[128+rsi]
742 movdqu xmm9,XMMWORD[112+rdi]
743 lea rdi,[128+rdi]
744 $L$ecb_dec_loop8_enter:
745
746 call _aesni_decrypt8
747
748 movups xmm0,XMMWORD[r11]
749 sub rdx,0x80
750 jnc NEAR $L$ecb_dec_loop8
751
752 movups XMMWORD[rsi],xmm2
753 pxor xmm2,xmm2
754 mov rcx,r11
755 movups XMMWORD[16+rsi],xmm3
756 pxor xmm3,xmm3
757 mov eax,r10d
758 movups XMMWORD[32+rsi],xmm4
759 pxor xmm4,xmm4
760 movups XMMWORD[48+rsi],xmm5
761 pxor xmm5,xmm5
762 movups XMMWORD[64+rsi],xmm6
763 pxor xmm6,xmm6
764 movups XMMWORD[80+rsi],xmm7
765 pxor xmm7,xmm7
766 movups XMMWORD[96+rsi],xmm8
767 pxor xmm8,xmm8
768 movups XMMWORD[112+rsi],xmm9
769 pxor xmm9,xmm9
770 lea rsi,[128+rsi]
771 add rdx,0x80
772 jz NEAR $L$ecb_ret
773
774 $L$ecb_dec_tail:
775 movups xmm2,XMMWORD[rdi]
776 cmp rdx,0x20
777 jb NEAR $L$ecb_dec_one
778 movups xmm3,XMMWORD[16+rdi]
779 je NEAR $L$ecb_dec_two
780 movups xmm4,XMMWORD[32+rdi]
781 cmp rdx,0x40
782 jb NEAR $L$ecb_dec_three
783 movups xmm5,XMMWORD[48+rdi]
784 je NEAR $L$ecb_dec_four
785 movups xmm6,XMMWORD[64+rdi]
786 cmp rdx,0x60
787 jb NEAR $L$ecb_dec_five
788 movups xmm7,XMMWORD[80+rdi]
789 je NEAR $L$ecb_dec_six
790 movups xmm8,XMMWORD[96+rdi]
791 movups xmm0,XMMWORD[rcx]
792 xorps xmm9,xmm9
793 call _aesni_decrypt8
794 movups XMMWORD[rsi],xmm2
795 pxor xmm2,xmm2
796 movups XMMWORD[16+rsi],xmm3
797 pxor xmm3,xmm3
798 movups XMMWORD[32+rsi],xmm4
799 pxor xmm4,xmm4
800 movups XMMWORD[48+rsi],xmm5
801 pxor xmm5,xmm5
802 movups XMMWORD[64+rsi],xmm6
803 pxor xmm6,xmm6
804 movups XMMWORD[80+rsi],xmm7
805 pxor xmm7,xmm7
806 movups XMMWORD[96+rsi],xmm8
807 pxor xmm8,xmm8
808 pxor xmm9,xmm9
809 jmp NEAR $L$ecb_ret
810 ALIGN 16
811 $L$ecb_dec_one:
812 movups xmm0,XMMWORD[rcx]
813 movups xmm1,XMMWORD[16+rcx]
814 lea rcx,[32+rcx]
815 xorps xmm2,xmm0
816 $L$oop_dec1_4:
817 DB 102,15,56,222,209
818 dec eax
819 movups xmm1,XMMWORD[rcx]
820 lea rcx,[16+rcx]
821 jnz NEAR $L$oop_dec1_4
822 DB 102,15,56,223,209
823 movups XMMWORD[rsi],xmm2
824 pxor xmm2,xmm2
825 jmp NEAR $L$ecb_ret
826 ALIGN 16
827 $L$ecb_dec_two:
828 call _aesni_decrypt2
829 movups XMMWORD[rsi],xmm2
830 pxor xmm2,xmm2
831 movups XMMWORD[16+rsi],xmm3
832 pxor xmm3,xmm3
833 jmp NEAR $L$ecb_ret
834 ALIGN 16
835 $L$ecb_dec_three:
836 call _aesni_decrypt3
837 movups XMMWORD[rsi],xmm2
838 pxor xmm2,xmm2
839 movups XMMWORD[16+rsi],xmm3
840 pxor xmm3,xmm3
841 movups XMMWORD[32+rsi],xmm4
842 pxor xmm4,xmm4
843 jmp NEAR $L$ecb_ret
844 ALIGN 16
845 $L$ecb_dec_four:
846 call _aesni_decrypt4
847 movups XMMWORD[rsi],xmm2
848 pxor xmm2,xmm2
849 movups XMMWORD[16+rsi],xmm3
850 pxor xmm3,xmm3
851 movups XMMWORD[32+rsi],xmm4
852 pxor xmm4,xmm4
853 movups XMMWORD[48+rsi],xmm5
854 pxor xmm5,xmm5
855 jmp NEAR $L$ecb_ret
856 ALIGN 16
857 $L$ecb_dec_five:
858 xorps xmm7,xmm7
859 call _aesni_decrypt6
860 movups XMMWORD[rsi],xmm2
861 pxor xmm2,xmm2
862 movups XMMWORD[16+rsi],xmm3
863 pxor xmm3,xmm3
864 movups XMMWORD[32+rsi],xmm4
865 pxor xmm4,xmm4
866 movups XMMWORD[48+rsi],xmm5
867 pxor xmm5,xmm5
868 movups XMMWORD[64+rsi],xmm6
869 pxor xmm6,xmm6
870 pxor xmm7,xmm7
871 jmp NEAR $L$ecb_ret
872 ALIGN 16
873 $L$ecb_dec_six:
874 call _aesni_decrypt6
875 movups XMMWORD[rsi],xmm2
876 pxor xmm2,xmm2
877 movups XMMWORD[16+rsi],xmm3
878 pxor xmm3,xmm3
879 movups XMMWORD[32+rsi],xmm4
880 pxor xmm4,xmm4
881 movups XMMWORD[48+rsi],xmm5
882 pxor xmm5,xmm5
883 movups XMMWORD[64+rsi],xmm6
884 pxor xmm6,xmm6
885 movups XMMWORD[80+rsi],xmm7
886 pxor xmm7,xmm7
887
888 $L$ecb_ret:
889 xorps xmm0,xmm0
890 pxor xmm1,xmm1
891 movaps xmm6,XMMWORD[rsp]
892 movaps XMMWORD[rsp],xmm0
893 movaps xmm7,XMMWORD[16+rsp]
894 movaps XMMWORD[16+rsp],xmm0
895 movaps xmm8,XMMWORD[32+rsp]
896 movaps XMMWORD[32+rsp],xmm0
897 movaps xmm9,XMMWORD[48+rsp]
898 movaps XMMWORD[48+rsp],xmm0
899 lea rsp,[88+rsp]
900 $L$ecb_enc_ret:
901 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
902 mov rsi,QWORD[16+rsp]
903 DB 0F3h,0C3h ;repret
904
905 $L$SEH_end_aes_hw_ecb_encrypt:
906 global aes_hw_ctr32_encrypt_blocks
907
908 ALIGN 16
909 aes_hw_ctr32_encrypt_blocks:
910 mov QWORD[8+rsp],rdi ;WIN64 prologue
911 mov QWORD[16+rsp],rsi
912 mov rax,rsp
913 $L$SEH_begin_aes_hw_ctr32_encrypt_blocks:
914 mov rdi,rcx
915 mov rsi,rdx
916 mov rdx,r8
917 mov rcx,r9
918 mov r8,QWORD[40+rsp]
919
920
921
922 %ifdef BORINGSSL_DISPATCH_TEST
923 mov BYTE[BORINGSSL_function_hit],1
924 %endif
925 cmp rdx,1
926 jne NEAR $L$ctr32_bulk
927
928
929
930 movups xmm2,XMMWORD[r8]
931 movups xmm3,XMMWORD[rdi]
932 mov edx,DWORD[240+rcx]
933 movups xmm0,XMMWORD[rcx]
934 movups xmm1,XMMWORD[16+rcx]
935 lea rcx,[32+rcx]
936 xorps xmm2,xmm0
937 $L$oop_enc1_5:
938 DB 102,15,56,220,209
939 dec edx
940 movups xmm1,XMMWORD[rcx]
941 lea rcx,[16+rcx]
942 jnz NEAR $L$oop_enc1_5
943 DB 102,15,56,221,209
944 pxor xmm0,xmm0
945 pxor xmm1,xmm1
946 xorps xmm2,xmm3
947 pxor xmm3,xmm3
948 movups XMMWORD[rsi],xmm2
949 xorps xmm2,xmm2
950 jmp NEAR $L$ctr32_epilogue
951
952 ALIGN 16
953 $L$ctr32_bulk:
954 lea r11,[rsp]
955
956 push rbp
957
958 sub rsp,288
959 and rsp,-16
960 movaps XMMWORD[(-168)+r11],xmm6
961 movaps XMMWORD[(-152)+r11],xmm7
962 movaps XMMWORD[(-136)+r11],xmm8
963 movaps XMMWORD[(-120)+r11],xmm9
964 movaps XMMWORD[(-104)+r11],xmm10
965 movaps XMMWORD[(-88)+r11],xmm11
966 movaps XMMWORD[(-72)+r11],xmm12
967 movaps XMMWORD[(-56)+r11],xmm13
968 movaps XMMWORD[(-40)+r11],xmm14
969 movaps XMMWORD[(-24)+r11],xmm15
970 $L$ctr32_body:
971
972
973
974
975 movdqu xmm2,XMMWORD[r8]
976 movdqu xmm0,XMMWORD[rcx]
977 mov r8d,DWORD[12+r8]
978 pxor xmm2,xmm0
979 mov ebp,DWORD[12+rcx]
980 movdqa XMMWORD[rsp],xmm2
981 bswap r8d
982 movdqa xmm3,xmm2
983 movdqa xmm4,xmm2
984 movdqa xmm5,xmm2
985 movdqa XMMWORD[64+rsp],xmm2
986 movdqa XMMWORD[80+rsp],xmm2
987 movdqa XMMWORD[96+rsp],xmm2
988 mov r10,rdx
989 movdqa XMMWORD[112+rsp],xmm2
990
991 lea rax,[1+r8]
992 lea rdx,[2+r8]
993 bswap eax
994 bswap edx
995 xor eax,ebp
996 xor edx,ebp
997 DB 102,15,58,34,216,3
998 lea rax,[3+r8]
999 movdqa XMMWORD[16+rsp],xmm3
1000 DB 102,15,58,34,226,3
1001 bswap eax
1002 mov rdx,r10
1003 lea r10,[4+r8]
1004 movdqa XMMWORD[32+rsp],xmm4
1005 xor eax,ebp
1006 bswap r10d
1007 DB 102,15,58,34,232,3
1008 xor r10d,ebp
1009 movdqa XMMWORD[48+rsp],xmm5
1010 lea r9,[5+r8]
1011 mov DWORD[((64+12))+rsp],r10d
1012 bswap r9d
1013 lea r10,[6+r8]
1014 mov eax,DWORD[240+rcx]
1015 xor r9d,ebp
1016 bswap r10d
1017 mov DWORD[((80+12))+rsp],r9d
1018 xor r10d,ebp
1019 lea r9,[7+r8]
1020 mov DWORD[((96+12))+rsp],r10d
1021 bswap r9d
1022 lea r10,[OPENSSL_ia32cap_P]
1023 mov r10d,DWORD[4+r10]
1024 xor r9d,ebp
1025 and r10d,71303168
1026 mov DWORD[((112+12))+rsp],r9d
1027
1028 movups xmm1,XMMWORD[16+rcx]
1029
1030 movdqa xmm6,XMMWORD[64+rsp]
1031 movdqa xmm7,XMMWORD[80+rsp]
1032
1033 cmp rdx,8
1034 jb NEAR $L$ctr32_tail
1035
1036 sub rdx,6
1037 cmp r10d,4194304
1038 je NEAR $L$ctr32_6x
1039
1040 lea rcx,[128+rcx]
1041 sub rdx,2
1042 jmp NEAR $L$ctr32_loop8
1043
1044 ALIGN 16
1045 $L$ctr32_6x:
1046 shl eax,4
1047 mov r10d,48
1048 bswap ebp
1049 lea rcx,[32+rax*1+rcx]
1050 sub r10,rax
1051 jmp NEAR $L$ctr32_loop6
1052
1053 ALIGN 16
1054 $L$ctr32_loop6:
1055 add r8d,6
1056 movups xmm0,XMMWORD[((-48))+r10*1+rcx]
1057 DB 102,15,56,220,209
1058 mov eax,r8d
1059 xor eax,ebp
1060 DB 102,15,56,220,217
1061 DB 0x0f,0x38,0xf1,0x44,0x24,12
1062 lea eax,[1+r8]
1063 DB 102,15,56,220,225
1064 xor eax,ebp
1065 DB 0x0f,0x38,0xf1,0x44,0x24,28
1066 DB 102,15,56,220,233
1067 lea eax,[2+r8]
1068 xor eax,ebp
1069 DB 102,15,56,220,241
1070 DB 0x0f,0x38,0xf1,0x44,0x24,44
1071 lea eax,[3+r8]
1072 DB 102,15,56,220,249
1073 movups xmm1,XMMWORD[((-32))+r10*1+rcx]
1074 xor eax,ebp
1075
1076 DB 102,15,56,220,208
1077 DB 0x0f,0x38,0xf1,0x44,0x24,60
1078 lea eax,[4+r8]
1079 DB 102,15,56,220,216
1080 xor eax,ebp
1081 DB 0x0f,0x38,0xf1,0x44,0x24,76
1082 DB 102,15,56,220,224
1083 lea eax,[5+r8]
1084 xor eax,ebp
1085 DB 102,15,56,220,232
1086 DB 0x0f,0x38,0xf1,0x44,0x24,92
1087 mov rax,r10
1088 DB 102,15,56,220,240
1089 DB 102,15,56,220,248
1090 movups xmm0,XMMWORD[((-16))+r10*1+rcx]
1091
1092 call $L$enc_loop6
1093
1094 movdqu xmm8,XMMWORD[rdi]
1095 movdqu xmm9,XMMWORD[16+rdi]
1096 movdqu xmm10,XMMWORD[32+rdi]
1097 movdqu xmm11,XMMWORD[48+rdi]
1098 movdqu xmm12,XMMWORD[64+rdi]
1099 movdqu xmm13,XMMWORD[80+rdi]
1100 lea rdi,[96+rdi]
1101 movups xmm1,XMMWORD[((-64))+r10*1+rcx]
1102 pxor xmm8,xmm2
1103 movaps xmm2,XMMWORD[rsp]
1104 pxor xmm9,xmm3
1105 movaps xmm3,XMMWORD[16+rsp]
1106 pxor xmm10,xmm4
1107 movaps xmm4,XMMWORD[32+rsp]
1108 pxor xmm11,xmm5
1109 movaps xmm5,XMMWORD[48+rsp]
1110 pxor xmm12,xmm6
1111 movaps xmm6,XMMWORD[64+rsp]
1112 pxor xmm13,xmm7
1113 movaps xmm7,XMMWORD[80+rsp]
1114 movdqu XMMWORD[rsi],xmm8
1115 movdqu XMMWORD[16+rsi],xmm9
1116 movdqu XMMWORD[32+rsi],xmm10
1117 movdqu XMMWORD[48+rsi],xmm11
1118 movdqu XMMWORD[64+rsi],xmm12
1119 movdqu XMMWORD[80+rsi],xmm13
1120 lea rsi,[96+rsi]
1121
1122 sub rdx,6
1123 jnc NEAR $L$ctr32_loop6
1124
1125 add rdx,6
1126 jz NEAR $L$ctr32_done
1127
1128 lea eax,[((-48))+r10]
1129 lea rcx,[((-80))+r10*1+rcx]
1130 neg eax
1131 shr eax,4
1132 jmp NEAR $L$ctr32_tail
1133
1134 ALIGN 32
1135 $L$ctr32_loop8:
1136 add r8d,8
1137 movdqa xmm8,XMMWORD[96+rsp]
1138 DB 102,15,56,220,209
1139 mov r9d,r8d
1140 movdqa xmm9,XMMWORD[112+rsp]
1141 DB 102,15,56,220,217
1142 bswap r9d
1143 movups xmm0,XMMWORD[((32-128))+rcx]
1144 DB 102,15,56,220,225
1145 xor r9d,ebp
1146 nop
1147 DB 102,15,56,220,233
1148 mov DWORD[((0+12))+rsp],r9d
1149 lea r9,[1+r8]
1150 DB 102,15,56,220,241
1151 DB 102,15,56,220,249
1152 DB 102,68,15,56,220,193
1153 DB 102,68,15,56,220,201
1154 movups xmm1,XMMWORD[((48-128))+rcx]
1155 bswap r9d
1156 DB 102,15,56,220,208
1157 DB 102,15,56,220,216
1158 xor r9d,ebp
1159 DB 0x66,0x90
1160 DB 102,15,56,220,224
1161 DB 102,15,56,220,232
1162 mov DWORD[((16+12))+rsp],r9d
1163 lea r9,[2+r8]
1164 DB 102,15,56,220,240
1165 DB 102,15,56,220,248
1166 DB 102,68,15,56,220,192
1167 DB 102,68,15,56,220,200
1168 movups xmm0,XMMWORD[((64-128))+rcx]
1169 bswap r9d
1170 DB 102,15,56,220,209
1171 DB 102,15,56,220,217
1172 xor r9d,ebp
1173 DB 0x66,0x90
1174 DB 102,15,56,220,225
1175 DB 102,15,56,220,233
1176 mov DWORD[((32+12))+rsp],r9d
1177 lea r9,[3+r8]
1178 DB 102,15,56,220,241
1179 DB 102,15,56,220,249
1180 DB 102,68,15,56,220,193
1181 DB 102,68,15,56,220,201
1182 movups xmm1,XMMWORD[((80-128))+rcx]
1183 bswap r9d
1184 DB 102,15,56,220,208
1185 DB 102,15,56,220,216
1186 xor r9d,ebp
1187 DB 0x66,0x90
1188 DB 102,15,56,220,224
1189 DB 102,15,56,220,232
1190 mov DWORD[((48+12))+rsp],r9d
1191 lea r9,[4+r8]
1192 DB 102,15,56,220,240
1193 DB 102,15,56,220,248
1194 DB 102,68,15,56,220,192
1195 DB 102,68,15,56,220,200
1196 movups xmm0,XMMWORD[((96-128))+rcx]
1197 bswap r9d
1198 DB 102,15,56,220,209
1199 DB 102,15,56,220,217
1200 xor r9d,ebp
1201 DB 0x66,0x90
1202 DB 102,15,56,220,225
1203 DB 102,15,56,220,233
1204 mov DWORD[((64+12))+rsp],r9d
1205 lea r9,[5+r8]
1206 DB 102,15,56,220,241
1207 DB 102,15,56,220,249
1208 DB 102,68,15,56,220,193
1209 DB 102,68,15,56,220,201
1210 movups xmm1,XMMWORD[((112-128))+rcx]
1211 bswap r9d
1212 DB 102,15,56,220,208
1213 DB 102,15,56,220,216
1214 xor r9d,ebp
1215 DB 0x66,0x90
1216 DB 102,15,56,220,224
1217 DB 102,15,56,220,232
1218 mov DWORD[((80+12))+rsp],r9d
1219 lea r9,[6+r8]
1220 DB 102,15,56,220,240
1221 DB 102,15,56,220,248
1222 DB 102,68,15,56,220,192
1223 DB 102,68,15,56,220,200
1224 movups xmm0,XMMWORD[((128-128))+rcx]
1225 bswap r9d
1226 DB 102,15,56,220,209
1227 DB 102,15,56,220,217
1228 xor r9d,ebp
1229 DB 0x66,0x90
1230 DB 102,15,56,220,225
1231 DB 102,15,56,220,233
1232 mov DWORD[((96+12))+rsp],r9d
1233 lea r9,[7+r8]
1234 DB 102,15,56,220,241
1235 DB 102,15,56,220,249
1236 DB 102,68,15,56,220,193
1237 DB 102,68,15,56,220,201
1238 movups xmm1,XMMWORD[((144-128))+rcx]
1239 bswap r9d
1240 DB 102,15,56,220,208
1241 DB 102,15,56,220,216
1242 DB 102,15,56,220,224
1243 xor r9d,ebp
1244 movdqu xmm10,XMMWORD[rdi]
1245 DB 102,15,56,220,232
1246 mov DWORD[((112+12))+rsp],r9d
1247 cmp eax,11
1248 DB 102,15,56,220,240
1249 DB 102,15,56,220,248
1250 DB 102,68,15,56,220,192
1251 DB 102,68,15,56,220,200
1252 movups xmm0,XMMWORD[((160-128))+rcx]
1253
1254 jb NEAR $L$ctr32_enc_done
1255
1256 DB 102,15,56,220,209
1257 DB 102,15,56,220,217
1258 DB 102,15,56,220,225
1259 DB 102,15,56,220,233
1260 DB 102,15,56,220,241
1261 DB 102,15,56,220,249
1262 DB 102,68,15,56,220,193
1263 DB 102,68,15,56,220,201
1264 movups xmm1,XMMWORD[((176-128))+rcx]
1265
1266 DB 102,15,56,220,208
1267 DB 102,15,56,220,216
1268 DB 102,15,56,220,224
1269 DB 102,15,56,220,232
1270 DB 102,15,56,220,240
1271 DB 102,15,56,220,248
1272 DB 102,68,15,56,220,192
1273 DB 102,68,15,56,220,200
1274 movups xmm0,XMMWORD[((192-128))+rcx]
1275 je NEAR $L$ctr32_enc_done
1276
1277 DB 102,15,56,220,209
1278 DB 102,15,56,220,217
1279 DB 102,15,56,220,225
1280 DB 102,15,56,220,233
1281 DB 102,15,56,220,241
1282 DB 102,15,56,220,249
1283 DB 102,68,15,56,220,193
1284 DB 102,68,15,56,220,201
1285 movups xmm1,XMMWORD[((208-128))+rcx]
1286
1287 DB 102,15,56,220,208
1288 DB 102,15,56,220,216
1289 DB 102,15,56,220,224
1290 DB 102,15,56,220,232
1291 DB 102,15,56,220,240
1292 DB 102,15,56,220,248
1293 DB 102,68,15,56,220,192
1294 DB 102,68,15,56,220,200
1295 movups xmm0,XMMWORD[((224-128))+rcx]
1296 jmp NEAR $L$ctr32_enc_done
1297
1298 ALIGN 16
1299 $L$ctr32_enc_done:
1300 movdqu xmm11,XMMWORD[16+rdi]
1301 pxor xmm10,xmm0
1302 movdqu xmm12,XMMWORD[32+rdi]
1303 pxor xmm11,xmm0
1304 movdqu xmm13,XMMWORD[48+rdi]
1305 pxor xmm12,xmm0
1306 movdqu xmm14,XMMWORD[64+rdi]
1307 pxor xmm13,xmm0
1308 movdqu xmm15,XMMWORD[80+rdi]
1309 pxor xmm14,xmm0
1310 pxor xmm15,xmm0
1311 DB 102,15,56,220,209
1312 DB 102,15,56,220,217
1313 DB 102,15,56,220,225
1314 DB 102,15,56,220,233
1315 DB 102,15,56,220,241
1316 DB 102,15,56,220,249
1317 DB 102,68,15,56,220,193
1318 DB 102,68,15,56,220,201
1319 movdqu xmm1,XMMWORD[96+rdi]
1320 lea rdi,[128+rdi]
1321
1322 DB 102,65,15,56,221,210
1323 pxor xmm1,xmm0
1324 movdqu xmm10,XMMWORD[((112-128))+rdi]
1325 DB 102,65,15,56,221,219
1326 pxor xmm10,xmm0
1327 movdqa xmm11,XMMWORD[rsp]
1328 DB 102,65,15,56,221,228
1329 DB 102,65,15,56,221,237
1330 movdqa xmm12,XMMWORD[16+rsp]
1331 movdqa xmm13,XMMWORD[32+rsp]
1332 DB 102,65,15,56,221,246
1333 DB 102,65,15,56,221,255
1334 movdqa xmm14,XMMWORD[48+rsp]
1335 movdqa xmm15,XMMWORD[64+rsp]
1336 DB 102,68,15,56,221,193
1337 movdqa xmm0,XMMWORD[80+rsp]
1338 movups xmm1,XMMWORD[((16-128))+rcx]
1339 DB 102,69,15,56,221,202
1340
1341 movups XMMWORD[rsi],xmm2
1342 movdqa xmm2,xmm11
1343 movups XMMWORD[16+rsi],xmm3
1344 movdqa xmm3,xmm12
1345 movups XMMWORD[32+rsi],xmm4
1346 movdqa xmm4,xmm13
1347 movups XMMWORD[48+rsi],xmm5
1348 movdqa xmm5,xmm14
1349 movups XMMWORD[64+rsi],xmm6
1350 movdqa xmm6,xmm15
1351 movups XMMWORD[80+rsi],xmm7
1352 movdqa xmm7,xmm0
1353 movups XMMWORD[96+rsi],xmm8
1354 movups XMMWORD[112+rsi],xmm9
1355 lea rsi,[128+rsi]
1356
1357 sub rdx,8
1358 jnc NEAR $L$ctr32_loop8
1359
1360 add rdx,8
1361 jz NEAR $L$ctr32_done
1362 lea rcx,[((-128))+rcx]
1363
1364 $L$ctr32_tail:
1365
1366
1367 lea rcx,[16+rcx]
1368 cmp rdx,4
1369 jb NEAR $L$ctr32_loop3
1370 je NEAR $L$ctr32_loop4
1371
1372
1373 shl eax,4
1374 movdqa xmm8,XMMWORD[96+rsp]
1375 pxor xmm9,xmm9
1376
1377 movups xmm0,XMMWORD[16+rcx]
1378 DB 102,15,56,220,209
1379 DB 102,15,56,220,217
1380 lea rcx,[((32-16))+rax*1+rcx]
1381 neg rax
1382 DB 102,15,56,220,225
1383 add rax,16
1384 movups xmm10,XMMWORD[rdi]
1385 DB 102,15,56,220,233
1386 DB 102,15,56,220,241
1387 movups xmm11,XMMWORD[16+rdi]
1388 movups xmm12,XMMWORD[32+rdi]
1389 DB 102,15,56,220,249
1390 DB 102,68,15,56,220,193
1391
1392 call $L$enc_loop8_enter
1393
1394 movdqu xmm13,XMMWORD[48+rdi]
1395 pxor xmm2,xmm10
1396 movdqu xmm10,XMMWORD[64+rdi]
1397 pxor xmm3,xmm11
1398 movdqu XMMWORD[rsi],xmm2
1399 pxor xmm4,xmm12
1400 movdqu XMMWORD[16+rsi],xmm3
1401 pxor xmm5,xmm13
1402 movdqu XMMWORD[32+rsi],xmm4
1403 pxor xmm6,xmm10
1404 movdqu XMMWORD[48+rsi],xmm5
1405 movdqu XMMWORD[64+rsi],xmm6
1406 cmp rdx,6
1407 jb NEAR $L$ctr32_done
1408
1409 movups xmm11,XMMWORD[80+rdi]
1410 xorps xmm7,xmm11
1411 movups XMMWORD[80+rsi],xmm7
1412 je NEAR $L$ctr32_done
1413
1414 movups xmm12,XMMWORD[96+rdi]
1415 xorps xmm8,xmm12
1416 movups XMMWORD[96+rsi],xmm8
1417 jmp NEAR $L$ctr32_done
1418
1419 ALIGN 32
1420 $L$ctr32_loop4:
1421 DB 102,15,56,220,209
1422 lea rcx,[16+rcx]
1423 dec eax
1424 DB 102,15,56,220,217
1425 DB 102,15,56,220,225
1426 DB 102,15,56,220,233
1427 movups xmm1,XMMWORD[rcx]
1428 jnz NEAR $L$ctr32_loop4
1429 DB 102,15,56,221,209
1430 DB 102,15,56,221,217
1431 movups xmm10,XMMWORD[rdi]
1432 movups xmm11,XMMWORD[16+rdi]
1433 DB 102,15,56,221,225
1434 DB 102,15,56,221,233
1435 movups xmm12,XMMWORD[32+rdi]
1436 movups xmm13,XMMWORD[48+rdi]
1437
1438 xorps xmm2,xmm10
1439 movups XMMWORD[rsi],xmm2
1440 xorps xmm3,xmm11
1441 movups XMMWORD[16+rsi],xmm3
1442 pxor xmm4,xmm12
1443 movdqu XMMWORD[32+rsi],xmm4
1444 pxor xmm5,xmm13
1445 movdqu XMMWORD[48+rsi],xmm5
1446 jmp NEAR $L$ctr32_done
1447
1448 ALIGN 32
1449 $L$ctr32_loop3:
1450 DB 102,15,56,220,209
1451 lea rcx,[16+rcx]
1452 dec eax
1453 DB 102,15,56,220,217
1454 DB 102,15,56,220,225
1455 movups xmm1,XMMWORD[rcx]
1456 jnz NEAR $L$ctr32_loop3
1457 DB 102,15,56,221,209
1458 DB 102,15,56,221,217
1459 DB 102,15,56,221,225
1460
1461 movups xmm10,XMMWORD[rdi]
1462 xorps xmm2,xmm10
1463 movups XMMWORD[rsi],xmm2
1464 cmp rdx,2
1465 jb NEAR $L$ctr32_done
1466
1467 movups xmm11,XMMWORD[16+rdi]
1468 xorps xmm3,xmm11
1469 movups XMMWORD[16+rsi],xmm3
1470 je NEAR $L$ctr32_done
1471
1472 movups xmm12,XMMWORD[32+rdi]
1473 xorps xmm4,xmm12
1474 movups XMMWORD[32+rsi],xmm4
1475
1476 $L$ctr32_done:
1477 xorps xmm0,xmm0
1478 xor ebp,ebp
1479 pxor xmm1,xmm1
1480 pxor xmm2,xmm2
1481 pxor xmm3,xmm3
1482 pxor xmm4,xmm4
1483 pxor xmm5,xmm5
1484 movaps xmm6,XMMWORD[((-168))+r11]
1485 movaps XMMWORD[(-168)+r11],xmm0
1486 movaps xmm7,XMMWORD[((-152))+r11]
1487 movaps XMMWORD[(-152)+r11],xmm0
1488 movaps xmm8,XMMWORD[((-136))+r11]
1489 movaps XMMWORD[(-136)+r11],xmm0
1490 movaps xmm9,XMMWORD[((-120))+r11]
1491 movaps XMMWORD[(-120)+r11],xmm0
1492 movaps xmm10,XMMWORD[((-104))+r11]
1493 movaps XMMWORD[(-104)+r11],xmm0
1494 movaps xmm11,XMMWORD[((-88))+r11]
1495 movaps XMMWORD[(-88)+r11],xmm0
1496 movaps xmm12,XMMWORD[((-72))+r11]
1497 movaps XMMWORD[(-72)+r11],xmm0
1498 movaps xmm13,XMMWORD[((-56))+r11]
1499 movaps XMMWORD[(-56)+r11],xmm0
1500 movaps xmm14,XMMWORD[((-40))+r11]
1501 movaps XMMWORD[(-40)+r11],xmm0
1502 movaps xmm15,XMMWORD[((-24))+r11]
1503 movaps XMMWORD[(-24)+r11],xmm0
1504 movaps XMMWORD[rsp],xmm0
1505 movaps XMMWORD[16+rsp],xmm0
1506 movaps XMMWORD[32+rsp],xmm0
1507 movaps XMMWORD[48+rsp],xmm0
1508 movaps XMMWORD[64+rsp],xmm0
1509 movaps XMMWORD[80+rsp],xmm0
1510 movaps XMMWORD[96+rsp],xmm0
1511 movaps XMMWORD[112+rsp],xmm0
1512 mov rbp,QWORD[((-8))+r11]
1513
1514 lea rsp,[r11]
1515
1516 $L$ctr32_epilogue:
1517 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
1518 mov rsi,QWORD[16+rsp]
1519 DB 0F3h,0C3h ;repret
1520
1521 $L$SEH_end_aes_hw_ctr32_encrypt_blocks:
1522 global aes_hw_cbc_encrypt
1523
1524 ALIGN 16
1525 aes_hw_cbc_encrypt:
1526 mov QWORD[8+rsp],rdi ;WIN64 prologue
1527 mov QWORD[16+rsp],rsi
1528 mov rax,rsp
1529 $L$SEH_begin_aes_hw_cbc_encrypt:
1530 mov rdi,rcx
1531 mov rsi,rdx
1532 mov rdx,r8
1533 mov rcx,r9
1534 mov r8,QWORD[40+rsp]
1535 mov r9,QWORD[48+rsp]
1536
1537
1538
1539 test rdx,rdx
1540 jz NEAR $L$cbc_ret
1541
1542 mov r10d,DWORD[240+rcx]
1543 mov r11,rcx
1544 test r9d,r9d
1545 jz NEAR $L$cbc_decrypt
1546
1547 movups xmm2,XMMWORD[r8]
1548 mov eax,r10d
1549 cmp rdx,16
1550 jb NEAR $L$cbc_enc_tail
1551 sub rdx,16
1552 jmp NEAR $L$cbc_enc_loop
1553 ALIGN 16
1554 $L$cbc_enc_loop:
1555 movups xmm3,XMMWORD[rdi]
1556 lea rdi,[16+rdi]
1557
1558 movups xmm0,XMMWORD[rcx]
1559 movups xmm1,XMMWORD[16+rcx]
1560 xorps xmm3,xmm0
1561 lea rcx,[32+rcx]
1562 xorps xmm2,xmm3
1563 $L$oop_enc1_6:
1564 DB 102,15,56,220,209
1565 dec eax
1566 movups xmm1,XMMWORD[rcx]
1567 lea rcx,[16+rcx]
1568 jnz NEAR $L$oop_enc1_6
1569 DB 102,15,56,221,209
1570 mov eax,r10d
1571 mov rcx,r11
1572 movups XMMWORD[rsi],xmm2
1573 lea rsi,[16+rsi]
1574 sub rdx,16
1575 jnc NEAR $L$cbc_enc_loop
1576 add rdx,16
1577 jnz NEAR $L$cbc_enc_tail
1578 pxor xmm0,xmm0
1579 pxor xmm1,xmm1
1580 movups XMMWORD[r8],xmm2
1581 pxor xmm2,xmm2
1582 pxor xmm3,xmm3
1583 jmp NEAR $L$cbc_ret
1584
1585 $L$cbc_enc_tail:
1586 mov rcx,rdx
1587 xchg rsi,rdi
1588 DD 0x9066A4F3
1589 mov ecx,16
1590 sub rcx,rdx
1591 xor eax,eax
1592 DD 0x9066AAF3
1593 lea rdi,[((-16))+rdi]
1594 mov eax,r10d
1595 mov rsi,rdi
1596 mov rcx,r11
1597 xor rdx,rdx
1598 jmp NEAR $L$cbc_enc_loop
1599
1600 ALIGN 16
1601 $L$cbc_decrypt:
1602 cmp rdx,16
1603 jne NEAR $L$cbc_decrypt_bulk
1604
1605
1606
1607 movdqu xmm2,XMMWORD[rdi]
1608 movdqu xmm3,XMMWORD[r8]
1609 movdqa xmm4,xmm2
1610 movups xmm0,XMMWORD[rcx]
1611 movups xmm1,XMMWORD[16+rcx]
1612 lea rcx,[32+rcx]
1613 xorps xmm2,xmm0
1614 $L$oop_dec1_7:
1615 DB 102,15,56,222,209
1616 dec r10d
1617 movups xmm1,XMMWORD[rcx]
1618 lea rcx,[16+rcx]
1619 jnz NEAR $L$oop_dec1_7
1620 DB 102,15,56,223,209
1621 pxor xmm0,xmm0
1622 pxor xmm1,xmm1
1623 movdqu XMMWORD[r8],xmm4
1624 xorps xmm2,xmm3
1625 pxor xmm3,xmm3
1626 movups XMMWORD[rsi],xmm2
1627 pxor xmm2,xmm2
1628 jmp NEAR $L$cbc_ret
1629 ALIGN 16
1630 $L$cbc_decrypt_bulk:
1631 lea r11,[rsp]
1632
1633 push rbp
1634
1635 sub rsp,176
1636 and rsp,-16
1637 movaps XMMWORD[16+rsp],xmm6
1638 movaps XMMWORD[32+rsp],xmm7
1639 movaps XMMWORD[48+rsp],xmm8
1640 movaps XMMWORD[64+rsp],xmm9
1641 movaps XMMWORD[80+rsp],xmm10
1642 movaps XMMWORD[96+rsp],xmm11
1643 movaps XMMWORD[112+rsp],xmm12
1644 movaps XMMWORD[128+rsp],xmm13
1645 movaps XMMWORD[144+rsp],xmm14
1646 movaps XMMWORD[160+rsp],xmm15
1647 $L$cbc_decrypt_body:
1648 mov rbp,rcx
1649 movups xmm10,XMMWORD[r8]
1650 mov eax,r10d
1651 cmp rdx,0x50
1652 jbe NEAR $L$cbc_dec_tail
1653
1654 movups xmm0,XMMWORD[rcx]
1655 movdqu xmm2,XMMWORD[rdi]
1656 movdqu xmm3,XMMWORD[16+rdi]
1657 movdqa xmm11,xmm2
1658 movdqu xmm4,XMMWORD[32+rdi]
1659 movdqa xmm12,xmm3
1660 movdqu xmm5,XMMWORD[48+rdi]
1661 movdqa xmm13,xmm4
1662 movdqu xmm6,XMMWORD[64+rdi]
1663 movdqa xmm14,xmm5
1664 movdqu xmm7,XMMWORD[80+rdi]
1665 movdqa xmm15,xmm6
1666 lea r9,[OPENSSL_ia32cap_P]
1667 mov r9d,DWORD[4+r9]
1668 cmp rdx,0x70
1669 jbe NEAR $L$cbc_dec_six_or_seven
1670
1671 and r9d,71303168
1672 sub rdx,0x50
1673 cmp r9d,4194304
1674 je NEAR $L$cbc_dec_loop6_enter
1675 sub rdx,0x20
1676 lea rcx,[112+rcx]
1677 jmp NEAR $L$cbc_dec_loop8_enter
1678 ALIGN 16
1679 $L$cbc_dec_loop8:
1680 movups XMMWORD[rsi],xmm9
1681 lea rsi,[16+rsi]
1682 $L$cbc_dec_loop8_enter:
1683 movdqu xmm8,XMMWORD[96+rdi]
1684 pxor xmm2,xmm0
1685 movdqu xmm9,XMMWORD[112+rdi]
1686 pxor xmm3,xmm0
1687 movups xmm1,XMMWORD[((16-112))+rcx]
1688 pxor xmm4,xmm0
1689 mov rbp,-1
1690 cmp rdx,0x70
1691 pxor xmm5,xmm0
1692 pxor xmm6,xmm0
1693 pxor xmm7,xmm0
1694 pxor xmm8,xmm0
1695
1696 DB 102,15,56,222,209
1697 pxor xmm9,xmm0
1698 movups xmm0,XMMWORD[((32-112))+rcx]
1699 DB 102,15,56,222,217
1700 DB 102,15,56,222,225
1701 DB 102,15,56,222,233
1702 DB 102,15,56,222,241
1703 DB 102,15,56,222,249
1704 DB 102,68,15,56,222,193
1705 adc rbp,0
1706 and rbp,128
1707 DB 102,68,15,56,222,201
1708 add rbp,rdi
1709 movups xmm1,XMMWORD[((48-112))+rcx]
1710 DB 102,15,56,222,208
1711 DB 102,15,56,222,216
1712 DB 102,15,56,222,224
1713 DB 102,15,56,222,232
1714 DB 102,15,56,222,240
1715 DB 102,15,56,222,248
1716 DB 102,68,15,56,222,192
1717 DB 102,68,15,56,222,200
1718 movups xmm0,XMMWORD[((64-112))+rcx]
1719 nop
1720 DB 102,15,56,222,209
1721 DB 102,15,56,222,217
1722 DB 102,15,56,222,225
1723 DB 102,15,56,222,233
1724 DB 102,15,56,222,241
1725 DB 102,15,56,222,249
1726 DB 102,68,15,56,222,193
1727 DB 102,68,15,56,222,201
1728 movups xmm1,XMMWORD[((80-112))+rcx]
1729 nop
1730 DB 102,15,56,222,208
1731 DB 102,15,56,222,216
1732 DB 102,15,56,222,224
1733 DB 102,15,56,222,232
1734 DB 102,15,56,222,240
1735 DB 102,15,56,222,248
1736 DB 102,68,15,56,222,192
1737 DB 102,68,15,56,222,200
1738 movups xmm0,XMMWORD[((96-112))+rcx]
1739 nop
1740 DB 102,15,56,222,209
1741 DB 102,15,56,222,217
1742 DB 102,15,56,222,225
1743 DB 102,15,56,222,233
1744 DB 102,15,56,222,241
1745 DB 102,15,56,222,249
1746 DB 102,68,15,56,222,193
1747 DB 102,68,15,56,222,201
1748 movups xmm1,XMMWORD[((112-112))+rcx]
1749 nop
1750 DB 102,15,56,222,208
1751 DB 102,15,56,222,216
1752 DB 102,15,56,222,224
1753 DB 102,15,56,222,232
1754 DB 102,15,56,222,240
1755 DB 102,15,56,222,248
1756 DB 102,68,15,56,222,192
1757 DB 102,68,15,56,222,200
1758 movups xmm0,XMMWORD[((128-112))+rcx]
1759 nop
1760 DB 102,15,56,222,209
1761 DB 102,15,56,222,217
1762 DB 102,15,56,222,225
1763 DB 102,15,56,222,233
1764 DB 102,15,56,222,241
1765 DB 102,15,56,222,249
1766 DB 102,68,15,56,222,193
1767 DB 102,68,15,56,222,201
1768 movups xmm1,XMMWORD[((144-112))+rcx]
1769 cmp eax,11
1770 DB 102,15,56,222,208
1771 DB 102,15,56,222,216
1772 DB 102,15,56,222,224
1773 DB 102,15,56,222,232
1774 DB 102,15,56,222,240
1775 DB 102,15,56,222,248
1776 DB 102,68,15,56,222,192
1777 DB 102,68,15,56,222,200
1778 movups xmm0,XMMWORD[((160-112))+rcx]
1779 jb NEAR $L$cbc_dec_done
1780 DB 102,15,56,222,209
1781 DB 102,15,56,222,217
1782 DB 102,15,56,222,225
1783 DB 102,15,56,222,233
1784 DB 102,15,56,222,241
1785 DB 102,15,56,222,249
1786 DB 102,68,15,56,222,193
1787 DB 102,68,15,56,222,201
1788 movups xmm1,XMMWORD[((176-112))+rcx]
1789 nop
1790 DB 102,15,56,222,208
1791 DB 102,15,56,222,216
1792 DB 102,15,56,222,224
1793 DB 102,15,56,222,232
1794 DB 102,15,56,222,240
1795 DB 102,15,56,222,248
1796 DB 102,68,15,56,222,192
1797 DB 102,68,15,56,222,200
1798 movups xmm0,XMMWORD[((192-112))+rcx]
1799 je NEAR $L$cbc_dec_done
1800 DB 102,15,56,222,209
1801 DB 102,15,56,222,217
1802 DB 102,15,56,222,225
1803 DB 102,15,56,222,233
1804 DB 102,15,56,222,241
1805 DB 102,15,56,222,249
1806 DB 102,68,15,56,222,193
1807 DB 102,68,15,56,222,201
1808 movups xmm1,XMMWORD[((208-112))+rcx]
1809 nop
1810 DB 102,15,56,222,208
1811 DB 102,15,56,222,216
1812 DB 102,15,56,222,224
1813 DB 102,15,56,222,232
1814 DB 102,15,56,222,240
1815 DB 102,15,56,222,248
1816 DB 102,68,15,56,222,192
1817 DB 102,68,15,56,222,200
1818 movups xmm0,XMMWORD[((224-112))+rcx]
1819 jmp NEAR $L$cbc_dec_done
1820 ALIGN 16
1821 $L$cbc_dec_done:
1822 DB 102,15,56,222,209
1823 DB 102,15,56,222,217
1824 pxor xmm10,xmm0
1825 pxor xmm11,xmm0
1826 DB 102,15,56,222,225
1827 DB 102,15,56,222,233
1828 pxor xmm12,xmm0
1829 pxor xmm13,xmm0
1830 DB 102,15,56,222,241
1831 DB 102,15,56,222,249
1832 pxor xmm14,xmm0
1833 pxor xmm15,xmm0
1834 DB 102,68,15,56,222,193
1835 DB 102,68,15,56,222,201
1836 movdqu xmm1,XMMWORD[80+rdi]
1837
1838 DB 102,65,15,56,223,210
1839 movdqu xmm10,XMMWORD[96+rdi]
1840 pxor xmm1,xmm0
1841 DB 102,65,15,56,223,219
1842 pxor xmm10,xmm0
1843 movdqu xmm0,XMMWORD[112+rdi]
1844 DB 102,65,15,56,223,228
1845 lea rdi,[128+rdi]
1846 movdqu xmm11,XMMWORD[rbp]
1847 DB 102,65,15,56,223,237
1848 DB 102,65,15,56,223,246
1849 movdqu xmm12,XMMWORD[16+rbp]
1850 movdqu xmm13,XMMWORD[32+rbp]
1851 DB 102,65,15,56,223,255
1852 DB 102,68,15,56,223,193
1853 movdqu xmm14,XMMWORD[48+rbp]
1854 movdqu xmm15,XMMWORD[64+rbp]
1855 DB 102,69,15,56,223,202
1856 movdqa xmm10,xmm0
1857 movdqu xmm1,XMMWORD[80+rbp]
1858 movups xmm0,XMMWORD[((-112))+rcx]
1859
1860 movups XMMWORD[rsi],xmm2
1861 movdqa xmm2,xmm11
1862 movups XMMWORD[16+rsi],xmm3
1863 movdqa xmm3,xmm12
1864 movups XMMWORD[32+rsi],xmm4
1865 movdqa xmm4,xmm13
1866 movups XMMWORD[48+rsi],xmm5
1867 movdqa xmm5,xmm14
1868 movups XMMWORD[64+rsi],xmm6
1869 movdqa xmm6,xmm15
1870 movups XMMWORD[80+rsi],xmm7
1871 movdqa xmm7,xmm1
1872 movups XMMWORD[96+rsi],xmm8
1873 lea rsi,[112+rsi]
1874
1875 sub rdx,0x80
1876 ja NEAR $L$cbc_dec_loop8
1877
1878 movaps xmm2,xmm9
1879 lea rcx,[((-112))+rcx]
1880 add rdx,0x70
1881 jle NEAR $L$cbc_dec_clear_tail_collected
1882 movups XMMWORD[rsi],xmm9
1883 lea rsi,[16+rsi]
1884 cmp rdx,0x50
1885 jbe NEAR $L$cbc_dec_tail
1886
1887 movaps xmm2,xmm11
1888 $L$cbc_dec_six_or_seven:
1889 cmp rdx,0x60
1890 ja NEAR $L$cbc_dec_seven
1891
1892 movaps xmm8,xmm7
1893 call _aesni_decrypt6
1894 pxor xmm2,xmm10
1895 movaps xmm10,xmm8
1896 pxor xmm3,xmm11
1897 movdqu XMMWORD[rsi],xmm2
1898 pxor xmm4,xmm12
1899 movdqu XMMWORD[16+rsi],xmm3
1900 pxor xmm3,xmm3
1901 pxor xmm5,xmm13
1902 movdqu XMMWORD[32+rsi],xmm4
1903 pxor xmm4,xmm4
1904 pxor xmm6,xmm14
1905 movdqu XMMWORD[48+rsi],xmm5
1906 pxor xmm5,xmm5
1907 pxor xmm7,xmm15
1908 movdqu XMMWORD[64+rsi],xmm6
1909 pxor xmm6,xmm6
1910 lea rsi,[80+rsi]
1911 movdqa xmm2,xmm7
1912 pxor xmm7,xmm7
1913 jmp NEAR $L$cbc_dec_tail_collected
1914
1915 ALIGN 16
1916 $L$cbc_dec_seven:
1917 movups xmm8,XMMWORD[96+rdi]
1918 xorps xmm9,xmm9
1919 call _aesni_decrypt8
1920 movups xmm9,XMMWORD[80+rdi]
1921 pxor xmm2,xmm10
1922 movups xmm10,XMMWORD[96+rdi]
1923 pxor xmm3,xmm11
1924 movdqu XMMWORD[rsi],xmm2
1925 pxor xmm4,xmm12
1926 movdqu XMMWORD[16+rsi],xmm3
1927 pxor xmm3,xmm3
1928 pxor xmm5,xmm13
1929 movdqu XMMWORD[32+rsi],xmm4
1930 pxor xmm4,xmm4
1931 pxor xmm6,xmm14
1932 movdqu XMMWORD[48+rsi],xmm5
1933 pxor xmm5,xmm5
1934 pxor xmm7,xmm15
1935 movdqu XMMWORD[64+rsi],xmm6
1936 pxor xmm6,xmm6
1937 pxor xmm8,xmm9
1938 movdqu XMMWORD[80+rsi],xmm7
1939 pxor xmm7,xmm7
1940 lea rsi,[96+rsi]
1941 movdqa xmm2,xmm8
1942 pxor xmm8,xmm8
1943 pxor xmm9,xmm9
1944 jmp NEAR $L$cbc_dec_tail_collected
1945
1946 ALIGN 16
1947 $L$cbc_dec_loop6:
1948 movups XMMWORD[rsi],xmm7
1949 lea rsi,[16+rsi]
1950 movdqu xmm2,XMMWORD[rdi]
1951 movdqu xmm3,XMMWORD[16+rdi]
1952 movdqa xmm11,xmm2
1953 movdqu xmm4,XMMWORD[32+rdi]
1954 movdqa xmm12,xmm3
1955 movdqu xmm5,XMMWORD[48+rdi]
1956 movdqa xmm13,xmm4
1957 movdqu xmm6,XMMWORD[64+rdi]
1958 movdqa xmm14,xmm5
1959 movdqu xmm7,XMMWORD[80+rdi]
1960 movdqa xmm15,xmm6
1961 $L$cbc_dec_loop6_enter:
1962 lea rdi,[96+rdi]
1963 movdqa xmm8,xmm7
1964
1965 call _aesni_decrypt6
1966
1967 pxor xmm2,xmm10
1968 movdqa xmm10,xmm8
1969 pxor xmm3,xmm11
1970 movdqu XMMWORD[rsi],xmm2
1971 pxor xmm4,xmm12
1972 movdqu XMMWORD[16+rsi],xmm3
1973 pxor xmm5,xmm13
1974 movdqu XMMWORD[32+rsi],xmm4
1975 pxor xmm6,xmm14
1976 mov rcx,rbp
1977 movdqu XMMWORD[48+rsi],xmm5
1978 pxor xmm7,xmm15
1979 mov eax,r10d
1980 movdqu XMMWORD[64+rsi],xmm6
1981 lea rsi,[80+rsi]
1982 sub rdx,0x60
1983 ja NEAR $L$cbc_dec_loop6
1984
1985 movdqa xmm2,xmm7
1986 add rdx,0x50
1987 jle NEAR $L$cbc_dec_clear_tail_collected
1988 movups XMMWORD[rsi],xmm7
1989 lea rsi,[16+rsi]
1990
1991 $L$cbc_dec_tail:
1992 movups xmm2,XMMWORD[rdi]
1993 sub rdx,0x10
1994 jbe NEAR $L$cbc_dec_one
1995
1996 movups xmm3,XMMWORD[16+rdi]
1997 movaps xmm11,xmm2
1998 sub rdx,0x10
1999 jbe NEAR $L$cbc_dec_two
2000
2001 movups xmm4,XMMWORD[32+rdi]
2002 movaps xmm12,xmm3
2003 sub rdx,0x10
2004 jbe NEAR $L$cbc_dec_three
2005
2006 movups xmm5,XMMWORD[48+rdi]
2007 movaps xmm13,xmm4
2008 sub rdx,0x10
2009 jbe NEAR $L$cbc_dec_four
2010
2011 movups xmm6,XMMWORD[64+rdi]
2012 movaps xmm14,xmm5
2013 movaps xmm15,xmm6
2014 xorps xmm7,xmm7
2015 call _aesni_decrypt6
2016 pxor xmm2,xmm10
2017 movaps xmm10,xmm15
2018 pxor xmm3,xmm11
2019 movdqu XMMWORD[rsi],xmm2
2020 pxor xmm4,xmm12
2021 movdqu XMMWORD[16+rsi],xmm3
2022 pxor xmm3,xmm3
2023 pxor xmm5,xmm13
2024 movdqu XMMWORD[32+rsi],xmm4
2025 pxor xmm4,xmm4
2026 pxor xmm6,xmm14
2027 movdqu XMMWORD[48+rsi],xmm5
2028 pxor xmm5,xmm5
2029 lea rsi,[64+rsi]
2030 movdqa xmm2,xmm6
2031 pxor xmm6,xmm6
2032 pxor xmm7,xmm7
2033 sub rdx,0x10
2034 jmp NEAR $L$cbc_dec_tail_collected
2035
2036 ALIGN 16
2037 $L$cbc_dec_one:
2038 movaps xmm11,xmm2
2039 movups xmm0,XMMWORD[rcx]
2040 movups xmm1,XMMWORD[16+rcx]
2041 lea rcx,[32+rcx]
2042 xorps xmm2,xmm0
2043 $L$oop_dec1_8:
2044 DB 102,15,56,222,209
2045 dec eax
2046 movups xmm1,XMMWORD[rcx]
2047 lea rcx,[16+rcx]
2048 jnz NEAR $L$oop_dec1_8
2049 DB 102,15,56,223,209
2050 xorps xmm2,xmm10
2051 movaps xmm10,xmm11
2052 jmp NEAR $L$cbc_dec_tail_collected
2053 ALIGN 16
2054 $L$cbc_dec_two:
2055 movaps xmm12,xmm3
2056 call _aesni_decrypt2
2057 pxor xmm2,xmm10
2058 movaps xmm10,xmm12
2059 pxor xmm3,xmm11
2060 movdqu XMMWORD[rsi],xmm2
2061 movdqa xmm2,xmm3
2062 pxor xmm3,xmm3
2063 lea rsi,[16+rsi]
2064 jmp NEAR $L$cbc_dec_tail_collected
2065 ALIGN 16
2066 $L$cbc_dec_three:
2067 movaps xmm13,xmm4
2068 call _aesni_decrypt3
2069 pxor xmm2,xmm10
2070 movaps xmm10,xmm13
2071 pxor xmm3,xmm11
2072 movdqu XMMWORD[rsi],xmm2
2073 pxor xmm4,xmm12
2074 movdqu XMMWORD[16+rsi],xmm3
2075 pxor xmm3,xmm3
2076 movdqa xmm2,xmm4
2077 pxor xmm4,xmm4
2078 lea rsi,[32+rsi]
2079 jmp NEAR $L$cbc_dec_tail_collected
2080 ALIGN 16
2081 $L$cbc_dec_four:
2082 movaps xmm14,xmm5
2083 call _aesni_decrypt4
2084 pxor xmm2,xmm10
2085 movaps xmm10,xmm14
2086 pxor xmm3,xmm11
2087 movdqu XMMWORD[rsi],xmm2
2088 pxor xmm4,xmm12
2089 movdqu XMMWORD[16+rsi],xmm3
2090 pxor xmm3,xmm3
2091 pxor xmm5,xmm13
2092 movdqu XMMWORD[32+rsi],xmm4
2093 pxor xmm4,xmm4
2094 movdqa xmm2,xmm5
2095 pxor xmm5,xmm5
2096 lea rsi,[48+rsi]
2097 jmp NEAR $L$cbc_dec_tail_collected
2098
2099 ALIGN 16
2100 $L$cbc_dec_clear_tail_collected:
2101 pxor xmm3,xmm3
2102 pxor xmm4,xmm4
2103 pxor xmm5,xmm5
2104 $L$cbc_dec_tail_collected:
2105 movups XMMWORD[r8],xmm10
2106 and rdx,15
2107 jnz NEAR $L$cbc_dec_tail_partial
2108 movups XMMWORD[rsi],xmm2
2109 pxor xmm2,xmm2
2110 jmp NEAR $L$cbc_dec_ret
2111 ALIGN 16
2112 $L$cbc_dec_tail_partial:
2113 movaps XMMWORD[rsp],xmm2
2114 pxor xmm2,xmm2
2115 mov rcx,16
2116 mov rdi,rsi
2117 sub rcx,rdx
2118 lea rsi,[rsp]
2119 DD 0x9066A4F3
2120 movdqa XMMWORD[rsp],xmm2
2121
2122 $L$cbc_dec_ret:
2123 xorps xmm0,xmm0
2124 pxor xmm1,xmm1
2125 movaps xmm6,XMMWORD[16+rsp]
2126 movaps XMMWORD[16+rsp],xmm0
2127 movaps xmm7,XMMWORD[32+rsp]
2128 movaps XMMWORD[32+rsp],xmm0
2129 movaps xmm8,XMMWORD[48+rsp]
2130 movaps XMMWORD[48+rsp],xmm0
2131 movaps xmm9,XMMWORD[64+rsp]
2132 movaps XMMWORD[64+rsp],xmm0
2133 movaps xmm10,XMMWORD[80+rsp]
2134 movaps XMMWORD[80+rsp],xmm0
2135 movaps xmm11,XMMWORD[96+rsp]
2136 movaps XMMWORD[96+rsp],xmm0
2137 movaps xmm12,XMMWORD[112+rsp]
2138 movaps XMMWORD[112+rsp],xmm0
2139 movaps xmm13,XMMWORD[128+rsp]
2140 movaps XMMWORD[128+rsp],xmm0
2141 movaps xmm14,XMMWORD[144+rsp]
2142 movaps XMMWORD[144+rsp],xmm0
2143 movaps xmm15,XMMWORD[160+rsp]
2144 movaps XMMWORD[160+rsp],xmm0
2145 mov rbp,QWORD[((-8))+r11]
2146
2147 lea rsp,[r11]
2148
2149 $L$cbc_ret:
2150 mov rdi,QWORD[8+rsp] ;WIN64 epilogue
2151 mov rsi,QWORD[16+rsp]
2152 DB 0F3h,0C3h ;repret
2153
2154 $L$SEH_end_aes_hw_cbc_encrypt:
2155 global aes_hw_set_decrypt_key
2156
2157 ALIGN 16
2158 aes_hw_set_decrypt_key:
2159
2160 DB 0x48,0x83,0xEC,0x08
2161
2162 call __aesni_set_encrypt_key
2163 shl edx,4
2164 test eax,eax
2165 jnz NEAR $L$dec_key_ret
2166 lea rcx,[16+rdx*1+r8]
2167
2168 movups xmm0,XMMWORD[r8]
2169 movups xmm1,XMMWORD[rcx]
2170 movups XMMWORD[rcx],xmm0
2171 movups XMMWORD[r8],xmm1
2172 lea r8,[16+r8]
2173 lea rcx,[((-16))+rcx]
2174
2175 $L$dec_key_inverse:
2176 movups xmm0,XMMWORD[r8]
2177 movups xmm1,XMMWORD[rcx]
2178 DB 102,15,56,219,192
2179 DB 102,15,56,219,201
2180 lea r8,[16+r8]
2181 lea rcx,[((-16))+rcx]
2182 movups XMMWORD[16+rcx],xmm0
2183 movups XMMWORD[(-16)+r8],xmm1
2184 cmp rcx,r8
2185 ja NEAR $L$dec_key_inverse
2186
2187 movups xmm0,XMMWORD[r8]
2188 DB 102,15,56,219,192
2189 pxor xmm1,xmm1
2190 movups XMMWORD[rcx],xmm0
2191 pxor xmm0,xmm0
2192 $L$dec_key_ret:
2193 add rsp,8
2194
2195 DB 0F3h,0C3h ;repret
2196
2197 $L$SEH_end_set_decrypt_key:
2198
2199 global aes_hw_set_encrypt_key
2200
2201 ALIGN 16
2202 aes_hw_set_encrypt_key:
2203 __aesni_set_encrypt_key:
2204
2205 %ifdef BORINGSSL_DISPATCH_TEST
2206 mov BYTE[((BORINGSSL_function_hit+3))],1
2207 %endif
2208 DB 0x48,0x83,0xEC,0x08
2209
2210 mov rax,-1
2211 test rcx,rcx
2212 jz NEAR $L$enc_key_ret
2213 test r8,r8
2214 jz NEAR $L$enc_key_ret
2215
2216 movups xmm0,XMMWORD[rcx]
2217 xorps xmm4,xmm4
2218 lea r10,[OPENSSL_ia32cap_P]
2219 mov r10d,DWORD[4+r10]
2220 and r10d,268437504
2221 lea rax,[16+r8]
2222 cmp edx,256
2223 je NEAR $L$14rounds
2224 cmp edx,192
2225 je NEAR $L$12rounds
2226 cmp edx,128
2227 jne NEAR $L$bad_keybits
2228
2229 $L$10rounds:
2230 mov edx,9
2231 cmp r10d,268435456
2232 je NEAR $L$10rounds_alt
2233
2234 movups XMMWORD[r8],xmm0
2235 DB 102,15,58,223,200,1
2236 call $L$key_expansion_128_cold
2237 DB 102,15,58,223,200,2
2238 call $L$key_expansion_128
2239 DB 102,15,58,223,200,4
2240 call $L$key_expansion_128
2241 DB 102,15,58,223,200,8
2242 call $L$key_expansion_128
2243 DB 102,15,58,223,200,16
2244 call $L$key_expansion_128
2245 DB 102,15,58,223,200,32
2246 call $L$key_expansion_128
2247 DB 102,15,58,223,200,64
2248 call $L$key_expansion_128
2249 DB 102,15,58,223,200,128
2250 call $L$key_expansion_128
2251 DB 102,15,58,223,200,27
2252 call $L$key_expansion_128
2253 DB 102,15,58,223,200,54
2254 call $L$key_expansion_128
2255 movups XMMWORD[rax],xmm0
2256 mov DWORD[80+rax],edx
2257 xor eax,eax
2258 jmp NEAR $L$enc_key_ret
2259
2260 ALIGN 16
2261 $L$10rounds_alt:
2262 movdqa xmm5,XMMWORD[$L$key_rotate]
2263 mov r10d,8
2264 movdqa xmm4,XMMWORD[$L$key_rcon1]
2265 movdqa xmm2,xmm0
2266 movdqu XMMWORD[r8],xmm0
2267 jmp NEAR $L$oop_key128
2268
2269 ALIGN 16
2270 $L$oop_key128:
2271 DB 102,15,56,0,197
2272 DB 102,15,56,221,196
2273 pslld xmm4,1
2274 lea rax,[16+rax]
2275
2276 movdqa xmm3,xmm2
2277 pslldq xmm2,4
2278 pxor xmm3,xmm2
2279 pslldq xmm2,4
2280 pxor xmm3,xmm2
2281 pslldq xmm2,4
2282 pxor xmm2,xmm3
2283
2284 pxor xmm0,xmm2
2285 movdqu XMMWORD[(-16)+rax],xmm0
2286 movdqa xmm2,xmm0
2287
2288 dec r10d
2289 jnz NEAR $L$oop_key128
2290
2291 movdqa xmm4,XMMWORD[$L$key_rcon1b]
2292
2293 DB 102,15,56,0,197
2294 DB 102,15,56,221,196
2295 pslld xmm4,1
2296
2297 movdqa xmm3,xmm2
2298 pslldq xmm2,4
2299 pxor xmm3,xmm2
2300 pslldq xmm2,4
2301 pxor xmm3,xmm2
2302 pslldq xmm2,4
2303 pxor xmm2,xmm3
2304
2305 pxor xmm0,xmm2
2306 movdqu XMMWORD[rax],xmm0
2307
2308 movdqa xmm2,xmm0
2309 DB 102,15,56,0,197
2310 DB 102,15,56,221,196
2311
2312 movdqa xmm3,xmm2
2313 pslldq xmm2,4
2314 pxor xmm3,xmm2
2315 pslldq xmm2,4
2316 pxor xmm3,xmm2
2317 pslldq xmm2,4
2318 pxor xmm2,xmm3
2319
2320 pxor xmm0,xmm2
2321 movdqu XMMWORD[16+rax],xmm0
2322
2323 mov DWORD[96+rax],edx
2324 xor eax,eax
2325 jmp NEAR $L$enc_key_ret
2326
2327 ALIGN 16
2328 $L$12rounds:
2329 movq xmm2,QWORD[16+rcx]
2330 mov edx,11
2331 cmp r10d,268435456
2332 je NEAR $L$12rounds_alt
2333
2334 movups XMMWORD[r8],xmm0
2335 DB 102,15,58,223,202,1
2336 call $L$key_expansion_192a_cold
2337 DB 102,15,58,223,202,2
2338 call $L$key_expansion_192b
2339 DB 102,15,58,223,202,4
2340 call $L$key_expansion_192a
2341 DB 102,15,58,223,202,8
2342 call $L$key_expansion_192b
2343 DB 102,15,58,223,202,16
2344 call $L$key_expansion_192a
2345 DB 102,15,58,223,202,32
2346 call $L$key_expansion_192b
2347 DB 102,15,58,223,202,64
2348 call $L$key_expansion_192a
2349 DB 102,15,58,223,202,128
2350 call $L$key_expansion_192b
2351 movups XMMWORD[rax],xmm0
2352 mov DWORD[48+rax],edx
2353 xor rax,rax
2354 jmp NEAR $L$enc_key_ret
2355
2356 ALIGN 16
2357 $L$12rounds_alt:
2358 movdqa xmm5,XMMWORD[$L$key_rotate192]
2359 movdqa xmm4,XMMWORD[$L$key_rcon1]
2360 mov r10d,8
2361 movdqu XMMWORD[r8],xmm0
2362 jmp NEAR $L$oop_key192
2363
2364 ALIGN 16
2365 $L$oop_key192:
2366 movq QWORD[rax],xmm2
2367 movdqa xmm1,xmm2
2368 DB 102,15,56,0,213
2369 DB 102,15,56,221,212
2370 pslld xmm4,1
2371 lea rax,[24+rax]
2372
2373 movdqa xmm3,xmm0
2374 pslldq xmm0,4
2375 pxor xmm3,xmm0
2376 pslldq xmm0,4
2377 pxor xmm3,xmm0
2378 pslldq xmm0,4
2379 pxor xmm0,xmm3
2380
2381 pshufd xmm3,xmm0,0xff
2382 pxor xmm3,xmm1
2383 pslldq xmm1,4
2384 pxor xmm3,xmm1
2385
2386 pxor xmm0,xmm2
2387 pxor xmm2,xmm3
2388 movdqu XMMWORD[(-16)+rax],xmm0
2389
2390 dec r10d
2391 jnz NEAR $L$oop_key192
2392
2393 mov DWORD[32+rax],edx
2394 xor eax,eax
2395 jmp NEAR $L$enc_key_ret
2396
2397 ALIGN 16
2398 $L$14rounds:
2399 movups xmm2,XMMWORD[16+rcx]
2400 mov edx,13
2401 lea rax,[16+rax]
2402 cmp r10d,268435456
2403 je NEAR $L$14rounds_alt
2404
2405 movups XMMWORD[r8],xmm0
2406 movups XMMWORD[16+r8],xmm2
2407 DB 102,15,58,223,202,1
2408 call $L$key_expansion_256a_cold
2409 DB 102,15,58,223,200,1
2410 call $L$key_expansion_256b
2411 DB 102,15,58,223,202,2
2412 call $L$key_expansion_256a
2413 DB 102,15,58,223,200,2
2414 call $L$key_expansion_256b
2415 DB 102,15,58,223,202,4
2416 call $L$key_expansion_256a
2417 DB 102,15,58,223,200,4
2418 call $L$key_expansion_256b
2419 DB 102,15,58,223,202,8
2420 call $L$key_expansion_256a
2421 DB 102,15,58,223,200,8
2422 call $L$key_expansion_256b
2423 DB 102,15,58,223,202,16
2424 call $L$key_expansion_256a
2425 DB 102,15,58,223,200,16
2426 call $L$key_expansion_256b
2427 DB 102,15,58,223,202,32
2428 call $L$key_expansion_256a
2429 DB 102,15,58,223,200,32
2430 call $L$key_expansion_256b
2431 DB 102,15,58,223,202,64
2432 call $L$key_expansion_256a
2433 movups XMMWORD[rax],xmm0
2434 mov DWORD[16+rax],edx
2435 xor rax,rax
2436 jmp NEAR $L$enc_key_ret
2437
2438 ALIGN 16
2439 $L$14rounds_alt:
2440 movdqa xmm5,XMMWORD[$L$key_rotate]
2441 movdqa xmm4,XMMWORD[$L$key_rcon1]
2442 mov r10d,7
2443 movdqu XMMWORD[r8],xmm0
2444 movdqa xmm1,xmm2
2445 movdqu XMMWORD[16+r8],xmm2
2446 jmp NEAR $L$oop_key256
2447
2448 ALIGN 16
2449 $L$oop_key256:
2450 DB 102,15,56,0,213
2451 DB 102,15,56,221,212
2452
2453 movdqa xmm3,xmm0
2454 pslldq xmm0,4
2455 pxor xmm3,xmm0
2456 pslldq xmm0,4
2457 pxor xmm3,xmm0
2458 pslldq xmm0,4
2459 pxor xmm0,xmm3
2460 pslld xmm4,1
2461
2462 pxor xmm0,xmm2
2463 movdqu XMMWORD[rax],xmm0
2464
2465 dec r10d
2466 jz NEAR $L$done_key256
2467
2468 pshufd xmm2,xmm0,0xff
2469 pxor xmm3,xmm3
2470 DB 102,15,56,221,211
2471
2472 movdqa xmm3,xmm1
2473 pslldq xmm1,4
2474 pxor xmm3,xmm1
2475 pslldq xmm1,4
2476 pxor xmm3,xmm1
2477 pslldq xmm1,4
2478 pxor xmm1,xmm3
2479
2480 pxor xmm2,xmm1
2481 movdqu XMMWORD[16+rax],xmm2
2482 lea rax,[32+rax]
2483 movdqa xmm1,xmm2
2484
2485 jmp NEAR $L$oop_key256
2486
2487 $L$done_key256:
2488 mov DWORD[16+rax],edx
2489 xor eax,eax
2490 jmp NEAR $L$enc_key_ret
2491
2492 ALIGN 16
2493 $L$bad_keybits:
2494 mov rax,-2
2495 $L$enc_key_ret:
2496 pxor xmm0,xmm0
2497 pxor xmm1,xmm1
2498 pxor xmm2,xmm2
2499 pxor xmm3,xmm3
2500 pxor xmm4,xmm4
2501 pxor xmm5,xmm5
2502 add rsp,8
2503
2504 DB 0F3h,0C3h ;repret
2505
2506 $L$SEH_end_set_encrypt_key:
2507
2508 ALIGN 16
2509 $L$key_expansion_128:
2510 movups XMMWORD[rax],xmm0
2511 lea rax,[16+rax]
2512 $L$key_expansion_128_cold:
2513 shufps xmm4,xmm0,16
2514 xorps xmm0,xmm4
2515 shufps xmm4,xmm0,140
2516 xorps xmm0,xmm4
2517 shufps xmm1,xmm1,255
2518 xorps xmm0,xmm1
2519 DB 0F3h,0C3h ;repret
2520
2521 ALIGN 16
2522 $L$key_expansion_192a:
2523 movups XMMWORD[rax],xmm0
2524 lea rax,[16+rax]
2525 $L$key_expansion_192a_cold:
2526 movaps xmm5,xmm2
2527 $L$key_expansion_192b_warm:
2528 shufps xmm4,xmm0,16
2529 movdqa xmm3,xmm2
2530 xorps xmm0,xmm4
2531 shufps xmm4,xmm0,140
2532 pslldq xmm3,4
2533 xorps xmm0,xmm4
2534 pshufd xmm1,xmm1,85
2535 pxor xmm2,xmm3
2536 pxor xmm0,xmm1
2537 pshufd xmm3,xmm0,255
2538 pxor xmm2,xmm3
2539 DB 0F3h,0C3h ;repret
2540
2541 ALIGN 16
2542 $L$key_expansion_192b:
2543 movaps xmm3,xmm0
2544 shufps xmm5,xmm0,68
2545 movups XMMWORD[rax],xmm5
2546 shufps xmm3,xmm2,78
2547 movups XMMWORD[16+rax],xmm3
2548 lea rax,[32+rax]
2549 jmp NEAR $L$key_expansion_192b_warm
2550
2551 ALIGN 16
2552 $L$key_expansion_256a:
2553 movups XMMWORD[rax],xmm2
2554 lea rax,[16+rax]
2555 $L$key_expansion_256a_cold:
2556 shufps xmm4,xmm0,16
2557 xorps xmm0,xmm4
2558 shufps xmm4,xmm0,140
2559 xorps xmm0,xmm4
2560 shufps xmm1,xmm1,255
2561 xorps xmm0,xmm1
2562 DB 0F3h,0C3h ;repret
2563
2564 ALIGN 16
2565 $L$key_expansion_256b:
2566 movups XMMWORD[rax],xmm0
2567 lea rax,[16+rax]
2568
2569 shufps xmm4,xmm2,16
2570 xorps xmm2,xmm4
2571 shufps xmm4,xmm2,140
2572 xorps xmm2,xmm4
2573 shufps xmm1,xmm1,170
2574 xorps xmm2,xmm1
2575 DB 0F3h,0C3h ;repret
2576
2577
2578 section .rdata rdata align=8
2579 ALIGN 64
2580 $L$bswap_mask:
2581 DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0
2582 $L$increment32:
2583 DD 6,6,6,0
2584 $L$increment64:
2585 DD 1,0,0,0
2586 $L$xts_magic:
2587 DD 0x87,0,1,0
2588 $L$increment1:
2589 DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
2590 $L$key_rotate:
2591 DD 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d
2592 $L$key_rotate192:
2593 DD 0x04070605,0x04070605,0x04070605,0x04070605
2594 $L$key_rcon1:
2595 DD 1,1,1,1
2596 $L$key_rcon1b:
2597 DD 0x1b,0x1b,0x1b,0x1b
2598
2599 DB 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69
2600 DB 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83
2601 DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115
2602 DB 115,108,46,111,114,103,62,0
2603 ALIGN 64
2604 section .text
2605
2606 EXTERN __imp_RtlVirtualUnwind
2607
2608 ALIGN 16
2609 ecb_ccm64_se_handler:
2610 push rsi
2611 push rdi
2612 push rbx
2613 push rbp
2614 push r12
2615 push r13
2616 push r14
2617 push r15
2618 pushfq
2619 sub rsp,64
2620
2621 mov rax,QWORD[120+r8]
2622 mov rbx,QWORD[248+r8]
2623
2624 mov rsi,QWORD[8+r9]
2625 mov r11,QWORD[56+r9]
2626
2627 mov r10d,DWORD[r11]
2628 lea r10,[r10*1+rsi]
2629 cmp rbx,r10
2630 jb NEAR $L$common_seh_tail
2631
2632 mov rax,QWORD[152+r8]
2633
2634 mov r10d,DWORD[4+r11]
2635 lea r10,[r10*1+rsi]
2636 cmp rbx,r10
2637 jae NEAR $L$common_seh_tail
2638
2639 lea rsi,[rax]
2640 lea rdi,[512+r8]
2641 mov ecx,8
2642 DD 0xa548f3fc
2643 lea rax,[88+rax]
2644
2645 jmp NEAR $L$common_seh_tail
2646
2647
2648
2649 ALIGN 16
2650 ctr_xts_se_handler:
2651 push rsi
2652 push rdi
2653 push rbx
2654 push rbp
2655 push r12
2656 push r13
2657 push r14
2658 push r15
2659 pushfq
2660 sub rsp,64
2661
2662 mov rax,QWORD[120+r8]
2663 mov rbx,QWORD[248+r8]
2664
2665 mov rsi,QWORD[8+r9]
2666 mov r11,QWORD[56+r9]
2667
2668 mov r10d,DWORD[r11]
2669 lea r10,[r10*1+rsi]
2670 cmp rbx,r10
2671 jb NEAR $L$common_seh_tail
2672
2673 mov rax,QWORD[152+r8]
2674
2675 mov r10d,DWORD[4+r11]
2676 lea r10,[r10*1+rsi]
2677 cmp rbx,r10
2678 jae NEAR $L$common_seh_tail
2679
2680 mov rax,QWORD[208+r8]
2681
2682 lea rsi,[((-168))+rax]
2683 lea rdi,[512+r8]
2684 mov ecx,20
2685 DD 0xa548f3fc
2686
2687 mov rbp,QWORD[((-8))+rax]
2688 mov QWORD[160+r8],rbp
2689 jmp NEAR $L$common_seh_tail
2690
2691
2692
2693 ALIGN 16
2694 cbc_se_handler:
2695 push rsi
2696 push rdi
2697 push rbx
2698 push rbp
2699 push r12
2700 push r13
2701 push r14
2702 push r15
2703 pushfq
2704 sub rsp,64
2705
2706 mov rax,QWORD[152+r8]
2707 mov rbx,QWORD[248+r8]
2708
2709 lea r10,[$L$cbc_decrypt_bulk]
2710 cmp rbx,r10
2711 jb NEAR $L$common_seh_tail
2712
2713 mov rax,QWORD[120+r8]
2714
2715 lea r10,[$L$cbc_decrypt_body]
2716 cmp rbx,r10
2717 jb NEAR $L$common_seh_tail
2718
2719 mov rax,QWORD[152+r8]
2720
2721 lea r10,[$L$cbc_ret]
2722 cmp rbx,r10
2723 jae NEAR $L$common_seh_tail
2724
2725 lea rsi,[16+rax]
2726 lea rdi,[512+r8]
2727 mov ecx,20
2728 DD 0xa548f3fc
2729
2730 mov rax,QWORD[208+r8]
2731
2732 mov rbp,QWORD[((-8))+rax]
2733 mov QWORD[160+r8],rbp
2734
2735 $L$common_seh_tail:
2736 mov rdi,QWORD[8+rax]
2737 mov rsi,QWORD[16+rax]
2738 mov QWORD[152+r8],rax
2739 mov QWORD[168+r8],rsi
2740 mov QWORD[176+r8],rdi
2741
2742 mov rdi,QWORD[40+r9]
2743 mov rsi,r8
2744 mov ecx,154
2745 DD 0xa548f3fc
2746
2747 mov rsi,r9
2748 xor rcx,rcx
2749 mov rdx,QWORD[8+rsi]
2750 mov r8,QWORD[rsi]
2751 mov r9,QWORD[16+rsi]
2752 mov r10,QWORD[40+rsi]
2753 lea r11,[56+rsi]
2754 lea r12,[24+rsi]
2755 mov QWORD[32+rsp],r10
2756 mov QWORD[40+rsp],r11
2757 mov QWORD[48+rsp],r12
2758 mov QWORD[56+rsp],rcx
2759 call QWORD[__imp_RtlVirtualUnwind]
2760
2761 mov eax,1
2762 add rsp,64
2763 popfq
2764 pop r15
2765 pop r14
2766 pop r13
2767 pop r12
2768 pop rbp
2769 pop rbx
2770 pop rdi
2771 pop rsi
2772 DB 0F3h,0C3h ;repret
2773
2774
2775 section .pdata rdata align=4
2776 ALIGN 4
2777 DD $L$SEH_begin_aes_hw_ecb_encrypt wrt ..imagebase
2778 DD $L$SEH_end_aes_hw_ecb_encrypt wrt ..imagebase
2779 DD $L$SEH_info_ecb wrt ..imagebase
2780
2781 DD $L$SEH_begin_aes_hw_ctr32_encrypt_blocks wrt ..imagebase
2782 DD $L$SEH_end_aes_hw_ctr32_encrypt_blocks wrt ..imagebase
2783 DD $L$SEH_info_ctr32 wrt ..imagebase
2784 DD $L$SEH_begin_aes_hw_cbc_encrypt wrt ..imagebase
2785 DD $L$SEH_end_aes_hw_cbc_encrypt wrt ..imagebase
2786 DD $L$SEH_info_cbc wrt ..imagebase
2787
2788 DD aes_hw_set_decrypt_key wrt ..imagebase
2789 DD $L$SEH_end_set_decrypt_key wrt ..imagebase
2790 DD $L$SEH_info_key wrt ..imagebase
2791
2792 DD aes_hw_set_encrypt_key wrt ..imagebase
2793 DD $L$SEH_end_set_encrypt_key wrt ..imagebase
2794 DD $L$SEH_info_key wrt ..imagebase
2795 section .xdata rdata align=8
2796 ALIGN 8
2797 $L$SEH_info_ecb:
2798 DB 9,0,0,0
2799 DD ecb_ccm64_se_handler wrt ..imagebase
2800 DD $L$ecb_enc_body wrt ..imagebase,$L$ecb_enc_ret wrt ..imagebase
2801 $L$SEH_info_ctr32:
2802 DB 9,0,0,0
2803 DD ctr_xts_se_handler wrt ..imagebase
2804 DD $L$ctr32_body wrt ..imagebase,$L$ctr32_epilogue wrt ..imagebase
2805 $L$SEH_info_cbc:
2806 DB 9,0,0,0
2807 DD cbc_se_handler wrt ..imagebase
2808 $L$SEH_info_key:
2809 DB 0x01,0x04,0x01,0x00
2810 DB 0x04,0x02,0x00,0x00
2811 %else
2812 ; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738
2813 ret
2814 %endif