12c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#!/usr/bin/env perl
22c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
32c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org######################################################################
42c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org## Constant-time SSSE3 AES core implementation.
52c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org## version 0.1
62c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
72c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org## By Mike Hamburg (Stanford University), 2009
82c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org## Public domain.
92c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org## For details see http://shiftleft.org/papers/vector_aes/ and
112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org## http://crypto.stanford.edu/vpaes/.
122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org######################################################################
142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# September 2011.
152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# Interface to OpenSSL as "almost" drop-in replacement for
172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# aes-x86_64.pl. "Almost" refers to the fact that AES_cbc_encrypt
182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# doesn't handle partial vectors (doesn't have to if called from
192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# EVP only). "Drop-in" implies that this module doesn't share key
202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# schedule structure with the original nor does it make assumption
212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# about its alignment...
222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# Performance summary. aes-x86_64.pl column lists large-block CBC
242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# encrypt/decrypt/with-hyper-threading-off(*) results in cycles per
252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# byte processed with 128-bit key, and vpaes-x86_64.pl column -
262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# [also large-block CBC] encrypt/decrypt.
272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#		aes-x86_64.pl		vpaes-x86_64.pl
292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# Core 2(**)	30.5/43.7/14.3		21.8/25.7(***)
312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# Nehalem	30.5/42.2/14.6		 9.8/11.8
322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# Atom		63.9/79.0/32.1		64.0/84.8(***)
332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# (*)	"Hyper-threading" in the context refers rather to cache shared
352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#	among multiple cores, than to specifically Intel HTT. As vast
362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#	majority of contemporary cores share cache, slower code path
372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#	is common place. In other words "with-hyper-threading-off"
382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#	results are presented mostly for reference purposes.
392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# (**)	"Core 2" refers to initial 65nm design, a.k.a. Conroe.
412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# (***)	Less impressive improvement on Core 2 and Atom is due to slow
432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#	pshufb,	yet it's respectable +40%/78% improvement on Core 2
442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#	(as implied, over "hyper-threading-safe" code path).
452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#						<appro@openssl.org>
472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$flavour = shift;
492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$output  = shift;
502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgif ($flavour =~ /\./) { $output = $flavour; undef $flavour; }
512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/);
532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or
562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or
572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgdie "can't locate x86_64-xlate.pl";
582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
597453c6c0666947e06d87565404f4397a4b387f91digit@chromium.orgopen OUT,"| \"$^X\" $xlate $flavour $output";
607453c6c0666947e06d87565404f4397a4b387f91digit@chromium.org*STDOUT=*OUT;
612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$PREFIX="vpaes";
632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.text
662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  _aes_encrypt_core
692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  AES-encrypt %xmm0.
712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Inputs:
732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##     %xmm0 = input
742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##     %xmm9-%xmm15 as in _vpaes_preheat
752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    (%rdx) = scheduled keys
762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Output in %xmm0
782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Clobbers  %xmm1-%xmm5, %r9, %r10, %r11, %rax
792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Preserves %xmm6 - %xmm8 so you get some local vectors
802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_encrypt_core,\@abi-omnipotent
832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align 16
842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_encrypt_core:
852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rdx,	%r9
862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$16,	%r11
872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	240(%rdx),%eax
882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm9,	%xmm1
892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_ipt(%rip), %xmm2	# iptlo
902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm0,	%xmm1
912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%r9),	%xmm5		# round0 key
922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,	%xmm1
932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9,	%xmm0
942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm0,	%xmm2
952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_ipt+16(%rip), %xmm0	# ipthi
962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm0
972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5,	%xmm2
982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm0
992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$16,	%r9
1002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_mc_backward(%rip),%r10
1012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Lenc_entry
1022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
1032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align 16
1042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lenc_loop:
1052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# middle of middle round
1062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  %xmm13,	%xmm4	# 4 : sb1u
1072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm2,	%xmm4	# 4 = sb1u
1082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5,	%xmm4	# 4 = sb1u + k
1092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  %xmm12,	%xmm0	# 0 : sb1t
1102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm0	# 0 = sb1t
1112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0	# 0 = A
1122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  %xmm15,	%xmm5	# 4 : sb2u
1132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm2,	%xmm5	# 4 = sb2u
1142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	-0x40(%r11,%r10), %xmm1		# .Lk_mc_forward[]
1152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm14, %xmm2	# 2 : sb2t
1162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm3,  %xmm2	# 2 = sb2t
1172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5,	%xmm2	# 2 = 2A
1182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	(%r11,%r10), %xmm4		# .Lk_mc_backward[]
1192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,  %xmm3	# 3 = A
1202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm1,  %xmm0	# 0 = B
1212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$16,	%r9	# next key
1222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,  %xmm0	# 0 = 2A+B
1232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm4,	%xmm3	# 3 = D
1242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$16,	%r11	# next mc
1252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm3	# 3 = 2A+B+D
1262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm1,	%xmm0	# 0 = 2B+C
1272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	and	\$0x30,	%r11	# ... mod 4
1282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm3,	%xmm0	# 0 = 2A+3B+C+D
1292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	\$1,%rax	# nr--
1302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
1312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lenc_entry:
1322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# top of round
1332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  %xmm9, 	%xmm1	# 1 : i
1342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm0, 	%xmm1	# 1 = i<<4
1352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,   	%xmm1   # 1 = i
1362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9, 	%xmm0   # 0 = k
1372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm11, %xmm5	# 2 : a/k
1382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm0,  %xmm5	# 2 = a/k
1392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm0	# 0 = j
1402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm3  	# 3 : 1/i
1412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm1, 	%xmm3  	# 3 = 1/i
1422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5, 	%xmm3  	# 3 = iak = 1/i + a/k
1432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm4  	# 4 : 1/j
1442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm0, 	%xmm4  	# 4 = 1/j
1452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5, 	%xmm4  	# 4 = jak = 1/j + a/k
1462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm2  	# 2 : 1/iak
1472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm2  	# 2 = 1/iak
1482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0, 	%xmm2  	# 2 = io
1492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10, %xmm3   # 3 : 1/jak
1502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%r9),	%xmm5
1512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm4,  %xmm3   # 3 = 1/jak
1522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,  %xmm3   # 3 = jo
1532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnz	.Lenc_loop
1542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
1552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# middle of last round
1562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	-0x60(%r10), %xmm4	# 3 : sbou	.Lk_sbo
1572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	-0x50(%r10), %xmm0	# 0 : sbot	.Lk_sbo+16
1582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm2,  %xmm4	# 4 = sbou
1592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5,  %xmm4	# 4 = sb1u + k
1602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm0	# 0 = sb1t
1612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x40(%r11,%r10), %xmm1		# .Lk_sr[]
1622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0	# 0 = A
1632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm0
1642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
1652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_encrypt_core,.-_vpaes_encrypt_core
1662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
1672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
1682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Decryption core
1692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
1702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Same API as encryption core.
1712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
1722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_decrypt_core,\@abi-omnipotent
1732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
1742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_decrypt_core:
1752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rdx,	%r9		# load key
1762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	240(%rdx),%eax
1772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm9,	%xmm1
1782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_dipt(%rip), %xmm2	# iptlo
1792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm0,	%xmm1
1802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rax,	%r11
1812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,	%xmm1
1822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%r9),	%xmm5		# round0 key
1832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	shl	\$4,	%r11
1842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9,	%xmm0
1852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm0,	%xmm2
1862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_dipt+16(%rip), %xmm0 # ipthi
1872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xor	\$0x30,	%r11
1882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_dsbd(%rip),%r10
1892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm0
1902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	and	\$0x30,	%r11
1912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5,	%xmm2
1922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_mc_forward+48(%rip), %xmm5
1932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm0
1942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$16,	%r9
1952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	%r10,	%r11
1962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Ldec_entry
1972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
1982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align 16
1992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Ldec_loop:
2002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
2012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Inverse mix columns
2022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
2032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  -0x20(%r10),%xmm4	# 4 : sb9u
2042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm2,	%xmm4		# 4 = sb9u
2052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm4
2062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  -0x10(%r10),%xmm0	# 0 : sb9t
2072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm3,	%xmm0		# 0 = sb9t
2082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0		# 0 = ch
2092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$16, %r9		# next round key
2102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm0		# MC ch
2122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  0x00(%r10),%xmm4	# 4 : sbdu
2132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm2,	%xmm4		# 4 = sbdu
2142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm4		# 4 = ch
2152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  0x10(%r10),%xmm0	# 0 : sbdt
2162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm3,	%xmm0		# 0 = sbdt
2172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0		# 0 = ch
2182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	\$1,%rax		# nr--
2192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm0		# MC ch
2212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  0x20(%r10),%xmm4	# 4 : sbbu
2222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm2,	%xmm4		# 4 = sbbu
2232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm4		# 4 = ch
2242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  0x30(%r10),%xmm0	# 0 : sbbt
2252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm3,	%xmm0		# 0 = sbbt
2262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0		# 0 = ch
2272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm0		# MC ch
2292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  0x40(%r10),%xmm4	# 4 : sbeu
2302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm2,	%xmm4		# 4 = sbeu
2312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm4		# 4 = ch
2322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  0x50(%r10),%xmm0	# 0 : sbet
2332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm3,	%xmm0		# 0 = sbet
2342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0		# 0 = ch
2352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	palignr	\$12,	%xmm5,	%xmm5
2372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Ldec_entry:
2392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# top of round
2402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  %xmm9, 	%xmm1	# 1 : i
2412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm0, 	%xmm1	# 1 = i<<4
2422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,    %xmm1	# 1 = i
2432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9, 	%xmm0	# 0 = k
2442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm11, %xmm2	# 2 : a/k
2452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm0,  %xmm2	# 2 = a/k
2462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm0	# 0 = j
2472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm3	# 3 : 1/i
2482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm1, 	%xmm3	# 3 = 1/i
2492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2, 	%xmm3	# 3 = iak = 1/i + a/k
2502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm4	# 4 : 1/j
2512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm0, 	%xmm4	# 4 = 1/j
2522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2, 	%xmm4	# 4 = jak = 1/j + a/k
2532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm2	# 2 : 1/iak
2542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm2	# 2 = 1/iak
2552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0, 	%xmm2	# 2 = io
2562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10, %xmm3	# 3 : 1/jak
2572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm4,  %xmm3	# 3 = 1/jak
2582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,  %xmm3	# 3 = jo
2592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%r9),	%xmm0
2602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnz	.Ldec_loop
2612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# middle of last round
2632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x60(%r10), %xmm4	# 3 : sbou
2642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm2,  %xmm4	# 4 = sbou
2652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,  %xmm4	# 4 = sb1u + k
2662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x70(%r10), %xmm0	# 0 : sbot
2672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	-0x160(%r11), %xmm2	# .Lk_sr-.Lk_dsbd=-0x160
2682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm0	# 0 = sb1t
2692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm0	# 0 = A
2702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm2,	%xmm0
2712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
2722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_decrypt_core,.-_vpaes_decrypt_core
2732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org########################################################
2752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##                                                    ##
2762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##                  AES key schedule                  ##
2772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##                                                    ##
2782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org########################################################
2792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_schedule_core,\@abi-omnipotent
2802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
2812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_schedule_core:
2822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# rdi = key
2832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# rsi = size in bits
2842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# rdx = buffer
2852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# rcx = direction.  0=encrypt, 1=decrypt
2862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_preheat		# load the tables
2882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_rcon(%rip), %xmm8	# load rcon
2892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%rdi),	%xmm0		# load key (unaligned)
2902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# input transform
2922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,	%xmm3
2932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_ipt(%rip), %r11
2942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_transform
2952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,	%xmm7
2962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
2972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_sr(%rip),%r10
2982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	test	%rcx,	%rcx
2992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnz	.Lschedule_am_decrypting
3002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# encrypting, output zeroth round key after transform
3022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm0,	(%rdx)
3032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Lschedule_go
3042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_am_decrypting:
3062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# decrypting, output zeroth round key after shiftrows
3072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	(%r8,%r10),%xmm1
3082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm1,	%xmm3
3092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm3,	(%rdx)
3102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xor	\$0x30, %r8
3112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_go:
3132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	cmp	\$192,	%esi
3142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ja	.Lschedule_256
3152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	je	.Lschedule_192
3162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# 128: fall though
3172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .schedule_128
3202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  128-bit specific part of key schedule.
3222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  This schedule is really simple, because all its parts
3242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  are accomplished by the subroutines.
3252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_128:
3272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$10, %esi
3282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Loop_schedule_128:
3302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call 	_vpaes_schedule_round
3312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	dec	%rsi
3322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jz 	.Lschedule_mangle_last
3332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_mangle	# write output
3342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp 	.Loop_schedule_128
3352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_192
3382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  192-bit specific part of key schedule.
3402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  The main body of this schedule is the same as the 128-bit
3422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  schedule, but with more smearing.  The long, high side is
3432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  stored in %xmm7 as before, and the short, low side is in
3442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  the high bits of %xmm6.
3452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  This schedule is somewhat nastier, however, because each
3472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  round produces 192 bits of key material, or 1.5 round keys.
3482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Therefore, on each cycle we do 2 rounds and produce 3 round
3492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  keys.
3502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
3522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_192:
3532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	8(%rdi),%xmm0		# load key part 2 (very unaligned)
3542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_transform	# input transform
3552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,	%xmm6		# save short part
3562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm4		# clear 4
3572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movhlps	%xmm4,	%xmm6		# clobber low side with zeros
3582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$4,	%esi
3592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Loop_schedule_192:
3612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_round
3622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	palignr	\$8,%xmm6,%xmm0
3632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_mangle	# save key n
3642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_192_smear
3652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_mangle	# save key n+1
3662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_round
3672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	dec	%rsi
3682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jz 	.Lschedule_mangle_last
3692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_mangle	# save key n+2
3702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_192_smear
3712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Loop_schedule_192
3722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_256
3752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  256-bit specific part of key schedule.
3772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  The structure here is very similar to the 128-bit
3792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  schedule, but with an additional "low side" in
3802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  %xmm6.  The low side's rounds are the same as the
3812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  high side's, except no rcon and no rotation.
3822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
3832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
3842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_256:
3852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	16(%rdi),%xmm0		# load key part 2 (unaligned)
3862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_transform	# input transform
3872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$7, %esi
3882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Loop_schedule_256:
3902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_mangle	# output low result
3912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,	%xmm6		# save cur_lo in xmm6
3922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# high round
3942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_round
3952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	dec	%rsi
3962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jz 	.Lschedule_mangle_last
3972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_mangle
3982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
3992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# low round. swap xmm7 and xmm6
4002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufd	\$0xFF,	%xmm0,	%xmm0
4012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm7,	%xmm5
4022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm6,	%xmm7
4032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_low_round
4042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm5,	%xmm7
4052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Loop_schedule_256
4072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_mangle_last
4112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Mangler for last round of key schedule
4132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Mangles %xmm0
4142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    when encrypting, outputs out(%xmm0) ^ 63
4152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    when decrypting, outputs unskew(%xmm0)
4162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Always called right before return... jumps to cleanup and exits
4182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
4202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_mangle_last:
4212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# schedule last round key from xmm0
4222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_deskew(%rip),%r11	# prepare to deskew
4232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	test	%rcx, 	%rcx
4242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnz	.Lschedule_mangle_last_dec
4252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# encrypting
4272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	(%r8,%r10),%xmm1
4282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm0		# output permute
4292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_opt(%rip),	%r11	# prepare to output transform
4302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$32,	%rdx
4312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_mangle_last_dec:
4332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$-16,	%rdx
4342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	.Lk_s63(%rip),	%xmm0
4352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_transform # output transform
4362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm0,	(%rdx)		# save last key
4372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# cleanup
4392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,  %xmm0
4402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,  %xmm1
4412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,  %xmm2
4422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm3,  %xmm3
4432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,  %xmm4
4442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm5,  %xmm5
4452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm6,  %xmm6
4462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm7,  %xmm7
4472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
4482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_schedule_core,.-_vpaes_schedule_core
4492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_192_smear
4522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Smear the short, low side in the 192-bit key schedule.
4542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Inputs:
4562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    %xmm7: high side, b  a  x  y
4572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    %xmm6:  low side, d  c  0  0
4582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    %xmm13: 0
4592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Outputs:
4612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    %xmm6: b+c+d  b+c  0  0
4622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    %xmm0: b+c+d  b+c  b  a
4632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_schedule_192_smear,\@abi-omnipotent
4652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
4662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_schedule_192_smear:
4672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufd	\$0x80,	%xmm6,	%xmm0	# d c 0 0 -> c 0 0 0
4682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm6		# -> c+d c 0 0
4692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufd	\$0xFE,	%xmm7,	%xmm0	# b a _ _ -> b b b a
4702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0,	%xmm6		# -> b+c+d b+c b a
4712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm6,	%xmm0
4722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm1
4732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movhlps	%xmm1,	%xmm6		# clobber low side with zeros
4742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
4752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear
4762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
4772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_round
4792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Runs one main round of the key schedule on %xmm0, %xmm7
4812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Specifically, runs subbytes on the high dword of %xmm0
4832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  then rotates it by one byte and xors into the low dword of
4842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  %xmm7.
4852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Adds rcon from low byte of %xmm8, then rotates %xmm8 for
4872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  next rcon.
4882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Smears the dwords of %xmm7 by xoring the low into the
4902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  second low, result into third, result into highest.
4912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Returns results in %xmm7 = %xmm0.
4932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Clobbers %xmm1-%xmm4, %r11.
4942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
4952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_schedule_round,\@abi-omnipotent
4962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
4972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_schedule_round:
4982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# extract rcon from xmm8
4992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm1
5002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	palignr	\$15,	%xmm8,	%xmm1
5012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	palignr	\$15,	%xmm8,	%xmm8
5022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm7
5032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# rotate
5052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufd	\$0xFF,	%xmm0,	%xmm0
5062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	palignr	\$1,	%xmm0,	%xmm0
5072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# fall through...
5092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# low round: same as high round, but no rotation and no rcon.
5112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_schedule_low_round:
5122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# smear xmm7
5132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm7,	%xmm1
5142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pslldq	\$4,	%xmm7
5152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm7
5162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm7,	%xmm1
5172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pslldq	\$8,	%xmm7
5182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm7
5192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	.Lk_s63(%rip), %xmm7
5202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# subbytes
5222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa  %xmm9, 	%xmm1
5232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm0, 	%xmm1
5242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,    %xmm1		# 1 = i
5252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9, 	%xmm0		# 0 = k
5262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm11, %xmm2		# 2 : a/k
5272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm0,  %xmm2		# 2 = a/k
5282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,	%xmm0		# 0 = j
5292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm3		# 3 : 1/i
5302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm1, 	%xmm3		# 3 = 1/i
5312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2, 	%xmm3		# 3 = iak = 1/i + a/k
5322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm4		# 4 : 1/j
5332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm0, 	%xmm4		# 4 = 1/j
5342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2, 	%xmm4		# 4 = jak = 1/j + a/k
5352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10,	%xmm2		# 2 : 1/iak
5362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm2		# 2 = 1/iak
5372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm0, 	%xmm2		# 2 = io
5382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm10, %xmm3		# 3 : 1/jak
5392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm4,  %xmm3		# 3 = 1/jak
5402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm1,  %xmm3		# 3 = jo
5412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm13, %xmm4		# 4 : sbou
5422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm2,  %xmm4		# 4 = sbou
5432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm12, %xmm0		# 0 : sbot
5442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb  %xmm3,	%xmm0		# 0 = sb1t
5452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4, 	%xmm0		# 0 = sbox output
5462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# add in smeared stuff
5482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm7,	%xmm0
5492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,	%xmm7
5502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
5512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_schedule_round,.-_vpaes_schedule_round
5522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_transform
5552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Linear-transform %xmm0 according to tables at (%r11)
5572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Requires that %xmm9 = 0x0F0F... as in preheat
5592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Output in %xmm0
5602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Clobbers %xmm1, %xmm2
5612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_schedule_transform,\@abi-omnipotent
5632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
5642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_schedule_transform:
5652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm9,	%xmm1
5662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm0,	%xmm1
5672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,	%xmm1
5682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9,	%xmm0
5692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	(%r11), %xmm2 	# lo
5702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm0,	%xmm2
5712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	16(%r11), %xmm0 # hi
5722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm0
5732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm0
5742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
5752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_schedule_transform,.-_vpaes_schedule_transform
5762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
5772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  .aes_schedule_mangle
5792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Mangle xmm0 from (basis-transformed) standard version
5812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  to our version.
5822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  On encrypt,
5842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    xor with 0x63
5852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    multiply by circulant 0,1,1,1
5862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    apply shiftrows transform
5872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  On decrypt,
5892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    xor with 0x63
5902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    multiply by "inverse mixcolumns" circulant E,B,D,9
5912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    deskew
5922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##    apply shiftrows transform
5932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
5952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Writes out to (%rdx), and increments or decrements it
5962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Keeps track of round number mod 4 in %r8
5972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Preserves xmm0
5982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Clobbers xmm1-xmm5
5992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
6002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_schedule_mangle,\@abi-omnipotent
6012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
6022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_schedule_mangle:
6032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,	%xmm4	# save xmm0 for later
6042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	.Lk_mc_forward(%rip),%xmm5
6052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	test	%rcx, 	%rcx
6062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnz	.Lschedule_mangle_dec
6072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# encrypting
6092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$16,	%rdx
6102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	.Lk_s63(%rip),%xmm4
6112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm4
6122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm4,	%xmm3
6132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm4
6142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm3
6152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm4
6162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm4,	%xmm3
6172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Lschedule_mangle_both
6192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
6202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_mangle_dec:
6212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	# inverse mix columns
6222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_dksd(%rip),%r11
6232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm9,	%xmm1
6242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pandn	%xmm4,	%xmm1
6252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	psrld	\$4,	%xmm1	# 1 = hi
6262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pand	%xmm9,	%xmm4	# 4 = lo
6272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x00(%r11), %xmm2
6292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm4,	%xmm2
6302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x10(%r11), %xmm3
6312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm3
6322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm3
6332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm3
6342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x20(%r11), %xmm2
6362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm4,	%xmm2
6372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm3,	%xmm2
6382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x30(%r11), %xmm3
6392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm3
6402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm3
6412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm3
6422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x40(%r11), %xmm2
6442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm4,	%xmm2
6452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm3,	%xmm2
6462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x50(%r11), %xmm3
6472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm3
6482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm3
6492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm5,	%xmm3
6502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x60(%r11), %xmm2
6522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm4,	%xmm2
6532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm3,	%xmm2
6542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x70(%r11), %xmm3
6552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,	%xmm3
6562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm2,	%xmm3
6572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$-16,	%rdx
6592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lschedule_mangle_both:
6612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	(%r8,%r10),%xmm1
6622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pshufb	%xmm1,%xmm3
6632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$-16,	%r8
6642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	and	\$0x30,	%r8
6652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm3,	(%rdx)
6662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
6672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_schedule_mangle,.-_vpaes_schedule_mangle
6682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
6702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# Interface to OpenSSL
6712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#
6722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.globl	${PREFIX}_set_encrypt_key
6732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	${PREFIX}_set_encrypt_key,\@function,3
6742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
6752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org${PREFIX}_set_encrypt_key:
6762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
6772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
6782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	-0xb8(%rsp),%rsp
6792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm6,0x10(%rsp)
6802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm7,0x20(%rsp)
6812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm8,0x30(%rsp)
6822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm9,0x40(%rsp)
6832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm10,0x50(%rsp)
6842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm11,0x60(%rsp)
6852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm12,0x70(%rsp)
6862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm13,0x80(%rsp)
6872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm14,0x90(%rsp)
6882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm15,0xa0(%rsp)
6892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lenc_key_body:
6902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
6912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
6922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%esi,%eax
6932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	shr	\$5,%eax
6942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$5,%eax
6952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%eax,240(%rdx)	# AES_KEY->rounds = nbits/32+5;
6962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
6972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$0,%ecx
6982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$0x30,%r8d
6992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_core
7002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
7022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x10(%rsp),%xmm6
7032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x20(%rsp),%xmm7
7042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x30(%rsp),%xmm8
7052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x40(%rsp),%xmm9
7062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x50(%rsp),%xmm10
7072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x60(%rsp),%xmm11
7082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x70(%rsp),%xmm12
7092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x80(%rsp),%xmm13
7102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x90(%rsp),%xmm14
7112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0xa0(%rsp),%xmm15
7122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	0xb8(%rsp),%rsp
7132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lenc_key_epilogue:
7142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
7162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xor	%eax,%eax
7172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
7182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	${PREFIX}_set_encrypt_key,.-${PREFIX}_set_encrypt_key
7192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
7202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.globl	${PREFIX}_set_decrypt_key
7212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	${PREFIX}_set_decrypt_key,\@function,3
7222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
7232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org${PREFIX}_set_decrypt_key:
7242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
7262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	-0xb8(%rsp),%rsp
7272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm6,0x10(%rsp)
7282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm7,0x20(%rsp)
7292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm8,0x30(%rsp)
7302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm9,0x40(%rsp)
7312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm10,0x50(%rsp)
7322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm11,0x60(%rsp)
7332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm12,0x70(%rsp)
7342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm13,0x80(%rsp)
7352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm14,0x90(%rsp)
7362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm15,0xa0(%rsp)
7372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Ldec_key_body:
7382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
7402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%esi,%eax
7412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	shr	\$5,%eax
7422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$5,%eax
7432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%eax,240(%rdx)	# AES_KEY->rounds = nbits/32+5;
7442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	shl	\$4,%eax
7452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	16(%rdx,%rax),%rdx
7462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
7472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$1,%ecx
7482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%esi,%r8d
7492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	shr	\$1,%r8d
7502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	and	\$32,%r8d
7512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xor	\$32,%r8d	# nbits==192?0:32
7522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_schedule_core
7532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
7552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x10(%rsp),%xmm6
7562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x20(%rsp),%xmm7
7572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x30(%rsp),%xmm8
7582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x40(%rsp),%xmm9
7592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x50(%rsp),%xmm10
7602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x60(%rsp),%xmm11
7612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x70(%rsp),%xmm12
7622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x80(%rsp),%xmm13
7632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x90(%rsp),%xmm14
7642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0xa0(%rsp),%xmm15
7652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	0xb8(%rsp),%rsp
7662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Ldec_key_epilogue:
7672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
7692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xor	%eax,%eax
7702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
7712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	${PREFIX}_set_decrypt_key,.-${PREFIX}_set_decrypt_key
7722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
7732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.globl	${PREFIX}_encrypt
7742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	${PREFIX}_encrypt,\@function,3
7752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
7762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org${PREFIX}_encrypt:
7772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
7792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	-0xb8(%rsp),%rsp
7802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm6,0x10(%rsp)
7812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm7,0x20(%rsp)
7822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm8,0x30(%rsp)
7832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm9,0x40(%rsp)
7842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm10,0x50(%rsp)
7852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm11,0x60(%rsp)
7862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm12,0x70(%rsp)
7872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm13,0x80(%rsp)
7882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm14,0x90(%rsp)
7892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm15,0xa0(%rsp)
7902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lenc_body:
7912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
7932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%rdi),%xmm0
7942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_preheat
7952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_encrypt_core
7962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm0,(%rsi)
7972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
7982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
7992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x10(%rsp),%xmm6
8002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x20(%rsp),%xmm7
8012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x30(%rsp),%xmm8
8022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x40(%rsp),%xmm9
8032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x50(%rsp),%xmm10
8042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x60(%rsp),%xmm11
8052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x70(%rsp),%xmm12
8062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x80(%rsp),%xmm13
8072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x90(%rsp),%xmm14
8082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0xa0(%rsp),%xmm15
8092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	0xb8(%rsp),%rsp
8102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lenc_epilogue:
8112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
8132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
8142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	${PREFIX}_encrypt,.-${PREFIX}_encrypt
8152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
8162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.globl	${PREFIX}_decrypt
8172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	${PREFIX}_decrypt,\@function,3
8182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
8192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org${PREFIX}_decrypt:
8202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
8222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	-0xb8(%rsp),%rsp
8232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm6,0x10(%rsp)
8242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm7,0x20(%rsp)
8252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm8,0x30(%rsp)
8262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm9,0x40(%rsp)
8272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm10,0x50(%rsp)
8282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm11,0x60(%rsp)
8292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm12,0x70(%rsp)
8302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm13,0x80(%rsp)
8312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm14,0x90(%rsp)
8322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm15,0xa0(%rsp)
8332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Ldec_body:
8342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
8362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	(%rdi),%xmm0
8372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_preheat
8382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_decrypt_core
8392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm0,(%rsi)
8402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
8422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x10(%rsp),%xmm6
8432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x20(%rsp),%xmm7
8442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x30(%rsp),%xmm8
8452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x40(%rsp),%xmm9
8462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x50(%rsp),%xmm10
8472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x60(%rsp),%xmm11
8482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x70(%rsp),%xmm12
8492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x80(%rsp),%xmm13
8502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x90(%rsp),%xmm14
8512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0xa0(%rsp),%xmm15
8522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	0xb8(%rsp),%rsp
8532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Ldec_epilogue:
8542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
8562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
8572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	${PREFIX}_decrypt,.-${PREFIX}_decrypt
8582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org{
8602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgmy ($inp,$out,$len,$key,$ivp,$enc)=("%rdi","%rsi","%rdx","%rcx","%r8","%r9");
8612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# void AES_cbc_encrypt (const void char *inp, unsigned char *out,
8622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#                       size_t length, const AES_KEY *key,
8632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#                       unsigned char *ivp,const int enc);
8642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
8652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.globl	${PREFIX}_cbc_encrypt
8662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	${PREFIX}_cbc_encrypt,\@function,6
8672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
8682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org${PREFIX}_cbc_encrypt:
8692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xchg	$key,$len
8702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org($len,$key)=($key,$len);
8722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
8732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	\$16,$len
8742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jc	.Lcbc_abort
8752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
8772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	-0xb8(%rsp),%rsp
8782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm6,0x10(%rsp)
8792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm7,0x20(%rsp)
8802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm8,0x30(%rsp)
8812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm9,0x40(%rsp)
8822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm10,0x50(%rsp)
8832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm11,0x60(%rsp)
8842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm12,0x70(%rsp)
8852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm13,0x80(%rsp)
8862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm14,0x90(%rsp)
8872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	%xmm15,0xa0(%rsp)
8882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lcbc_body:
8892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
8902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
8912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	($ivp),%xmm6		# load IV
8922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	$inp,$out
8932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_preheat
8942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	cmp	\$0,${enc}d
8952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	je	.Lcbc_dec_loop
8962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Lcbc_enc_loop
8972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
8982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lcbc_enc_loop:
8992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	($inp),%xmm0
9002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm6,%xmm0
9012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_encrypt_core
9022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,%xmm6
9032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm0,($out,$inp)
9042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	16($inp),$inp
9052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	\$16,$len
9062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnc	.Lcbc_enc_loop
9072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jmp	.Lcbc_done
9082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
9092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lcbc_dec_loop:
9102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	($inp),%xmm0
9112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm0,%xmm7
9122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	_vpaes_decrypt_core
9132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pxor	%xmm6,%xmm0
9142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	%xmm7,%xmm6
9152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm0,($out,$inp)
9162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	16($inp),$inp
9172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	\$16,$len
9182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jnc	.Lcbc_dec_loop
9192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lcbc_done:
9202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqu	%xmm6,($ivp)		# save IV
9212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
9222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___ if ($win64);
9232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x10(%rsp),%xmm6
9242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x20(%rsp),%xmm7
9252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x30(%rsp),%xmm8
9262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x40(%rsp),%xmm9
9272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x50(%rsp),%xmm10
9282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x60(%rsp),%xmm11
9292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x70(%rsp),%xmm12
9302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x80(%rsp),%xmm13
9312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0x90(%rsp),%xmm14
9322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movaps	0xa0(%rsp),%xmm15
9332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	0xb8(%rsp),%rsp
9342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lcbc_epilogue:
9352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
9362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
9372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lcbc_abort:
9382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
9392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
9402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
9412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org}
9422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
9432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
9442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  _aes_preheat
9452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
9462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Fills register %r10 -> .aes_consts (so you can -fPIC)
9472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  and %xmm9-%xmm15 as specified below.
9482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
9492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_preheat,\@abi-omnipotent
9502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
9512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_preheat:
9522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	.Lk_s0F(%rip), %r10
9532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	-0x20(%r10), %xmm10	# .Lk_inv
9542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	-0x10(%r10), %xmm11	# .Lk_inv+16
9552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x00(%r10), %xmm9	# .Lk_s0F
9562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x30(%r10), %xmm13	# .Lk_sb1
9572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x40(%r10), %xmm12	# .Lk_sb1+16
9582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x50(%r10), %xmm15	# .Lk_sb2
9592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	movdqa	0x60(%r10), %xmm14	# .Lk_sb2+16
9602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
9612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_preheat,.-_vpaes_preheat
9622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org########################################################
9632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##                                                    ##
9642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##                     Constants                      ##
9652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##                                                    ##
9662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org########################################################
9672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	_vpaes_consts,\@object
9682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	64
9692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org_vpaes_consts:
9702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_inv:	# inv, inva
9712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0E05060F0D080180, 0x040703090A0B0C02
9722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x01040A060F0B0780, 0x030D0E0C02050809
9732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
9742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_s0F:	# s0F
9752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F
9762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
9772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_ipt:	# input transform (lo, hi)
9782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xC2B2E8985A2A7000, 0xCABAE09052227808
9792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81
9802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
9812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_sb1:	# sb1u, sb1t
9822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xB19BE18FCB503E00, 0xA5DF7A6E142AF544
9832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF
9842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_sb2:	# sb2u, sb2t
9852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xE27A93C60B712400, 0x5EB7E955BC982FCD
9862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x69EB88400AE12900, 0xC2A163C8AB82234A
9872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_sbo:	# sbou, sbot
9882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xD0D26D176FBDC700, 0x15AABF7AC502A878
9892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA
9902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
9912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_mc_forward:	# mc_forward
9922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0407060500030201, 0x0C0F0E0D080B0A09
9932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x080B0A0904070605, 0x000302010C0F0E0D
9942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0C0F0E0D080B0A09, 0x0407060500030201
9952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x000302010C0F0E0D, 0x080B0A0904070605
9962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
9972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_mc_backward:# mc_backward
9982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0605040702010003, 0x0E0D0C0F0A09080B
9992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x020100030E0D0C0F, 0x0A09080B06050407
10002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0E0D0C0F0A09080B, 0x0605040702010003
10012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0A09080B06050407, 0x020100030E0D0C0F
10022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_sr:		# sr
10042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0706050403020100, 0x0F0E0D0C0B0A0908
10052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x030E09040F0A0500, 0x0B06010C07020D08
10062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0F060D040B020900, 0x070E050C030A0108
10072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0B0E0104070A0D00, 0x0306090C0F020508
10082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_rcon:	# rcon
10102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81
10112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_s63:	# s63: all equal to 0x63 transformed
10132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x5B5B5B5B5B5B5B5B, 0x5B5B5B5B5B5B5B5B
10142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_opt:	# output transform
10162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xFF9F4929D6B66000, 0xF7974121DEBE6808
10172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0
10182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_deskew:	# deskew tables: inverts the sbox's "skew"
10202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A
10212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77
10222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
10242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Decryption stuff
10252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Key schedule constants
10262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
10272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dksd:	# decryption key schedule: invskew x*D
10282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9
10292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x41C277F4B5368300, 0x5FDC69EAAB289D1E
10302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dksb:	# decryption key schedule: invskew x*B
10312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x9A4FCA1F8550D500, 0x03D653861CC94C99
10322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x115BEDA7B6FC4A00, 0xD993256F7E3482C8
10332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dkse:	# decryption key schedule: invskew x*E + 0x63
10342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xD5031CCA1FC9D600, 0x53859A4C994F5086
10352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xA23196054FDC7BE8, 0xCD5EF96A20B31487
10362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dks9:	# decryption key schedule: invskew x*9
10372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xB6116FC87ED9A700, 0x4AED933482255BFC
10382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x4576516227143300, 0x8BB89FACE9DAFDCE
10392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
10412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Decryption stuff
10422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##  Round function constants
10432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org##
10442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dipt:	# decryption input transform
10452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0F505B040B545F00, 0x154A411E114E451A
10462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x86E383E660056500, 0x12771772F491F194
10472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dsb9:	# decryption sbox output *9*u, *9*t
10492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x851C03539A86D600, 0xCAD51F504F994CC9
10502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xC03B1789ECD74900, 0x725E2C9EB2FBA565
10512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dsbd:	# decryption sbox output *D*u, *D*t
10522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x7D57CCDFE6B1A200, 0xF56E9B13882A4439
10532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x3CE2FAF724C6CB00, 0x2931180D15DEEFD3
10542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dsbb:	# decryption sbox output *B*u, *B*t
10552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xD022649296B44200, 0x602646F6B0F2D404
10562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0xC19498A6CD596700, 0xF3FF0C3E3255AA6B
10572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dsbe:	# decryption sbox output *E*u, *E*t
10582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x46F2929626D4D000, 0x2242600464B4F6B0
10592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x0C55A6CDFFAAC100, 0x9467F36B98593E32
10602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lk_dsbo:	# decryption sbox final output
10612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x1387EA537EF94000, 0xC7AA6DB9D4943E2D
10622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.quad	0x12D7560F93441D00, 0xCA4B8159D8C58E9C
10632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.asciz	"Vector Permutaion AES for x86_64/SSSE3, Mike Hamburg (Stanford University)"
10642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	64
10652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	_vpaes_consts,.-_vpaes_consts
10662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
10672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgif ($win64) {
10692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame,
10702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org#		CONTEXT *context,DISPATCHER_CONTEXT *disp)
10712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$rec="%rcx";
10722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$frame="%rdx";
10732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$context="%r8";
10742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$disp="%r9";
10752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code.=<<___;
10772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.extern	__imp_RtlVirtualUnwind
10782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.type	se_handler,\@abi-omnipotent
10792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	16
10802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgse_handler:
10812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%rsi
10822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%rdi
10832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%rbx
10842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%rbp
10852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%r12
10862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%r13
10872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%r14
10882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	push	%r15
10892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pushfq
10902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	sub	\$64,%rsp
10912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	120($context),%rax	# pull context->Rax
10932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	248($context),%rbx	# pull context->Rip
10942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	8($disp),%rsi		# disp->ImageBase
10962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	56($disp),%r11		# disp->HandlerData
10972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
10982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	0(%r11),%r10d		# HandlerData[0]
10992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	(%rsi,%r10),%r10	# prologue label
11002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	cmp	%r10,%rbx		# context->Rip<prologue label
11012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jb	.Lin_prologue
11022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	152($context),%rax	# pull context->Rsp
11042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	4(%r11),%r10d		# HandlerData[1]
11062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	(%rsi,%r10),%r10	# epilogue label
11072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	cmp	%r10,%rbx		# context->Rip>=epilogue label
11082c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	jae	.Lin_prologue
11092c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11102c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	16(%rax),%rsi		# %xmm save area
11112c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	512($context),%rdi	# &context.Xmm6
11122c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$20,%ecx		# 10*sizeof(%xmm0)/sizeof(%rax)
11132c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.long	0xa548f3fc		# cld; rep movsq
11142c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	0xb8(%rax),%rax		# adjust stack pointer
11152c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11162c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.Lin_prologue:
11172c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	8(%rax),%rdi
11182c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	16(%rax),%rsi
11192c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rax,152($context)	# restore context->Rsp
11202c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rsi,168($context)	# restore context->Rsi
11212c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rdi,176($context)	# restore context->Rdi
11222c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11232c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	40($disp),%rdi		# disp->ContextRecord
11242c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	$context,%rsi		# context
11252c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$`1232/8`,%ecx		# sizeof(CONTEXT)
11262c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.long	0xa548f3fc		# cld; rep movsq
11272c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11282c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	$disp,%rsi
11292c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	xor	%rcx,%rcx		# arg1, UNW_FLAG_NHANDLER
11302c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	8(%rsi),%rdx		# arg2, disp->ImageBase
11312c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	0(%rsi),%r8		# arg3, disp->ControlPc
11322c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	16(%rsi),%r9		# arg4, disp->FunctionEntry
11332c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	40(%rsi),%r10		# disp->ContextRecord
11342c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	56(%rsi),%r11		# &disp->HandlerData
11352c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	lea	24(%rsi),%r12		# &disp->EstablisherFrame
11362c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%r10,32(%rsp)		# arg5
11372c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%r11,40(%rsp)		# arg6
11382c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%r12,48(%rsp)		# arg7
11392c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	%rcx,56(%rsp)		# arg8, (NULL)
11402c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	call	*__imp_RtlVirtualUnwind(%rip)
11412c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11422c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	mov	\$1,%eax		# ExceptionContinueSearch
11432c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	add	\$64,%rsp
11442c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	popfq
11452c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%r15
11462c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%r14
11472c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%r13
11482c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%r12
11492c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%rbp
11502c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%rbx
11512c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%rdi
11522c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	pop	%rsi
11532c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	ret
11542c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.size	se_handler,.-se_handler
11552c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11562c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.section	.pdata
11572c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	4
11582c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_begin_${PREFIX}_set_encrypt_key
11592c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_end_${PREFIX}_set_encrypt_key
11602c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_info_${PREFIX}_set_encrypt_key
11612c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11622c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_begin_${PREFIX}_set_decrypt_key
11632c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_end_${PREFIX}_set_decrypt_key
11642c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_info_${PREFIX}_set_decrypt_key
11652c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11662c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_begin_${PREFIX}_encrypt
11672c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_end_${PREFIX}_encrypt
11682c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_info_${PREFIX}_encrypt
11692c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11702c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_begin_${PREFIX}_decrypt
11712c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_end_${PREFIX}_decrypt
11722c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_info_${PREFIX}_decrypt
11732c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11742c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_begin_${PREFIX}_cbc_encrypt
11752c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_end_${PREFIX}_cbc_encrypt
11762c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.LSEH_info_${PREFIX}_cbc_encrypt
11772c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
11782c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.section	.xdata
11792c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.align	8
11802c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.LSEH_info_${PREFIX}_set_encrypt_key:
11812c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.byte	9,0,0,0
11822c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	se_handler
11832c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.Lenc_key_body,.Lenc_key_epilogue	# HandlerData[]
11842c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.LSEH_info_${PREFIX}_set_decrypt_key:
11852c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.byte	9,0,0,0
11862c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	se_handler
11872c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.Ldec_key_body,.Ldec_key_epilogue	# HandlerData[]
11882c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.LSEH_info_${PREFIX}_encrypt:
11892c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.byte	9,0,0,0
11902c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	se_handler
11912c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.Lenc_body,.Lenc_epilogue		# HandlerData[]
11922c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.LSEH_info_${PREFIX}_decrypt:
11932c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.byte	9,0,0,0
11942c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	se_handler
11952c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.Ldec_body,.Ldec_epilogue		# HandlerData[]
11962c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org.LSEH_info_${PREFIX}_cbc_encrypt:
11972c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.byte	9,0,0,0
11982c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	se_handler
11992c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org	.rva	.Lcbc_body,.Lcbc_epilogue		# HandlerData[]
12002c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org___
12012c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org}
12022c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
12032c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org$code =~ s/\`([^\`]*)\`/eval($1)/gem;
12042c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
12052c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgprint $code;
12062c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.org
12072c4508dfe2bc5b6296c01114ed11ddc64b7718c6digit@chromium.orgclose STDOUT;
1208