VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1g/crypto/genasm-nasm/bsaes-x86_64.S@ 86352

最後變更 在這個檔案從86352是 83531,由 vboxsync 提交於 5 年 前

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

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

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