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