1*1f13597dSJung-uk Kim#!/usr/bin/env perl 2*1f13597dSJung-uk Kim 3*1f13597dSJung-uk Kim# ==================================================================== 4*1f13597dSJung-uk Kim# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL 5*1f13597dSJung-uk Kim# project. The module is, however, dual licensed under OpenSSL and 6*1f13597dSJung-uk Kim# CRYPTOGAMS licenses depending on where you obtain it. For further 7*1f13597dSJung-uk Kim# details see http://www.openssl.org/~appro/cryptogams/. 8*1f13597dSJung-uk Kim# ==================================================================== 9*1f13597dSJung-uk Kim 10*1f13597dSJung-uk Kim# Needs more work: key setup, CBC routine... 11*1f13597dSJung-uk Kim# 12*1f13597dSJung-uk Kim# ppc_AES_[en|de]crypt perform at 18 cycles per byte processed with 13*1f13597dSJung-uk Kim# 128-bit key, which is ~40% better than 64-bit code generated by gcc 14*1f13597dSJung-uk Kim# 4.0. But these are not the ones currently used! Their "compact" 15*1f13597dSJung-uk Kim# counterparts are, for security reason. ppc_AES_encrypt_compact runs 16*1f13597dSJung-uk Kim# at 1/2 of ppc_AES_encrypt speed, while ppc_AES_decrypt_compact - 17*1f13597dSJung-uk Kim# at 1/3 of ppc_AES_decrypt. 18*1f13597dSJung-uk Kim 19*1f13597dSJung-uk Kim# February 2010 20*1f13597dSJung-uk Kim# 21*1f13597dSJung-uk Kim# Rescheduling instructions to favour Power6 pipeline gave 10% 22*1f13597dSJung-uk Kim# performance improvement on the platfrom in question (and marginal 23*1f13597dSJung-uk Kim# improvement even on others). It should be noted that Power6 fails 24*1f13597dSJung-uk Kim# to process byte in 18 cycles, only in 23, because it fails to issue 25*1f13597dSJung-uk Kim# 4 load instructions in two cycles, only in 3. As result non-compact 26*1f13597dSJung-uk Kim# block subroutines are 25% slower than one would expect. Compact 27*1f13597dSJung-uk Kim# functions scale better, because they have pure computational part, 28*1f13597dSJung-uk Kim# which scales perfectly with clock frequency. To be specific 29*1f13597dSJung-uk Kim# ppc_AES_encrypt_compact operates at 42 cycles per byte, while 30*1f13597dSJung-uk Kim# ppc_AES_decrypt_compact - at 55 (in 64-bit build). 31*1f13597dSJung-uk Kim 32*1f13597dSJung-uk Kim$flavour = shift; 33*1f13597dSJung-uk Kim 34*1f13597dSJung-uk Kimif ($flavour =~ /64/) { 35*1f13597dSJung-uk Kim $SIZE_T =8; 36*1f13597dSJung-uk Kim $LRSAVE =2*$SIZE_T; 37*1f13597dSJung-uk Kim $STU ="stdu"; 38*1f13597dSJung-uk Kim $POP ="ld"; 39*1f13597dSJung-uk Kim $PUSH ="std"; 40*1f13597dSJung-uk Kim} elsif ($flavour =~ /32/) { 41*1f13597dSJung-uk Kim $SIZE_T =4; 42*1f13597dSJung-uk Kim $LRSAVE =$SIZE_T; 43*1f13597dSJung-uk Kim $STU ="stwu"; 44*1f13597dSJung-uk Kim $POP ="lwz"; 45*1f13597dSJung-uk Kim $PUSH ="stw"; 46*1f13597dSJung-uk Kim} else { die "nonsense $flavour"; } 47*1f13597dSJung-uk Kim 48*1f13597dSJung-uk Kim$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; 49*1f13597dSJung-uk Kim( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or 50*1f13597dSJung-uk Kim( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or 51*1f13597dSJung-uk Kimdie "can't locate ppc-xlate.pl"; 52*1f13597dSJung-uk Kim 53*1f13597dSJung-uk Kimopen STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!"; 54*1f13597dSJung-uk Kim 55*1f13597dSJung-uk Kim$FRAME=32*$SIZE_T; 56*1f13597dSJung-uk Kim 57*1f13597dSJung-uk Kimsub _data_word() 58*1f13597dSJung-uk Kim{ my $i; 59*1f13597dSJung-uk Kim while(defined($i=shift)) { $code.=sprintf"\t.long\t0x%08x,0x%08x\n",$i,$i; } 60*1f13597dSJung-uk Kim} 61*1f13597dSJung-uk Kim 62*1f13597dSJung-uk Kim$sp="r1"; 63*1f13597dSJung-uk Kim$toc="r2"; 64*1f13597dSJung-uk Kim$inp="r3"; 65*1f13597dSJung-uk Kim$out="r4"; 66*1f13597dSJung-uk Kim$key="r5"; 67*1f13597dSJung-uk Kim 68*1f13597dSJung-uk Kim$Tbl0="r3"; 69*1f13597dSJung-uk Kim$Tbl1="r6"; 70*1f13597dSJung-uk Kim$Tbl2="r7"; 71*1f13597dSJung-uk Kim$Tbl3="r2"; 72*1f13597dSJung-uk Kim 73*1f13597dSJung-uk Kim$s0="r8"; 74*1f13597dSJung-uk Kim$s1="r9"; 75*1f13597dSJung-uk Kim$s2="r10"; 76*1f13597dSJung-uk Kim$s3="r11"; 77*1f13597dSJung-uk Kim 78*1f13597dSJung-uk Kim$t0="r12"; 79*1f13597dSJung-uk Kim$t1="r13"; 80*1f13597dSJung-uk Kim$t2="r14"; 81*1f13597dSJung-uk Kim$t3="r15"; 82*1f13597dSJung-uk Kim 83*1f13597dSJung-uk Kim$acc00="r16"; 84*1f13597dSJung-uk Kim$acc01="r17"; 85*1f13597dSJung-uk Kim$acc02="r18"; 86*1f13597dSJung-uk Kim$acc03="r19"; 87*1f13597dSJung-uk Kim 88*1f13597dSJung-uk Kim$acc04="r20"; 89*1f13597dSJung-uk Kim$acc05="r21"; 90*1f13597dSJung-uk Kim$acc06="r22"; 91*1f13597dSJung-uk Kim$acc07="r23"; 92*1f13597dSJung-uk Kim 93*1f13597dSJung-uk Kim$acc08="r24"; 94*1f13597dSJung-uk Kim$acc09="r25"; 95*1f13597dSJung-uk Kim$acc10="r26"; 96*1f13597dSJung-uk Kim$acc11="r27"; 97*1f13597dSJung-uk Kim 98*1f13597dSJung-uk Kim$acc12="r28"; 99*1f13597dSJung-uk Kim$acc13="r29"; 100*1f13597dSJung-uk Kim$acc14="r30"; 101*1f13597dSJung-uk Kim$acc15="r31"; 102*1f13597dSJung-uk Kim 103*1f13597dSJung-uk Kim# stay away from TLS pointer 104*1f13597dSJung-uk Kimif ($SIZE_T==8) { die if ($t1 ne "r13"); $t1="r0"; } 105*1f13597dSJung-uk Kimelse { die if ($Tbl3 ne "r2"); $Tbl3=$t0; $t0="r0"; } 106*1f13597dSJung-uk Kim$mask80=$Tbl2; 107*1f13597dSJung-uk Kim$mask1b=$Tbl3; 108*1f13597dSJung-uk Kim 109*1f13597dSJung-uk Kim$code.=<<___; 110*1f13597dSJung-uk Kim.machine "any" 111*1f13597dSJung-uk Kim.text 112*1f13597dSJung-uk Kim 113*1f13597dSJung-uk Kim.align 7 114*1f13597dSJung-uk KimLAES_Te: 115*1f13597dSJung-uk Kim mflr r0 116*1f13597dSJung-uk Kim bcl 20,31,\$+4 117*1f13597dSJung-uk Kim mflr $Tbl0 ; vvvvv "distance" between . and 1st data entry 118*1f13597dSJung-uk Kim addi $Tbl0,$Tbl0,`128-8` 119*1f13597dSJung-uk Kim mtlr r0 120*1f13597dSJung-uk Kim blr 121*1f13597dSJung-uk Kim .long 0 122*1f13597dSJung-uk Kim .byte 0,12,0x14,0,0,0,0,0 123*1f13597dSJung-uk Kim .space `64-9*4` 124*1f13597dSJung-uk KimLAES_Td: 125*1f13597dSJung-uk Kim mflr r0 126*1f13597dSJung-uk Kim bcl 20,31,\$+4 127*1f13597dSJung-uk Kim mflr $Tbl0 ; vvvvvvvv "distance" between . and 1st data entry 128*1f13597dSJung-uk Kim addi $Tbl0,$Tbl0,`128-64-8+2048+256` 129*1f13597dSJung-uk Kim mtlr r0 130*1f13597dSJung-uk Kim blr 131*1f13597dSJung-uk Kim .long 0 132*1f13597dSJung-uk Kim .byte 0,12,0x14,0,0,0,0,0 133*1f13597dSJung-uk Kim .space `128-64-9*4` 134*1f13597dSJung-uk Kim___ 135*1f13597dSJung-uk Kim&_data_word( 136*1f13597dSJung-uk Kim 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 137*1f13597dSJung-uk Kim 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 138*1f13597dSJung-uk Kim 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 139*1f13597dSJung-uk Kim 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 140*1f13597dSJung-uk Kim 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 141*1f13597dSJung-uk Kim 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 142*1f13597dSJung-uk Kim 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 143*1f13597dSJung-uk Kim 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 144*1f13597dSJung-uk Kim 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 145*1f13597dSJung-uk Kim 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 146*1f13597dSJung-uk Kim 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 147*1f13597dSJung-uk Kim 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 148*1f13597dSJung-uk Kim 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 149*1f13597dSJung-uk Kim 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 150*1f13597dSJung-uk Kim 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 151*1f13597dSJung-uk Kim 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 152*1f13597dSJung-uk Kim 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 153*1f13597dSJung-uk Kim 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 154*1f13597dSJung-uk Kim 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 155*1f13597dSJung-uk Kim 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 156*1f13597dSJung-uk Kim 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 157*1f13597dSJung-uk Kim 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 158*1f13597dSJung-uk Kim 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 159*1f13597dSJung-uk Kim 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 160*1f13597dSJung-uk Kim 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 161*1f13597dSJung-uk Kim 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 162*1f13597dSJung-uk Kim 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 163*1f13597dSJung-uk Kim 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 164*1f13597dSJung-uk Kim 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 165*1f13597dSJung-uk Kim 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 166*1f13597dSJung-uk Kim 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 167*1f13597dSJung-uk Kim 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 168*1f13597dSJung-uk Kim 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 169*1f13597dSJung-uk Kim 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 170*1f13597dSJung-uk Kim 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 171*1f13597dSJung-uk Kim 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 172*1f13597dSJung-uk Kim 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 173*1f13597dSJung-uk Kim 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 174*1f13597dSJung-uk Kim 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 175*1f13597dSJung-uk Kim 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 176*1f13597dSJung-uk Kim 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 177*1f13597dSJung-uk Kim 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 178*1f13597dSJung-uk Kim 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 179*1f13597dSJung-uk Kim 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 180*1f13597dSJung-uk Kim 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 181*1f13597dSJung-uk Kim 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 182*1f13597dSJung-uk Kim 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 183*1f13597dSJung-uk Kim 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 184*1f13597dSJung-uk Kim 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 185*1f13597dSJung-uk Kim 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 186*1f13597dSJung-uk Kim 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 187*1f13597dSJung-uk Kim 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 188*1f13597dSJung-uk Kim 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 189*1f13597dSJung-uk Kim 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 190*1f13597dSJung-uk Kim 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 191*1f13597dSJung-uk Kim 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 192*1f13597dSJung-uk Kim 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 193*1f13597dSJung-uk Kim 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 194*1f13597dSJung-uk Kim 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 195*1f13597dSJung-uk Kim 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 196*1f13597dSJung-uk Kim 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 197*1f13597dSJung-uk Kim 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 198*1f13597dSJung-uk Kim 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 199*1f13597dSJung-uk Kim 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a); 200*1f13597dSJung-uk Kim$code.=<<___; 201*1f13597dSJung-uk Kim.byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 202*1f13597dSJung-uk Kim.byte 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76 203*1f13597dSJung-uk Kim.byte 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0 204*1f13597dSJung-uk Kim.byte 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0 205*1f13597dSJung-uk Kim.byte 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc 206*1f13597dSJung-uk Kim.byte 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15 207*1f13597dSJung-uk Kim.byte 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a 208*1f13597dSJung-uk Kim.byte 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75 209*1f13597dSJung-uk Kim.byte 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0 210*1f13597dSJung-uk Kim.byte 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84 211*1f13597dSJung-uk Kim.byte 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b 212*1f13597dSJung-uk Kim.byte 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf 213*1f13597dSJung-uk Kim.byte 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85 214*1f13597dSJung-uk Kim.byte 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8 215*1f13597dSJung-uk Kim.byte 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5 216*1f13597dSJung-uk Kim.byte 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2 217*1f13597dSJung-uk Kim.byte 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17 218*1f13597dSJung-uk Kim.byte 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73 219*1f13597dSJung-uk Kim.byte 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88 220*1f13597dSJung-uk Kim.byte 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb 221*1f13597dSJung-uk Kim.byte 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c 222*1f13597dSJung-uk Kim.byte 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79 223*1f13597dSJung-uk Kim.byte 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9 224*1f13597dSJung-uk Kim.byte 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08 225*1f13597dSJung-uk Kim.byte 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6 226*1f13597dSJung-uk Kim.byte 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a 227*1f13597dSJung-uk Kim.byte 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e 228*1f13597dSJung-uk Kim.byte 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e 229*1f13597dSJung-uk Kim.byte 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94 230*1f13597dSJung-uk Kim.byte 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf 231*1f13597dSJung-uk Kim.byte 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68 232*1f13597dSJung-uk Kim.byte 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 233*1f13597dSJung-uk Kim___ 234*1f13597dSJung-uk Kim&_data_word( 235*1f13597dSJung-uk Kim 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 236*1f13597dSJung-uk Kim 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 237*1f13597dSJung-uk Kim 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 238*1f13597dSJung-uk Kim 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 239*1f13597dSJung-uk Kim 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 240*1f13597dSJung-uk Kim 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 241*1f13597dSJung-uk Kim 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 242*1f13597dSJung-uk Kim 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 243*1f13597dSJung-uk Kim 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 244*1f13597dSJung-uk Kim 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 245*1f13597dSJung-uk Kim 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 246*1f13597dSJung-uk Kim 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 247*1f13597dSJung-uk Kim 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 248*1f13597dSJung-uk Kim 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 249*1f13597dSJung-uk Kim 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 250*1f13597dSJung-uk Kim 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 251*1f13597dSJung-uk Kim 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 252*1f13597dSJung-uk Kim 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 253*1f13597dSJung-uk Kim 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 254*1f13597dSJung-uk Kim 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 255*1f13597dSJung-uk Kim 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 256*1f13597dSJung-uk Kim 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 257*1f13597dSJung-uk Kim 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 258*1f13597dSJung-uk Kim 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 259*1f13597dSJung-uk Kim 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 260*1f13597dSJung-uk Kim 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 261*1f13597dSJung-uk Kim 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 262*1f13597dSJung-uk Kim 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 263*1f13597dSJung-uk Kim 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 264*1f13597dSJung-uk Kim 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 265*1f13597dSJung-uk Kim 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 266*1f13597dSJung-uk Kim 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 267*1f13597dSJung-uk Kim 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 268*1f13597dSJung-uk Kim 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 269*1f13597dSJung-uk Kim 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 270*1f13597dSJung-uk Kim 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 271*1f13597dSJung-uk Kim 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 272*1f13597dSJung-uk Kim 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 273*1f13597dSJung-uk Kim 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 274*1f13597dSJung-uk Kim 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 275*1f13597dSJung-uk Kim 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 276*1f13597dSJung-uk Kim 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 277*1f13597dSJung-uk Kim 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 278*1f13597dSJung-uk Kim 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 279*1f13597dSJung-uk Kim 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 280*1f13597dSJung-uk Kim 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 281*1f13597dSJung-uk Kim 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 282*1f13597dSJung-uk Kim 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 283*1f13597dSJung-uk Kim 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 284*1f13597dSJung-uk Kim 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 285*1f13597dSJung-uk Kim 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 286*1f13597dSJung-uk Kim 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 287*1f13597dSJung-uk Kim 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 288*1f13597dSJung-uk Kim 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 289*1f13597dSJung-uk Kim 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 290*1f13597dSJung-uk Kim 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 291*1f13597dSJung-uk Kim 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 292*1f13597dSJung-uk Kim 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 293*1f13597dSJung-uk Kim 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 294*1f13597dSJung-uk Kim 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 295*1f13597dSJung-uk Kim 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 296*1f13597dSJung-uk Kim 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 297*1f13597dSJung-uk Kim 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 298*1f13597dSJung-uk Kim 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742); 299*1f13597dSJung-uk Kim$code.=<<___; 300*1f13597dSJung-uk Kim.byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38 301*1f13597dSJung-uk Kim.byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb 302*1f13597dSJung-uk Kim.byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87 303*1f13597dSJung-uk Kim.byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb 304*1f13597dSJung-uk Kim.byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d 305*1f13597dSJung-uk Kim.byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e 306*1f13597dSJung-uk Kim.byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2 307*1f13597dSJung-uk Kim.byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 308*1f13597dSJung-uk Kim.byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16 309*1f13597dSJung-uk Kim.byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 310*1f13597dSJung-uk Kim.byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda 311*1f13597dSJung-uk Kim.byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 312*1f13597dSJung-uk Kim.byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a 313*1f13597dSJung-uk Kim.byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 314*1f13597dSJung-uk Kim.byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02 315*1f13597dSJung-uk Kim.byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b 316*1f13597dSJung-uk Kim.byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea 317*1f13597dSJung-uk Kim.byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 318*1f13597dSJung-uk Kim.byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85 319*1f13597dSJung-uk Kim.byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e 320*1f13597dSJung-uk Kim.byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89 321*1f13597dSJung-uk Kim.byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b 322*1f13597dSJung-uk Kim.byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20 323*1f13597dSJung-uk Kim.byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 324*1f13597dSJung-uk Kim.byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31 325*1f13597dSJung-uk Kim.byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f 326*1f13597dSJung-uk Kim.byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d 327*1f13597dSJung-uk Kim.byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef 328*1f13597dSJung-uk Kim.byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0 329*1f13597dSJung-uk Kim.byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 330*1f13597dSJung-uk Kim.byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26 331*1f13597dSJung-uk Kim.byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d 332*1f13597dSJung-uk Kim 333*1f13597dSJung-uk Kim 334*1f13597dSJung-uk Kim.globl .AES_encrypt 335*1f13597dSJung-uk Kim.align 7 336*1f13597dSJung-uk Kim.AES_encrypt: 337*1f13597dSJung-uk Kim $STU $sp,-$FRAME($sp) 338*1f13597dSJung-uk Kim mflr r0 339*1f13597dSJung-uk Kim 340*1f13597dSJung-uk Kim $PUSH $toc,`$FRAME-$SIZE_T*20`($sp) 341*1f13597dSJung-uk Kim $PUSH r13,`$FRAME-$SIZE_T*19`($sp) 342*1f13597dSJung-uk Kim $PUSH r14,`$FRAME-$SIZE_T*18`($sp) 343*1f13597dSJung-uk Kim $PUSH r15,`$FRAME-$SIZE_T*17`($sp) 344*1f13597dSJung-uk Kim $PUSH r16,`$FRAME-$SIZE_T*16`($sp) 345*1f13597dSJung-uk Kim $PUSH r17,`$FRAME-$SIZE_T*15`($sp) 346*1f13597dSJung-uk Kim $PUSH r18,`$FRAME-$SIZE_T*14`($sp) 347*1f13597dSJung-uk Kim $PUSH r19,`$FRAME-$SIZE_T*13`($sp) 348*1f13597dSJung-uk Kim $PUSH r20,`$FRAME-$SIZE_T*12`($sp) 349*1f13597dSJung-uk Kim $PUSH r21,`$FRAME-$SIZE_T*11`($sp) 350*1f13597dSJung-uk Kim $PUSH r22,`$FRAME-$SIZE_T*10`($sp) 351*1f13597dSJung-uk Kim $PUSH r23,`$FRAME-$SIZE_T*9`($sp) 352*1f13597dSJung-uk Kim $PUSH r24,`$FRAME-$SIZE_T*8`($sp) 353*1f13597dSJung-uk Kim $PUSH r25,`$FRAME-$SIZE_T*7`($sp) 354*1f13597dSJung-uk Kim $PUSH r26,`$FRAME-$SIZE_T*6`($sp) 355*1f13597dSJung-uk Kim $PUSH r27,`$FRAME-$SIZE_T*5`($sp) 356*1f13597dSJung-uk Kim $PUSH r28,`$FRAME-$SIZE_T*4`($sp) 357*1f13597dSJung-uk Kim $PUSH r29,`$FRAME-$SIZE_T*3`($sp) 358*1f13597dSJung-uk Kim $PUSH r30,`$FRAME-$SIZE_T*2`($sp) 359*1f13597dSJung-uk Kim $PUSH r31,`$FRAME-$SIZE_T*1`($sp) 360*1f13597dSJung-uk Kim $PUSH r0,`$FRAME+$LRSAVE`($sp) 361*1f13597dSJung-uk Kim 362*1f13597dSJung-uk Kim andi. $t0,$inp,3 363*1f13597dSJung-uk Kim andi. $t1,$out,3 364*1f13597dSJung-uk Kim or. $t0,$t0,$t1 365*1f13597dSJung-uk Kim bne Lenc_unaligned 366*1f13597dSJung-uk Kim 367*1f13597dSJung-uk KimLenc_unaligned_ok: 368*1f13597dSJung-uk Kim lwz $s0,0($inp) 369*1f13597dSJung-uk Kim lwz $s1,4($inp) 370*1f13597dSJung-uk Kim lwz $s2,8($inp) 371*1f13597dSJung-uk Kim lwz $s3,12($inp) 372*1f13597dSJung-uk Kim bl LAES_Te 373*1f13597dSJung-uk Kim bl Lppc_AES_encrypt_compact 374*1f13597dSJung-uk Kim stw $s0,0($out) 375*1f13597dSJung-uk Kim stw $s1,4($out) 376*1f13597dSJung-uk Kim stw $s2,8($out) 377*1f13597dSJung-uk Kim stw $s3,12($out) 378*1f13597dSJung-uk Kim b Lenc_done 379*1f13597dSJung-uk Kim 380*1f13597dSJung-uk KimLenc_unaligned: 381*1f13597dSJung-uk Kim subfic $t0,$inp,4096 382*1f13597dSJung-uk Kim subfic $t1,$out,4096 383*1f13597dSJung-uk Kim andi. $t0,$t0,4096-16 384*1f13597dSJung-uk Kim beq Lenc_xpage 385*1f13597dSJung-uk Kim andi. $t1,$t1,4096-16 386*1f13597dSJung-uk Kim bne Lenc_unaligned_ok 387*1f13597dSJung-uk Kim 388*1f13597dSJung-uk KimLenc_xpage: 389*1f13597dSJung-uk Kim lbz $acc00,0($inp) 390*1f13597dSJung-uk Kim lbz $acc01,1($inp) 391*1f13597dSJung-uk Kim lbz $acc02,2($inp) 392*1f13597dSJung-uk Kim lbz $s0,3($inp) 393*1f13597dSJung-uk Kim lbz $acc04,4($inp) 394*1f13597dSJung-uk Kim lbz $acc05,5($inp) 395*1f13597dSJung-uk Kim lbz $acc06,6($inp) 396*1f13597dSJung-uk Kim lbz $s1,7($inp) 397*1f13597dSJung-uk Kim lbz $acc08,8($inp) 398*1f13597dSJung-uk Kim lbz $acc09,9($inp) 399*1f13597dSJung-uk Kim lbz $acc10,10($inp) 400*1f13597dSJung-uk Kim insrwi $s0,$acc00,8,0 401*1f13597dSJung-uk Kim lbz $s2,11($inp) 402*1f13597dSJung-uk Kim insrwi $s1,$acc04,8,0 403*1f13597dSJung-uk Kim lbz $acc12,12($inp) 404*1f13597dSJung-uk Kim insrwi $s0,$acc01,8,8 405*1f13597dSJung-uk Kim lbz $acc13,13($inp) 406*1f13597dSJung-uk Kim insrwi $s1,$acc05,8,8 407*1f13597dSJung-uk Kim lbz $acc14,14($inp) 408*1f13597dSJung-uk Kim insrwi $s0,$acc02,8,16 409*1f13597dSJung-uk Kim lbz $s3,15($inp) 410*1f13597dSJung-uk Kim insrwi $s1,$acc06,8,16 411*1f13597dSJung-uk Kim insrwi $s2,$acc08,8,0 412*1f13597dSJung-uk Kim insrwi $s3,$acc12,8,0 413*1f13597dSJung-uk Kim insrwi $s2,$acc09,8,8 414*1f13597dSJung-uk Kim insrwi $s3,$acc13,8,8 415*1f13597dSJung-uk Kim insrwi $s2,$acc10,8,16 416*1f13597dSJung-uk Kim insrwi $s3,$acc14,8,16 417*1f13597dSJung-uk Kim 418*1f13597dSJung-uk Kim bl LAES_Te 419*1f13597dSJung-uk Kim bl Lppc_AES_encrypt_compact 420*1f13597dSJung-uk Kim 421*1f13597dSJung-uk Kim extrwi $acc00,$s0,8,0 422*1f13597dSJung-uk Kim extrwi $acc01,$s0,8,8 423*1f13597dSJung-uk Kim stb $acc00,0($out) 424*1f13597dSJung-uk Kim extrwi $acc02,$s0,8,16 425*1f13597dSJung-uk Kim stb $acc01,1($out) 426*1f13597dSJung-uk Kim stb $acc02,2($out) 427*1f13597dSJung-uk Kim extrwi $acc04,$s1,8,0 428*1f13597dSJung-uk Kim stb $s0,3($out) 429*1f13597dSJung-uk Kim extrwi $acc05,$s1,8,8 430*1f13597dSJung-uk Kim stb $acc04,4($out) 431*1f13597dSJung-uk Kim extrwi $acc06,$s1,8,16 432*1f13597dSJung-uk Kim stb $acc05,5($out) 433*1f13597dSJung-uk Kim stb $acc06,6($out) 434*1f13597dSJung-uk Kim extrwi $acc08,$s2,8,0 435*1f13597dSJung-uk Kim stb $s1,7($out) 436*1f13597dSJung-uk Kim extrwi $acc09,$s2,8,8 437*1f13597dSJung-uk Kim stb $acc08,8($out) 438*1f13597dSJung-uk Kim extrwi $acc10,$s2,8,16 439*1f13597dSJung-uk Kim stb $acc09,9($out) 440*1f13597dSJung-uk Kim stb $acc10,10($out) 441*1f13597dSJung-uk Kim extrwi $acc12,$s3,8,0 442*1f13597dSJung-uk Kim stb $s2,11($out) 443*1f13597dSJung-uk Kim extrwi $acc13,$s3,8,8 444*1f13597dSJung-uk Kim stb $acc12,12($out) 445*1f13597dSJung-uk Kim extrwi $acc14,$s3,8,16 446*1f13597dSJung-uk Kim stb $acc13,13($out) 447*1f13597dSJung-uk Kim stb $acc14,14($out) 448*1f13597dSJung-uk Kim stb $s3,15($out) 449*1f13597dSJung-uk Kim 450*1f13597dSJung-uk KimLenc_done: 451*1f13597dSJung-uk Kim $POP r0,`$FRAME+$LRSAVE`($sp) 452*1f13597dSJung-uk Kim $POP $toc,`$FRAME-$SIZE_T*20`($sp) 453*1f13597dSJung-uk Kim $POP r13,`$FRAME-$SIZE_T*19`($sp) 454*1f13597dSJung-uk Kim $POP r14,`$FRAME-$SIZE_T*18`($sp) 455*1f13597dSJung-uk Kim $POP r15,`$FRAME-$SIZE_T*17`($sp) 456*1f13597dSJung-uk Kim $POP r16,`$FRAME-$SIZE_T*16`($sp) 457*1f13597dSJung-uk Kim $POP r17,`$FRAME-$SIZE_T*15`($sp) 458*1f13597dSJung-uk Kim $POP r18,`$FRAME-$SIZE_T*14`($sp) 459*1f13597dSJung-uk Kim $POP r19,`$FRAME-$SIZE_T*13`($sp) 460*1f13597dSJung-uk Kim $POP r20,`$FRAME-$SIZE_T*12`($sp) 461*1f13597dSJung-uk Kim $POP r21,`$FRAME-$SIZE_T*11`($sp) 462*1f13597dSJung-uk Kim $POP r22,`$FRAME-$SIZE_T*10`($sp) 463*1f13597dSJung-uk Kim $POP r23,`$FRAME-$SIZE_T*9`($sp) 464*1f13597dSJung-uk Kim $POP r24,`$FRAME-$SIZE_T*8`($sp) 465*1f13597dSJung-uk Kim $POP r25,`$FRAME-$SIZE_T*7`($sp) 466*1f13597dSJung-uk Kim $POP r26,`$FRAME-$SIZE_T*6`($sp) 467*1f13597dSJung-uk Kim $POP r27,`$FRAME-$SIZE_T*5`($sp) 468*1f13597dSJung-uk Kim $POP r28,`$FRAME-$SIZE_T*4`($sp) 469*1f13597dSJung-uk Kim $POP r29,`$FRAME-$SIZE_T*3`($sp) 470*1f13597dSJung-uk Kim $POP r30,`$FRAME-$SIZE_T*2`($sp) 471*1f13597dSJung-uk Kim $POP r31,`$FRAME-$SIZE_T*1`($sp) 472*1f13597dSJung-uk Kim mtlr r0 473*1f13597dSJung-uk Kim addi $sp,$sp,$FRAME 474*1f13597dSJung-uk Kim blr 475*1f13597dSJung-uk Kim .long 0 476*1f13597dSJung-uk Kim .byte 0,12,4,1,0x80,18,3,0 477*1f13597dSJung-uk Kim .long 0 478*1f13597dSJung-uk Kim 479*1f13597dSJung-uk Kim.align 5 480*1f13597dSJung-uk KimLppc_AES_encrypt: 481*1f13597dSJung-uk Kim lwz $acc00,240($key) 482*1f13597dSJung-uk Kim addi $Tbl1,$Tbl0,3 483*1f13597dSJung-uk Kim lwz $t0,0($key) 484*1f13597dSJung-uk Kim addi $Tbl2,$Tbl0,2 485*1f13597dSJung-uk Kim lwz $t1,4($key) 486*1f13597dSJung-uk Kim addi $Tbl3,$Tbl0,1 487*1f13597dSJung-uk Kim lwz $t2,8($key) 488*1f13597dSJung-uk Kim addi $acc00,$acc00,-1 489*1f13597dSJung-uk Kim lwz $t3,12($key) 490*1f13597dSJung-uk Kim addi $key,$key,16 491*1f13597dSJung-uk Kim xor $s0,$s0,$t0 492*1f13597dSJung-uk Kim xor $s1,$s1,$t1 493*1f13597dSJung-uk Kim xor $s2,$s2,$t2 494*1f13597dSJung-uk Kim xor $s3,$s3,$t3 495*1f13597dSJung-uk Kim mtctr $acc00 496*1f13597dSJung-uk Kim.align 4 497*1f13597dSJung-uk KimLenc_loop: 498*1f13597dSJung-uk Kim rlwinm $acc00,$s0,`32-24+3`,21,28 499*1f13597dSJung-uk Kim rlwinm $acc01,$s1,`32-24+3`,21,28 500*1f13597dSJung-uk Kim rlwinm $acc02,$s2,`32-24+3`,21,28 501*1f13597dSJung-uk Kim rlwinm $acc03,$s3,`32-24+3`,21,28 502*1f13597dSJung-uk Kim lwz $t0,0($key) 503*1f13597dSJung-uk Kim rlwinm $acc04,$s1,`32-16+3`,21,28 504*1f13597dSJung-uk Kim lwz $t1,4($key) 505*1f13597dSJung-uk Kim rlwinm $acc05,$s2,`32-16+3`,21,28 506*1f13597dSJung-uk Kim lwz $t2,8($key) 507*1f13597dSJung-uk Kim rlwinm $acc06,$s3,`32-16+3`,21,28 508*1f13597dSJung-uk Kim lwz $t3,12($key) 509*1f13597dSJung-uk Kim rlwinm $acc07,$s0,`32-16+3`,21,28 510*1f13597dSJung-uk Kim lwzx $acc00,$Tbl0,$acc00 511*1f13597dSJung-uk Kim rlwinm $acc08,$s2,`32-8+3`,21,28 512*1f13597dSJung-uk Kim lwzx $acc01,$Tbl0,$acc01 513*1f13597dSJung-uk Kim rlwinm $acc09,$s3,`32-8+3`,21,28 514*1f13597dSJung-uk Kim lwzx $acc02,$Tbl0,$acc02 515*1f13597dSJung-uk Kim rlwinm $acc10,$s0,`32-8+3`,21,28 516*1f13597dSJung-uk Kim lwzx $acc03,$Tbl0,$acc03 517*1f13597dSJung-uk Kim rlwinm $acc11,$s1,`32-8+3`,21,28 518*1f13597dSJung-uk Kim lwzx $acc04,$Tbl1,$acc04 519*1f13597dSJung-uk Kim rlwinm $acc12,$s3,`0+3`,21,28 520*1f13597dSJung-uk Kim lwzx $acc05,$Tbl1,$acc05 521*1f13597dSJung-uk Kim rlwinm $acc13,$s0,`0+3`,21,28 522*1f13597dSJung-uk Kim lwzx $acc06,$Tbl1,$acc06 523*1f13597dSJung-uk Kim rlwinm $acc14,$s1,`0+3`,21,28 524*1f13597dSJung-uk Kim lwzx $acc07,$Tbl1,$acc07 525*1f13597dSJung-uk Kim rlwinm $acc15,$s2,`0+3`,21,28 526*1f13597dSJung-uk Kim lwzx $acc08,$Tbl2,$acc08 527*1f13597dSJung-uk Kim xor $t0,$t0,$acc00 528*1f13597dSJung-uk Kim lwzx $acc09,$Tbl2,$acc09 529*1f13597dSJung-uk Kim xor $t1,$t1,$acc01 530*1f13597dSJung-uk Kim lwzx $acc10,$Tbl2,$acc10 531*1f13597dSJung-uk Kim xor $t2,$t2,$acc02 532*1f13597dSJung-uk Kim lwzx $acc11,$Tbl2,$acc11 533*1f13597dSJung-uk Kim xor $t3,$t3,$acc03 534*1f13597dSJung-uk Kim lwzx $acc12,$Tbl3,$acc12 535*1f13597dSJung-uk Kim xor $t0,$t0,$acc04 536*1f13597dSJung-uk Kim lwzx $acc13,$Tbl3,$acc13 537*1f13597dSJung-uk Kim xor $t1,$t1,$acc05 538*1f13597dSJung-uk Kim lwzx $acc14,$Tbl3,$acc14 539*1f13597dSJung-uk Kim xor $t2,$t2,$acc06 540*1f13597dSJung-uk Kim lwzx $acc15,$Tbl3,$acc15 541*1f13597dSJung-uk Kim xor $t3,$t3,$acc07 542*1f13597dSJung-uk Kim xor $t0,$t0,$acc08 543*1f13597dSJung-uk Kim xor $t1,$t1,$acc09 544*1f13597dSJung-uk Kim xor $t2,$t2,$acc10 545*1f13597dSJung-uk Kim xor $t3,$t3,$acc11 546*1f13597dSJung-uk Kim xor $s0,$t0,$acc12 547*1f13597dSJung-uk Kim xor $s1,$t1,$acc13 548*1f13597dSJung-uk Kim xor $s2,$t2,$acc14 549*1f13597dSJung-uk Kim xor $s3,$t3,$acc15 550*1f13597dSJung-uk Kim addi $key,$key,16 551*1f13597dSJung-uk Kim bdnz- Lenc_loop 552*1f13597dSJung-uk Kim 553*1f13597dSJung-uk Kim addi $Tbl2,$Tbl0,2048 554*1f13597dSJung-uk Kim nop 555*1f13597dSJung-uk Kim lwz $t0,0($key) 556*1f13597dSJung-uk Kim rlwinm $acc00,$s0,`32-24`,24,31 557*1f13597dSJung-uk Kim lwz $t1,4($key) 558*1f13597dSJung-uk Kim rlwinm $acc01,$s1,`32-24`,24,31 559*1f13597dSJung-uk Kim lwz $t2,8($key) 560*1f13597dSJung-uk Kim rlwinm $acc02,$s2,`32-24`,24,31 561*1f13597dSJung-uk Kim lwz $t3,12($key) 562*1f13597dSJung-uk Kim rlwinm $acc03,$s3,`32-24`,24,31 563*1f13597dSJung-uk Kim lwz $acc08,`2048+0`($Tbl0) ! prefetch Te4 564*1f13597dSJung-uk Kim rlwinm $acc04,$s1,`32-16`,24,31 565*1f13597dSJung-uk Kim lwz $acc09,`2048+32`($Tbl0) 566*1f13597dSJung-uk Kim rlwinm $acc05,$s2,`32-16`,24,31 567*1f13597dSJung-uk Kim lwz $acc10,`2048+64`($Tbl0) 568*1f13597dSJung-uk Kim rlwinm $acc06,$s3,`32-16`,24,31 569*1f13597dSJung-uk Kim lwz $acc11,`2048+96`($Tbl0) 570*1f13597dSJung-uk Kim rlwinm $acc07,$s0,`32-16`,24,31 571*1f13597dSJung-uk Kim lwz $acc12,`2048+128`($Tbl0) 572*1f13597dSJung-uk Kim rlwinm $acc08,$s2,`32-8`,24,31 573*1f13597dSJung-uk Kim lwz $acc13,`2048+160`($Tbl0) 574*1f13597dSJung-uk Kim rlwinm $acc09,$s3,`32-8`,24,31 575*1f13597dSJung-uk Kim lwz $acc14,`2048+192`($Tbl0) 576*1f13597dSJung-uk Kim rlwinm $acc10,$s0,`32-8`,24,31 577*1f13597dSJung-uk Kim lwz $acc15,`2048+224`($Tbl0) 578*1f13597dSJung-uk Kim rlwinm $acc11,$s1,`32-8`,24,31 579*1f13597dSJung-uk Kim lbzx $acc00,$Tbl2,$acc00 580*1f13597dSJung-uk Kim rlwinm $acc12,$s3,`0`,24,31 581*1f13597dSJung-uk Kim lbzx $acc01,$Tbl2,$acc01 582*1f13597dSJung-uk Kim rlwinm $acc13,$s0,`0`,24,31 583*1f13597dSJung-uk Kim lbzx $acc02,$Tbl2,$acc02 584*1f13597dSJung-uk Kim rlwinm $acc14,$s1,`0`,24,31 585*1f13597dSJung-uk Kim lbzx $acc03,$Tbl2,$acc03 586*1f13597dSJung-uk Kim rlwinm $acc15,$s2,`0`,24,31 587*1f13597dSJung-uk Kim lbzx $acc04,$Tbl2,$acc04 588*1f13597dSJung-uk Kim rlwinm $s0,$acc00,24,0,7 589*1f13597dSJung-uk Kim lbzx $acc05,$Tbl2,$acc05 590*1f13597dSJung-uk Kim rlwinm $s1,$acc01,24,0,7 591*1f13597dSJung-uk Kim lbzx $acc06,$Tbl2,$acc06 592*1f13597dSJung-uk Kim rlwinm $s2,$acc02,24,0,7 593*1f13597dSJung-uk Kim lbzx $acc07,$Tbl2,$acc07 594*1f13597dSJung-uk Kim rlwinm $s3,$acc03,24,0,7 595*1f13597dSJung-uk Kim lbzx $acc08,$Tbl2,$acc08 596*1f13597dSJung-uk Kim rlwimi $s0,$acc04,16,8,15 597*1f13597dSJung-uk Kim lbzx $acc09,$Tbl2,$acc09 598*1f13597dSJung-uk Kim rlwimi $s1,$acc05,16,8,15 599*1f13597dSJung-uk Kim lbzx $acc10,$Tbl2,$acc10 600*1f13597dSJung-uk Kim rlwimi $s2,$acc06,16,8,15 601*1f13597dSJung-uk Kim lbzx $acc11,$Tbl2,$acc11 602*1f13597dSJung-uk Kim rlwimi $s3,$acc07,16,8,15 603*1f13597dSJung-uk Kim lbzx $acc12,$Tbl2,$acc12 604*1f13597dSJung-uk Kim rlwimi $s0,$acc08,8,16,23 605*1f13597dSJung-uk Kim lbzx $acc13,$Tbl2,$acc13 606*1f13597dSJung-uk Kim rlwimi $s1,$acc09,8,16,23 607*1f13597dSJung-uk Kim lbzx $acc14,$Tbl2,$acc14 608*1f13597dSJung-uk Kim rlwimi $s2,$acc10,8,16,23 609*1f13597dSJung-uk Kim lbzx $acc15,$Tbl2,$acc15 610*1f13597dSJung-uk Kim rlwimi $s3,$acc11,8,16,23 611*1f13597dSJung-uk Kim or $s0,$s0,$acc12 612*1f13597dSJung-uk Kim or $s1,$s1,$acc13 613*1f13597dSJung-uk Kim or $s2,$s2,$acc14 614*1f13597dSJung-uk Kim or $s3,$s3,$acc15 615*1f13597dSJung-uk Kim xor $s0,$s0,$t0 616*1f13597dSJung-uk Kim xor $s1,$s1,$t1 617*1f13597dSJung-uk Kim xor $s2,$s2,$t2 618*1f13597dSJung-uk Kim xor $s3,$s3,$t3 619*1f13597dSJung-uk Kim blr 620*1f13597dSJung-uk Kim .long 0 621*1f13597dSJung-uk Kim .byte 0,12,0x14,0,0,0,0,0 622*1f13597dSJung-uk Kim 623*1f13597dSJung-uk Kim.align 4 624*1f13597dSJung-uk KimLppc_AES_encrypt_compact: 625*1f13597dSJung-uk Kim lwz $acc00,240($key) 626*1f13597dSJung-uk Kim addi $Tbl1,$Tbl0,2048 627*1f13597dSJung-uk Kim lwz $t0,0($key) 628*1f13597dSJung-uk Kim lis $mask80,0x8080 629*1f13597dSJung-uk Kim lwz $t1,4($key) 630*1f13597dSJung-uk Kim lis $mask1b,0x1b1b 631*1f13597dSJung-uk Kim lwz $t2,8($key) 632*1f13597dSJung-uk Kim ori $mask80,$mask80,0x8080 633*1f13597dSJung-uk Kim lwz $t3,12($key) 634*1f13597dSJung-uk Kim ori $mask1b,$mask1b,0x1b1b 635*1f13597dSJung-uk Kim addi $key,$key,16 636*1f13597dSJung-uk Kim mtctr $acc00 637*1f13597dSJung-uk Kim.align 4 638*1f13597dSJung-uk KimLenc_compact_loop: 639*1f13597dSJung-uk Kim xor $s0,$s0,$t0 640*1f13597dSJung-uk Kim xor $s1,$s1,$t1 641*1f13597dSJung-uk Kim rlwinm $acc00,$s0,`32-24`,24,31 642*1f13597dSJung-uk Kim xor $s2,$s2,$t2 643*1f13597dSJung-uk Kim rlwinm $acc01,$s1,`32-24`,24,31 644*1f13597dSJung-uk Kim xor $s3,$s3,$t3 645*1f13597dSJung-uk Kim rlwinm $acc02,$s2,`32-24`,24,31 646*1f13597dSJung-uk Kim rlwinm $acc03,$s3,`32-24`,24,31 647*1f13597dSJung-uk Kim rlwinm $acc04,$s1,`32-16`,24,31 648*1f13597dSJung-uk Kim rlwinm $acc05,$s2,`32-16`,24,31 649*1f13597dSJung-uk Kim rlwinm $acc06,$s3,`32-16`,24,31 650*1f13597dSJung-uk Kim rlwinm $acc07,$s0,`32-16`,24,31 651*1f13597dSJung-uk Kim lbzx $acc00,$Tbl1,$acc00 652*1f13597dSJung-uk Kim rlwinm $acc08,$s2,`32-8`,24,31 653*1f13597dSJung-uk Kim lbzx $acc01,$Tbl1,$acc01 654*1f13597dSJung-uk Kim rlwinm $acc09,$s3,`32-8`,24,31 655*1f13597dSJung-uk Kim lbzx $acc02,$Tbl1,$acc02 656*1f13597dSJung-uk Kim rlwinm $acc10,$s0,`32-8`,24,31 657*1f13597dSJung-uk Kim lbzx $acc03,$Tbl1,$acc03 658*1f13597dSJung-uk Kim rlwinm $acc11,$s1,`32-8`,24,31 659*1f13597dSJung-uk Kim lbzx $acc04,$Tbl1,$acc04 660*1f13597dSJung-uk Kim rlwinm $acc12,$s3,`0`,24,31 661*1f13597dSJung-uk Kim lbzx $acc05,$Tbl1,$acc05 662*1f13597dSJung-uk Kim rlwinm $acc13,$s0,`0`,24,31 663*1f13597dSJung-uk Kim lbzx $acc06,$Tbl1,$acc06 664*1f13597dSJung-uk Kim rlwinm $acc14,$s1,`0`,24,31 665*1f13597dSJung-uk Kim lbzx $acc07,$Tbl1,$acc07 666*1f13597dSJung-uk Kim rlwinm $acc15,$s2,`0`,24,31 667*1f13597dSJung-uk Kim lbzx $acc08,$Tbl1,$acc08 668*1f13597dSJung-uk Kim rlwinm $s0,$acc00,24,0,7 669*1f13597dSJung-uk Kim lbzx $acc09,$Tbl1,$acc09 670*1f13597dSJung-uk Kim rlwinm $s1,$acc01,24,0,7 671*1f13597dSJung-uk Kim lbzx $acc10,$Tbl1,$acc10 672*1f13597dSJung-uk Kim rlwinm $s2,$acc02,24,0,7 673*1f13597dSJung-uk Kim lbzx $acc11,$Tbl1,$acc11 674*1f13597dSJung-uk Kim rlwinm $s3,$acc03,24,0,7 675*1f13597dSJung-uk Kim lbzx $acc12,$Tbl1,$acc12 676*1f13597dSJung-uk Kim rlwimi $s0,$acc04,16,8,15 677*1f13597dSJung-uk Kim lbzx $acc13,$Tbl1,$acc13 678*1f13597dSJung-uk Kim rlwimi $s1,$acc05,16,8,15 679*1f13597dSJung-uk Kim lbzx $acc14,$Tbl1,$acc14 680*1f13597dSJung-uk Kim rlwimi $s2,$acc06,16,8,15 681*1f13597dSJung-uk Kim lbzx $acc15,$Tbl1,$acc15 682*1f13597dSJung-uk Kim rlwimi $s3,$acc07,16,8,15 683*1f13597dSJung-uk Kim rlwimi $s0,$acc08,8,16,23 684*1f13597dSJung-uk Kim rlwimi $s1,$acc09,8,16,23 685*1f13597dSJung-uk Kim rlwimi $s2,$acc10,8,16,23 686*1f13597dSJung-uk Kim rlwimi $s3,$acc11,8,16,23 687*1f13597dSJung-uk Kim lwz $t0,0($key) 688*1f13597dSJung-uk Kim or $s0,$s0,$acc12 689*1f13597dSJung-uk Kim lwz $t1,4($key) 690*1f13597dSJung-uk Kim or $s1,$s1,$acc13 691*1f13597dSJung-uk Kim lwz $t2,8($key) 692*1f13597dSJung-uk Kim or $s2,$s2,$acc14 693*1f13597dSJung-uk Kim lwz $t3,12($key) 694*1f13597dSJung-uk Kim or $s3,$s3,$acc15 695*1f13597dSJung-uk Kim 696*1f13597dSJung-uk Kim addi $key,$key,16 697*1f13597dSJung-uk Kim bdz Lenc_compact_done 698*1f13597dSJung-uk Kim 699*1f13597dSJung-uk Kim and $acc00,$s0,$mask80 # r1=r0&0x80808080 700*1f13597dSJung-uk Kim and $acc01,$s1,$mask80 701*1f13597dSJung-uk Kim and $acc02,$s2,$mask80 702*1f13597dSJung-uk Kim and $acc03,$s3,$mask80 703*1f13597dSJung-uk Kim srwi $acc04,$acc00,7 # r1>>7 704*1f13597dSJung-uk Kim andc $acc08,$s0,$mask80 # r0&0x7f7f7f7f 705*1f13597dSJung-uk Kim srwi $acc05,$acc01,7 706*1f13597dSJung-uk Kim andc $acc09,$s1,$mask80 707*1f13597dSJung-uk Kim srwi $acc06,$acc02,7 708*1f13597dSJung-uk Kim andc $acc10,$s2,$mask80 709*1f13597dSJung-uk Kim srwi $acc07,$acc03,7 710*1f13597dSJung-uk Kim andc $acc11,$s3,$mask80 711*1f13597dSJung-uk Kim sub $acc00,$acc00,$acc04 # r1-(r1>>7) 712*1f13597dSJung-uk Kim sub $acc01,$acc01,$acc05 713*1f13597dSJung-uk Kim sub $acc02,$acc02,$acc06 714*1f13597dSJung-uk Kim sub $acc03,$acc03,$acc07 715*1f13597dSJung-uk Kim add $acc08,$acc08,$acc08 # (r0&0x7f7f7f7f)<<1 716*1f13597dSJung-uk Kim add $acc09,$acc09,$acc09 717*1f13597dSJung-uk Kim add $acc10,$acc10,$acc10 718*1f13597dSJung-uk Kim add $acc11,$acc11,$acc11 719*1f13597dSJung-uk Kim and $acc00,$acc00,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 720*1f13597dSJung-uk Kim and $acc01,$acc01,$mask1b 721*1f13597dSJung-uk Kim and $acc02,$acc02,$mask1b 722*1f13597dSJung-uk Kim and $acc03,$acc03,$mask1b 723*1f13597dSJung-uk Kim xor $acc00,$acc00,$acc08 # r2 724*1f13597dSJung-uk Kim xor $acc01,$acc01,$acc09 725*1f13597dSJung-uk Kim rotlwi $acc12,$s0,16 # ROTATE(r0,16) 726*1f13597dSJung-uk Kim xor $acc02,$acc02,$acc10 727*1f13597dSJung-uk Kim rotlwi $acc13,$s1,16 728*1f13597dSJung-uk Kim xor $acc03,$acc03,$acc11 729*1f13597dSJung-uk Kim rotlwi $acc14,$s2,16 730*1f13597dSJung-uk Kim 731*1f13597dSJung-uk Kim xor $s0,$s0,$acc00 # r0^r2 732*1f13597dSJung-uk Kim rotlwi $acc15,$s3,16 733*1f13597dSJung-uk Kim xor $s1,$s1,$acc01 734*1f13597dSJung-uk Kim rotrwi $s0,$s0,24 # ROTATE(r2^r0,24) 735*1f13597dSJung-uk Kim xor $s2,$s2,$acc02 736*1f13597dSJung-uk Kim rotrwi $s1,$s1,24 737*1f13597dSJung-uk Kim xor $s3,$s3,$acc03 738*1f13597dSJung-uk Kim rotrwi $s2,$s2,24 739*1f13597dSJung-uk Kim xor $s0,$s0,$acc00 # ROTATE(r2^r0,24)^r2 740*1f13597dSJung-uk Kim rotrwi $s3,$s3,24 741*1f13597dSJung-uk Kim xor $s1,$s1,$acc01 742*1f13597dSJung-uk Kim xor $s2,$s2,$acc02 743*1f13597dSJung-uk Kim xor $s3,$s3,$acc03 744*1f13597dSJung-uk Kim rotlwi $acc08,$acc12,8 # ROTATE(r0,24) 745*1f13597dSJung-uk Kim xor $s0,$s0,$acc12 # 746*1f13597dSJung-uk Kim rotlwi $acc09,$acc13,8 747*1f13597dSJung-uk Kim xor $s1,$s1,$acc13 748*1f13597dSJung-uk Kim rotlwi $acc10,$acc14,8 749*1f13597dSJung-uk Kim xor $s2,$s2,$acc14 750*1f13597dSJung-uk Kim rotlwi $acc11,$acc15,8 751*1f13597dSJung-uk Kim xor $s3,$s3,$acc15 752*1f13597dSJung-uk Kim xor $s0,$s0,$acc08 # 753*1f13597dSJung-uk Kim xor $s1,$s1,$acc09 754*1f13597dSJung-uk Kim xor $s2,$s2,$acc10 755*1f13597dSJung-uk Kim xor $s3,$s3,$acc11 756*1f13597dSJung-uk Kim 757*1f13597dSJung-uk Kim b Lenc_compact_loop 758*1f13597dSJung-uk Kim.align 4 759*1f13597dSJung-uk KimLenc_compact_done: 760*1f13597dSJung-uk Kim xor $s0,$s0,$t0 761*1f13597dSJung-uk Kim xor $s1,$s1,$t1 762*1f13597dSJung-uk Kim xor $s2,$s2,$t2 763*1f13597dSJung-uk Kim xor $s3,$s3,$t3 764*1f13597dSJung-uk Kim blr 765*1f13597dSJung-uk Kim .long 0 766*1f13597dSJung-uk Kim .byte 0,12,0x14,0,0,0,0,0 767*1f13597dSJung-uk Kim 768*1f13597dSJung-uk Kim.globl .AES_decrypt 769*1f13597dSJung-uk Kim.align 7 770*1f13597dSJung-uk Kim.AES_decrypt: 771*1f13597dSJung-uk Kim $STU $sp,-$FRAME($sp) 772*1f13597dSJung-uk Kim mflr r0 773*1f13597dSJung-uk Kim 774*1f13597dSJung-uk Kim $PUSH $toc,`$FRAME-$SIZE_T*20`($sp) 775*1f13597dSJung-uk Kim $PUSH r13,`$FRAME-$SIZE_T*19`($sp) 776*1f13597dSJung-uk Kim $PUSH r14,`$FRAME-$SIZE_T*18`($sp) 777*1f13597dSJung-uk Kim $PUSH r15,`$FRAME-$SIZE_T*17`($sp) 778*1f13597dSJung-uk Kim $PUSH r16,`$FRAME-$SIZE_T*16`($sp) 779*1f13597dSJung-uk Kim $PUSH r17,`$FRAME-$SIZE_T*15`($sp) 780*1f13597dSJung-uk Kim $PUSH r18,`$FRAME-$SIZE_T*14`($sp) 781*1f13597dSJung-uk Kim $PUSH r19,`$FRAME-$SIZE_T*13`($sp) 782*1f13597dSJung-uk Kim $PUSH r20,`$FRAME-$SIZE_T*12`($sp) 783*1f13597dSJung-uk Kim $PUSH r21,`$FRAME-$SIZE_T*11`($sp) 784*1f13597dSJung-uk Kim $PUSH r22,`$FRAME-$SIZE_T*10`($sp) 785*1f13597dSJung-uk Kim $PUSH r23,`$FRAME-$SIZE_T*9`($sp) 786*1f13597dSJung-uk Kim $PUSH r24,`$FRAME-$SIZE_T*8`($sp) 787*1f13597dSJung-uk Kim $PUSH r25,`$FRAME-$SIZE_T*7`($sp) 788*1f13597dSJung-uk Kim $PUSH r26,`$FRAME-$SIZE_T*6`($sp) 789*1f13597dSJung-uk Kim $PUSH r27,`$FRAME-$SIZE_T*5`($sp) 790*1f13597dSJung-uk Kim $PUSH r28,`$FRAME-$SIZE_T*4`($sp) 791*1f13597dSJung-uk Kim $PUSH r29,`$FRAME-$SIZE_T*3`($sp) 792*1f13597dSJung-uk Kim $PUSH r30,`$FRAME-$SIZE_T*2`($sp) 793*1f13597dSJung-uk Kim $PUSH r31,`$FRAME-$SIZE_T*1`($sp) 794*1f13597dSJung-uk Kim $PUSH r0,`$FRAME+$LRSAVE`($sp) 795*1f13597dSJung-uk Kim 796*1f13597dSJung-uk Kim andi. $t0,$inp,3 797*1f13597dSJung-uk Kim andi. $t1,$out,3 798*1f13597dSJung-uk Kim or. $t0,$t0,$t1 799*1f13597dSJung-uk Kim bne Ldec_unaligned 800*1f13597dSJung-uk Kim 801*1f13597dSJung-uk KimLdec_unaligned_ok: 802*1f13597dSJung-uk Kim lwz $s0,0($inp) 803*1f13597dSJung-uk Kim lwz $s1,4($inp) 804*1f13597dSJung-uk Kim lwz $s2,8($inp) 805*1f13597dSJung-uk Kim lwz $s3,12($inp) 806*1f13597dSJung-uk Kim bl LAES_Td 807*1f13597dSJung-uk Kim bl Lppc_AES_decrypt_compact 808*1f13597dSJung-uk Kim stw $s0,0($out) 809*1f13597dSJung-uk Kim stw $s1,4($out) 810*1f13597dSJung-uk Kim stw $s2,8($out) 811*1f13597dSJung-uk Kim stw $s3,12($out) 812*1f13597dSJung-uk Kim b Ldec_done 813*1f13597dSJung-uk Kim 814*1f13597dSJung-uk KimLdec_unaligned: 815*1f13597dSJung-uk Kim subfic $t0,$inp,4096 816*1f13597dSJung-uk Kim subfic $t1,$out,4096 817*1f13597dSJung-uk Kim andi. $t0,$t0,4096-16 818*1f13597dSJung-uk Kim beq Ldec_xpage 819*1f13597dSJung-uk Kim andi. $t1,$t1,4096-16 820*1f13597dSJung-uk Kim bne Ldec_unaligned_ok 821*1f13597dSJung-uk Kim 822*1f13597dSJung-uk KimLdec_xpage: 823*1f13597dSJung-uk Kim lbz $acc00,0($inp) 824*1f13597dSJung-uk Kim lbz $acc01,1($inp) 825*1f13597dSJung-uk Kim lbz $acc02,2($inp) 826*1f13597dSJung-uk Kim lbz $s0,3($inp) 827*1f13597dSJung-uk Kim lbz $acc04,4($inp) 828*1f13597dSJung-uk Kim lbz $acc05,5($inp) 829*1f13597dSJung-uk Kim lbz $acc06,6($inp) 830*1f13597dSJung-uk Kim lbz $s1,7($inp) 831*1f13597dSJung-uk Kim lbz $acc08,8($inp) 832*1f13597dSJung-uk Kim lbz $acc09,9($inp) 833*1f13597dSJung-uk Kim lbz $acc10,10($inp) 834*1f13597dSJung-uk Kim insrwi $s0,$acc00,8,0 835*1f13597dSJung-uk Kim lbz $s2,11($inp) 836*1f13597dSJung-uk Kim insrwi $s1,$acc04,8,0 837*1f13597dSJung-uk Kim lbz $acc12,12($inp) 838*1f13597dSJung-uk Kim insrwi $s0,$acc01,8,8 839*1f13597dSJung-uk Kim lbz $acc13,13($inp) 840*1f13597dSJung-uk Kim insrwi $s1,$acc05,8,8 841*1f13597dSJung-uk Kim lbz $acc14,14($inp) 842*1f13597dSJung-uk Kim insrwi $s0,$acc02,8,16 843*1f13597dSJung-uk Kim lbz $s3,15($inp) 844*1f13597dSJung-uk Kim insrwi $s1,$acc06,8,16 845*1f13597dSJung-uk Kim insrwi $s2,$acc08,8,0 846*1f13597dSJung-uk Kim insrwi $s3,$acc12,8,0 847*1f13597dSJung-uk Kim insrwi $s2,$acc09,8,8 848*1f13597dSJung-uk Kim insrwi $s3,$acc13,8,8 849*1f13597dSJung-uk Kim insrwi $s2,$acc10,8,16 850*1f13597dSJung-uk Kim insrwi $s3,$acc14,8,16 851*1f13597dSJung-uk Kim 852*1f13597dSJung-uk Kim bl LAES_Td 853*1f13597dSJung-uk Kim bl Lppc_AES_decrypt_compact 854*1f13597dSJung-uk Kim 855*1f13597dSJung-uk Kim extrwi $acc00,$s0,8,0 856*1f13597dSJung-uk Kim extrwi $acc01,$s0,8,8 857*1f13597dSJung-uk Kim stb $acc00,0($out) 858*1f13597dSJung-uk Kim extrwi $acc02,$s0,8,16 859*1f13597dSJung-uk Kim stb $acc01,1($out) 860*1f13597dSJung-uk Kim stb $acc02,2($out) 861*1f13597dSJung-uk Kim extrwi $acc04,$s1,8,0 862*1f13597dSJung-uk Kim stb $s0,3($out) 863*1f13597dSJung-uk Kim extrwi $acc05,$s1,8,8 864*1f13597dSJung-uk Kim stb $acc04,4($out) 865*1f13597dSJung-uk Kim extrwi $acc06,$s1,8,16 866*1f13597dSJung-uk Kim stb $acc05,5($out) 867*1f13597dSJung-uk Kim stb $acc06,6($out) 868*1f13597dSJung-uk Kim extrwi $acc08,$s2,8,0 869*1f13597dSJung-uk Kim stb $s1,7($out) 870*1f13597dSJung-uk Kim extrwi $acc09,$s2,8,8 871*1f13597dSJung-uk Kim stb $acc08,8($out) 872*1f13597dSJung-uk Kim extrwi $acc10,$s2,8,16 873*1f13597dSJung-uk Kim stb $acc09,9($out) 874*1f13597dSJung-uk Kim stb $acc10,10($out) 875*1f13597dSJung-uk Kim extrwi $acc12,$s3,8,0 876*1f13597dSJung-uk Kim stb $s2,11($out) 877*1f13597dSJung-uk Kim extrwi $acc13,$s3,8,8 878*1f13597dSJung-uk Kim stb $acc12,12($out) 879*1f13597dSJung-uk Kim extrwi $acc14,$s3,8,16 880*1f13597dSJung-uk Kim stb $acc13,13($out) 881*1f13597dSJung-uk Kim stb $acc14,14($out) 882*1f13597dSJung-uk Kim stb $s3,15($out) 883*1f13597dSJung-uk Kim 884*1f13597dSJung-uk KimLdec_done: 885*1f13597dSJung-uk Kim $POP r0,`$FRAME+$LRSAVE`($sp) 886*1f13597dSJung-uk Kim $POP $toc,`$FRAME-$SIZE_T*20`($sp) 887*1f13597dSJung-uk Kim $POP r13,`$FRAME-$SIZE_T*19`($sp) 888*1f13597dSJung-uk Kim $POP r14,`$FRAME-$SIZE_T*18`($sp) 889*1f13597dSJung-uk Kim $POP r15,`$FRAME-$SIZE_T*17`($sp) 890*1f13597dSJung-uk Kim $POP r16,`$FRAME-$SIZE_T*16`($sp) 891*1f13597dSJung-uk Kim $POP r17,`$FRAME-$SIZE_T*15`($sp) 892*1f13597dSJung-uk Kim $POP r18,`$FRAME-$SIZE_T*14`($sp) 893*1f13597dSJung-uk Kim $POP r19,`$FRAME-$SIZE_T*13`($sp) 894*1f13597dSJung-uk Kim $POP r20,`$FRAME-$SIZE_T*12`($sp) 895*1f13597dSJung-uk Kim $POP r21,`$FRAME-$SIZE_T*11`($sp) 896*1f13597dSJung-uk Kim $POP r22,`$FRAME-$SIZE_T*10`($sp) 897*1f13597dSJung-uk Kim $POP r23,`$FRAME-$SIZE_T*9`($sp) 898*1f13597dSJung-uk Kim $POP r24,`$FRAME-$SIZE_T*8`($sp) 899*1f13597dSJung-uk Kim $POP r25,`$FRAME-$SIZE_T*7`($sp) 900*1f13597dSJung-uk Kim $POP r26,`$FRAME-$SIZE_T*6`($sp) 901*1f13597dSJung-uk Kim $POP r27,`$FRAME-$SIZE_T*5`($sp) 902*1f13597dSJung-uk Kim $POP r28,`$FRAME-$SIZE_T*4`($sp) 903*1f13597dSJung-uk Kim $POP r29,`$FRAME-$SIZE_T*3`($sp) 904*1f13597dSJung-uk Kim $POP r30,`$FRAME-$SIZE_T*2`($sp) 905*1f13597dSJung-uk Kim $POP r31,`$FRAME-$SIZE_T*1`($sp) 906*1f13597dSJung-uk Kim mtlr r0 907*1f13597dSJung-uk Kim addi $sp,$sp,$FRAME 908*1f13597dSJung-uk Kim blr 909*1f13597dSJung-uk Kim .long 0 910*1f13597dSJung-uk Kim .byte 0,12,4,1,0x80,18,3,0 911*1f13597dSJung-uk Kim .long 0 912*1f13597dSJung-uk Kim 913*1f13597dSJung-uk Kim.align 5 914*1f13597dSJung-uk KimLppc_AES_decrypt: 915*1f13597dSJung-uk Kim lwz $acc00,240($key) 916*1f13597dSJung-uk Kim addi $Tbl1,$Tbl0,3 917*1f13597dSJung-uk Kim lwz $t0,0($key) 918*1f13597dSJung-uk Kim addi $Tbl2,$Tbl0,2 919*1f13597dSJung-uk Kim lwz $t1,4($key) 920*1f13597dSJung-uk Kim addi $Tbl3,$Tbl0,1 921*1f13597dSJung-uk Kim lwz $t2,8($key) 922*1f13597dSJung-uk Kim addi $acc00,$acc00,-1 923*1f13597dSJung-uk Kim lwz $t3,12($key) 924*1f13597dSJung-uk Kim addi $key,$key,16 925*1f13597dSJung-uk Kim xor $s0,$s0,$t0 926*1f13597dSJung-uk Kim xor $s1,$s1,$t1 927*1f13597dSJung-uk Kim xor $s2,$s2,$t2 928*1f13597dSJung-uk Kim xor $s3,$s3,$t3 929*1f13597dSJung-uk Kim mtctr $acc00 930*1f13597dSJung-uk Kim.align 4 931*1f13597dSJung-uk KimLdec_loop: 932*1f13597dSJung-uk Kim rlwinm $acc00,$s0,`32-24+3`,21,28 933*1f13597dSJung-uk Kim rlwinm $acc01,$s1,`32-24+3`,21,28 934*1f13597dSJung-uk Kim rlwinm $acc02,$s2,`32-24+3`,21,28 935*1f13597dSJung-uk Kim rlwinm $acc03,$s3,`32-24+3`,21,28 936*1f13597dSJung-uk Kim lwz $t0,0($key) 937*1f13597dSJung-uk Kim rlwinm $acc04,$s3,`32-16+3`,21,28 938*1f13597dSJung-uk Kim lwz $t1,4($key) 939*1f13597dSJung-uk Kim rlwinm $acc05,$s0,`32-16+3`,21,28 940*1f13597dSJung-uk Kim lwz $t2,8($key) 941*1f13597dSJung-uk Kim rlwinm $acc06,$s1,`32-16+3`,21,28 942*1f13597dSJung-uk Kim lwz $t3,12($key) 943*1f13597dSJung-uk Kim rlwinm $acc07,$s2,`32-16+3`,21,28 944*1f13597dSJung-uk Kim lwzx $acc00,$Tbl0,$acc00 945*1f13597dSJung-uk Kim rlwinm $acc08,$s2,`32-8+3`,21,28 946*1f13597dSJung-uk Kim lwzx $acc01,$Tbl0,$acc01 947*1f13597dSJung-uk Kim rlwinm $acc09,$s3,`32-8+3`,21,28 948*1f13597dSJung-uk Kim lwzx $acc02,$Tbl0,$acc02 949*1f13597dSJung-uk Kim rlwinm $acc10,$s0,`32-8+3`,21,28 950*1f13597dSJung-uk Kim lwzx $acc03,$Tbl0,$acc03 951*1f13597dSJung-uk Kim rlwinm $acc11,$s1,`32-8+3`,21,28 952*1f13597dSJung-uk Kim lwzx $acc04,$Tbl1,$acc04 953*1f13597dSJung-uk Kim rlwinm $acc12,$s1,`0+3`,21,28 954*1f13597dSJung-uk Kim lwzx $acc05,$Tbl1,$acc05 955*1f13597dSJung-uk Kim rlwinm $acc13,$s2,`0+3`,21,28 956*1f13597dSJung-uk Kim lwzx $acc06,$Tbl1,$acc06 957*1f13597dSJung-uk Kim rlwinm $acc14,$s3,`0+3`,21,28 958*1f13597dSJung-uk Kim lwzx $acc07,$Tbl1,$acc07 959*1f13597dSJung-uk Kim rlwinm $acc15,$s0,`0+3`,21,28 960*1f13597dSJung-uk Kim lwzx $acc08,$Tbl2,$acc08 961*1f13597dSJung-uk Kim xor $t0,$t0,$acc00 962*1f13597dSJung-uk Kim lwzx $acc09,$Tbl2,$acc09 963*1f13597dSJung-uk Kim xor $t1,$t1,$acc01 964*1f13597dSJung-uk Kim lwzx $acc10,$Tbl2,$acc10 965*1f13597dSJung-uk Kim xor $t2,$t2,$acc02 966*1f13597dSJung-uk Kim lwzx $acc11,$Tbl2,$acc11 967*1f13597dSJung-uk Kim xor $t3,$t3,$acc03 968*1f13597dSJung-uk Kim lwzx $acc12,$Tbl3,$acc12 969*1f13597dSJung-uk Kim xor $t0,$t0,$acc04 970*1f13597dSJung-uk Kim lwzx $acc13,$Tbl3,$acc13 971*1f13597dSJung-uk Kim xor $t1,$t1,$acc05 972*1f13597dSJung-uk Kim lwzx $acc14,$Tbl3,$acc14 973*1f13597dSJung-uk Kim xor $t2,$t2,$acc06 974*1f13597dSJung-uk Kim lwzx $acc15,$Tbl3,$acc15 975*1f13597dSJung-uk Kim xor $t3,$t3,$acc07 976*1f13597dSJung-uk Kim xor $t0,$t0,$acc08 977*1f13597dSJung-uk Kim xor $t1,$t1,$acc09 978*1f13597dSJung-uk Kim xor $t2,$t2,$acc10 979*1f13597dSJung-uk Kim xor $t3,$t3,$acc11 980*1f13597dSJung-uk Kim xor $s0,$t0,$acc12 981*1f13597dSJung-uk Kim xor $s1,$t1,$acc13 982*1f13597dSJung-uk Kim xor $s2,$t2,$acc14 983*1f13597dSJung-uk Kim xor $s3,$t3,$acc15 984*1f13597dSJung-uk Kim addi $key,$key,16 985*1f13597dSJung-uk Kim bdnz- Ldec_loop 986*1f13597dSJung-uk Kim 987*1f13597dSJung-uk Kim addi $Tbl2,$Tbl0,2048 988*1f13597dSJung-uk Kim nop 989*1f13597dSJung-uk Kim lwz $t0,0($key) 990*1f13597dSJung-uk Kim rlwinm $acc00,$s0,`32-24`,24,31 991*1f13597dSJung-uk Kim lwz $t1,4($key) 992*1f13597dSJung-uk Kim rlwinm $acc01,$s1,`32-24`,24,31 993*1f13597dSJung-uk Kim lwz $t2,8($key) 994*1f13597dSJung-uk Kim rlwinm $acc02,$s2,`32-24`,24,31 995*1f13597dSJung-uk Kim lwz $t3,12($key) 996*1f13597dSJung-uk Kim rlwinm $acc03,$s3,`32-24`,24,31 997*1f13597dSJung-uk Kim lwz $acc08,`2048+0`($Tbl0) ! prefetch Td4 998*1f13597dSJung-uk Kim rlwinm $acc04,$s3,`32-16`,24,31 999*1f13597dSJung-uk Kim lwz $acc09,`2048+32`($Tbl0) 1000*1f13597dSJung-uk Kim rlwinm $acc05,$s0,`32-16`,24,31 1001*1f13597dSJung-uk Kim lwz $acc10,`2048+64`($Tbl0) 1002*1f13597dSJung-uk Kim lbzx $acc00,$Tbl2,$acc00 1003*1f13597dSJung-uk Kim lwz $acc11,`2048+96`($Tbl0) 1004*1f13597dSJung-uk Kim lbzx $acc01,$Tbl2,$acc01 1005*1f13597dSJung-uk Kim lwz $acc12,`2048+128`($Tbl0) 1006*1f13597dSJung-uk Kim rlwinm $acc06,$s1,`32-16`,24,31 1007*1f13597dSJung-uk Kim lwz $acc13,`2048+160`($Tbl0) 1008*1f13597dSJung-uk Kim rlwinm $acc07,$s2,`32-16`,24,31 1009*1f13597dSJung-uk Kim lwz $acc14,`2048+192`($Tbl0) 1010*1f13597dSJung-uk Kim rlwinm $acc08,$s2,`32-8`,24,31 1011*1f13597dSJung-uk Kim lwz $acc15,`2048+224`($Tbl0) 1012*1f13597dSJung-uk Kim rlwinm $acc09,$s3,`32-8`,24,31 1013*1f13597dSJung-uk Kim lbzx $acc02,$Tbl2,$acc02 1014*1f13597dSJung-uk Kim rlwinm $acc10,$s0,`32-8`,24,31 1015*1f13597dSJung-uk Kim lbzx $acc03,$Tbl2,$acc03 1016*1f13597dSJung-uk Kim rlwinm $acc11,$s1,`32-8`,24,31 1017*1f13597dSJung-uk Kim lbzx $acc04,$Tbl2,$acc04 1018*1f13597dSJung-uk Kim rlwinm $acc12,$s1,`0`,24,31 1019*1f13597dSJung-uk Kim lbzx $acc05,$Tbl2,$acc05 1020*1f13597dSJung-uk Kim rlwinm $acc13,$s2,`0`,24,31 1021*1f13597dSJung-uk Kim lbzx $acc06,$Tbl2,$acc06 1022*1f13597dSJung-uk Kim rlwinm $acc14,$s3,`0`,24,31 1023*1f13597dSJung-uk Kim lbzx $acc07,$Tbl2,$acc07 1024*1f13597dSJung-uk Kim rlwinm $acc15,$s0,`0`,24,31 1025*1f13597dSJung-uk Kim lbzx $acc08,$Tbl2,$acc08 1026*1f13597dSJung-uk Kim rlwinm $s0,$acc00,24,0,7 1027*1f13597dSJung-uk Kim lbzx $acc09,$Tbl2,$acc09 1028*1f13597dSJung-uk Kim rlwinm $s1,$acc01,24,0,7 1029*1f13597dSJung-uk Kim lbzx $acc10,$Tbl2,$acc10 1030*1f13597dSJung-uk Kim rlwinm $s2,$acc02,24,0,7 1031*1f13597dSJung-uk Kim lbzx $acc11,$Tbl2,$acc11 1032*1f13597dSJung-uk Kim rlwinm $s3,$acc03,24,0,7 1033*1f13597dSJung-uk Kim lbzx $acc12,$Tbl2,$acc12 1034*1f13597dSJung-uk Kim rlwimi $s0,$acc04,16,8,15 1035*1f13597dSJung-uk Kim lbzx $acc13,$Tbl2,$acc13 1036*1f13597dSJung-uk Kim rlwimi $s1,$acc05,16,8,15 1037*1f13597dSJung-uk Kim lbzx $acc14,$Tbl2,$acc14 1038*1f13597dSJung-uk Kim rlwimi $s2,$acc06,16,8,15 1039*1f13597dSJung-uk Kim lbzx $acc15,$Tbl2,$acc15 1040*1f13597dSJung-uk Kim rlwimi $s3,$acc07,16,8,15 1041*1f13597dSJung-uk Kim rlwimi $s0,$acc08,8,16,23 1042*1f13597dSJung-uk Kim rlwimi $s1,$acc09,8,16,23 1043*1f13597dSJung-uk Kim rlwimi $s2,$acc10,8,16,23 1044*1f13597dSJung-uk Kim rlwimi $s3,$acc11,8,16,23 1045*1f13597dSJung-uk Kim or $s0,$s0,$acc12 1046*1f13597dSJung-uk Kim or $s1,$s1,$acc13 1047*1f13597dSJung-uk Kim or $s2,$s2,$acc14 1048*1f13597dSJung-uk Kim or $s3,$s3,$acc15 1049*1f13597dSJung-uk Kim xor $s0,$s0,$t0 1050*1f13597dSJung-uk Kim xor $s1,$s1,$t1 1051*1f13597dSJung-uk Kim xor $s2,$s2,$t2 1052*1f13597dSJung-uk Kim xor $s3,$s3,$t3 1053*1f13597dSJung-uk Kim blr 1054*1f13597dSJung-uk Kim .long 0 1055*1f13597dSJung-uk Kim .byte 0,12,0x14,0,0,0,0,0 1056*1f13597dSJung-uk Kim 1057*1f13597dSJung-uk Kim.align 4 1058*1f13597dSJung-uk KimLppc_AES_decrypt_compact: 1059*1f13597dSJung-uk Kim lwz $acc00,240($key) 1060*1f13597dSJung-uk Kim addi $Tbl1,$Tbl0,2048 1061*1f13597dSJung-uk Kim lwz $t0,0($key) 1062*1f13597dSJung-uk Kim lis $mask80,0x8080 1063*1f13597dSJung-uk Kim lwz $t1,4($key) 1064*1f13597dSJung-uk Kim lis $mask1b,0x1b1b 1065*1f13597dSJung-uk Kim lwz $t2,8($key) 1066*1f13597dSJung-uk Kim ori $mask80,$mask80,0x8080 1067*1f13597dSJung-uk Kim lwz $t3,12($key) 1068*1f13597dSJung-uk Kim ori $mask1b,$mask1b,0x1b1b 1069*1f13597dSJung-uk Kim addi $key,$key,16 1070*1f13597dSJung-uk Kim___ 1071*1f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==8); 1072*1f13597dSJung-uk Kim insrdi $mask80,$mask80,32,0 1073*1f13597dSJung-uk Kim insrdi $mask1b,$mask1b,32,0 1074*1f13597dSJung-uk Kim___ 1075*1f13597dSJung-uk Kim$code.=<<___; 1076*1f13597dSJung-uk Kim mtctr $acc00 1077*1f13597dSJung-uk Kim.align 4 1078*1f13597dSJung-uk KimLdec_compact_loop: 1079*1f13597dSJung-uk Kim xor $s0,$s0,$t0 1080*1f13597dSJung-uk Kim xor $s1,$s1,$t1 1081*1f13597dSJung-uk Kim rlwinm $acc00,$s0,`32-24`,24,31 1082*1f13597dSJung-uk Kim xor $s2,$s2,$t2 1083*1f13597dSJung-uk Kim rlwinm $acc01,$s1,`32-24`,24,31 1084*1f13597dSJung-uk Kim xor $s3,$s3,$t3 1085*1f13597dSJung-uk Kim rlwinm $acc02,$s2,`32-24`,24,31 1086*1f13597dSJung-uk Kim rlwinm $acc03,$s3,`32-24`,24,31 1087*1f13597dSJung-uk Kim rlwinm $acc04,$s3,`32-16`,24,31 1088*1f13597dSJung-uk Kim rlwinm $acc05,$s0,`32-16`,24,31 1089*1f13597dSJung-uk Kim rlwinm $acc06,$s1,`32-16`,24,31 1090*1f13597dSJung-uk Kim rlwinm $acc07,$s2,`32-16`,24,31 1091*1f13597dSJung-uk Kim lbzx $acc00,$Tbl1,$acc00 1092*1f13597dSJung-uk Kim rlwinm $acc08,$s2,`32-8`,24,31 1093*1f13597dSJung-uk Kim lbzx $acc01,$Tbl1,$acc01 1094*1f13597dSJung-uk Kim rlwinm $acc09,$s3,`32-8`,24,31 1095*1f13597dSJung-uk Kim lbzx $acc02,$Tbl1,$acc02 1096*1f13597dSJung-uk Kim rlwinm $acc10,$s0,`32-8`,24,31 1097*1f13597dSJung-uk Kim lbzx $acc03,$Tbl1,$acc03 1098*1f13597dSJung-uk Kim rlwinm $acc11,$s1,`32-8`,24,31 1099*1f13597dSJung-uk Kim lbzx $acc04,$Tbl1,$acc04 1100*1f13597dSJung-uk Kim rlwinm $acc12,$s1,`0`,24,31 1101*1f13597dSJung-uk Kim lbzx $acc05,$Tbl1,$acc05 1102*1f13597dSJung-uk Kim rlwinm $acc13,$s2,`0`,24,31 1103*1f13597dSJung-uk Kim lbzx $acc06,$Tbl1,$acc06 1104*1f13597dSJung-uk Kim rlwinm $acc14,$s3,`0`,24,31 1105*1f13597dSJung-uk Kim lbzx $acc07,$Tbl1,$acc07 1106*1f13597dSJung-uk Kim rlwinm $acc15,$s0,`0`,24,31 1107*1f13597dSJung-uk Kim lbzx $acc08,$Tbl1,$acc08 1108*1f13597dSJung-uk Kim rlwinm $s0,$acc00,24,0,7 1109*1f13597dSJung-uk Kim lbzx $acc09,$Tbl1,$acc09 1110*1f13597dSJung-uk Kim rlwinm $s1,$acc01,24,0,7 1111*1f13597dSJung-uk Kim lbzx $acc10,$Tbl1,$acc10 1112*1f13597dSJung-uk Kim rlwinm $s2,$acc02,24,0,7 1113*1f13597dSJung-uk Kim lbzx $acc11,$Tbl1,$acc11 1114*1f13597dSJung-uk Kim rlwinm $s3,$acc03,24,0,7 1115*1f13597dSJung-uk Kim lbzx $acc12,$Tbl1,$acc12 1116*1f13597dSJung-uk Kim rlwimi $s0,$acc04,16,8,15 1117*1f13597dSJung-uk Kim lbzx $acc13,$Tbl1,$acc13 1118*1f13597dSJung-uk Kim rlwimi $s1,$acc05,16,8,15 1119*1f13597dSJung-uk Kim lbzx $acc14,$Tbl1,$acc14 1120*1f13597dSJung-uk Kim rlwimi $s2,$acc06,16,8,15 1121*1f13597dSJung-uk Kim lbzx $acc15,$Tbl1,$acc15 1122*1f13597dSJung-uk Kim rlwimi $s3,$acc07,16,8,15 1123*1f13597dSJung-uk Kim rlwimi $s0,$acc08,8,16,23 1124*1f13597dSJung-uk Kim rlwimi $s1,$acc09,8,16,23 1125*1f13597dSJung-uk Kim rlwimi $s2,$acc10,8,16,23 1126*1f13597dSJung-uk Kim rlwimi $s3,$acc11,8,16,23 1127*1f13597dSJung-uk Kim lwz $t0,0($key) 1128*1f13597dSJung-uk Kim or $s0,$s0,$acc12 1129*1f13597dSJung-uk Kim lwz $t1,4($key) 1130*1f13597dSJung-uk Kim or $s1,$s1,$acc13 1131*1f13597dSJung-uk Kim lwz $t2,8($key) 1132*1f13597dSJung-uk Kim or $s2,$s2,$acc14 1133*1f13597dSJung-uk Kim lwz $t3,12($key) 1134*1f13597dSJung-uk Kim or $s3,$s3,$acc15 1135*1f13597dSJung-uk Kim 1136*1f13597dSJung-uk Kim addi $key,$key,16 1137*1f13597dSJung-uk Kim bdz Ldec_compact_done 1138*1f13597dSJung-uk Kim___ 1139*1f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==8); 1140*1f13597dSJung-uk Kim # vectorized permutation improves decrypt performance by 10% 1141*1f13597dSJung-uk Kim insrdi $s0,$s1,32,0 1142*1f13597dSJung-uk Kim insrdi $s2,$s3,32,0 1143*1f13597dSJung-uk Kim 1144*1f13597dSJung-uk Kim and $acc00,$s0,$mask80 # r1=r0&0x80808080 1145*1f13597dSJung-uk Kim and $acc02,$s2,$mask80 1146*1f13597dSJung-uk Kim srdi $acc04,$acc00,7 # r1>>7 1147*1f13597dSJung-uk Kim srdi $acc06,$acc02,7 1148*1f13597dSJung-uk Kim andc $acc08,$s0,$mask80 # r0&0x7f7f7f7f 1149*1f13597dSJung-uk Kim andc $acc10,$s2,$mask80 1150*1f13597dSJung-uk Kim sub $acc00,$acc00,$acc04 # r1-(r1>>7) 1151*1f13597dSJung-uk Kim sub $acc02,$acc02,$acc06 1152*1f13597dSJung-uk Kim add $acc08,$acc08,$acc08 # (r0&0x7f7f7f7f)<<1 1153*1f13597dSJung-uk Kim add $acc10,$acc10,$acc10 1154*1f13597dSJung-uk Kim and $acc00,$acc00,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 1155*1f13597dSJung-uk Kim and $acc02,$acc02,$mask1b 1156*1f13597dSJung-uk Kim xor $acc00,$acc00,$acc08 # r2 1157*1f13597dSJung-uk Kim xor $acc02,$acc02,$acc10 1158*1f13597dSJung-uk Kim 1159*1f13597dSJung-uk Kim and $acc04,$acc00,$mask80 # r1=r2&0x80808080 1160*1f13597dSJung-uk Kim and $acc06,$acc02,$mask80 1161*1f13597dSJung-uk Kim srdi $acc08,$acc04,7 # r1>>7 1162*1f13597dSJung-uk Kim srdi $acc10,$acc06,7 1163*1f13597dSJung-uk Kim andc $acc12,$acc00,$mask80 # r2&0x7f7f7f7f 1164*1f13597dSJung-uk Kim andc $acc14,$acc02,$mask80 1165*1f13597dSJung-uk Kim sub $acc04,$acc04,$acc08 # r1-(r1>>7) 1166*1f13597dSJung-uk Kim sub $acc06,$acc06,$acc10 1167*1f13597dSJung-uk Kim add $acc12,$acc12,$acc12 # (r2&0x7f7f7f7f)<<1 1168*1f13597dSJung-uk Kim add $acc14,$acc14,$acc14 1169*1f13597dSJung-uk Kim and $acc04,$acc04,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 1170*1f13597dSJung-uk Kim and $acc06,$acc06,$mask1b 1171*1f13597dSJung-uk Kim xor $acc04,$acc04,$acc12 # r4 1172*1f13597dSJung-uk Kim xor $acc06,$acc06,$acc14 1173*1f13597dSJung-uk Kim 1174*1f13597dSJung-uk Kim and $acc08,$acc04,$mask80 # r1=r4&0x80808080 1175*1f13597dSJung-uk Kim and $acc10,$acc06,$mask80 1176*1f13597dSJung-uk Kim srdi $acc12,$acc08,7 # r1>>7 1177*1f13597dSJung-uk Kim srdi $acc14,$acc10,7 1178*1f13597dSJung-uk Kim sub $acc08,$acc08,$acc12 # r1-(r1>>7) 1179*1f13597dSJung-uk Kim sub $acc10,$acc10,$acc14 1180*1f13597dSJung-uk Kim andc $acc12,$acc04,$mask80 # r4&0x7f7f7f7f 1181*1f13597dSJung-uk Kim andc $acc14,$acc06,$mask80 1182*1f13597dSJung-uk Kim add $acc12,$acc12,$acc12 # (r4&0x7f7f7f7f)<<1 1183*1f13597dSJung-uk Kim add $acc14,$acc14,$acc14 1184*1f13597dSJung-uk Kim and $acc08,$acc08,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 1185*1f13597dSJung-uk Kim and $acc10,$acc10,$mask1b 1186*1f13597dSJung-uk Kim xor $acc08,$acc08,$acc12 # r8 1187*1f13597dSJung-uk Kim xor $acc10,$acc10,$acc14 1188*1f13597dSJung-uk Kim 1189*1f13597dSJung-uk Kim xor $acc00,$acc00,$s0 # r2^r0 1190*1f13597dSJung-uk Kim xor $acc02,$acc02,$s2 1191*1f13597dSJung-uk Kim xor $acc04,$acc04,$s0 # r4^r0 1192*1f13597dSJung-uk Kim xor $acc06,$acc06,$s2 1193*1f13597dSJung-uk Kim 1194*1f13597dSJung-uk Kim extrdi $acc01,$acc00,32,0 1195*1f13597dSJung-uk Kim extrdi $acc03,$acc02,32,0 1196*1f13597dSJung-uk Kim extrdi $acc05,$acc04,32,0 1197*1f13597dSJung-uk Kim extrdi $acc07,$acc06,32,0 1198*1f13597dSJung-uk Kim extrdi $acc09,$acc08,32,0 1199*1f13597dSJung-uk Kim extrdi $acc11,$acc10,32,0 1200*1f13597dSJung-uk Kim___ 1201*1f13597dSJung-uk Kim$code.=<<___ if ($SIZE_T==4); 1202*1f13597dSJung-uk Kim and $acc00,$s0,$mask80 # r1=r0&0x80808080 1203*1f13597dSJung-uk Kim and $acc01,$s1,$mask80 1204*1f13597dSJung-uk Kim and $acc02,$s2,$mask80 1205*1f13597dSJung-uk Kim and $acc03,$s3,$mask80 1206*1f13597dSJung-uk Kim srwi $acc04,$acc00,7 # r1>>7 1207*1f13597dSJung-uk Kim andc $acc08,$s0,$mask80 # r0&0x7f7f7f7f 1208*1f13597dSJung-uk Kim srwi $acc05,$acc01,7 1209*1f13597dSJung-uk Kim andc $acc09,$s1,$mask80 1210*1f13597dSJung-uk Kim srwi $acc06,$acc02,7 1211*1f13597dSJung-uk Kim andc $acc10,$s2,$mask80 1212*1f13597dSJung-uk Kim srwi $acc07,$acc03,7 1213*1f13597dSJung-uk Kim andc $acc11,$s3,$mask80 1214*1f13597dSJung-uk Kim sub $acc00,$acc00,$acc04 # r1-(r1>>7) 1215*1f13597dSJung-uk Kim sub $acc01,$acc01,$acc05 1216*1f13597dSJung-uk Kim sub $acc02,$acc02,$acc06 1217*1f13597dSJung-uk Kim sub $acc03,$acc03,$acc07 1218*1f13597dSJung-uk Kim add $acc08,$acc08,$acc08 # (r0&0x7f7f7f7f)<<1 1219*1f13597dSJung-uk Kim add $acc09,$acc09,$acc09 1220*1f13597dSJung-uk Kim add $acc10,$acc10,$acc10 1221*1f13597dSJung-uk Kim add $acc11,$acc11,$acc11 1222*1f13597dSJung-uk Kim and $acc00,$acc00,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 1223*1f13597dSJung-uk Kim and $acc01,$acc01,$mask1b 1224*1f13597dSJung-uk Kim and $acc02,$acc02,$mask1b 1225*1f13597dSJung-uk Kim and $acc03,$acc03,$mask1b 1226*1f13597dSJung-uk Kim xor $acc00,$acc00,$acc08 # r2 1227*1f13597dSJung-uk Kim xor $acc01,$acc01,$acc09 1228*1f13597dSJung-uk Kim xor $acc02,$acc02,$acc10 1229*1f13597dSJung-uk Kim xor $acc03,$acc03,$acc11 1230*1f13597dSJung-uk Kim 1231*1f13597dSJung-uk Kim and $acc04,$acc00,$mask80 # r1=r2&0x80808080 1232*1f13597dSJung-uk Kim and $acc05,$acc01,$mask80 1233*1f13597dSJung-uk Kim and $acc06,$acc02,$mask80 1234*1f13597dSJung-uk Kim and $acc07,$acc03,$mask80 1235*1f13597dSJung-uk Kim srwi $acc08,$acc04,7 # r1>>7 1236*1f13597dSJung-uk Kim andc $acc12,$acc00,$mask80 # r2&0x7f7f7f7f 1237*1f13597dSJung-uk Kim srwi $acc09,$acc05,7 1238*1f13597dSJung-uk Kim andc $acc13,$acc01,$mask80 1239*1f13597dSJung-uk Kim srwi $acc10,$acc06,7 1240*1f13597dSJung-uk Kim andc $acc14,$acc02,$mask80 1241*1f13597dSJung-uk Kim srwi $acc11,$acc07,7 1242*1f13597dSJung-uk Kim andc $acc15,$acc03,$mask80 1243*1f13597dSJung-uk Kim sub $acc04,$acc04,$acc08 # r1-(r1>>7) 1244*1f13597dSJung-uk Kim sub $acc05,$acc05,$acc09 1245*1f13597dSJung-uk Kim sub $acc06,$acc06,$acc10 1246*1f13597dSJung-uk Kim sub $acc07,$acc07,$acc11 1247*1f13597dSJung-uk Kim add $acc12,$acc12,$acc12 # (r2&0x7f7f7f7f)<<1 1248*1f13597dSJung-uk Kim add $acc13,$acc13,$acc13 1249*1f13597dSJung-uk Kim add $acc14,$acc14,$acc14 1250*1f13597dSJung-uk Kim add $acc15,$acc15,$acc15 1251*1f13597dSJung-uk Kim and $acc04,$acc04,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 1252*1f13597dSJung-uk Kim and $acc05,$acc05,$mask1b 1253*1f13597dSJung-uk Kim and $acc06,$acc06,$mask1b 1254*1f13597dSJung-uk Kim and $acc07,$acc07,$mask1b 1255*1f13597dSJung-uk Kim xor $acc04,$acc04,$acc12 # r4 1256*1f13597dSJung-uk Kim xor $acc05,$acc05,$acc13 1257*1f13597dSJung-uk Kim xor $acc06,$acc06,$acc14 1258*1f13597dSJung-uk Kim xor $acc07,$acc07,$acc15 1259*1f13597dSJung-uk Kim 1260*1f13597dSJung-uk Kim and $acc08,$acc04,$mask80 # r1=r4&0x80808080 1261*1f13597dSJung-uk Kim and $acc09,$acc05,$mask80 1262*1f13597dSJung-uk Kim srwi $acc12,$acc08,7 # r1>>7 1263*1f13597dSJung-uk Kim and $acc10,$acc06,$mask80 1264*1f13597dSJung-uk Kim srwi $acc13,$acc09,7 1265*1f13597dSJung-uk Kim and $acc11,$acc07,$mask80 1266*1f13597dSJung-uk Kim srwi $acc14,$acc10,7 1267*1f13597dSJung-uk Kim sub $acc08,$acc08,$acc12 # r1-(r1>>7) 1268*1f13597dSJung-uk Kim srwi $acc15,$acc11,7 1269*1f13597dSJung-uk Kim sub $acc09,$acc09,$acc13 1270*1f13597dSJung-uk Kim sub $acc10,$acc10,$acc14 1271*1f13597dSJung-uk Kim sub $acc11,$acc11,$acc15 1272*1f13597dSJung-uk Kim andc $acc12,$acc04,$mask80 # r4&0x7f7f7f7f 1273*1f13597dSJung-uk Kim andc $acc13,$acc05,$mask80 1274*1f13597dSJung-uk Kim andc $acc14,$acc06,$mask80 1275*1f13597dSJung-uk Kim andc $acc15,$acc07,$mask80 1276*1f13597dSJung-uk Kim add $acc12,$acc12,$acc12 # (r4&0x7f7f7f7f)<<1 1277*1f13597dSJung-uk Kim add $acc13,$acc13,$acc13 1278*1f13597dSJung-uk Kim add $acc14,$acc14,$acc14 1279*1f13597dSJung-uk Kim add $acc15,$acc15,$acc15 1280*1f13597dSJung-uk Kim and $acc08,$acc08,$mask1b # (r1-(r1>>7))&0x1b1b1b1b 1281*1f13597dSJung-uk Kim and $acc09,$acc09,$mask1b 1282*1f13597dSJung-uk Kim and $acc10,$acc10,$mask1b 1283*1f13597dSJung-uk Kim and $acc11,$acc11,$mask1b 1284*1f13597dSJung-uk Kim xor $acc08,$acc08,$acc12 # r8 1285*1f13597dSJung-uk Kim xor $acc09,$acc09,$acc13 1286*1f13597dSJung-uk Kim xor $acc10,$acc10,$acc14 1287*1f13597dSJung-uk Kim xor $acc11,$acc11,$acc15 1288*1f13597dSJung-uk Kim 1289*1f13597dSJung-uk Kim xor $acc00,$acc00,$s0 # r2^r0 1290*1f13597dSJung-uk Kim xor $acc01,$acc01,$s1 1291*1f13597dSJung-uk Kim xor $acc02,$acc02,$s2 1292*1f13597dSJung-uk Kim xor $acc03,$acc03,$s3 1293*1f13597dSJung-uk Kim xor $acc04,$acc04,$s0 # r4^r0 1294*1f13597dSJung-uk Kim xor $acc05,$acc05,$s1 1295*1f13597dSJung-uk Kim xor $acc06,$acc06,$s2 1296*1f13597dSJung-uk Kim xor $acc07,$acc07,$s3 1297*1f13597dSJung-uk Kim___ 1298*1f13597dSJung-uk Kim$code.=<<___; 1299*1f13597dSJung-uk Kim rotrwi $s0,$s0,8 # = ROTATE(r0,8) 1300*1f13597dSJung-uk Kim rotrwi $s1,$s1,8 1301*1f13597dSJung-uk Kim xor $s0,$s0,$acc00 # ^= r2^r0 1302*1f13597dSJung-uk Kim rotrwi $s2,$s2,8 1303*1f13597dSJung-uk Kim xor $s1,$s1,$acc01 1304*1f13597dSJung-uk Kim rotrwi $s3,$s3,8 1305*1f13597dSJung-uk Kim xor $s2,$s2,$acc02 1306*1f13597dSJung-uk Kim xor $s3,$s3,$acc03 1307*1f13597dSJung-uk Kim xor $acc00,$acc00,$acc08 1308*1f13597dSJung-uk Kim xor $acc01,$acc01,$acc09 1309*1f13597dSJung-uk Kim xor $acc02,$acc02,$acc10 1310*1f13597dSJung-uk Kim xor $acc03,$acc03,$acc11 1311*1f13597dSJung-uk Kim xor $s0,$s0,$acc04 # ^= r4^r0 1312*1f13597dSJung-uk Kim rotrwi $acc00,$acc00,24 1313*1f13597dSJung-uk Kim xor $s1,$s1,$acc05 1314*1f13597dSJung-uk Kim rotrwi $acc01,$acc01,24 1315*1f13597dSJung-uk Kim xor $s2,$s2,$acc06 1316*1f13597dSJung-uk Kim rotrwi $acc02,$acc02,24 1317*1f13597dSJung-uk Kim xor $s3,$s3,$acc07 1318*1f13597dSJung-uk Kim rotrwi $acc03,$acc03,24 1319*1f13597dSJung-uk Kim xor $acc04,$acc04,$acc08 1320*1f13597dSJung-uk Kim xor $acc05,$acc05,$acc09 1321*1f13597dSJung-uk Kim xor $acc06,$acc06,$acc10 1322*1f13597dSJung-uk Kim xor $acc07,$acc07,$acc11 1323*1f13597dSJung-uk Kim xor $s0,$s0,$acc08 # ^= r8 [^((r4^r0)^(r2^r0)=r4^r2)] 1324*1f13597dSJung-uk Kim rotrwi $acc04,$acc04,16 1325*1f13597dSJung-uk Kim xor $s1,$s1,$acc09 1326*1f13597dSJung-uk Kim rotrwi $acc05,$acc05,16 1327*1f13597dSJung-uk Kim xor $s2,$s2,$acc10 1328*1f13597dSJung-uk Kim rotrwi $acc06,$acc06,16 1329*1f13597dSJung-uk Kim xor $s3,$s3,$acc11 1330*1f13597dSJung-uk Kim rotrwi $acc07,$acc07,16 1331*1f13597dSJung-uk Kim xor $s0,$s0,$acc00 # ^= ROTATE(r8^r2^r0,24) 1332*1f13597dSJung-uk Kim rotrwi $acc08,$acc08,8 1333*1f13597dSJung-uk Kim xor $s1,$s1,$acc01 1334*1f13597dSJung-uk Kim rotrwi $acc09,$acc09,8 1335*1f13597dSJung-uk Kim xor $s2,$s2,$acc02 1336*1f13597dSJung-uk Kim rotrwi $acc10,$acc10,8 1337*1f13597dSJung-uk Kim xor $s3,$s3,$acc03 1338*1f13597dSJung-uk Kim rotrwi $acc11,$acc11,8 1339*1f13597dSJung-uk Kim xor $s0,$s0,$acc04 # ^= ROTATE(r8^r4^r0,16) 1340*1f13597dSJung-uk Kim xor $s1,$s1,$acc05 1341*1f13597dSJung-uk Kim xor $s2,$s2,$acc06 1342*1f13597dSJung-uk Kim xor $s3,$s3,$acc07 1343*1f13597dSJung-uk Kim xor $s0,$s0,$acc08 # ^= ROTATE(r8,8) 1344*1f13597dSJung-uk Kim xor $s1,$s1,$acc09 1345*1f13597dSJung-uk Kim xor $s2,$s2,$acc10 1346*1f13597dSJung-uk Kim xor $s3,$s3,$acc11 1347*1f13597dSJung-uk Kim 1348*1f13597dSJung-uk Kim b Ldec_compact_loop 1349*1f13597dSJung-uk Kim.align 4 1350*1f13597dSJung-uk KimLdec_compact_done: 1351*1f13597dSJung-uk Kim xor $s0,$s0,$t0 1352*1f13597dSJung-uk Kim xor $s1,$s1,$t1 1353*1f13597dSJung-uk Kim xor $s2,$s2,$t2 1354*1f13597dSJung-uk Kim xor $s3,$s3,$t3 1355*1f13597dSJung-uk Kim blr 1356*1f13597dSJung-uk Kim .long 0 1357*1f13597dSJung-uk Kim .byte 0,12,0x14,0,0,0,0,0 1358*1f13597dSJung-uk Kim 1359*1f13597dSJung-uk Kim.asciz "AES for PPC, CRYPTOGAMS by <appro\@openssl.org>" 1360*1f13597dSJung-uk Kim.align 7 1361*1f13597dSJung-uk Kim___ 1362*1f13597dSJung-uk Kim 1363*1f13597dSJung-uk Kim$code =~ s/\`([^\`]*)\`/eval $1/gem; 1364*1f13597dSJung-uk Kimprint $code; 1365*1f13597dSJung-uk Kimclose STDOUT; 1366