xref: /freebsd/crypto/openssl/crypto/aes/asm/aes-ppc.pl (revision e71b70530d95c4f34d8bdbd78d1242df1ba4a945)
11f13597dSJung-uk Kim#! /usr/bin/env perl
2*e71b7053SJung-uk Kim# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
3*e71b7053SJung-uk Kim#
4*e71b7053SJung-uk Kim# Licensed under the OpenSSL license (the "License").  You may not use
5*e71b7053SJung-uk Kim# this file except in compliance with the License.  You can obtain a copy
6*e71b7053SJung-uk Kim# in the file LICENSE in the source distribution or at
7*e71b7053SJung-uk Kim# https://www.openssl.org/source/license.html
8*e71b7053SJung-uk Kim
91f13597dSJung-uk Kim
101f13597dSJung-uk Kim# ====================================================================
11*e71b7053SJung-uk Kim# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
121f13597dSJung-uk Kim# project. The module is, however, dual licensed under OpenSSL and
131f13597dSJung-uk Kim# CRYPTOGAMS licenses depending on where you obtain it. For further
141f13597dSJung-uk Kim# details see http://www.openssl.org/~appro/cryptogams/.
151f13597dSJung-uk Kim# ====================================================================
161f13597dSJung-uk Kim
171f13597dSJung-uk Kim# Needs more work: key setup, CBC routine...
181f13597dSJung-uk Kim#
191f13597dSJung-uk Kim# ppc_AES_[en|de]crypt perform at 18 cycles per byte processed with
201f13597dSJung-uk Kim# 128-bit key, which is ~40% better than 64-bit code generated by gcc
211f13597dSJung-uk Kim# 4.0. But these are not the ones currently used! Their "compact"
221f13597dSJung-uk Kim# counterparts are, for security reason. ppc_AES_encrypt_compact runs
231f13597dSJung-uk Kim# at 1/2 of ppc_AES_encrypt speed, while ppc_AES_decrypt_compact -
241f13597dSJung-uk Kim# at 1/3 of ppc_AES_decrypt.
251f13597dSJung-uk Kim
261f13597dSJung-uk Kim# February 2010
271f13597dSJung-uk Kim#
281f13597dSJung-uk Kim# Rescheduling instructions to favour Power6 pipeline gave 10%
29*e71b7053SJung-uk Kim# performance improvement on the platform in question (and marginal
301f13597dSJung-uk Kim# improvement even on others). It should be noted that Power6 fails
311f13597dSJung-uk Kim# to process byte in 18 cycles, only in 23, because it fails to issue
321f13597dSJung-uk Kim# 4 load instructions in two cycles, only in 3. As result non-compact
331f13597dSJung-uk Kim# block subroutines are 25% slower than one would expect. Compact
341f13597dSJung-uk Kim# functions scale better, because they have pure computational part,
351f13597dSJung-uk Kim# which scales perfectly with clock frequency. To be specific
361f13597dSJung-uk Kim# ppc_AES_encrypt_compact operates at 42 cycles per byte, while
371f13597dSJung-uk Kim# ppc_AES_decrypt_compact - at 55 (in 64-bit build).
381f13597dSJung-uk Kim
391f13597dSJung-uk Kim$flavour = shift;
401f13597dSJung-uk Kim
411f13597dSJung-uk Kimif ($flavour =~ /64/) {
421f13597dSJung-uk Kim	$SIZE_T	=8;
431f13597dSJung-uk Kim	$LRSAVE	=2*$SIZE_T;
441f13597dSJung-uk Kim	$STU	="stdu";
451f13597dSJung-uk Kim	$POP	="ld";
461f13597dSJung-uk Kim	$PUSH	="std";
471f13597dSJung-uk Kim} elsif ($flavour =~ /32/) {
481f13597dSJung-uk Kim	$SIZE_T	=4;
491f13597dSJung-uk Kim	$LRSAVE	=$SIZE_T;
501f13597dSJung-uk Kim	$STU	="stwu";
511f13597dSJung-uk Kim	$POP	="lwz";
521f13597dSJung-uk Kim	$PUSH	="stw";
531f13597dSJung-uk Kim} else { die "nonsense $flavour"; }
541f13597dSJung-uk Kim
557bded2dbSJung-uk Kim$LITTLE_ENDIAN = ($flavour=~/le$/) ? $SIZE_T : 0;
567bded2dbSJung-uk Kim
571f13597dSJung-uk Kim$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
581f13597dSJung-uk Kim( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
591f13597dSJung-uk Kim( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
601f13597dSJung-uk Kimdie "can't locate ppc-xlate.pl";
611f13597dSJung-uk Kim
621f13597dSJung-uk Kimopen STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
631f13597dSJung-uk Kim
641f13597dSJung-uk Kim$FRAME=32*$SIZE_T;
651f13597dSJung-uk Kim
661f13597dSJung-uk Kimsub _data_word()
671f13597dSJung-uk Kim{ my $i;
681f13597dSJung-uk Kim    while(defined($i=shift)) { $code.=sprintf"\t.long\t0x%08x,0x%08x\n",$i,$i; }
691f13597dSJung-uk Kim}
701f13597dSJung-uk Kim
711f13597dSJung-uk Kim$sp="r1";
721f13597dSJung-uk Kim$toc="r2";
731f13597dSJung-uk Kim$inp="r3";
741f13597dSJung-uk Kim$out="r4";
751f13597dSJung-uk Kim$key="r5";
761f13597dSJung-uk Kim
771f13597dSJung-uk Kim$Tbl0="r3";
781f13597dSJung-uk Kim$Tbl1="r6";
791f13597dSJung-uk Kim$Tbl2="r7";
807bded2dbSJung-uk Kim$Tbl3=$out;	# stay away from "r2"; $out is offloaded to stack
811f13597dSJung-uk Kim
821f13597dSJung-uk Kim$s0="r8";
831f13597dSJung-uk Kim$s1="r9";
841f13597dSJung-uk Kim$s2="r10";
851f13597dSJung-uk Kim$s3="r11";
861f13597dSJung-uk Kim
871f13597dSJung-uk Kim$t0="r12";
887bded2dbSJung-uk Kim$t1="r0";	# stay away from "r13";
891f13597dSJung-uk Kim$t2="r14";
901f13597dSJung-uk Kim$t3="r15";
911f13597dSJung-uk Kim
921f13597dSJung-uk Kim$acc00="r16";
931f13597dSJung-uk Kim$acc01="r17";
941f13597dSJung-uk Kim$acc02="r18";
951f13597dSJung-uk Kim$acc03="r19";
961f13597dSJung-uk Kim
971f13597dSJung-uk Kim$acc04="r20";
981f13597dSJung-uk Kim$acc05="r21";
991f13597dSJung-uk Kim$acc06="r22";
1001f13597dSJung-uk Kim$acc07="r23";
1011f13597dSJung-uk Kim
1021f13597dSJung-uk Kim$acc08="r24";
1031f13597dSJung-uk Kim$acc09="r25";
1041f13597dSJung-uk Kim$acc10="r26";
1051f13597dSJung-uk Kim$acc11="r27";
1061f13597dSJung-uk Kim
1071f13597dSJung-uk Kim$acc12="r28";
1081f13597dSJung-uk Kim$acc13="r29";
1091f13597dSJung-uk Kim$acc14="r30";
1101f13597dSJung-uk Kim$acc15="r31";
1111f13597dSJung-uk Kim
1121f13597dSJung-uk Kim$mask80=$Tbl2;
1131f13597dSJung-uk Kim$mask1b=$Tbl3;
1141f13597dSJung-uk Kim
1151f13597dSJung-uk Kim$code.=<<___;
1161f13597dSJung-uk Kim.machine	"any"
1171f13597dSJung-uk Kim.text
1181f13597dSJung-uk Kim
1191f13597dSJung-uk Kim.align	7
1201f13597dSJung-uk KimLAES_Te:
1211f13597dSJung-uk Kim	mflr	r0
1221f13597dSJung-uk Kim	bcl	20,31,\$+4
1231f13597dSJung-uk Kim	mflr	$Tbl0	;    vvvvv "distance" between . and 1st data entry
1241f13597dSJung-uk Kim	addi	$Tbl0,$Tbl0,`128-8`
1251f13597dSJung-uk Kim	mtlr	r0
1261f13597dSJung-uk Kim	blr
1271f13597dSJung-uk Kim	.long	0
1281f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
1291f13597dSJung-uk Kim	.space	`64-9*4`
1301f13597dSJung-uk KimLAES_Td:
1311f13597dSJung-uk Kim	mflr	r0
1321f13597dSJung-uk Kim	bcl	20,31,\$+4
1331f13597dSJung-uk Kim	mflr	$Tbl0	;    vvvvvvvv "distance" between . and 1st data entry
1341f13597dSJung-uk Kim	addi	$Tbl0,$Tbl0,`128-64-8+2048+256`
1351f13597dSJung-uk Kim	mtlr	r0
1361f13597dSJung-uk Kim	blr
1371f13597dSJung-uk Kim	.long	0
1381f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
1391f13597dSJung-uk Kim	.space	`128-64-9*4`
1401f13597dSJung-uk Kim___
1411f13597dSJung-uk Kim&_data_word(
1421f13597dSJung-uk Kim	0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d,
1431f13597dSJung-uk Kim	0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554,
1441f13597dSJung-uk Kim	0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d,
1451f13597dSJung-uk Kim	0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a,
1461f13597dSJung-uk Kim	0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87,
1471f13597dSJung-uk Kim	0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b,
1481f13597dSJung-uk Kim	0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea,
1491f13597dSJung-uk Kim	0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b,
1501f13597dSJung-uk Kim	0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a,
1511f13597dSJung-uk Kim	0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f,
1521f13597dSJung-uk Kim	0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108,
1531f13597dSJung-uk Kim	0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f,
1541f13597dSJung-uk Kim	0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e,
1551f13597dSJung-uk Kim	0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5,
1561f13597dSJung-uk Kim	0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d,
1571f13597dSJung-uk Kim	0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f,
1581f13597dSJung-uk Kim	0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e,
1591f13597dSJung-uk Kim	0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb,
1601f13597dSJung-uk Kim	0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce,
1611f13597dSJung-uk Kim	0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497,
1621f13597dSJung-uk Kim	0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c,
1631f13597dSJung-uk Kim	0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed,
1641f13597dSJung-uk Kim	0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b,
1651f13597dSJung-uk Kim	0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a,
1661f13597dSJung-uk Kim	0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16,
1671f13597dSJung-uk Kim	0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594,
1681f13597dSJung-uk Kim	0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81,
1691f13597dSJung-uk Kim	0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3,
1701f13597dSJung-uk Kim	0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a,
1711f13597dSJung-uk Kim	0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504,
1721f13597dSJung-uk Kim	0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163,
1731f13597dSJung-uk Kim	0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d,
1741f13597dSJung-uk Kim	0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f,
1751f13597dSJung-uk Kim	0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739,
1761f13597dSJung-uk Kim	0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47,
1771f13597dSJung-uk Kim	0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395,
1781f13597dSJung-uk Kim	0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f,
1791f13597dSJung-uk Kim	0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883,
1801f13597dSJung-uk Kim	0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c,
1811f13597dSJung-uk Kim	0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76,
1821f13597dSJung-uk Kim	0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e,
1831f13597dSJung-uk Kim	0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4,
1841f13597dSJung-uk Kim	0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6,
1851f13597dSJung-uk Kim	0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b,
1861f13597dSJung-uk Kim	0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7,
1871f13597dSJung-uk Kim	0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0,
1881f13597dSJung-uk Kim	0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25,
1891f13597dSJung-uk Kim	0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818,
1901f13597dSJung-uk Kim	0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72,
1911f13597dSJung-uk Kim	0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651,
1921f13597dSJung-uk Kim	0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21,
1931f13597dSJung-uk Kim	0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85,
1941f13597dSJung-uk Kim	0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa,
1951f13597dSJung-uk Kim	0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12,
1961f13597dSJung-uk Kim	0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0,
1971f13597dSJung-uk Kim	0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9,
1981f13597dSJung-uk Kim	0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133,
1991f13597dSJung-uk Kim	0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7,
2001f13597dSJung-uk Kim	0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920,
2011f13597dSJung-uk Kim	0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a,
2021f13597dSJung-uk Kim	0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17,
2031f13597dSJung-uk Kim	0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8,
2041f13597dSJung-uk Kim	0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11,
2051f13597dSJung-uk Kim	0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a);
2061f13597dSJung-uk Kim$code.=<<___;
2071f13597dSJung-uk Kim.byte	0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5
2081f13597dSJung-uk Kim.byte	0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76
2091f13597dSJung-uk Kim.byte	0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0
2101f13597dSJung-uk Kim.byte	0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0
2111f13597dSJung-uk Kim.byte	0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc
2121f13597dSJung-uk Kim.byte	0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15
2131f13597dSJung-uk Kim.byte	0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a
2141f13597dSJung-uk Kim.byte	0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75
2151f13597dSJung-uk Kim.byte	0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0
2161f13597dSJung-uk Kim.byte	0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84
2171f13597dSJung-uk Kim.byte	0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b
2181f13597dSJung-uk Kim.byte	0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf
2191f13597dSJung-uk Kim.byte	0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85
2201f13597dSJung-uk Kim.byte	0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8
2211f13597dSJung-uk Kim.byte	0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5
2221f13597dSJung-uk Kim.byte	0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2
2231f13597dSJung-uk Kim.byte	0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17
2241f13597dSJung-uk Kim.byte	0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73
2251f13597dSJung-uk Kim.byte	0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88
2261f13597dSJung-uk Kim.byte	0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb
2271f13597dSJung-uk Kim.byte	0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c
2281f13597dSJung-uk Kim.byte	0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79
2291f13597dSJung-uk Kim.byte	0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9
2301f13597dSJung-uk Kim.byte	0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08
2311f13597dSJung-uk Kim.byte	0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6
2321f13597dSJung-uk Kim.byte	0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a
2331f13597dSJung-uk Kim.byte	0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e
2341f13597dSJung-uk Kim.byte	0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e
2351f13597dSJung-uk Kim.byte	0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94
2361f13597dSJung-uk Kim.byte	0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf
2371f13597dSJung-uk Kim.byte	0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68
2381f13597dSJung-uk Kim.byte	0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
2391f13597dSJung-uk Kim___
2401f13597dSJung-uk Kim&_data_word(
2411f13597dSJung-uk Kim	0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96,
2421f13597dSJung-uk Kim	0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393,
2431f13597dSJung-uk Kim	0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25,
2441f13597dSJung-uk Kim	0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f,
2451f13597dSJung-uk Kim	0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1,
2461f13597dSJung-uk Kim	0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6,
2471f13597dSJung-uk Kim	0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da,
2481f13597dSJung-uk Kim	0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844,
2491f13597dSJung-uk Kim	0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd,
2501f13597dSJung-uk Kim	0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4,
2511f13597dSJung-uk Kim	0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45,
2521f13597dSJung-uk Kim	0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94,
2531f13597dSJung-uk Kim	0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7,
2541f13597dSJung-uk Kim	0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a,
2551f13597dSJung-uk Kim	0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5,
2561f13597dSJung-uk Kim	0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c,
2571f13597dSJung-uk Kim	0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1,
2581f13597dSJung-uk Kim	0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a,
2591f13597dSJung-uk Kim	0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75,
2601f13597dSJung-uk Kim	0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051,
2611f13597dSJung-uk Kim	0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46,
2621f13597dSJung-uk Kim	0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff,
2631f13597dSJung-uk Kim	0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77,
2641f13597dSJung-uk Kim	0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb,
2651f13597dSJung-uk Kim	0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000,
2661f13597dSJung-uk Kim	0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e,
2671f13597dSJung-uk Kim	0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927,
2681f13597dSJung-uk Kim	0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a,
2691f13597dSJung-uk Kim	0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e,
2701f13597dSJung-uk Kim	0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16,
2711f13597dSJung-uk Kim	0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d,
2721f13597dSJung-uk Kim	0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8,
2731f13597dSJung-uk Kim	0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd,
2741f13597dSJung-uk Kim	0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34,
2751f13597dSJung-uk Kim	0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163,
2761f13597dSJung-uk Kim	0xd731dcca, 0x42638510, 0x13972240, 0x84c61120,
2771f13597dSJung-uk Kim	0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d,
2781f13597dSJung-uk Kim	0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0,
2791f13597dSJung-uk Kim	0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422,
2801f13597dSJung-uk Kim	0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef,
2811f13597dSJung-uk Kim	0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36,
2821f13597dSJung-uk Kim	0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4,
2831f13597dSJung-uk Kim	0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662,
2841f13597dSJung-uk Kim	0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5,
2851f13597dSJung-uk Kim	0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3,
2861f13597dSJung-uk Kim	0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b,
2871f13597dSJung-uk Kim	0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8,
2881f13597dSJung-uk Kim	0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6,
2891f13597dSJung-uk Kim	0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6,
2901f13597dSJung-uk Kim	0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0,
2911f13597dSJung-uk Kim	0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815,
2921f13597dSJung-uk Kim	0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f,
2931f13597dSJung-uk Kim	0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df,
2941f13597dSJung-uk Kim	0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f,
2951f13597dSJung-uk Kim	0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e,
2961f13597dSJung-uk Kim	0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713,
2971f13597dSJung-uk Kim	0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89,
2981f13597dSJung-uk Kim	0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c,
2991f13597dSJung-uk Kim	0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf,
3001f13597dSJung-uk Kim	0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86,
3011f13597dSJung-uk Kim	0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f,
3021f13597dSJung-uk Kim	0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541,
3031f13597dSJung-uk Kim	0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190,
3041f13597dSJung-uk Kim	0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742);
3051f13597dSJung-uk Kim$code.=<<___;
3061f13597dSJung-uk Kim.byte	0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38
3071f13597dSJung-uk Kim.byte	0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb
3081f13597dSJung-uk Kim.byte	0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87
3091f13597dSJung-uk Kim.byte	0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb
3101f13597dSJung-uk Kim.byte	0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d
3111f13597dSJung-uk Kim.byte	0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e
3121f13597dSJung-uk Kim.byte	0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2
3131f13597dSJung-uk Kim.byte	0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25
3141f13597dSJung-uk Kim.byte	0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16
3151f13597dSJung-uk Kim.byte	0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92
3161f13597dSJung-uk Kim.byte	0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda
3171f13597dSJung-uk Kim.byte	0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84
3181f13597dSJung-uk Kim.byte	0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a
3191f13597dSJung-uk Kim.byte	0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06
3201f13597dSJung-uk Kim.byte	0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02
3211f13597dSJung-uk Kim.byte	0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b
3221f13597dSJung-uk Kim.byte	0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea
3231f13597dSJung-uk Kim.byte	0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73
3241f13597dSJung-uk Kim.byte	0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85
3251f13597dSJung-uk Kim.byte	0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e
3261f13597dSJung-uk Kim.byte	0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89
3271f13597dSJung-uk Kim.byte	0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b
3281f13597dSJung-uk Kim.byte	0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20
3291f13597dSJung-uk Kim.byte	0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4
3301f13597dSJung-uk Kim.byte	0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31
3311f13597dSJung-uk Kim.byte	0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f
3321f13597dSJung-uk Kim.byte	0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d
3331f13597dSJung-uk Kim.byte	0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef
3341f13597dSJung-uk Kim.byte	0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0
3351f13597dSJung-uk Kim.byte	0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61
3361f13597dSJung-uk Kim.byte	0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26
3371f13597dSJung-uk Kim.byte	0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d
3381f13597dSJung-uk Kim
3391f13597dSJung-uk Kim
3401f13597dSJung-uk Kim.globl	.AES_encrypt
3411f13597dSJung-uk Kim.align	7
3421f13597dSJung-uk Kim.AES_encrypt:
3431f13597dSJung-uk Kim	$STU	$sp,-$FRAME($sp)
3441f13597dSJung-uk Kim	mflr	r0
3451f13597dSJung-uk Kim
3467bded2dbSJung-uk Kim	$PUSH	$out,`$FRAME-$SIZE_T*19`($sp)
3471f13597dSJung-uk Kim	$PUSH	r14,`$FRAME-$SIZE_T*18`($sp)
3481f13597dSJung-uk Kim	$PUSH	r15,`$FRAME-$SIZE_T*17`($sp)
3491f13597dSJung-uk Kim	$PUSH	r16,`$FRAME-$SIZE_T*16`($sp)
3501f13597dSJung-uk Kim	$PUSH	r17,`$FRAME-$SIZE_T*15`($sp)
3511f13597dSJung-uk Kim	$PUSH	r18,`$FRAME-$SIZE_T*14`($sp)
3521f13597dSJung-uk Kim	$PUSH	r19,`$FRAME-$SIZE_T*13`($sp)
3531f13597dSJung-uk Kim	$PUSH	r20,`$FRAME-$SIZE_T*12`($sp)
3541f13597dSJung-uk Kim	$PUSH	r21,`$FRAME-$SIZE_T*11`($sp)
3551f13597dSJung-uk Kim	$PUSH	r22,`$FRAME-$SIZE_T*10`($sp)
3561f13597dSJung-uk Kim	$PUSH	r23,`$FRAME-$SIZE_T*9`($sp)
3571f13597dSJung-uk Kim	$PUSH	r24,`$FRAME-$SIZE_T*8`($sp)
3581f13597dSJung-uk Kim	$PUSH	r25,`$FRAME-$SIZE_T*7`($sp)
3591f13597dSJung-uk Kim	$PUSH	r26,`$FRAME-$SIZE_T*6`($sp)
3601f13597dSJung-uk Kim	$PUSH	r27,`$FRAME-$SIZE_T*5`($sp)
3611f13597dSJung-uk Kim	$PUSH	r28,`$FRAME-$SIZE_T*4`($sp)
3621f13597dSJung-uk Kim	$PUSH	r29,`$FRAME-$SIZE_T*3`($sp)
3631f13597dSJung-uk Kim	$PUSH	r30,`$FRAME-$SIZE_T*2`($sp)
3641f13597dSJung-uk Kim	$PUSH	r31,`$FRAME-$SIZE_T*1`($sp)
3651f13597dSJung-uk Kim	$PUSH	r0,`$FRAME+$LRSAVE`($sp)
3661f13597dSJung-uk Kim
3671f13597dSJung-uk Kim	andi.	$t0,$inp,3
3681f13597dSJung-uk Kim	andi.	$t1,$out,3
3691f13597dSJung-uk Kim	or.	$t0,$t0,$t1
3701f13597dSJung-uk Kim	bne	Lenc_unaligned
3711f13597dSJung-uk Kim
3721f13597dSJung-uk KimLenc_unaligned_ok:
3737bded2dbSJung-uk Kim___
3747bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
3751f13597dSJung-uk Kim	lwz	$s0,0($inp)
3761f13597dSJung-uk Kim	lwz	$s1,4($inp)
3771f13597dSJung-uk Kim	lwz	$s2,8($inp)
3781f13597dSJung-uk Kim	lwz	$s3,12($inp)
3797bded2dbSJung-uk Kim___
3807bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
3817bded2dbSJung-uk Kim	lwz	$t0,0($inp)
3827bded2dbSJung-uk Kim	lwz	$t1,4($inp)
3837bded2dbSJung-uk Kim	lwz	$t2,8($inp)
3847bded2dbSJung-uk Kim	lwz	$t3,12($inp)
3857bded2dbSJung-uk Kim	rotlwi	$s0,$t0,8
3867bded2dbSJung-uk Kim	rotlwi	$s1,$t1,8
3877bded2dbSJung-uk Kim	rotlwi	$s2,$t2,8
3887bded2dbSJung-uk Kim	rotlwi	$s3,$t3,8
3897bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,0,7
3907bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,0,7
3917bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,0,7
3927bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,0,7
3937bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,16,23
3947bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,16,23
3957bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,16,23
3967bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,16,23
3977bded2dbSJung-uk Kim___
3987bded2dbSJung-uk Kim$code.=<<___;
3991f13597dSJung-uk Kim	bl	LAES_Te
4001f13597dSJung-uk Kim	bl	Lppc_AES_encrypt_compact
4017bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
4027bded2dbSJung-uk Kim___
4037bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
4047bded2dbSJung-uk Kim	rotlwi	$t0,$s0,8
4057bded2dbSJung-uk Kim	rotlwi	$t1,$s1,8
4067bded2dbSJung-uk Kim	rotlwi	$t2,$s2,8
4077bded2dbSJung-uk Kim	rotlwi	$t3,$s3,8
4087bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,0,7
4097bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,0,7
4107bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,0,7
4117bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,0,7
4127bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,16,23
4137bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,16,23
4147bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,16,23
4157bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,16,23
4167bded2dbSJung-uk Kim	stw	$t0,0($out)
4177bded2dbSJung-uk Kim	stw	$t1,4($out)
4187bded2dbSJung-uk Kim	stw	$t2,8($out)
4197bded2dbSJung-uk Kim	stw	$t3,12($out)
4207bded2dbSJung-uk Kim___
4217bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
4221f13597dSJung-uk Kim	stw	$s0,0($out)
4231f13597dSJung-uk Kim	stw	$s1,4($out)
4241f13597dSJung-uk Kim	stw	$s2,8($out)
4251f13597dSJung-uk Kim	stw	$s3,12($out)
4267bded2dbSJung-uk Kim___
4277bded2dbSJung-uk Kim$code.=<<___;
4281f13597dSJung-uk Kim	b	Lenc_done
4291f13597dSJung-uk Kim
4301f13597dSJung-uk KimLenc_unaligned:
4311f13597dSJung-uk Kim	subfic	$t0,$inp,4096
4321f13597dSJung-uk Kim	subfic	$t1,$out,4096
4331f13597dSJung-uk Kim	andi.	$t0,$t0,4096-16
4341f13597dSJung-uk Kim	beq	Lenc_xpage
4351f13597dSJung-uk Kim	andi.	$t1,$t1,4096-16
4361f13597dSJung-uk Kim	bne	Lenc_unaligned_ok
4371f13597dSJung-uk Kim
4381f13597dSJung-uk KimLenc_xpage:
4391f13597dSJung-uk Kim	lbz	$acc00,0($inp)
4401f13597dSJung-uk Kim	lbz	$acc01,1($inp)
4411f13597dSJung-uk Kim	lbz	$acc02,2($inp)
4421f13597dSJung-uk Kim	lbz	$s0,3($inp)
4431f13597dSJung-uk Kim	lbz	$acc04,4($inp)
4441f13597dSJung-uk Kim	lbz	$acc05,5($inp)
4451f13597dSJung-uk Kim	lbz	$acc06,6($inp)
4461f13597dSJung-uk Kim	lbz	$s1,7($inp)
4471f13597dSJung-uk Kim	lbz	$acc08,8($inp)
4481f13597dSJung-uk Kim	lbz	$acc09,9($inp)
4491f13597dSJung-uk Kim	lbz	$acc10,10($inp)
4501f13597dSJung-uk Kim	insrwi	$s0,$acc00,8,0
4511f13597dSJung-uk Kim	lbz	$s2,11($inp)
4521f13597dSJung-uk Kim	insrwi	$s1,$acc04,8,0
4531f13597dSJung-uk Kim	lbz	$acc12,12($inp)
4541f13597dSJung-uk Kim	insrwi	$s0,$acc01,8,8
4551f13597dSJung-uk Kim	lbz	$acc13,13($inp)
4561f13597dSJung-uk Kim	insrwi	$s1,$acc05,8,8
4571f13597dSJung-uk Kim	lbz	$acc14,14($inp)
4581f13597dSJung-uk Kim	insrwi	$s0,$acc02,8,16
4591f13597dSJung-uk Kim	lbz	$s3,15($inp)
4601f13597dSJung-uk Kim	insrwi	$s1,$acc06,8,16
4611f13597dSJung-uk Kim	insrwi	$s2,$acc08,8,0
4621f13597dSJung-uk Kim	insrwi	$s3,$acc12,8,0
4631f13597dSJung-uk Kim	insrwi	$s2,$acc09,8,8
4641f13597dSJung-uk Kim	insrwi	$s3,$acc13,8,8
4651f13597dSJung-uk Kim	insrwi	$s2,$acc10,8,16
4661f13597dSJung-uk Kim	insrwi	$s3,$acc14,8,16
4671f13597dSJung-uk Kim
4681f13597dSJung-uk Kim	bl	LAES_Te
4691f13597dSJung-uk Kim	bl	Lppc_AES_encrypt_compact
4707bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
4711f13597dSJung-uk Kim
4721f13597dSJung-uk Kim	extrwi	$acc00,$s0,8,0
4731f13597dSJung-uk Kim	extrwi	$acc01,$s0,8,8
4741f13597dSJung-uk Kim	stb	$acc00,0($out)
4751f13597dSJung-uk Kim	extrwi	$acc02,$s0,8,16
4761f13597dSJung-uk Kim	stb	$acc01,1($out)
4771f13597dSJung-uk Kim	stb	$acc02,2($out)
4781f13597dSJung-uk Kim	extrwi	$acc04,$s1,8,0
4791f13597dSJung-uk Kim	stb	$s0,3($out)
4801f13597dSJung-uk Kim	extrwi	$acc05,$s1,8,8
4811f13597dSJung-uk Kim	stb	$acc04,4($out)
4821f13597dSJung-uk Kim	extrwi	$acc06,$s1,8,16
4831f13597dSJung-uk Kim	stb	$acc05,5($out)
4841f13597dSJung-uk Kim	stb	$acc06,6($out)
4851f13597dSJung-uk Kim	extrwi	$acc08,$s2,8,0
4861f13597dSJung-uk Kim	stb	$s1,7($out)
4871f13597dSJung-uk Kim	extrwi	$acc09,$s2,8,8
4881f13597dSJung-uk Kim	stb	$acc08,8($out)
4891f13597dSJung-uk Kim	extrwi	$acc10,$s2,8,16
4901f13597dSJung-uk Kim	stb	$acc09,9($out)
4911f13597dSJung-uk Kim	stb	$acc10,10($out)
4921f13597dSJung-uk Kim	extrwi	$acc12,$s3,8,0
4931f13597dSJung-uk Kim	stb	$s2,11($out)
4941f13597dSJung-uk Kim	extrwi	$acc13,$s3,8,8
4951f13597dSJung-uk Kim	stb	$acc12,12($out)
4961f13597dSJung-uk Kim	extrwi	$acc14,$s3,8,16
4971f13597dSJung-uk Kim	stb	$acc13,13($out)
4981f13597dSJung-uk Kim	stb	$acc14,14($out)
4991f13597dSJung-uk Kim	stb	$s3,15($out)
5001f13597dSJung-uk Kim
5011f13597dSJung-uk KimLenc_done:
5021f13597dSJung-uk Kim	$POP	r0,`$FRAME+$LRSAVE`($sp)
5031f13597dSJung-uk Kim	$POP	r14,`$FRAME-$SIZE_T*18`($sp)
5041f13597dSJung-uk Kim	$POP	r15,`$FRAME-$SIZE_T*17`($sp)
5051f13597dSJung-uk Kim	$POP	r16,`$FRAME-$SIZE_T*16`($sp)
5061f13597dSJung-uk Kim	$POP	r17,`$FRAME-$SIZE_T*15`($sp)
5071f13597dSJung-uk Kim	$POP	r18,`$FRAME-$SIZE_T*14`($sp)
5081f13597dSJung-uk Kim	$POP	r19,`$FRAME-$SIZE_T*13`($sp)
5091f13597dSJung-uk Kim	$POP	r20,`$FRAME-$SIZE_T*12`($sp)
5101f13597dSJung-uk Kim	$POP	r21,`$FRAME-$SIZE_T*11`($sp)
5111f13597dSJung-uk Kim	$POP	r22,`$FRAME-$SIZE_T*10`($sp)
5121f13597dSJung-uk Kim	$POP	r23,`$FRAME-$SIZE_T*9`($sp)
5131f13597dSJung-uk Kim	$POP	r24,`$FRAME-$SIZE_T*8`($sp)
5141f13597dSJung-uk Kim	$POP	r25,`$FRAME-$SIZE_T*7`($sp)
5151f13597dSJung-uk Kim	$POP	r26,`$FRAME-$SIZE_T*6`($sp)
5161f13597dSJung-uk Kim	$POP	r27,`$FRAME-$SIZE_T*5`($sp)
5171f13597dSJung-uk Kim	$POP	r28,`$FRAME-$SIZE_T*4`($sp)
5181f13597dSJung-uk Kim	$POP	r29,`$FRAME-$SIZE_T*3`($sp)
5191f13597dSJung-uk Kim	$POP	r30,`$FRAME-$SIZE_T*2`($sp)
5201f13597dSJung-uk Kim	$POP	r31,`$FRAME-$SIZE_T*1`($sp)
5211f13597dSJung-uk Kim	mtlr	r0
5221f13597dSJung-uk Kim	addi	$sp,$sp,$FRAME
5231f13597dSJung-uk Kim	blr
5241f13597dSJung-uk Kim	.long	0
5251f13597dSJung-uk Kim	.byte	0,12,4,1,0x80,18,3,0
5261f13597dSJung-uk Kim	.long	0
5271f13597dSJung-uk Kim
5281f13597dSJung-uk Kim.align	5
5291f13597dSJung-uk KimLppc_AES_encrypt:
5301f13597dSJung-uk Kim	lwz	$acc00,240($key)
5311f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,3
5321f13597dSJung-uk Kim	lwz	$t0,0($key)
5331f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2
5341f13597dSJung-uk Kim	lwz	$t1,4($key)
5351f13597dSJung-uk Kim	addi	$Tbl3,$Tbl0,1
5361f13597dSJung-uk Kim	lwz	$t2,8($key)
5371f13597dSJung-uk Kim	addi	$acc00,$acc00,-1
5381f13597dSJung-uk Kim	lwz	$t3,12($key)
5391f13597dSJung-uk Kim	addi	$key,$key,16
5401f13597dSJung-uk Kim	xor	$s0,$s0,$t0
5411f13597dSJung-uk Kim	xor	$s1,$s1,$t1
5421f13597dSJung-uk Kim	xor	$s2,$s2,$t2
5431f13597dSJung-uk Kim	xor	$s3,$s3,$t3
5441f13597dSJung-uk Kim	mtctr	$acc00
5451f13597dSJung-uk Kim.align	4
5461f13597dSJung-uk KimLenc_loop:
5471f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24+3`,21,28
5481f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24+3`,21,28
5491f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24+3`,21,28
5501f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24+3`,21,28
5511f13597dSJung-uk Kim	lwz	$t0,0($key)
5521f13597dSJung-uk Kim	rlwinm	$acc04,$s1,`32-16+3`,21,28
5531f13597dSJung-uk Kim	lwz	$t1,4($key)
5541f13597dSJung-uk Kim	rlwinm	$acc05,$s2,`32-16+3`,21,28
5551f13597dSJung-uk Kim	lwz	$t2,8($key)
5561f13597dSJung-uk Kim	rlwinm	$acc06,$s3,`32-16+3`,21,28
5571f13597dSJung-uk Kim	lwz	$t3,12($key)
5581f13597dSJung-uk Kim	rlwinm	$acc07,$s0,`32-16+3`,21,28
5591f13597dSJung-uk Kim	lwzx	$acc00,$Tbl0,$acc00
5601f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8+3`,21,28
5611f13597dSJung-uk Kim	lwzx	$acc01,$Tbl0,$acc01
5621f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8+3`,21,28
5631f13597dSJung-uk Kim	lwzx	$acc02,$Tbl0,$acc02
5641f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8+3`,21,28
5651f13597dSJung-uk Kim	lwzx	$acc03,$Tbl0,$acc03
5661f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8+3`,21,28
5671f13597dSJung-uk Kim	lwzx	$acc04,$Tbl1,$acc04
5681f13597dSJung-uk Kim	rlwinm	$acc12,$s3,`0+3`,21,28
5691f13597dSJung-uk Kim	lwzx	$acc05,$Tbl1,$acc05
5701f13597dSJung-uk Kim	rlwinm	$acc13,$s0,`0+3`,21,28
5711f13597dSJung-uk Kim	lwzx	$acc06,$Tbl1,$acc06
5721f13597dSJung-uk Kim	rlwinm	$acc14,$s1,`0+3`,21,28
5731f13597dSJung-uk Kim	lwzx	$acc07,$Tbl1,$acc07
5741f13597dSJung-uk Kim	rlwinm	$acc15,$s2,`0+3`,21,28
5751f13597dSJung-uk Kim	lwzx	$acc08,$Tbl2,$acc08
5761f13597dSJung-uk Kim	xor	$t0,$t0,$acc00
5771f13597dSJung-uk Kim	lwzx	$acc09,$Tbl2,$acc09
5781f13597dSJung-uk Kim	xor	$t1,$t1,$acc01
5791f13597dSJung-uk Kim	lwzx	$acc10,$Tbl2,$acc10
5801f13597dSJung-uk Kim	xor	$t2,$t2,$acc02
5811f13597dSJung-uk Kim	lwzx	$acc11,$Tbl2,$acc11
5821f13597dSJung-uk Kim	xor	$t3,$t3,$acc03
5831f13597dSJung-uk Kim	lwzx	$acc12,$Tbl3,$acc12
5841f13597dSJung-uk Kim	xor	$t0,$t0,$acc04
5851f13597dSJung-uk Kim	lwzx	$acc13,$Tbl3,$acc13
5861f13597dSJung-uk Kim	xor	$t1,$t1,$acc05
5871f13597dSJung-uk Kim	lwzx	$acc14,$Tbl3,$acc14
5881f13597dSJung-uk Kim	xor	$t2,$t2,$acc06
5891f13597dSJung-uk Kim	lwzx	$acc15,$Tbl3,$acc15
5901f13597dSJung-uk Kim	xor	$t3,$t3,$acc07
5911f13597dSJung-uk Kim	xor	$t0,$t0,$acc08
5921f13597dSJung-uk Kim	xor	$t1,$t1,$acc09
5931f13597dSJung-uk Kim	xor	$t2,$t2,$acc10
5941f13597dSJung-uk Kim	xor	$t3,$t3,$acc11
5951f13597dSJung-uk Kim	xor	$s0,$t0,$acc12
5961f13597dSJung-uk Kim	xor	$s1,$t1,$acc13
5971f13597dSJung-uk Kim	xor	$s2,$t2,$acc14
5981f13597dSJung-uk Kim	xor	$s3,$t3,$acc15
5991f13597dSJung-uk Kim	addi	$key,$key,16
600b8721c16SJung-uk Kim	bdnz	Lenc_loop
6011f13597dSJung-uk Kim
6021f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2048
6031f13597dSJung-uk Kim	nop
6041f13597dSJung-uk Kim	lwz	$t0,0($key)
6051f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
6061f13597dSJung-uk Kim	lwz	$t1,4($key)
6071f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
6081f13597dSJung-uk Kim	lwz	$t2,8($key)
6091f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
6101f13597dSJung-uk Kim	lwz	$t3,12($key)
6111f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
6121f13597dSJung-uk Kim	lwz	$acc08,`2048+0`($Tbl0)	! prefetch Te4
6131f13597dSJung-uk Kim	rlwinm	$acc04,$s1,`32-16`,24,31
6141f13597dSJung-uk Kim	lwz	$acc09,`2048+32`($Tbl0)
6151f13597dSJung-uk Kim	rlwinm	$acc05,$s2,`32-16`,24,31
6161f13597dSJung-uk Kim	lwz	$acc10,`2048+64`($Tbl0)
6171f13597dSJung-uk Kim	rlwinm	$acc06,$s3,`32-16`,24,31
6181f13597dSJung-uk Kim	lwz	$acc11,`2048+96`($Tbl0)
6191f13597dSJung-uk Kim	rlwinm	$acc07,$s0,`32-16`,24,31
6201f13597dSJung-uk Kim	lwz	$acc12,`2048+128`($Tbl0)
6211f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
6221f13597dSJung-uk Kim	lwz	$acc13,`2048+160`($Tbl0)
6231f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
6241f13597dSJung-uk Kim	lwz	$acc14,`2048+192`($Tbl0)
6251f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
6261f13597dSJung-uk Kim	lwz	$acc15,`2048+224`($Tbl0)
6271f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
6281f13597dSJung-uk Kim	lbzx	$acc00,$Tbl2,$acc00
6291f13597dSJung-uk Kim	rlwinm	$acc12,$s3,`0`,24,31
6301f13597dSJung-uk Kim	lbzx	$acc01,$Tbl2,$acc01
6311f13597dSJung-uk Kim	rlwinm	$acc13,$s0,`0`,24,31
6321f13597dSJung-uk Kim	lbzx	$acc02,$Tbl2,$acc02
6331f13597dSJung-uk Kim	rlwinm	$acc14,$s1,`0`,24,31
6341f13597dSJung-uk Kim	lbzx	$acc03,$Tbl2,$acc03
6351f13597dSJung-uk Kim	rlwinm	$acc15,$s2,`0`,24,31
6361f13597dSJung-uk Kim	lbzx	$acc04,$Tbl2,$acc04
6371f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
6381f13597dSJung-uk Kim	lbzx	$acc05,$Tbl2,$acc05
6391f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
6401f13597dSJung-uk Kim	lbzx	$acc06,$Tbl2,$acc06
6411f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
6421f13597dSJung-uk Kim	lbzx	$acc07,$Tbl2,$acc07
6431f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
6441f13597dSJung-uk Kim	lbzx	$acc08,$Tbl2,$acc08
6451f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
6461f13597dSJung-uk Kim	lbzx	$acc09,$Tbl2,$acc09
6471f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
6481f13597dSJung-uk Kim	lbzx	$acc10,$Tbl2,$acc10
6491f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
6501f13597dSJung-uk Kim	lbzx	$acc11,$Tbl2,$acc11
6511f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
6521f13597dSJung-uk Kim	lbzx	$acc12,$Tbl2,$acc12
6531f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
6541f13597dSJung-uk Kim	lbzx	$acc13,$Tbl2,$acc13
6551f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
6561f13597dSJung-uk Kim	lbzx	$acc14,$Tbl2,$acc14
6571f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
6581f13597dSJung-uk Kim	lbzx	$acc15,$Tbl2,$acc15
6591f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
6601f13597dSJung-uk Kim	or	$s0,$s0,$acc12
6611f13597dSJung-uk Kim	or	$s1,$s1,$acc13
6621f13597dSJung-uk Kim	or	$s2,$s2,$acc14
6631f13597dSJung-uk Kim	or	$s3,$s3,$acc15
6641f13597dSJung-uk Kim	xor	$s0,$s0,$t0
6651f13597dSJung-uk Kim	xor	$s1,$s1,$t1
6661f13597dSJung-uk Kim	xor	$s2,$s2,$t2
6671f13597dSJung-uk Kim	xor	$s3,$s3,$t3
6681f13597dSJung-uk Kim	blr
6691f13597dSJung-uk Kim	.long	0
6701f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
6711f13597dSJung-uk Kim
6721f13597dSJung-uk Kim.align	4
6731f13597dSJung-uk KimLppc_AES_encrypt_compact:
6741f13597dSJung-uk Kim	lwz	$acc00,240($key)
6751f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,2048
6761f13597dSJung-uk Kim	lwz	$t0,0($key)
6771f13597dSJung-uk Kim	lis	$mask80,0x8080
6781f13597dSJung-uk Kim	lwz	$t1,4($key)
6791f13597dSJung-uk Kim	lis	$mask1b,0x1b1b
6801f13597dSJung-uk Kim	lwz	$t2,8($key)
6811f13597dSJung-uk Kim	ori	$mask80,$mask80,0x8080
6821f13597dSJung-uk Kim	lwz	$t3,12($key)
6831f13597dSJung-uk Kim	ori	$mask1b,$mask1b,0x1b1b
6841f13597dSJung-uk Kim	addi	$key,$key,16
6851f13597dSJung-uk Kim	mtctr	$acc00
6861f13597dSJung-uk Kim.align	4
6871f13597dSJung-uk KimLenc_compact_loop:
6881f13597dSJung-uk Kim	xor	$s0,$s0,$t0
6891f13597dSJung-uk Kim	xor	$s1,$s1,$t1
6901f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
6911f13597dSJung-uk Kim	xor	$s2,$s2,$t2
6921f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
6931f13597dSJung-uk Kim	xor	$s3,$s3,$t3
6941f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
6951f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
6961f13597dSJung-uk Kim	rlwinm	$acc04,$s1,`32-16`,24,31
6971f13597dSJung-uk Kim	rlwinm	$acc05,$s2,`32-16`,24,31
6981f13597dSJung-uk Kim	rlwinm	$acc06,$s3,`32-16`,24,31
6991f13597dSJung-uk Kim	rlwinm	$acc07,$s0,`32-16`,24,31
7001f13597dSJung-uk Kim	lbzx	$acc00,$Tbl1,$acc00
7011f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
7021f13597dSJung-uk Kim	lbzx	$acc01,$Tbl1,$acc01
7031f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
7041f13597dSJung-uk Kim	lbzx	$acc02,$Tbl1,$acc02
7051f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
7061f13597dSJung-uk Kim	lbzx	$acc03,$Tbl1,$acc03
7071f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
7081f13597dSJung-uk Kim	lbzx	$acc04,$Tbl1,$acc04
7091f13597dSJung-uk Kim	rlwinm	$acc12,$s3,`0`,24,31
7101f13597dSJung-uk Kim	lbzx	$acc05,$Tbl1,$acc05
7111f13597dSJung-uk Kim	rlwinm	$acc13,$s0,`0`,24,31
7121f13597dSJung-uk Kim	lbzx	$acc06,$Tbl1,$acc06
7131f13597dSJung-uk Kim	rlwinm	$acc14,$s1,`0`,24,31
7141f13597dSJung-uk Kim	lbzx	$acc07,$Tbl1,$acc07
7151f13597dSJung-uk Kim	rlwinm	$acc15,$s2,`0`,24,31
7161f13597dSJung-uk Kim	lbzx	$acc08,$Tbl1,$acc08
7171f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
7181f13597dSJung-uk Kim	lbzx	$acc09,$Tbl1,$acc09
7191f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
7201f13597dSJung-uk Kim	lbzx	$acc10,$Tbl1,$acc10
7211f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
7221f13597dSJung-uk Kim	lbzx	$acc11,$Tbl1,$acc11
7231f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
7241f13597dSJung-uk Kim	lbzx	$acc12,$Tbl1,$acc12
7251f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
7261f13597dSJung-uk Kim	lbzx	$acc13,$Tbl1,$acc13
7271f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
7281f13597dSJung-uk Kim	lbzx	$acc14,$Tbl1,$acc14
7291f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
7301f13597dSJung-uk Kim	lbzx	$acc15,$Tbl1,$acc15
7311f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
7321f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
7331f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
7341f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
7351f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
7361f13597dSJung-uk Kim	lwz	$t0,0($key)
7371f13597dSJung-uk Kim	or	$s0,$s0,$acc12
7381f13597dSJung-uk Kim	lwz	$t1,4($key)
7391f13597dSJung-uk Kim	or	$s1,$s1,$acc13
7401f13597dSJung-uk Kim	lwz	$t2,8($key)
7411f13597dSJung-uk Kim	or	$s2,$s2,$acc14
7421f13597dSJung-uk Kim	lwz	$t3,12($key)
7431f13597dSJung-uk Kim	or	$s3,$s3,$acc15
7441f13597dSJung-uk Kim
7451f13597dSJung-uk Kim	addi	$key,$key,16
7461f13597dSJung-uk Kim	bdz	Lenc_compact_done
7471f13597dSJung-uk Kim
7481f13597dSJung-uk Kim	and	$acc00,$s0,$mask80	# r1=r0&0x80808080
7491f13597dSJung-uk Kim	and	$acc01,$s1,$mask80
7501f13597dSJung-uk Kim	and	$acc02,$s2,$mask80
7511f13597dSJung-uk Kim	and	$acc03,$s3,$mask80
7521f13597dSJung-uk Kim	srwi	$acc04,$acc00,7		# r1>>7
7531f13597dSJung-uk Kim	andc	$acc08,$s0,$mask80	# r0&0x7f7f7f7f
7541f13597dSJung-uk Kim	srwi	$acc05,$acc01,7
7551f13597dSJung-uk Kim	andc	$acc09,$s1,$mask80
7561f13597dSJung-uk Kim	srwi	$acc06,$acc02,7
7571f13597dSJung-uk Kim	andc	$acc10,$s2,$mask80
7581f13597dSJung-uk Kim	srwi	$acc07,$acc03,7
7591f13597dSJung-uk Kim	andc	$acc11,$s3,$mask80
7601f13597dSJung-uk Kim	sub	$acc00,$acc00,$acc04	# r1-(r1>>7)
7611f13597dSJung-uk Kim	sub	$acc01,$acc01,$acc05
7621f13597dSJung-uk Kim	sub	$acc02,$acc02,$acc06
7631f13597dSJung-uk Kim	sub	$acc03,$acc03,$acc07
7641f13597dSJung-uk Kim	add	$acc08,$acc08,$acc08	# (r0&0x7f7f7f7f)<<1
7651f13597dSJung-uk Kim	add	$acc09,$acc09,$acc09
7661f13597dSJung-uk Kim	add	$acc10,$acc10,$acc10
7671f13597dSJung-uk Kim	add	$acc11,$acc11,$acc11
7681f13597dSJung-uk Kim	and	$acc00,$acc00,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
7691f13597dSJung-uk Kim	and	$acc01,$acc01,$mask1b
7701f13597dSJung-uk Kim	and	$acc02,$acc02,$mask1b
7711f13597dSJung-uk Kim	and	$acc03,$acc03,$mask1b
7721f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08	# r2
7731f13597dSJung-uk Kim	xor	$acc01,$acc01,$acc09
7741f13597dSJung-uk Kim	 rotlwi	$acc12,$s0,16		# ROTATE(r0,16)
7751f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
7761f13597dSJung-uk Kim	 rotlwi	$acc13,$s1,16
7771f13597dSJung-uk Kim	xor	$acc03,$acc03,$acc11
7781f13597dSJung-uk Kim	 rotlwi	$acc14,$s2,16
7791f13597dSJung-uk Kim
7801f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# r0^r2
7811f13597dSJung-uk Kim	rotlwi	$acc15,$s3,16
7821f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
7831f13597dSJung-uk Kim	rotrwi	$s0,$s0,24		# ROTATE(r2^r0,24)
7841f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
7851f13597dSJung-uk Kim	rotrwi	$s1,$s1,24
7861f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
7871f13597dSJung-uk Kim	rotrwi	$s2,$s2,24
7881f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# ROTATE(r2^r0,24)^r2
7891f13597dSJung-uk Kim	rotrwi	$s3,$s3,24
7901f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
7911f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
7921f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
7931f13597dSJung-uk Kim	rotlwi	$acc08,$acc12,8		# ROTATE(r0,24)
7941f13597dSJung-uk Kim	xor	$s0,$s0,$acc12		#
7951f13597dSJung-uk Kim	rotlwi	$acc09,$acc13,8
7961f13597dSJung-uk Kim	xor	$s1,$s1,$acc13
7971f13597dSJung-uk Kim	rotlwi	$acc10,$acc14,8
7981f13597dSJung-uk Kim	xor	$s2,$s2,$acc14
7991f13597dSJung-uk Kim	rotlwi	$acc11,$acc15,8
8001f13597dSJung-uk Kim	xor	$s3,$s3,$acc15
8011f13597dSJung-uk Kim	xor	$s0,$s0,$acc08		#
8021f13597dSJung-uk Kim	xor	$s1,$s1,$acc09
8031f13597dSJung-uk Kim	xor	$s2,$s2,$acc10
8041f13597dSJung-uk Kim	xor	$s3,$s3,$acc11
8051f13597dSJung-uk Kim
8061f13597dSJung-uk Kim	b	Lenc_compact_loop
8071f13597dSJung-uk Kim.align	4
8081f13597dSJung-uk KimLenc_compact_done:
8091f13597dSJung-uk Kim	xor	$s0,$s0,$t0
8101f13597dSJung-uk Kim	xor	$s1,$s1,$t1
8111f13597dSJung-uk Kim	xor	$s2,$s2,$t2
8121f13597dSJung-uk Kim	xor	$s3,$s3,$t3
8131f13597dSJung-uk Kim	blr
8141f13597dSJung-uk Kim	.long	0
8151f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
8167bded2dbSJung-uk Kim.size	.AES_encrypt,.-.AES_encrypt
8171f13597dSJung-uk Kim
8181f13597dSJung-uk Kim.globl	.AES_decrypt
8191f13597dSJung-uk Kim.align	7
8201f13597dSJung-uk Kim.AES_decrypt:
8211f13597dSJung-uk Kim	$STU	$sp,-$FRAME($sp)
8221f13597dSJung-uk Kim	mflr	r0
8231f13597dSJung-uk Kim
8247bded2dbSJung-uk Kim	$PUSH	$out,`$FRAME-$SIZE_T*19`($sp)
8251f13597dSJung-uk Kim	$PUSH	r14,`$FRAME-$SIZE_T*18`($sp)
8261f13597dSJung-uk Kim	$PUSH	r15,`$FRAME-$SIZE_T*17`($sp)
8271f13597dSJung-uk Kim	$PUSH	r16,`$FRAME-$SIZE_T*16`($sp)
8281f13597dSJung-uk Kim	$PUSH	r17,`$FRAME-$SIZE_T*15`($sp)
8291f13597dSJung-uk Kim	$PUSH	r18,`$FRAME-$SIZE_T*14`($sp)
8301f13597dSJung-uk Kim	$PUSH	r19,`$FRAME-$SIZE_T*13`($sp)
8311f13597dSJung-uk Kim	$PUSH	r20,`$FRAME-$SIZE_T*12`($sp)
8321f13597dSJung-uk Kim	$PUSH	r21,`$FRAME-$SIZE_T*11`($sp)
8331f13597dSJung-uk Kim	$PUSH	r22,`$FRAME-$SIZE_T*10`($sp)
8341f13597dSJung-uk Kim	$PUSH	r23,`$FRAME-$SIZE_T*9`($sp)
8351f13597dSJung-uk Kim	$PUSH	r24,`$FRAME-$SIZE_T*8`($sp)
8361f13597dSJung-uk Kim	$PUSH	r25,`$FRAME-$SIZE_T*7`($sp)
8371f13597dSJung-uk Kim	$PUSH	r26,`$FRAME-$SIZE_T*6`($sp)
8381f13597dSJung-uk Kim	$PUSH	r27,`$FRAME-$SIZE_T*5`($sp)
8391f13597dSJung-uk Kim	$PUSH	r28,`$FRAME-$SIZE_T*4`($sp)
8401f13597dSJung-uk Kim	$PUSH	r29,`$FRAME-$SIZE_T*3`($sp)
8411f13597dSJung-uk Kim	$PUSH	r30,`$FRAME-$SIZE_T*2`($sp)
8421f13597dSJung-uk Kim	$PUSH	r31,`$FRAME-$SIZE_T*1`($sp)
8431f13597dSJung-uk Kim	$PUSH	r0,`$FRAME+$LRSAVE`($sp)
8441f13597dSJung-uk Kim
8451f13597dSJung-uk Kim	andi.	$t0,$inp,3
8461f13597dSJung-uk Kim	andi.	$t1,$out,3
8471f13597dSJung-uk Kim	or.	$t0,$t0,$t1
8481f13597dSJung-uk Kim	bne	Ldec_unaligned
8491f13597dSJung-uk Kim
8501f13597dSJung-uk KimLdec_unaligned_ok:
8517bded2dbSJung-uk Kim___
8527bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
8531f13597dSJung-uk Kim	lwz	$s0,0($inp)
8541f13597dSJung-uk Kim	lwz	$s1,4($inp)
8551f13597dSJung-uk Kim	lwz	$s2,8($inp)
8561f13597dSJung-uk Kim	lwz	$s3,12($inp)
8577bded2dbSJung-uk Kim___
8587bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
8597bded2dbSJung-uk Kim	lwz	$t0,0($inp)
8607bded2dbSJung-uk Kim	lwz	$t1,4($inp)
8617bded2dbSJung-uk Kim	lwz	$t2,8($inp)
8627bded2dbSJung-uk Kim	lwz	$t3,12($inp)
8637bded2dbSJung-uk Kim	rotlwi	$s0,$t0,8
8647bded2dbSJung-uk Kim	rotlwi	$s1,$t1,8
8657bded2dbSJung-uk Kim	rotlwi	$s2,$t2,8
8667bded2dbSJung-uk Kim	rotlwi	$s3,$t3,8
8677bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,0,7
8687bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,0,7
8697bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,0,7
8707bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,0,7
8717bded2dbSJung-uk Kim	rlwimi	$s0,$t0,24,16,23
8727bded2dbSJung-uk Kim	rlwimi	$s1,$t1,24,16,23
8737bded2dbSJung-uk Kim	rlwimi	$s2,$t2,24,16,23
8747bded2dbSJung-uk Kim	rlwimi	$s3,$t3,24,16,23
8757bded2dbSJung-uk Kim___
8767bded2dbSJung-uk Kim$code.=<<___;
8771f13597dSJung-uk Kim	bl	LAES_Td
8781f13597dSJung-uk Kim	bl	Lppc_AES_decrypt_compact
8797bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
8807bded2dbSJung-uk Kim___
8817bded2dbSJung-uk Kim$code.=<<___ if ($LITTLE_ENDIAN);
8827bded2dbSJung-uk Kim	rotlwi	$t0,$s0,8
8837bded2dbSJung-uk Kim	rotlwi	$t1,$s1,8
8847bded2dbSJung-uk Kim	rotlwi	$t2,$s2,8
8857bded2dbSJung-uk Kim	rotlwi	$t3,$s3,8
8867bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,0,7
8877bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,0,7
8887bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,0,7
8897bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,0,7
8907bded2dbSJung-uk Kim	rlwimi	$t0,$s0,24,16,23
8917bded2dbSJung-uk Kim	rlwimi	$t1,$s1,24,16,23
8927bded2dbSJung-uk Kim	rlwimi	$t2,$s2,24,16,23
8937bded2dbSJung-uk Kim	rlwimi	$t3,$s3,24,16,23
8947bded2dbSJung-uk Kim	stw	$t0,0($out)
8957bded2dbSJung-uk Kim	stw	$t1,4($out)
8967bded2dbSJung-uk Kim	stw	$t2,8($out)
8977bded2dbSJung-uk Kim	stw	$t3,12($out)
8987bded2dbSJung-uk Kim___
8997bded2dbSJung-uk Kim$code.=<<___ if (!$LITTLE_ENDIAN);
9001f13597dSJung-uk Kim	stw	$s0,0($out)
9011f13597dSJung-uk Kim	stw	$s1,4($out)
9021f13597dSJung-uk Kim	stw	$s2,8($out)
9031f13597dSJung-uk Kim	stw	$s3,12($out)
9047bded2dbSJung-uk Kim___
9057bded2dbSJung-uk Kim$code.=<<___;
9061f13597dSJung-uk Kim	b	Ldec_done
9071f13597dSJung-uk Kim
9081f13597dSJung-uk KimLdec_unaligned:
9091f13597dSJung-uk Kim	subfic	$t0,$inp,4096
9101f13597dSJung-uk Kim	subfic	$t1,$out,4096
9111f13597dSJung-uk Kim	andi.	$t0,$t0,4096-16
9121f13597dSJung-uk Kim	beq	Ldec_xpage
9131f13597dSJung-uk Kim	andi.	$t1,$t1,4096-16
9141f13597dSJung-uk Kim	bne	Ldec_unaligned_ok
9151f13597dSJung-uk Kim
9161f13597dSJung-uk KimLdec_xpage:
9171f13597dSJung-uk Kim	lbz	$acc00,0($inp)
9181f13597dSJung-uk Kim	lbz	$acc01,1($inp)
9191f13597dSJung-uk Kim	lbz	$acc02,2($inp)
9201f13597dSJung-uk Kim	lbz	$s0,3($inp)
9211f13597dSJung-uk Kim	lbz	$acc04,4($inp)
9221f13597dSJung-uk Kim	lbz	$acc05,5($inp)
9231f13597dSJung-uk Kim	lbz	$acc06,6($inp)
9241f13597dSJung-uk Kim	lbz	$s1,7($inp)
9251f13597dSJung-uk Kim	lbz	$acc08,8($inp)
9261f13597dSJung-uk Kim	lbz	$acc09,9($inp)
9271f13597dSJung-uk Kim	lbz	$acc10,10($inp)
9281f13597dSJung-uk Kim	insrwi	$s0,$acc00,8,0
9291f13597dSJung-uk Kim	lbz	$s2,11($inp)
9301f13597dSJung-uk Kim	insrwi	$s1,$acc04,8,0
9311f13597dSJung-uk Kim	lbz	$acc12,12($inp)
9321f13597dSJung-uk Kim	insrwi	$s0,$acc01,8,8
9331f13597dSJung-uk Kim	lbz	$acc13,13($inp)
9341f13597dSJung-uk Kim	insrwi	$s1,$acc05,8,8
9351f13597dSJung-uk Kim	lbz	$acc14,14($inp)
9361f13597dSJung-uk Kim	insrwi	$s0,$acc02,8,16
9371f13597dSJung-uk Kim	lbz	$s3,15($inp)
9381f13597dSJung-uk Kim	insrwi	$s1,$acc06,8,16
9391f13597dSJung-uk Kim	insrwi	$s2,$acc08,8,0
9401f13597dSJung-uk Kim	insrwi	$s3,$acc12,8,0
9411f13597dSJung-uk Kim	insrwi	$s2,$acc09,8,8
9421f13597dSJung-uk Kim	insrwi	$s3,$acc13,8,8
9431f13597dSJung-uk Kim	insrwi	$s2,$acc10,8,16
9441f13597dSJung-uk Kim	insrwi	$s3,$acc14,8,16
9451f13597dSJung-uk Kim
9461f13597dSJung-uk Kim	bl	LAES_Td
9471f13597dSJung-uk Kim	bl	Lppc_AES_decrypt_compact
9487bded2dbSJung-uk Kim	$POP	$out,`$FRAME-$SIZE_T*19`($sp)
9491f13597dSJung-uk Kim
9501f13597dSJung-uk Kim	extrwi	$acc00,$s0,8,0
9511f13597dSJung-uk Kim	extrwi	$acc01,$s0,8,8
9521f13597dSJung-uk Kim	stb	$acc00,0($out)
9531f13597dSJung-uk Kim	extrwi	$acc02,$s0,8,16
9541f13597dSJung-uk Kim	stb	$acc01,1($out)
9551f13597dSJung-uk Kim	stb	$acc02,2($out)
9561f13597dSJung-uk Kim	extrwi	$acc04,$s1,8,0
9571f13597dSJung-uk Kim	stb	$s0,3($out)
9581f13597dSJung-uk Kim	extrwi	$acc05,$s1,8,8
9591f13597dSJung-uk Kim	stb	$acc04,4($out)
9601f13597dSJung-uk Kim	extrwi	$acc06,$s1,8,16
9611f13597dSJung-uk Kim	stb	$acc05,5($out)
9621f13597dSJung-uk Kim	stb	$acc06,6($out)
9631f13597dSJung-uk Kim	extrwi	$acc08,$s2,8,0
9641f13597dSJung-uk Kim	stb	$s1,7($out)
9651f13597dSJung-uk Kim	extrwi	$acc09,$s2,8,8
9661f13597dSJung-uk Kim	stb	$acc08,8($out)
9671f13597dSJung-uk Kim	extrwi	$acc10,$s2,8,16
9681f13597dSJung-uk Kim	stb	$acc09,9($out)
9691f13597dSJung-uk Kim	stb	$acc10,10($out)
9701f13597dSJung-uk Kim	extrwi	$acc12,$s3,8,0
9711f13597dSJung-uk Kim	stb	$s2,11($out)
9721f13597dSJung-uk Kim	extrwi	$acc13,$s3,8,8
9731f13597dSJung-uk Kim	stb	$acc12,12($out)
9741f13597dSJung-uk Kim	extrwi	$acc14,$s3,8,16
9751f13597dSJung-uk Kim	stb	$acc13,13($out)
9761f13597dSJung-uk Kim	stb	$acc14,14($out)
9771f13597dSJung-uk Kim	stb	$s3,15($out)
9781f13597dSJung-uk Kim
9791f13597dSJung-uk KimLdec_done:
9801f13597dSJung-uk Kim	$POP	r0,`$FRAME+$LRSAVE`($sp)
9811f13597dSJung-uk Kim	$POP	r14,`$FRAME-$SIZE_T*18`($sp)
9821f13597dSJung-uk Kim	$POP	r15,`$FRAME-$SIZE_T*17`($sp)
9831f13597dSJung-uk Kim	$POP	r16,`$FRAME-$SIZE_T*16`($sp)
9841f13597dSJung-uk Kim	$POP	r17,`$FRAME-$SIZE_T*15`($sp)
9851f13597dSJung-uk Kim	$POP	r18,`$FRAME-$SIZE_T*14`($sp)
9861f13597dSJung-uk Kim	$POP	r19,`$FRAME-$SIZE_T*13`($sp)
9871f13597dSJung-uk Kim	$POP	r20,`$FRAME-$SIZE_T*12`($sp)
9881f13597dSJung-uk Kim	$POP	r21,`$FRAME-$SIZE_T*11`($sp)
9891f13597dSJung-uk Kim	$POP	r22,`$FRAME-$SIZE_T*10`($sp)
9901f13597dSJung-uk Kim	$POP	r23,`$FRAME-$SIZE_T*9`($sp)
9911f13597dSJung-uk Kim	$POP	r24,`$FRAME-$SIZE_T*8`($sp)
9921f13597dSJung-uk Kim	$POP	r25,`$FRAME-$SIZE_T*7`($sp)
9931f13597dSJung-uk Kim	$POP	r26,`$FRAME-$SIZE_T*6`($sp)
9941f13597dSJung-uk Kim	$POP	r27,`$FRAME-$SIZE_T*5`($sp)
9951f13597dSJung-uk Kim	$POP	r28,`$FRAME-$SIZE_T*4`($sp)
9961f13597dSJung-uk Kim	$POP	r29,`$FRAME-$SIZE_T*3`($sp)
9971f13597dSJung-uk Kim	$POP	r30,`$FRAME-$SIZE_T*2`($sp)
9981f13597dSJung-uk Kim	$POP	r31,`$FRAME-$SIZE_T*1`($sp)
9991f13597dSJung-uk Kim	mtlr	r0
10001f13597dSJung-uk Kim	addi	$sp,$sp,$FRAME
10011f13597dSJung-uk Kim	blr
10021f13597dSJung-uk Kim	.long	0
10031f13597dSJung-uk Kim	.byte	0,12,4,1,0x80,18,3,0
10041f13597dSJung-uk Kim	.long	0
10051f13597dSJung-uk Kim
10061f13597dSJung-uk Kim.align	5
10071f13597dSJung-uk KimLppc_AES_decrypt:
10081f13597dSJung-uk Kim	lwz	$acc00,240($key)
10091f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,3
10101f13597dSJung-uk Kim	lwz	$t0,0($key)
10111f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2
10121f13597dSJung-uk Kim	lwz	$t1,4($key)
10131f13597dSJung-uk Kim	addi	$Tbl3,$Tbl0,1
10141f13597dSJung-uk Kim	lwz	$t2,8($key)
10151f13597dSJung-uk Kim	addi	$acc00,$acc00,-1
10161f13597dSJung-uk Kim	lwz	$t3,12($key)
10171f13597dSJung-uk Kim	addi	$key,$key,16
10181f13597dSJung-uk Kim	xor	$s0,$s0,$t0
10191f13597dSJung-uk Kim	xor	$s1,$s1,$t1
10201f13597dSJung-uk Kim	xor	$s2,$s2,$t2
10211f13597dSJung-uk Kim	xor	$s3,$s3,$t3
10221f13597dSJung-uk Kim	mtctr	$acc00
10231f13597dSJung-uk Kim.align	4
10241f13597dSJung-uk KimLdec_loop:
10251f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24+3`,21,28
10261f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24+3`,21,28
10271f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24+3`,21,28
10281f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24+3`,21,28
10291f13597dSJung-uk Kim	lwz	$t0,0($key)
10301f13597dSJung-uk Kim	rlwinm	$acc04,$s3,`32-16+3`,21,28
10311f13597dSJung-uk Kim	lwz	$t1,4($key)
10321f13597dSJung-uk Kim	rlwinm	$acc05,$s0,`32-16+3`,21,28
10331f13597dSJung-uk Kim	lwz	$t2,8($key)
10341f13597dSJung-uk Kim	rlwinm	$acc06,$s1,`32-16+3`,21,28
10351f13597dSJung-uk Kim	lwz	$t3,12($key)
10361f13597dSJung-uk Kim	rlwinm	$acc07,$s2,`32-16+3`,21,28
10371f13597dSJung-uk Kim	lwzx	$acc00,$Tbl0,$acc00
10381f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8+3`,21,28
10391f13597dSJung-uk Kim	lwzx	$acc01,$Tbl0,$acc01
10401f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8+3`,21,28
10411f13597dSJung-uk Kim	lwzx	$acc02,$Tbl0,$acc02
10421f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8+3`,21,28
10431f13597dSJung-uk Kim	lwzx	$acc03,$Tbl0,$acc03
10441f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8+3`,21,28
10451f13597dSJung-uk Kim	lwzx	$acc04,$Tbl1,$acc04
10461f13597dSJung-uk Kim	rlwinm	$acc12,$s1,`0+3`,21,28
10471f13597dSJung-uk Kim	lwzx	$acc05,$Tbl1,$acc05
10481f13597dSJung-uk Kim	rlwinm	$acc13,$s2,`0+3`,21,28
10491f13597dSJung-uk Kim	lwzx	$acc06,$Tbl1,$acc06
10501f13597dSJung-uk Kim	rlwinm	$acc14,$s3,`0+3`,21,28
10511f13597dSJung-uk Kim	lwzx	$acc07,$Tbl1,$acc07
10521f13597dSJung-uk Kim	rlwinm	$acc15,$s0,`0+3`,21,28
10531f13597dSJung-uk Kim	lwzx	$acc08,$Tbl2,$acc08
10541f13597dSJung-uk Kim	xor	$t0,$t0,$acc00
10551f13597dSJung-uk Kim	lwzx	$acc09,$Tbl2,$acc09
10561f13597dSJung-uk Kim	xor	$t1,$t1,$acc01
10571f13597dSJung-uk Kim	lwzx	$acc10,$Tbl2,$acc10
10581f13597dSJung-uk Kim	xor	$t2,$t2,$acc02
10591f13597dSJung-uk Kim	lwzx	$acc11,$Tbl2,$acc11
10601f13597dSJung-uk Kim	xor	$t3,$t3,$acc03
10611f13597dSJung-uk Kim	lwzx	$acc12,$Tbl3,$acc12
10621f13597dSJung-uk Kim	xor	$t0,$t0,$acc04
10631f13597dSJung-uk Kim	lwzx	$acc13,$Tbl3,$acc13
10641f13597dSJung-uk Kim	xor	$t1,$t1,$acc05
10651f13597dSJung-uk Kim	lwzx	$acc14,$Tbl3,$acc14
10661f13597dSJung-uk Kim	xor	$t2,$t2,$acc06
10671f13597dSJung-uk Kim	lwzx	$acc15,$Tbl3,$acc15
10681f13597dSJung-uk Kim	xor	$t3,$t3,$acc07
10691f13597dSJung-uk Kim	xor	$t0,$t0,$acc08
10701f13597dSJung-uk Kim	xor	$t1,$t1,$acc09
10711f13597dSJung-uk Kim	xor	$t2,$t2,$acc10
10721f13597dSJung-uk Kim	xor	$t3,$t3,$acc11
10731f13597dSJung-uk Kim	xor	$s0,$t0,$acc12
10741f13597dSJung-uk Kim	xor	$s1,$t1,$acc13
10751f13597dSJung-uk Kim	xor	$s2,$t2,$acc14
10761f13597dSJung-uk Kim	xor	$s3,$t3,$acc15
10771f13597dSJung-uk Kim	addi	$key,$key,16
1078b8721c16SJung-uk Kim	bdnz	Ldec_loop
10791f13597dSJung-uk Kim
10801f13597dSJung-uk Kim	addi	$Tbl2,$Tbl0,2048
10811f13597dSJung-uk Kim	nop
10821f13597dSJung-uk Kim	lwz	$t0,0($key)
10831f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
10841f13597dSJung-uk Kim	lwz	$t1,4($key)
10851f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
10861f13597dSJung-uk Kim	lwz	$t2,8($key)
10871f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
10881f13597dSJung-uk Kim	lwz	$t3,12($key)
10891f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
10901f13597dSJung-uk Kim	lwz	$acc08,`2048+0`($Tbl0)	! prefetch Td4
10911f13597dSJung-uk Kim	rlwinm	$acc04,$s3,`32-16`,24,31
10921f13597dSJung-uk Kim	lwz	$acc09,`2048+32`($Tbl0)
10931f13597dSJung-uk Kim	rlwinm	$acc05,$s0,`32-16`,24,31
10941f13597dSJung-uk Kim	lwz	$acc10,`2048+64`($Tbl0)
10951f13597dSJung-uk Kim	lbzx	$acc00,$Tbl2,$acc00
10961f13597dSJung-uk Kim	lwz	$acc11,`2048+96`($Tbl0)
10971f13597dSJung-uk Kim	lbzx	$acc01,$Tbl2,$acc01
10981f13597dSJung-uk Kim	lwz	$acc12,`2048+128`($Tbl0)
10991f13597dSJung-uk Kim	rlwinm	$acc06,$s1,`32-16`,24,31
11001f13597dSJung-uk Kim	lwz	$acc13,`2048+160`($Tbl0)
11011f13597dSJung-uk Kim	rlwinm	$acc07,$s2,`32-16`,24,31
11021f13597dSJung-uk Kim	lwz	$acc14,`2048+192`($Tbl0)
11031f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
11041f13597dSJung-uk Kim	lwz	$acc15,`2048+224`($Tbl0)
11051f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
11061f13597dSJung-uk Kim	lbzx	$acc02,$Tbl2,$acc02
11071f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
11081f13597dSJung-uk Kim	lbzx	$acc03,$Tbl2,$acc03
11091f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
11101f13597dSJung-uk Kim	lbzx	$acc04,$Tbl2,$acc04
11111f13597dSJung-uk Kim	rlwinm	$acc12,$s1,`0`,24,31
11121f13597dSJung-uk Kim	lbzx	$acc05,$Tbl2,$acc05
11131f13597dSJung-uk Kim	rlwinm	$acc13,$s2,`0`,24,31
11141f13597dSJung-uk Kim	lbzx	$acc06,$Tbl2,$acc06
11151f13597dSJung-uk Kim	rlwinm	$acc14,$s3,`0`,24,31
11161f13597dSJung-uk Kim	lbzx	$acc07,$Tbl2,$acc07
11171f13597dSJung-uk Kim	rlwinm	$acc15,$s0,`0`,24,31
11181f13597dSJung-uk Kim	lbzx	$acc08,$Tbl2,$acc08
11191f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
11201f13597dSJung-uk Kim	lbzx	$acc09,$Tbl2,$acc09
11211f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
11221f13597dSJung-uk Kim	lbzx	$acc10,$Tbl2,$acc10
11231f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
11241f13597dSJung-uk Kim	lbzx	$acc11,$Tbl2,$acc11
11251f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
11261f13597dSJung-uk Kim	lbzx	$acc12,$Tbl2,$acc12
11271f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
11281f13597dSJung-uk Kim	lbzx	$acc13,$Tbl2,$acc13
11291f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
11301f13597dSJung-uk Kim	lbzx	$acc14,$Tbl2,$acc14
11311f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
11321f13597dSJung-uk Kim	lbzx	$acc15,$Tbl2,$acc15
11331f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
11341f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
11351f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
11361f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
11371f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
11381f13597dSJung-uk Kim	or	$s0,$s0,$acc12
11391f13597dSJung-uk Kim	or	$s1,$s1,$acc13
11401f13597dSJung-uk Kim	or	$s2,$s2,$acc14
11411f13597dSJung-uk Kim	or	$s3,$s3,$acc15
11421f13597dSJung-uk Kim	xor	$s0,$s0,$t0
11431f13597dSJung-uk Kim	xor	$s1,$s1,$t1
11441f13597dSJung-uk Kim	xor	$s2,$s2,$t2
11451f13597dSJung-uk Kim	xor	$s3,$s3,$t3
11461f13597dSJung-uk Kim	blr
11471f13597dSJung-uk Kim	.long	0
11481f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
11491f13597dSJung-uk Kim
11501f13597dSJung-uk Kim.align	4
11511f13597dSJung-uk KimLppc_AES_decrypt_compact:
11521f13597dSJung-uk Kim	lwz	$acc00,240($key)
11531f13597dSJung-uk Kim	addi	$Tbl1,$Tbl0,2048
11541f13597dSJung-uk Kim	lwz	$t0,0($key)
11551f13597dSJung-uk Kim	lis	$mask80,0x8080
11561f13597dSJung-uk Kim	lwz	$t1,4($key)
11571f13597dSJung-uk Kim	lis	$mask1b,0x1b1b
11581f13597dSJung-uk Kim	lwz	$t2,8($key)
11591f13597dSJung-uk Kim	ori	$mask80,$mask80,0x8080
11601f13597dSJung-uk Kim	lwz	$t3,12($key)
11611f13597dSJung-uk Kim	ori	$mask1b,$mask1b,0x1b1b
11621f13597dSJung-uk Kim	addi	$key,$key,16
11631f13597dSJung-uk Kim___
11641f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==8);
11651f13597dSJung-uk Kim	insrdi	$mask80,$mask80,32,0
11661f13597dSJung-uk Kim	insrdi	$mask1b,$mask1b,32,0
11671f13597dSJung-uk Kim___
11681f13597dSJung-uk Kim$code.=<<___;
11691f13597dSJung-uk Kim	mtctr	$acc00
11701f13597dSJung-uk Kim.align	4
11711f13597dSJung-uk KimLdec_compact_loop:
11721f13597dSJung-uk Kim	xor	$s0,$s0,$t0
11731f13597dSJung-uk Kim	xor	$s1,$s1,$t1
11741f13597dSJung-uk Kim	rlwinm	$acc00,$s0,`32-24`,24,31
11751f13597dSJung-uk Kim	xor	$s2,$s2,$t2
11761f13597dSJung-uk Kim	rlwinm	$acc01,$s1,`32-24`,24,31
11771f13597dSJung-uk Kim	xor	$s3,$s3,$t3
11781f13597dSJung-uk Kim	rlwinm	$acc02,$s2,`32-24`,24,31
11791f13597dSJung-uk Kim	rlwinm	$acc03,$s3,`32-24`,24,31
11801f13597dSJung-uk Kim	rlwinm	$acc04,$s3,`32-16`,24,31
11811f13597dSJung-uk Kim	rlwinm	$acc05,$s0,`32-16`,24,31
11821f13597dSJung-uk Kim	rlwinm	$acc06,$s1,`32-16`,24,31
11831f13597dSJung-uk Kim	rlwinm	$acc07,$s2,`32-16`,24,31
11841f13597dSJung-uk Kim	lbzx	$acc00,$Tbl1,$acc00
11851f13597dSJung-uk Kim	rlwinm	$acc08,$s2,`32-8`,24,31
11861f13597dSJung-uk Kim	lbzx	$acc01,$Tbl1,$acc01
11871f13597dSJung-uk Kim	rlwinm	$acc09,$s3,`32-8`,24,31
11881f13597dSJung-uk Kim	lbzx	$acc02,$Tbl1,$acc02
11891f13597dSJung-uk Kim	rlwinm	$acc10,$s0,`32-8`,24,31
11901f13597dSJung-uk Kim	lbzx	$acc03,$Tbl1,$acc03
11911f13597dSJung-uk Kim	rlwinm	$acc11,$s1,`32-8`,24,31
11921f13597dSJung-uk Kim	lbzx	$acc04,$Tbl1,$acc04
11931f13597dSJung-uk Kim	rlwinm	$acc12,$s1,`0`,24,31
11941f13597dSJung-uk Kim	lbzx	$acc05,$Tbl1,$acc05
11951f13597dSJung-uk Kim	rlwinm	$acc13,$s2,`0`,24,31
11961f13597dSJung-uk Kim	lbzx	$acc06,$Tbl1,$acc06
11971f13597dSJung-uk Kim	rlwinm	$acc14,$s3,`0`,24,31
11981f13597dSJung-uk Kim	lbzx	$acc07,$Tbl1,$acc07
11991f13597dSJung-uk Kim	rlwinm	$acc15,$s0,`0`,24,31
12001f13597dSJung-uk Kim	lbzx	$acc08,$Tbl1,$acc08
12011f13597dSJung-uk Kim	rlwinm	$s0,$acc00,24,0,7
12021f13597dSJung-uk Kim	lbzx	$acc09,$Tbl1,$acc09
12031f13597dSJung-uk Kim	rlwinm	$s1,$acc01,24,0,7
12041f13597dSJung-uk Kim	lbzx	$acc10,$Tbl1,$acc10
12051f13597dSJung-uk Kim	rlwinm	$s2,$acc02,24,0,7
12061f13597dSJung-uk Kim	lbzx	$acc11,$Tbl1,$acc11
12071f13597dSJung-uk Kim	rlwinm	$s3,$acc03,24,0,7
12081f13597dSJung-uk Kim	lbzx	$acc12,$Tbl1,$acc12
12091f13597dSJung-uk Kim	rlwimi	$s0,$acc04,16,8,15
12101f13597dSJung-uk Kim	lbzx	$acc13,$Tbl1,$acc13
12111f13597dSJung-uk Kim	rlwimi	$s1,$acc05,16,8,15
12121f13597dSJung-uk Kim	lbzx	$acc14,$Tbl1,$acc14
12131f13597dSJung-uk Kim	rlwimi	$s2,$acc06,16,8,15
12141f13597dSJung-uk Kim	lbzx	$acc15,$Tbl1,$acc15
12151f13597dSJung-uk Kim	rlwimi	$s3,$acc07,16,8,15
12161f13597dSJung-uk Kim	rlwimi	$s0,$acc08,8,16,23
12171f13597dSJung-uk Kim	rlwimi	$s1,$acc09,8,16,23
12181f13597dSJung-uk Kim	rlwimi	$s2,$acc10,8,16,23
12191f13597dSJung-uk Kim	rlwimi	$s3,$acc11,8,16,23
12201f13597dSJung-uk Kim	lwz	$t0,0($key)
12211f13597dSJung-uk Kim	or	$s0,$s0,$acc12
12221f13597dSJung-uk Kim	lwz	$t1,4($key)
12231f13597dSJung-uk Kim	or	$s1,$s1,$acc13
12241f13597dSJung-uk Kim	lwz	$t2,8($key)
12251f13597dSJung-uk Kim	or	$s2,$s2,$acc14
12261f13597dSJung-uk Kim	lwz	$t3,12($key)
12271f13597dSJung-uk Kim	or	$s3,$s3,$acc15
12281f13597dSJung-uk Kim
12291f13597dSJung-uk Kim	addi	$key,$key,16
12301f13597dSJung-uk Kim	bdz	Ldec_compact_done
12311f13597dSJung-uk Kim___
12321f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==8);
12331f13597dSJung-uk Kim	# vectorized permutation improves decrypt performance by 10%
12341f13597dSJung-uk Kim	insrdi	$s0,$s1,32,0
12351f13597dSJung-uk Kim	insrdi	$s2,$s3,32,0
12361f13597dSJung-uk Kim
12371f13597dSJung-uk Kim	and	$acc00,$s0,$mask80	# r1=r0&0x80808080
12381f13597dSJung-uk Kim	and	$acc02,$s2,$mask80
12391f13597dSJung-uk Kim	srdi	$acc04,$acc00,7		# r1>>7
12401f13597dSJung-uk Kim	srdi	$acc06,$acc02,7
12411f13597dSJung-uk Kim	andc	$acc08,$s0,$mask80	# r0&0x7f7f7f7f
12421f13597dSJung-uk Kim	andc	$acc10,$s2,$mask80
12431f13597dSJung-uk Kim	sub	$acc00,$acc00,$acc04	# r1-(r1>>7)
12441f13597dSJung-uk Kim	sub	$acc02,$acc02,$acc06
12451f13597dSJung-uk Kim	add	$acc08,$acc08,$acc08	# (r0&0x7f7f7f7f)<<1
12461f13597dSJung-uk Kim	add	$acc10,$acc10,$acc10
12471f13597dSJung-uk Kim	and	$acc00,$acc00,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
12481f13597dSJung-uk Kim	and	$acc02,$acc02,$mask1b
12491f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08	# r2
12501f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
12511f13597dSJung-uk Kim
12521f13597dSJung-uk Kim	and	$acc04,$acc00,$mask80	# r1=r2&0x80808080
12531f13597dSJung-uk Kim	and	$acc06,$acc02,$mask80
12541f13597dSJung-uk Kim	srdi	$acc08,$acc04,7		# r1>>7
12551f13597dSJung-uk Kim	srdi	$acc10,$acc06,7
12561f13597dSJung-uk Kim	andc	$acc12,$acc00,$mask80	# r2&0x7f7f7f7f
12571f13597dSJung-uk Kim	andc	$acc14,$acc02,$mask80
12581f13597dSJung-uk Kim	sub	$acc04,$acc04,$acc08	# r1-(r1>>7)
12591f13597dSJung-uk Kim	sub	$acc06,$acc06,$acc10
12601f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r2&0x7f7f7f7f)<<1
12611f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
12621f13597dSJung-uk Kim	and	$acc04,$acc04,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
12631f13597dSJung-uk Kim	and	$acc06,$acc06,$mask1b
12641f13597dSJung-uk Kim	xor	$acc04,$acc04,$acc12	# r4
12651f13597dSJung-uk Kim	xor	$acc06,$acc06,$acc14
12661f13597dSJung-uk Kim
12671f13597dSJung-uk Kim	and	$acc08,$acc04,$mask80	# r1=r4&0x80808080
12681f13597dSJung-uk Kim	and	$acc10,$acc06,$mask80
12691f13597dSJung-uk Kim	srdi	$acc12,$acc08,7		# r1>>7
12701f13597dSJung-uk Kim	srdi	$acc14,$acc10,7
12711f13597dSJung-uk Kim	sub	$acc08,$acc08,$acc12	# r1-(r1>>7)
12721f13597dSJung-uk Kim	sub	$acc10,$acc10,$acc14
12731f13597dSJung-uk Kim	andc	$acc12,$acc04,$mask80	# r4&0x7f7f7f7f
12741f13597dSJung-uk Kim	andc	$acc14,$acc06,$mask80
12751f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r4&0x7f7f7f7f)<<1
12761f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
12771f13597dSJung-uk Kim	and	$acc08,$acc08,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
12781f13597dSJung-uk Kim	and	$acc10,$acc10,$mask1b
12791f13597dSJung-uk Kim	xor	$acc08,$acc08,$acc12	# r8
12801f13597dSJung-uk Kim	xor	$acc10,$acc10,$acc14
12811f13597dSJung-uk Kim
12821f13597dSJung-uk Kim	xor	$acc00,$acc00,$s0	# r2^r0
12831f13597dSJung-uk Kim	xor	$acc02,$acc02,$s2
12841f13597dSJung-uk Kim	xor	$acc04,$acc04,$s0	# r4^r0
12851f13597dSJung-uk Kim	xor	$acc06,$acc06,$s2
12861f13597dSJung-uk Kim
12871f13597dSJung-uk Kim	extrdi	$acc01,$acc00,32,0
12881f13597dSJung-uk Kim	extrdi	$acc03,$acc02,32,0
12891f13597dSJung-uk Kim	extrdi	$acc05,$acc04,32,0
12901f13597dSJung-uk Kim	extrdi	$acc07,$acc06,32,0
12911f13597dSJung-uk Kim	extrdi	$acc09,$acc08,32,0
12921f13597dSJung-uk Kim	extrdi	$acc11,$acc10,32,0
12931f13597dSJung-uk Kim___
12941f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==4);
12951f13597dSJung-uk Kim	and	$acc00,$s0,$mask80	# r1=r0&0x80808080
12961f13597dSJung-uk Kim	and	$acc01,$s1,$mask80
12971f13597dSJung-uk Kim	and	$acc02,$s2,$mask80
12981f13597dSJung-uk Kim	and	$acc03,$s3,$mask80
12991f13597dSJung-uk Kim	srwi	$acc04,$acc00,7		# r1>>7
13001f13597dSJung-uk Kim	andc	$acc08,$s0,$mask80	# r0&0x7f7f7f7f
13011f13597dSJung-uk Kim	srwi	$acc05,$acc01,7
13021f13597dSJung-uk Kim	andc	$acc09,$s1,$mask80
13031f13597dSJung-uk Kim	srwi	$acc06,$acc02,7
13041f13597dSJung-uk Kim	andc	$acc10,$s2,$mask80
13051f13597dSJung-uk Kim	srwi	$acc07,$acc03,7
13061f13597dSJung-uk Kim	andc	$acc11,$s3,$mask80
13071f13597dSJung-uk Kim	sub	$acc00,$acc00,$acc04	# r1-(r1>>7)
13081f13597dSJung-uk Kim	sub	$acc01,$acc01,$acc05
13091f13597dSJung-uk Kim	sub	$acc02,$acc02,$acc06
13101f13597dSJung-uk Kim	sub	$acc03,$acc03,$acc07
13111f13597dSJung-uk Kim	add	$acc08,$acc08,$acc08	# (r0&0x7f7f7f7f)<<1
13121f13597dSJung-uk Kim	add	$acc09,$acc09,$acc09
13131f13597dSJung-uk Kim	add	$acc10,$acc10,$acc10
13141f13597dSJung-uk Kim	add	$acc11,$acc11,$acc11
13151f13597dSJung-uk Kim	and	$acc00,$acc00,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
13161f13597dSJung-uk Kim	and	$acc01,$acc01,$mask1b
13171f13597dSJung-uk Kim	and	$acc02,$acc02,$mask1b
13181f13597dSJung-uk Kim	and	$acc03,$acc03,$mask1b
13191f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08	# r2
13201f13597dSJung-uk Kim	xor	$acc01,$acc01,$acc09
13211f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
13221f13597dSJung-uk Kim	xor	$acc03,$acc03,$acc11
13231f13597dSJung-uk Kim
13241f13597dSJung-uk Kim	and	$acc04,$acc00,$mask80	# r1=r2&0x80808080
13251f13597dSJung-uk Kim	and	$acc05,$acc01,$mask80
13261f13597dSJung-uk Kim	and	$acc06,$acc02,$mask80
13271f13597dSJung-uk Kim	and	$acc07,$acc03,$mask80
13281f13597dSJung-uk Kim	srwi	$acc08,$acc04,7		# r1>>7
13291f13597dSJung-uk Kim	andc	$acc12,$acc00,$mask80	# r2&0x7f7f7f7f
13301f13597dSJung-uk Kim	srwi	$acc09,$acc05,7
13311f13597dSJung-uk Kim	andc	$acc13,$acc01,$mask80
13321f13597dSJung-uk Kim	srwi	$acc10,$acc06,7
13331f13597dSJung-uk Kim	andc	$acc14,$acc02,$mask80
13341f13597dSJung-uk Kim	srwi	$acc11,$acc07,7
13351f13597dSJung-uk Kim	andc	$acc15,$acc03,$mask80
13361f13597dSJung-uk Kim	sub	$acc04,$acc04,$acc08	# r1-(r1>>7)
13371f13597dSJung-uk Kim	sub	$acc05,$acc05,$acc09
13381f13597dSJung-uk Kim	sub	$acc06,$acc06,$acc10
13391f13597dSJung-uk Kim	sub	$acc07,$acc07,$acc11
13401f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r2&0x7f7f7f7f)<<1
13411f13597dSJung-uk Kim	add	$acc13,$acc13,$acc13
13421f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
13431f13597dSJung-uk Kim	add	$acc15,$acc15,$acc15
13441f13597dSJung-uk Kim	and	$acc04,$acc04,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
13451f13597dSJung-uk Kim	and	$acc05,$acc05,$mask1b
13461f13597dSJung-uk Kim	and	$acc06,$acc06,$mask1b
13471f13597dSJung-uk Kim	and	$acc07,$acc07,$mask1b
13481f13597dSJung-uk Kim	xor	$acc04,$acc04,$acc12	# r4
13491f13597dSJung-uk Kim	xor	$acc05,$acc05,$acc13
13501f13597dSJung-uk Kim	xor	$acc06,$acc06,$acc14
13511f13597dSJung-uk Kim	xor	$acc07,$acc07,$acc15
13521f13597dSJung-uk Kim
13531f13597dSJung-uk Kim	and	$acc08,$acc04,$mask80	# r1=r4&0x80808080
13541f13597dSJung-uk Kim	and	$acc09,$acc05,$mask80
13551f13597dSJung-uk Kim	srwi	$acc12,$acc08,7		# r1>>7
13561f13597dSJung-uk Kim	and	$acc10,$acc06,$mask80
13571f13597dSJung-uk Kim	srwi	$acc13,$acc09,7
13581f13597dSJung-uk Kim	and	$acc11,$acc07,$mask80
13591f13597dSJung-uk Kim	srwi	$acc14,$acc10,7
13601f13597dSJung-uk Kim	sub	$acc08,$acc08,$acc12	# r1-(r1>>7)
13611f13597dSJung-uk Kim	srwi	$acc15,$acc11,7
13621f13597dSJung-uk Kim	sub	$acc09,$acc09,$acc13
13631f13597dSJung-uk Kim	sub	$acc10,$acc10,$acc14
13641f13597dSJung-uk Kim	sub	$acc11,$acc11,$acc15
13651f13597dSJung-uk Kim	andc	$acc12,$acc04,$mask80	# r4&0x7f7f7f7f
13661f13597dSJung-uk Kim	andc	$acc13,$acc05,$mask80
13671f13597dSJung-uk Kim	andc	$acc14,$acc06,$mask80
13681f13597dSJung-uk Kim	andc	$acc15,$acc07,$mask80
13691f13597dSJung-uk Kim	add	$acc12,$acc12,$acc12	# (r4&0x7f7f7f7f)<<1
13701f13597dSJung-uk Kim	add	$acc13,$acc13,$acc13
13711f13597dSJung-uk Kim	add	$acc14,$acc14,$acc14
13721f13597dSJung-uk Kim	add	$acc15,$acc15,$acc15
13731f13597dSJung-uk Kim	and	$acc08,$acc08,$mask1b	# (r1-(r1>>7))&0x1b1b1b1b
13741f13597dSJung-uk Kim	and	$acc09,$acc09,$mask1b
13751f13597dSJung-uk Kim	and	$acc10,$acc10,$mask1b
13761f13597dSJung-uk Kim	and	$acc11,$acc11,$mask1b
13771f13597dSJung-uk Kim	xor	$acc08,$acc08,$acc12	# r8
13781f13597dSJung-uk Kim	xor	$acc09,$acc09,$acc13
13791f13597dSJung-uk Kim	xor	$acc10,$acc10,$acc14
13801f13597dSJung-uk Kim	xor	$acc11,$acc11,$acc15
13811f13597dSJung-uk Kim
13821f13597dSJung-uk Kim	xor	$acc00,$acc00,$s0	# r2^r0
13831f13597dSJung-uk Kim	xor	$acc01,$acc01,$s1
13841f13597dSJung-uk Kim	xor	$acc02,$acc02,$s2
13851f13597dSJung-uk Kim	xor	$acc03,$acc03,$s3
13861f13597dSJung-uk Kim	xor	$acc04,$acc04,$s0	# r4^r0
13871f13597dSJung-uk Kim	xor	$acc05,$acc05,$s1
13881f13597dSJung-uk Kim	xor	$acc06,$acc06,$s2
13891f13597dSJung-uk Kim	xor	$acc07,$acc07,$s3
13901f13597dSJung-uk Kim___
13911f13597dSJung-uk Kim$code.=<<___;
13921f13597dSJung-uk Kim	rotrwi	$s0,$s0,8		# = ROTATE(r0,8)
13931f13597dSJung-uk Kim	rotrwi	$s1,$s1,8
13941f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# ^= r2^r0
13951f13597dSJung-uk Kim	rotrwi	$s2,$s2,8
13961f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
13971f13597dSJung-uk Kim	rotrwi	$s3,$s3,8
13981f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
13991f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
14001f13597dSJung-uk Kim	xor	$acc00,$acc00,$acc08
14011f13597dSJung-uk Kim	xor	$acc01,$acc01,$acc09
14021f13597dSJung-uk Kim	xor	$acc02,$acc02,$acc10
14031f13597dSJung-uk Kim	xor	$acc03,$acc03,$acc11
14041f13597dSJung-uk Kim	xor	$s0,$s0,$acc04		# ^= r4^r0
14051f13597dSJung-uk Kim	rotrwi	$acc00,$acc00,24
14061f13597dSJung-uk Kim	xor	$s1,$s1,$acc05
14071f13597dSJung-uk Kim	rotrwi	$acc01,$acc01,24
14081f13597dSJung-uk Kim	xor	$s2,$s2,$acc06
14091f13597dSJung-uk Kim	rotrwi	$acc02,$acc02,24
14101f13597dSJung-uk Kim	xor	$s3,$s3,$acc07
14111f13597dSJung-uk Kim	rotrwi	$acc03,$acc03,24
14121f13597dSJung-uk Kim	xor	$acc04,$acc04,$acc08
14131f13597dSJung-uk Kim	xor	$acc05,$acc05,$acc09
14141f13597dSJung-uk Kim	xor	$acc06,$acc06,$acc10
14151f13597dSJung-uk Kim	xor	$acc07,$acc07,$acc11
14161f13597dSJung-uk Kim	xor	$s0,$s0,$acc08		# ^= r8 [^((r4^r0)^(r2^r0)=r4^r2)]
14171f13597dSJung-uk Kim	rotrwi	$acc04,$acc04,16
14181f13597dSJung-uk Kim	xor	$s1,$s1,$acc09
14191f13597dSJung-uk Kim	rotrwi	$acc05,$acc05,16
14201f13597dSJung-uk Kim	xor	$s2,$s2,$acc10
14211f13597dSJung-uk Kim	rotrwi	$acc06,$acc06,16
14221f13597dSJung-uk Kim	xor	$s3,$s3,$acc11
14231f13597dSJung-uk Kim	rotrwi	$acc07,$acc07,16
14241f13597dSJung-uk Kim	xor	$s0,$s0,$acc00		# ^= ROTATE(r8^r2^r0,24)
14251f13597dSJung-uk Kim	rotrwi	$acc08,$acc08,8
14261f13597dSJung-uk Kim	xor	$s1,$s1,$acc01
14271f13597dSJung-uk Kim	rotrwi	$acc09,$acc09,8
14281f13597dSJung-uk Kim	xor	$s2,$s2,$acc02
14291f13597dSJung-uk Kim	rotrwi	$acc10,$acc10,8
14301f13597dSJung-uk Kim	xor	$s3,$s3,$acc03
14311f13597dSJung-uk Kim	rotrwi	$acc11,$acc11,8
14321f13597dSJung-uk Kim	xor	$s0,$s0,$acc04		# ^= ROTATE(r8^r4^r0,16)
14331f13597dSJung-uk Kim	xor	$s1,$s1,$acc05
14341f13597dSJung-uk Kim	xor	$s2,$s2,$acc06
14351f13597dSJung-uk Kim	xor	$s3,$s3,$acc07
14361f13597dSJung-uk Kim	xor	$s0,$s0,$acc08		# ^= ROTATE(r8,8)
14371f13597dSJung-uk Kim	xor	$s1,$s1,$acc09
14381f13597dSJung-uk Kim	xor	$s2,$s2,$acc10
14391f13597dSJung-uk Kim	xor	$s3,$s3,$acc11
14401f13597dSJung-uk Kim
14411f13597dSJung-uk Kim	b	Ldec_compact_loop
14421f13597dSJung-uk Kim.align	4
14431f13597dSJung-uk KimLdec_compact_done:
14441f13597dSJung-uk Kim	xor	$s0,$s0,$t0
14451f13597dSJung-uk Kim	xor	$s1,$s1,$t1
14461f13597dSJung-uk Kim	xor	$s2,$s2,$t2
14471f13597dSJung-uk Kim	xor	$s3,$s3,$t3
14481f13597dSJung-uk Kim	blr
14491f13597dSJung-uk Kim	.long	0
14501f13597dSJung-uk Kim	.byte	0,12,0x14,0,0,0,0,0
14517bded2dbSJung-uk Kim.size	.AES_decrypt,.-.AES_decrypt
14521f13597dSJung-uk Kim
14531f13597dSJung-uk Kim.asciz	"AES for PPC, CRYPTOGAMS by <appro\@openssl.org>"
14541f13597dSJung-uk Kim.align	7
14551f13597dSJung-uk Kim___
14561f13597dSJung-uk Kim
14571f13597dSJung-uk Kim$code =~ s/\`([^\`]*)\`/eval $1/gem;
14581f13597dSJung-uk Kimprint $code;
14591f13597dSJung-uk Kimclose STDOUT;
1460