1e1051a39Sopenharmony_ci#! /usr/bin/env perl 2e1051a39Sopenharmony_ci# Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci# 4e1051a39Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci# this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci# in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci# https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci# ==================================================================== 11e1051a39Sopenharmony_ci# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL 12e1051a39Sopenharmony_ci# project. The module is, however, dual licensed under OpenSSL and 13e1051a39Sopenharmony_ci# CRYPTOGAMS licenses depending on where you obtain it. For further 14e1051a39Sopenharmony_ci# details see http://www.openssl.org/~appro/cryptogams/. 15e1051a39Sopenharmony_ci# ==================================================================== 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_ci# AES for MIPS 18e1051a39Sopenharmony_ci 19e1051a39Sopenharmony_ci# October 2010 20e1051a39Sopenharmony_ci# 21e1051a39Sopenharmony_ci# Code uses 1K[+256B] S-box and on single-issue core [such as R5000] 22e1051a39Sopenharmony_ci# spends ~68 cycles per byte processed with 128-bit key. This is ~16% 23e1051a39Sopenharmony_ci# faster than gcc-generated code, which is not very impressive. But 24e1051a39Sopenharmony_ci# recall that compressed S-box requires extra processing, namely 25e1051a39Sopenharmony_ci# additional rotations. Rotations are implemented with lwl/lwr pairs, 26e1051a39Sopenharmony_ci# which is normally used for loading unaligned data. Another cool 27e1051a39Sopenharmony_ci# thing about this module is its endian neutrality, which means that 28e1051a39Sopenharmony_ci# it processes data without ever changing byte order... 29e1051a39Sopenharmony_ci 30e1051a39Sopenharmony_ci# September 2012 31e1051a39Sopenharmony_ci# 32e1051a39Sopenharmony_ci# Add MIPS32R2 (~10% less instructions) and SmartMIPS ASE (further 33e1051a39Sopenharmony_ci# ~25% less instructions) code. Note that there is no run-time switch, 34e1051a39Sopenharmony_ci# instead, code path is chosen upon pre-process time, pass -mips32r2 35e1051a39Sopenharmony_ci# or/and -msmartmips. 36e1051a39Sopenharmony_ci 37e1051a39Sopenharmony_ci# February 2019 38e1051a39Sopenharmony_ci# 39e1051a39Sopenharmony_ci# Normalize MIPS32R2 AES table address calculation by always using EXT 40e1051a39Sopenharmony_ci# instruction. This reduces the standard codebase by another 10%. 41e1051a39Sopenharmony_ci 42e1051a39Sopenharmony_ci###################################################################### 43e1051a39Sopenharmony_ci# There is a number of MIPS ABI in use, O32 and N32/64 are most 44e1051a39Sopenharmony_ci# widely used. Then there is a new contender: NUBI. It appears that if 45e1051a39Sopenharmony_ci# one picks the latter, it's possible to arrange code in ABI neutral 46e1051a39Sopenharmony_ci# manner. Therefore let's stick to NUBI register layout: 47e1051a39Sopenharmony_ci# 48e1051a39Sopenharmony_ci($zero,$at,$t0,$t1,$t2)=map("\$$_",(0..2,24,25)); 49e1051a39Sopenharmony_ci($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("\$$_",(4..11)); 50e1051a39Sopenharmony_ci($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10,$s11)=map("\$$_",(12..23)); 51e1051a39Sopenharmony_ci($gp,$tp,$sp,$fp,$ra)=map("\$$_",(3,28..31)); 52e1051a39Sopenharmony_ci# 53e1051a39Sopenharmony_ci# The return value is placed in $a0. Following coding rules facilitate 54e1051a39Sopenharmony_ci# interoperability: 55e1051a39Sopenharmony_ci# 56e1051a39Sopenharmony_ci# - never ever touch $tp, "thread pointer", former $gp; 57e1051a39Sopenharmony_ci# - copy return value to $t0, former $v0 [or to $a0 if you're adapting 58e1051a39Sopenharmony_ci# old code]; 59e1051a39Sopenharmony_ci# - on O32 populate $a4-$a7 with 'lw $aN,4*N($sp)' if necessary; 60e1051a39Sopenharmony_ci# 61e1051a39Sopenharmony_ci# For reference here is register layout for N32/64 MIPS ABIs: 62e1051a39Sopenharmony_ci# 63e1051a39Sopenharmony_ci# ($zero,$at,$v0,$v1)=map("\$$_",(0..3)); 64e1051a39Sopenharmony_ci# ($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("\$$_",(4..11)); 65e1051a39Sopenharmony_ci# ($t0,$t1,$t2,$t3,$t8,$t9)=map("\$$_",(12..15,24,25)); 66e1051a39Sopenharmony_ci# ($s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7)=map("\$$_",(16..23)); 67e1051a39Sopenharmony_ci# ($gp,$sp,$fp,$ra)=map("\$$_",(28..31)); 68e1051a39Sopenharmony_ci 69e1051a39Sopenharmony_ci# $output is the last argument if it looks like a file (it has an extension) 70e1051a39Sopenharmony_ci# $flavour is the first argument if it doesn't look like a file 71e1051a39Sopenharmony_ci$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef; 72e1051a39Sopenharmony_ci$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef; 73e1051a39Sopenharmony_ci$flavour ||= "o32"; # supported flavours are o32,n32,64,nubi32,nubi64 74e1051a39Sopenharmony_ci 75e1051a39Sopenharmony_ciif ($flavour =~ /64|n32/i) { 76e1051a39Sopenharmony_ci $PTR_LA="dla"; 77e1051a39Sopenharmony_ci $PTR_ADD="daddu"; # incidentally works even on n32 78e1051a39Sopenharmony_ci $PTR_SUB="dsubu"; # incidentally works even on n32 79e1051a39Sopenharmony_ci $PTR_INS="dins"; 80e1051a39Sopenharmony_ci $REG_S="sd"; 81e1051a39Sopenharmony_ci $REG_L="ld"; 82e1051a39Sopenharmony_ci $PTR_SLL="dsll"; # incidentally works even on n32 83e1051a39Sopenharmony_ci $SZREG=8; 84e1051a39Sopenharmony_ci} else { 85e1051a39Sopenharmony_ci $PTR_LA="la"; 86e1051a39Sopenharmony_ci $PTR_ADD="addu"; 87e1051a39Sopenharmony_ci $PTR_SUB="subu"; 88e1051a39Sopenharmony_ci $PTR_INS="ins"; 89e1051a39Sopenharmony_ci $REG_S="sw"; 90e1051a39Sopenharmony_ci $REG_L="lw"; 91e1051a39Sopenharmony_ci $PTR_SLL="sll"; 92e1051a39Sopenharmony_ci $SZREG=4; 93e1051a39Sopenharmony_ci} 94e1051a39Sopenharmony_ci$pf = ($flavour =~ /nubi/i) ? $t0 : $t2; 95e1051a39Sopenharmony_ci# 96e1051a39Sopenharmony_ci# <appro@openssl.org> 97e1051a39Sopenharmony_ci# 98e1051a39Sopenharmony_ci###################################################################### 99e1051a39Sopenharmony_ci 100e1051a39Sopenharmony_ci$big_endian=(`echo MIPSEB | $ENV{CC} -E -`=~/MIPSEB/)?0:1 if ($ENV{CC}); 101e1051a39Sopenharmony_ci 102e1051a39Sopenharmony_ciif (!defined($big_endian)) 103e1051a39Sopenharmony_ci{ $big_endian=(unpack('L',pack('N',1))==1); } 104e1051a39Sopenharmony_ci 105e1051a39Sopenharmony_cimy ($MSB,$LSB)=(0,3); # automatically converted to little-endian 106e1051a39Sopenharmony_ci 107e1051a39Sopenharmony_ci$output and open STDOUT,">$output"; 108e1051a39Sopenharmony_ci 109e1051a39Sopenharmony_ci$code.=<<___; 110e1051a39Sopenharmony_ci#include "mips_arch.h" 111e1051a39Sopenharmony_ci 112e1051a39Sopenharmony_ci.text 113e1051a39Sopenharmony_ci#if !defined(__mips_eabi) && (!defined(__vxworks) || defined(__pic__)) 114e1051a39Sopenharmony_ci.option pic2 115e1051a39Sopenharmony_ci#endif 116e1051a39Sopenharmony_ci.set noat 117e1051a39Sopenharmony_ci___ 118e1051a39Sopenharmony_ci 119e1051a39Sopenharmony_ci{{{ 120e1051a39Sopenharmony_cimy $FRAMESIZE=16*$SZREG; 121e1051a39Sopenharmony_cimy $SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? "0xc0fff008" : "0xc0ff0000"; 122e1051a39Sopenharmony_ci 123e1051a39Sopenharmony_cimy ($inp,$out,$key,$Tbl,$s0,$s1,$s2,$s3)=($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7); 124e1051a39Sopenharmony_cimy ($i0,$i1,$i2,$i3)=($at,$t0,$t1,$t2); 125e1051a39Sopenharmony_cimy ($t0,$t1,$t2,$t3,$t4,$t5,$t6,$t7,$t8,$t9,$t10,$t11) = map("\$$_",(12..23)); 126e1051a39Sopenharmony_cimy ($key0,$cnt)=($gp,$fp); 127e1051a39Sopenharmony_ci 128e1051a39Sopenharmony_ci# instruction ordering is "stolen" from output from MIPSpro assembler 129e1051a39Sopenharmony_ci# invoked with -mips3 -O3 arguments... 130e1051a39Sopenharmony_ci$code.=<<___; 131e1051a39Sopenharmony_ci.align 5 132e1051a39Sopenharmony_ci.ent _mips_AES_encrypt 133e1051a39Sopenharmony_ci_mips_AES_encrypt: 134e1051a39Sopenharmony_ci .frame $sp,0,$ra 135e1051a39Sopenharmony_ci .set reorder 136e1051a39Sopenharmony_ci lw $t0,0($key) 137e1051a39Sopenharmony_ci lw $t1,4($key) 138e1051a39Sopenharmony_ci lw $t2,8($key) 139e1051a39Sopenharmony_ci lw $t3,12($key) 140e1051a39Sopenharmony_ci lw $cnt,240($key) 141e1051a39Sopenharmony_ci $PTR_ADD $key0,$key,16 142e1051a39Sopenharmony_ci 143e1051a39Sopenharmony_ci xor $s0,$t0 144e1051a39Sopenharmony_ci xor $s1,$t1 145e1051a39Sopenharmony_ci xor $s2,$t2 146e1051a39Sopenharmony_ci xor $s3,$t3 147e1051a39Sopenharmony_ci 148e1051a39Sopenharmony_ci subu $cnt,1 149e1051a39Sopenharmony_ci#if defined(__mips_smartmips) 150e1051a39Sopenharmony_ci ext $i0,$s1,16,8 151e1051a39Sopenharmony_ci.Loop_enc: 152e1051a39Sopenharmony_ci ext $i1,$s2,16,8 153e1051a39Sopenharmony_ci ext $i2,$s3,16,8 154e1051a39Sopenharmony_ci ext $i3,$s0,16,8 155e1051a39Sopenharmony_ci lwxs $t0,$i0($Tbl) # Te1[s1>>16] 156e1051a39Sopenharmony_ci ext $i0,$s2,8,8 157e1051a39Sopenharmony_ci lwxs $t1,$i1($Tbl) # Te1[s2>>16] 158e1051a39Sopenharmony_ci ext $i1,$s3,8,8 159e1051a39Sopenharmony_ci lwxs $t2,$i2($Tbl) # Te1[s3>>16] 160e1051a39Sopenharmony_ci ext $i2,$s0,8,8 161e1051a39Sopenharmony_ci lwxs $t3,$i3($Tbl) # Te1[s0>>16] 162e1051a39Sopenharmony_ci ext $i3,$s1,8,8 163e1051a39Sopenharmony_ci 164e1051a39Sopenharmony_ci lwxs $t4,$i0($Tbl) # Te2[s2>>8] 165e1051a39Sopenharmony_ci ext $i0,$s3,0,8 166e1051a39Sopenharmony_ci lwxs $t5,$i1($Tbl) # Te2[s3>>8] 167e1051a39Sopenharmony_ci ext $i1,$s0,0,8 168e1051a39Sopenharmony_ci lwxs $t6,$i2($Tbl) # Te2[s0>>8] 169e1051a39Sopenharmony_ci ext $i2,$s1,0,8 170e1051a39Sopenharmony_ci lwxs $t7,$i3($Tbl) # Te2[s1>>8] 171e1051a39Sopenharmony_ci ext $i3,$s2,0,8 172e1051a39Sopenharmony_ci 173e1051a39Sopenharmony_ci lwxs $t8,$i0($Tbl) # Te3[s3] 174e1051a39Sopenharmony_ci ext $i0,$s0,24,8 175e1051a39Sopenharmony_ci lwxs $t9,$i1($Tbl) # Te3[s0] 176e1051a39Sopenharmony_ci ext $i1,$s1,24,8 177e1051a39Sopenharmony_ci lwxs $t10,$i2($Tbl) # Te3[s1] 178e1051a39Sopenharmony_ci ext $i2,$s2,24,8 179e1051a39Sopenharmony_ci lwxs $t11,$i3($Tbl) # Te3[s2] 180e1051a39Sopenharmony_ci ext $i3,$s3,24,8 181e1051a39Sopenharmony_ci 182e1051a39Sopenharmony_ci rotr $t0,$t0,8 183e1051a39Sopenharmony_ci rotr $t1,$t1,8 184e1051a39Sopenharmony_ci rotr $t2,$t2,8 185e1051a39Sopenharmony_ci rotr $t3,$t3,8 186e1051a39Sopenharmony_ci 187e1051a39Sopenharmony_ci rotr $t4,$t4,16 188e1051a39Sopenharmony_ci rotr $t5,$t5,16 189e1051a39Sopenharmony_ci rotr $t6,$t6,16 190e1051a39Sopenharmony_ci rotr $t7,$t7,16 191e1051a39Sopenharmony_ci 192e1051a39Sopenharmony_ci xor $t0,$t4 193e1051a39Sopenharmony_ci lwxs $t4,$i0($Tbl) # Te0[s0>>24] 194e1051a39Sopenharmony_ci xor $t1,$t5 195e1051a39Sopenharmony_ci lwxs $t5,$i1($Tbl) # Te0[s1>>24] 196e1051a39Sopenharmony_ci xor $t2,$t6 197e1051a39Sopenharmony_ci lwxs $t6,$i2($Tbl) # Te0[s2>>24] 198e1051a39Sopenharmony_ci xor $t3,$t7 199e1051a39Sopenharmony_ci lwxs $t7,$i3($Tbl) # Te0[s3>>24] 200e1051a39Sopenharmony_ci 201e1051a39Sopenharmony_ci rotr $t8,$t8,24 202e1051a39Sopenharmony_ci lw $s0,0($key0) 203e1051a39Sopenharmony_ci rotr $t9,$t9,24 204e1051a39Sopenharmony_ci lw $s1,4($key0) 205e1051a39Sopenharmony_ci rotr $t10,$t10,24 206e1051a39Sopenharmony_ci lw $s2,8($key0) 207e1051a39Sopenharmony_ci rotr $t11,$t11,24 208e1051a39Sopenharmony_ci lw $s3,12($key0) 209e1051a39Sopenharmony_ci 210e1051a39Sopenharmony_ci xor $t0,$t8 211e1051a39Sopenharmony_ci xor $t1,$t9 212e1051a39Sopenharmony_ci xor $t2,$t10 213e1051a39Sopenharmony_ci xor $t3,$t11 214e1051a39Sopenharmony_ci 215e1051a39Sopenharmony_ci xor $t0,$t4 216e1051a39Sopenharmony_ci xor $t1,$t5 217e1051a39Sopenharmony_ci xor $t2,$t6 218e1051a39Sopenharmony_ci xor $t3,$t7 219e1051a39Sopenharmony_ci 220e1051a39Sopenharmony_ci subu $cnt,1 221e1051a39Sopenharmony_ci $PTR_ADD $key0,16 222e1051a39Sopenharmony_ci xor $s0,$t0 223e1051a39Sopenharmony_ci xor $s1,$t1 224e1051a39Sopenharmony_ci xor $s2,$t2 225e1051a39Sopenharmony_ci xor $s3,$t3 226e1051a39Sopenharmony_ci .set noreorder 227e1051a39Sopenharmony_ci bnez $cnt,.Loop_enc 228e1051a39Sopenharmony_ci ext $i0,$s1,16,8 229e1051a39Sopenharmony_ci 230e1051a39Sopenharmony_ci _xtr $i0,$s1,16-2 231e1051a39Sopenharmony_ci#else 232e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 233e1051a39Sopenharmony_ci move $i0,$Tbl 234e1051a39Sopenharmony_ci move $i1,$Tbl 235e1051a39Sopenharmony_ci move $i2,$Tbl 236e1051a39Sopenharmony_ci move $i3,$Tbl 237e1051a39Sopenharmony_ci ext $t0,$s1,16,8 238e1051a39Sopenharmony_ci.Loop_enc: 239e1051a39Sopenharmony_ci ext $t1,$s2,16,8 240e1051a39Sopenharmony_ci ext $t2,$s3,16,8 241e1051a39Sopenharmony_ci ext $t3,$s0,16,8 242e1051a39Sopenharmony_ci $PTR_INS $i0,$t0,2,8 243e1051a39Sopenharmony_ci $PTR_INS $i1,$t1,2,8 244e1051a39Sopenharmony_ci $PTR_INS $i2,$t2,2,8 245e1051a39Sopenharmony_ci $PTR_INS $i3,$t3,2,8 246e1051a39Sopenharmony_ci lw $t0,0($i0) # Te1[s1>>16] 247e1051a39Sopenharmony_ci ext $t4,$s2,8,8 248e1051a39Sopenharmony_ci lw $t1,0($i1) # Te1[s2>>16] 249e1051a39Sopenharmony_ci ext $t5,$s3,8,8 250e1051a39Sopenharmony_ci lw $t2,0($i2) # Te1[s3>>16] 251e1051a39Sopenharmony_ci ext $t6,$s0,8,8 252e1051a39Sopenharmony_ci lw $t3,0($i3) # Te1[s0>>16] 253e1051a39Sopenharmony_ci ext $t7,$s1,8,8 254e1051a39Sopenharmony_ci $PTR_INS $i0,$t4,2,8 255e1051a39Sopenharmony_ci $PTR_INS $i1,$t5,2,8 256e1051a39Sopenharmony_ci $PTR_INS $i2,$t6,2,8 257e1051a39Sopenharmony_ci $PTR_INS $i3,$t7,2,8 258e1051a39Sopenharmony_ci#else 259e1051a39Sopenharmony_ci _xtr $i0,$s1,16-2 260e1051a39Sopenharmony_ci.Loop_enc: 261e1051a39Sopenharmony_ci _xtr $i1,$s2,16-2 262e1051a39Sopenharmony_ci _xtr $i2,$s3,16-2 263e1051a39Sopenharmony_ci _xtr $i3,$s0,16-2 264e1051a39Sopenharmony_ci and $i0,0x3fc 265e1051a39Sopenharmony_ci and $i1,0x3fc 266e1051a39Sopenharmony_ci and $i2,0x3fc 267e1051a39Sopenharmony_ci and $i3,0x3fc 268e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 269e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 270e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 271e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 272e1051a39Sopenharmony_ci lwl $t0,3($i0) # Te1[s1>>16] 273e1051a39Sopenharmony_ci lwl $t1,3($i1) # Te1[s2>>16] 274e1051a39Sopenharmony_ci lwl $t2,3($i2) # Te1[s3>>16] 275e1051a39Sopenharmony_ci lwl $t3,3($i3) # Te1[s0>>16] 276e1051a39Sopenharmony_ci lwr $t0,2($i0) # Te1[s1>>16] 277e1051a39Sopenharmony_ci _xtr $i0,$s2,8-2 278e1051a39Sopenharmony_ci lwr $t1,2($i1) # Te1[s2>>16] 279e1051a39Sopenharmony_ci _xtr $i1,$s3,8-2 280e1051a39Sopenharmony_ci lwr $t2,2($i2) # Te1[s3>>16] 281e1051a39Sopenharmony_ci _xtr $i2,$s0,8-2 282e1051a39Sopenharmony_ci lwr $t3,2($i3) # Te1[s0>>16] 283e1051a39Sopenharmony_ci _xtr $i3,$s1,8-2 284e1051a39Sopenharmony_ci and $i0,0x3fc 285e1051a39Sopenharmony_ci and $i1,0x3fc 286e1051a39Sopenharmony_ci and $i2,0x3fc 287e1051a39Sopenharmony_ci and $i3,0x3fc 288e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 289e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 290e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 291e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 292e1051a39Sopenharmony_ci#endif 293e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 294e1051a39Sopenharmony_ci rotr $t0,$t0,8 295e1051a39Sopenharmony_ci rotr $t1,$t1,8 296e1051a39Sopenharmony_ci rotr $t2,$t2,8 297e1051a39Sopenharmony_ci rotr $t3,$t3,8 298e1051a39Sopenharmony_ci# if defined(_MIPSEL) 299e1051a39Sopenharmony_ci lw $t4,0($i0) # Te2[s2>>8] 300e1051a39Sopenharmony_ci ext $t8,$s3,0,8 301e1051a39Sopenharmony_ci lw $t5,0($i1) # Te2[s3>>8] 302e1051a39Sopenharmony_ci ext $t9,$s0,0,8 303e1051a39Sopenharmony_ci lw $t6,0($i2) # Te2[s0>>8] 304e1051a39Sopenharmony_ci ext $t10,$s1,0,8 305e1051a39Sopenharmony_ci lw $t7,0($i3) # Te2[s1>>8] 306e1051a39Sopenharmony_ci ext $t11,$s2,0,8 307e1051a39Sopenharmony_ci $PTR_INS $i0,$t8,2,8 308e1051a39Sopenharmony_ci $PTR_INS $i1,$t9,2,8 309e1051a39Sopenharmony_ci $PTR_INS $i2,$t10,2,8 310e1051a39Sopenharmony_ci $PTR_INS $i3,$t11,2,8 311e1051a39Sopenharmony_ci 312e1051a39Sopenharmony_ci lw $t8,0($i0) # Te3[s3] 313e1051a39Sopenharmony_ci $PTR_INS $i0,$s0,2,8 314e1051a39Sopenharmony_ci lw $t9,0($i1) # Te3[s0] 315e1051a39Sopenharmony_ci $PTR_INS $i1,$s1,2,8 316e1051a39Sopenharmony_ci lw $t10,0($i2) # Te3[s1] 317e1051a39Sopenharmony_ci $PTR_INS $i2,$s2,2,8 318e1051a39Sopenharmony_ci lw $t11,0($i3) # Te3[s2] 319e1051a39Sopenharmony_ci $PTR_INS $i3,$s3,2,8 320e1051a39Sopenharmony_ci# else 321e1051a39Sopenharmony_ci lw $t4,0($i0) # Te2[s2>>8] 322e1051a39Sopenharmony_ci $PTR_INS $i0,$s3,2,8 323e1051a39Sopenharmony_ci lw $t5,0($i1) # Te2[s3>>8] 324e1051a39Sopenharmony_ci $PTR_INS $i1,$s0,2,8 325e1051a39Sopenharmony_ci lw $t6,0($i2) # Te2[s0>>8] 326e1051a39Sopenharmony_ci $PTR_INS $i2,$s1,2,8 327e1051a39Sopenharmony_ci lw $t7,0($i3) # Te2[s1>>8] 328e1051a39Sopenharmony_ci $PTR_INS $i3,$s2,2,8 329e1051a39Sopenharmony_ci 330e1051a39Sopenharmony_ci lw $t8,0($i0) # Te3[s3] 331e1051a39Sopenharmony_ci _xtr $i0,$s0,24-2 332e1051a39Sopenharmony_ci lw $t9,0($i1) # Te3[s0] 333e1051a39Sopenharmony_ci _xtr $i1,$s1,24-2 334e1051a39Sopenharmony_ci lw $t10,0($i2) # Te3[s1] 335e1051a39Sopenharmony_ci _xtr $i2,$s2,24-2 336e1051a39Sopenharmony_ci lw $t11,0($i3) # Te3[s2] 337e1051a39Sopenharmony_ci _xtr $i3,$s3,24-2 338e1051a39Sopenharmony_ci 339e1051a39Sopenharmony_ci and $i0,0x3fc 340e1051a39Sopenharmony_ci and $i1,0x3fc 341e1051a39Sopenharmony_ci and $i2,0x3fc 342e1051a39Sopenharmony_ci and $i3,0x3fc 343e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 344e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 345e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 346e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 347e1051a39Sopenharmony_ci# endif 348e1051a39Sopenharmony_ci rotr $t4,$t4,16 349e1051a39Sopenharmony_ci rotr $t5,$t5,16 350e1051a39Sopenharmony_ci rotr $t6,$t6,16 351e1051a39Sopenharmony_ci rotr $t7,$t7,16 352e1051a39Sopenharmony_ci 353e1051a39Sopenharmony_ci rotr $t8,$t8,24 354e1051a39Sopenharmony_ci rotr $t9,$t9,24 355e1051a39Sopenharmony_ci rotr $t10,$t10,24 356e1051a39Sopenharmony_ci rotr $t11,$t11,24 357e1051a39Sopenharmony_ci#else 358e1051a39Sopenharmony_ci lwl $t4,2($i0) # Te2[s2>>8] 359e1051a39Sopenharmony_ci lwl $t5,2($i1) # Te2[s3>>8] 360e1051a39Sopenharmony_ci lwl $t6,2($i2) # Te2[s0>>8] 361e1051a39Sopenharmony_ci lwl $t7,2($i3) # Te2[s1>>8] 362e1051a39Sopenharmony_ci lwr $t4,1($i0) # Te2[s2>>8] 363e1051a39Sopenharmony_ci _xtr $i0,$s3,0-2 364e1051a39Sopenharmony_ci lwr $t5,1($i1) # Te2[s3>>8] 365e1051a39Sopenharmony_ci _xtr $i1,$s0,0-2 366e1051a39Sopenharmony_ci lwr $t6,1($i2) # Te2[s0>>8] 367e1051a39Sopenharmony_ci _xtr $i2,$s1,0-2 368e1051a39Sopenharmony_ci lwr $t7,1($i3) # Te2[s1>>8] 369e1051a39Sopenharmony_ci _xtr $i3,$s2,0-2 370e1051a39Sopenharmony_ci 371e1051a39Sopenharmony_ci and $i0,0x3fc 372e1051a39Sopenharmony_ci and $i1,0x3fc 373e1051a39Sopenharmony_ci and $i2,0x3fc 374e1051a39Sopenharmony_ci and $i3,0x3fc 375e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 376e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 377e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 378e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 379e1051a39Sopenharmony_ci lwl $t8,1($i0) # Te3[s3] 380e1051a39Sopenharmony_ci lwl $t9,1($i1) # Te3[s0] 381e1051a39Sopenharmony_ci lwl $t10,1($i2) # Te3[s1] 382e1051a39Sopenharmony_ci lwl $t11,1($i3) # Te3[s2] 383e1051a39Sopenharmony_ci lwr $t8,0($i0) # Te3[s3] 384e1051a39Sopenharmony_ci _xtr $i0,$s0,24-2 385e1051a39Sopenharmony_ci lwr $t9,0($i1) # Te3[s0] 386e1051a39Sopenharmony_ci _xtr $i1,$s1,24-2 387e1051a39Sopenharmony_ci lwr $t10,0($i2) # Te3[s1] 388e1051a39Sopenharmony_ci _xtr $i2,$s2,24-2 389e1051a39Sopenharmony_ci lwr $t11,0($i3) # Te3[s2] 390e1051a39Sopenharmony_ci _xtr $i3,$s3,24-2 391e1051a39Sopenharmony_ci 392e1051a39Sopenharmony_ci and $i0,0x3fc 393e1051a39Sopenharmony_ci and $i1,0x3fc 394e1051a39Sopenharmony_ci and $i2,0x3fc 395e1051a39Sopenharmony_ci and $i3,0x3fc 396e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 397e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 398e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 399e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 400e1051a39Sopenharmony_ci#endif 401e1051a39Sopenharmony_ci xor $t0,$t4 402e1051a39Sopenharmony_ci lw $t4,0($i0) # Te0[s0>>24] 403e1051a39Sopenharmony_ci xor $t1,$t5 404e1051a39Sopenharmony_ci lw $t5,0($i1) # Te0[s1>>24] 405e1051a39Sopenharmony_ci xor $t2,$t6 406e1051a39Sopenharmony_ci lw $t6,0($i2) # Te0[s2>>24] 407e1051a39Sopenharmony_ci xor $t3,$t7 408e1051a39Sopenharmony_ci lw $t7,0($i3) # Te0[s3>>24] 409e1051a39Sopenharmony_ci 410e1051a39Sopenharmony_ci xor $t0,$t8 411e1051a39Sopenharmony_ci lw $s0,0($key0) 412e1051a39Sopenharmony_ci xor $t1,$t9 413e1051a39Sopenharmony_ci lw $s1,4($key0) 414e1051a39Sopenharmony_ci xor $t2,$t10 415e1051a39Sopenharmony_ci lw $s2,8($key0) 416e1051a39Sopenharmony_ci xor $t3,$t11 417e1051a39Sopenharmony_ci lw $s3,12($key0) 418e1051a39Sopenharmony_ci 419e1051a39Sopenharmony_ci xor $t0,$t4 420e1051a39Sopenharmony_ci xor $t1,$t5 421e1051a39Sopenharmony_ci xor $t2,$t6 422e1051a39Sopenharmony_ci xor $t3,$t7 423e1051a39Sopenharmony_ci 424e1051a39Sopenharmony_ci subu $cnt,1 425e1051a39Sopenharmony_ci $PTR_ADD $key0,16 426e1051a39Sopenharmony_ci xor $s0,$t0 427e1051a39Sopenharmony_ci xor $s1,$t1 428e1051a39Sopenharmony_ci xor $s2,$t2 429e1051a39Sopenharmony_ci xor $s3,$t3 430e1051a39Sopenharmony_ci .set noreorder 431e1051a39Sopenharmony_ci bnez $cnt,.Loop_enc 432e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 433e1051a39Sopenharmony_ci ext $t0,$s1,16,8 434e1051a39Sopenharmony_ci#endif 435e1051a39Sopenharmony_ci _xtr $i0,$s1,16-2 436e1051a39Sopenharmony_ci#endif 437e1051a39Sopenharmony_ci 438e1051a39Sopenharmony_ci .set reorder 439e1051a39Sopenharmony_ci _xtr $i1,$s2,16-2 440e1051a39Sopenharmony_ci _xtr $i2,$s3,16-2 441e1051a39Sopenharmony_ci _xtr $i3,$s0,16-2 442e1051a39Sopenharmony_ci and $i0,0x3fc 443e1051a39Sopenharmony_ci and $i1,0x3fc 444e1051a39Sopenharmony_ci and $i2,0x3fc 445e1051a39Sopenharmony_ci and $i3,0x3fc 446e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 447e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 448e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 449e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 450e1051a39Sopenharmony_ci lbu $t0,2($i0) # Te4[s1>>16] 451e1051a39Sopenharmony_ci _xtr $i0,$s2,8-2 452e1051a39Sopenharmony_ci lbu $t1,2($i1) # Te4[s2>>16] 453e1051a39Sopenharmony_ci _xtr $i1,$s3,8-2 454e1051a39Sopenharmony_ci lbu $t2,2($i2) # Te4[s3>>16] 455e1051a39Sopenharmony_ci _xtr $i2,$s0,8-2 456e1051a39Sopenharmony_ci lbu $t3,2($i3) # Te4[s0>>16] 457e1051a39Sopenharmony_ci _xtr $i3,$s1,8-2 458e1051a39Sopenharmony_ci 459e1051a39Sopenharmony_ci and $i0,0x3fc 460e1051a39Sopenharmony_ci and $i1,0x3fc 461e1051a39Sopenharmony_ci and $i2,0x3fc 462e1051a39Sopenharmony_ci and $i3,0x3fc 463e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 464e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 465e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 466e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 467e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 468e1051a39Sopenharmony_ci# if defined(_MIPSEL) 469e1051a39Sopenharmony_ci lbu $t4,2($i0) # Te4[s2>>8] 470e1051a39Sopenharmony_ci $PTR_INS $i0,$s0,2,8 471e1051a39Sopenharmony_ci lbu $t5,2($i1) # Te4[s3>>8] 472e1051a39Sopenharmony_ci $PTR_INS $i1,$s1,2,8 473e1051a39Sopenharmony_ci lbu $t6,2($i2) # Te4[s0>>8] 474e1051a39Sopenharmony_ci $PTR_INS $i2,$s2,2,8 475e1051a39Sopenharmony_ci lbu $t7,2($i3) # Te4[s1>>8] 476e1051a39Sopenharmony_ci $PTR_INS $i3,$s3,2,8 477e1051a39Sopenharmony_ci 478e1051a39Sopenharmony_ci lbu $t8,2($i0) # Te4[s0>>24] 479e1051a39Sopenharmony_ci _xtr $i0,$s3,0-2 480e1051a39Sopenharmony_ci lbu $t9,2($i1) # Te4[s1>>24] 481e1051a39Sopenharmony_ci _xtr $i1,$s0,0-2 482e1051a39Sopenharmony_ci lbu $t10,2($i2) # Te4[s2>>24] 483e1051a39Sopenharmony_ci _xtr $i2,$s1,0-2 484e1051a39Sopenharmony_ci lbu $t11,2($i3) # Te4[s3>>24] 485e1051a39Sopenharmony_ci _xtr $i3,$s2,0-2 486e1051a39Sopenharmony_ci 487e1051a39Sopenharmony_ci and $i0,0x3fc 488e1051a39Sopenharmony_ci and $i1,0x3fc 489e1051a39Sopenharmony_ci and $i2,0x3fc 490e1051a39Sopenharmony_ci and $i3,0x3fc 491e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 492e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 493e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 494e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 495e1051a39Sopenharmony_ci# else 496e1051a39Sopenharmony_ci lbu $t4,2($i0) # Te4[s2>>8] 497e1051a39Sopenharmony_ci _xtr $i0,$s0,24-2 498e1051a39Sopenharmony_ci lbu $t5,2($i1) # Te4[s3>>8] 499e1051a39Sopenharmony_ci _xtr $i1,$s1,24-2 500e1051a39Sopenharmony_ci lbu $t6,2($i2) # Te4[s0>>8] 501e1051a39Sopenharmony_ci _xtr $i2,$s2,24-2 502e1051a39Sopenharmony_ci lbu $t7,2($i3) # Te4[s1>>8] 503e1051a39Sopenharmony_ci _xtr $i3,$s3,24-2 504e1051a39Sopenharmony_ci 505e1051a39Sopenharmony_ci and $i0,0x3fc 506e1051a39Sopenharmony_ci and $i1,0x3fc 507e1051a39Sopenharmony_ci and $i2,0x3fc 508e1051a39Sopenharmony_ci and $i3,0x3fc 509e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 510e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 511e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 512e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 513e1051a39Sopenharmony_ci lbu $t8,2($i0) # Te4[s0>>24] 514e1051a39Sopenharmony_ci $PTR_INS $i0,$s3,2,8 515e1051a39Sopenharmony_ci lbu $t9,2($i1) # Te4[s1>>24] 516e1051a39Sopenharmony_ci $PTR_INS $i1,$s0,2,8 517e1051a39Sopenharmony_ci lbu $t10,2($i2) # Te4[s2>>24] 518e1051a39Sopenharmony_ci $PTR_INS $i2,$s1,2,8 519e1051a39Sopenharmony_ci lbu $t11,2($i3) # Te4[s3>>24] 520e1051a39Sopenharmony_ci $PTR_INS $i3,$s2,2,8 521e1051a39Sopenharmony_ci# endif 522e1051a39Sopenharmony_ci _ins $t0,16 523e1051a39Sopenharmony_ci _ins $t1,16 524e1051a39Sopenharmony_ci _ins $t2,16 525e1051a39Sopenharmony_ci _ins $t3,16 526e1051a39Sopenharmony_ci 527e1051a39Sopenharmony_ci _ins2 $t0,$t4,8 528e1051a39Sopenharmony_ci lbu $t4,2($i0) # Te4[s3] 529e1051a39Sopenharmony_ci _ins2 $t1,$t5,8 530e1051a39Sopenharmony_ci lbu $t5,2($i1) # Te4[s0] 531e1051a39Sopenharmony_ci _ins2 $t2,$t6,8 532e1051a39Sopenharmony_ci lbu $t6,2($i2) # Te4[s1] 533e1051a39Sopenharmony_ci _ins2 $t3,$t7,8 534e1051a39Sopenharmony_ci lbu $t7,2($i3) # Te4[s2] 535e1051a39Sopenharmony_ci 536e1051a39Sopenharmony_ci _ins2 $t0,$t8,24 537e1051a39Sopenharmony_ci lw $s0,0($key0) 538e1051a39Sopenharmony_ci _ins2 $t1,$t9,24 539e1051a39Sopenharmony_ci lw $s1,4($key0) 540e1051a39Sopenharmony_ci _ins2 $t2,$t10,24 541e1051a39Sopenharmony_ci lw $s2,8($key0) 542e1051a39Sopenharmony_ci _ins2 $t3,$t11,24 543e1051a39Sopenharmony_ci lw $s3,12($key0) 544e1051a39Sopenharmony_ci 545e1051a39Sopenharmony_ci _ins2 $t0,$t4,0 546e1051a39Sopenharmony_ci _ins2 $t1,$t5,0 547e1051a39Sopenharmony_ci _ins2 $t2,$t6,0 548e1051a39Sopenharmony_ci _ins2 $t3,$t7,0 549e1051a39Sopenharmony_ci#else 550e1051a39Sopenharmony_ci lbu $t4,2($i0) # Te4[s2>>8] 551e1051a39Sopenharmony_ci _xtr $i0,$s0,24-2 552e1051a39Sopenharmony_ci lbu $t5,2($i1) # Te4[s3>>8] 553e1051a39Sopenharmony_ci _xtr $i1,$s1,24-2 554e1051a39Sopenharmony_ci lbu $t6,2($i2) # Te4[s0>>8] 555e1051a39Sopenharmony_ci _xtr $i2,$s2,24-2 556e1051a39Sopenharmony_ci lbu $t7,2($i3) # Te4[s1>>8] 557e1051a39Sopenharmony_ci _xtr $i3,$s3,24-2 558e1051a39Sopenharmony_ci 559e1051a39Sopenharmony_ci and $i0,0x3fc 560e1051a39Sopenharmony_ci and $i1,0x3fc 561e1051a39Sopenharmony_ci and $i2,0x3fc 562e1051a39Sopenharmony_ci and $i3,0x3fc 563e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 564e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 565e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 566e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 567e1051a39Sopenharmony_ci lbu $t8,2($i0) # Te4[s0>>24] 568e1051a39Sopenharmony_ci _xtr $i0,$s3,0-2 569e1051a39Sopenharmony_ci lbu $t9,2($i1) # Te4[s1>>24] 570e1051a39Sopenharmony_ci _xtr $i1,$s0,0-2 571e1051a39Sopenharmony_ci lbu $t10,2($i2) # Te4[s2>>24] 572e1051a39Sopenharmony_ci _xtr $i2,$s1,0-2 573e1051a39Sopenharmony_ci lbu $t11,2($i3) # Te4[s3>>24] 574e1051a39Sopenharmony_ci _xtr $i3,$s2,0-2 575e1051a39Sopenharmony_ci 576e1051a39Sopenharmony_ci and $i0,0x3fc 577e1051a39Sopenharmony_ci and $i1,0x3fc 578e1051a39Sopenharmony_ci and $i2,0x3fc 579e1051a39Sopenharmony_ci and $i3,0x3fc 580e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 581e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 582e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 583e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 584e1051a39Sopenharmony_ci 585e1051a39Sopenharmony_ci _ins $t0,16 586e1051a39Sopenharmony_ci _ins $t1,16 587e1051a39Sopenharmony_ci _ins $t2,16 588e1051a39Sopenharmony_ci _ins $t3,16 589e1051a39Sopenharmony_ci 590e1051a39Sopenharmony_ci _ins $t4,8 591e1051a39Sopenharmony_ci _ins $t5,8 592e1051a39Sopenharmony_ci _ins $t6,8 593e1051a39Sopenharmony_ci _ins $t7,8 594e1051a39Sopenharmony_ci 595e1051a39Sopenharmony_ci xor $t0,$t4 596e1051a39Sopenharmony_ci lbu $t4,2($i0) # Te4[s3] 597e1051a39Sopenharmony_ci xor $t1,$t5 598e1051a39Sopenharmony_ci lbu $t5,2($i1) # Te4[s0] 599e1051a39Sopenharmony_ci xor $t2,$t6 600e1051a39Sopenharmony_ci lbu $t6,2($i2) # Te4[s1] 601e1051a39Sopenharmony_ci xor $t3,$t7 602e1051a39Sopenharmony_ci lbu $t7,2($i3) # Te4[s2] 603e1051a39Sopenharmony_ci 604e1051a39Sopenharmony_ci _ins $t8,24 605e1051a39Sopenharmony_ci lw $s0,0($key0) 606e1051a39Sopenharmony_ci _ins $t9,24 607e1051a39Sopenharmony_ci lw $s1,4($key0) 608e1051a39Sopenharmony_ci _ins $t10,24 609e1051a39Sopenharmony_ci lw $s2,8($key0) 610e1051a39Sopenharmony_ci _ins $t11,24 611e1051a39Sopenharmony_ci lw $s3,12($key0) 612e1051a39Sopenharmony_ci 613e1051a39Sopenharmony_ci xor $t0,$t8 614e1051a39Sopenharmony_ci xor $t1,$t9 615e1051a39Sopenharmony_ci xor $t2,$t10 616e1051a39Sopenharmony_ci xor $t3,$t11 617e1051a39Sopenharmony_ci 618e1051a39Sopenharmony_ci _ins $t4,0 619e1051a39Sopenharmony_ci _ins $t5,0 620e1051a39Sopenharmony_ci _ins $t6,0 621e1051a39Sopenharmony_ci _ins $t7,0 622e1051a39Sopenharmony_ci 623e1051a39Sopenharmony_ci xor $t0,$t4 624e1051a39Sopenharmony_ci xor $t1,$t5 625e1051a39Sopenharmony_ci xor $t2,$t6 626e1051a39Sopenharmony_ci xor $t3,$t7 627e1051a39Sopenharmony_ci#endif 628e1051a39Sopenharmony_ci xor $s0,$t0 629e1051a39Sopenharmony_ci xor $s1,$t1 630e1051a39Sopenharmony_ci xor $s2,$t2 631e1051a39Sopenharmony_ci xor $s3,$t3 632e1051a39Sopenharmony_ci 633e1051a39Sopenharmony_ci jr $ra 634e1051a39Sopenharmony_ci.end _mips_AES_encrypt 635e1051a39Sopenharmony_ci 636e1051a39Sopenharmony_ci.align 5 637e1051a39Sopenharmony_ci.globl AES_encrypt 638e1051a39Sopenharmony_ci.ent AES_encrypt 639e1051a39Sopenharmony_ciAES_encrypt: 640e1051a39Sopenharmony_ci .frame $sp,$FRAMESIZE,$ra 641e1051a39Sopenharmony_ci .mask $SAVED_REGS_MASK,-$SZREG 642e1051a39Sopenharmony_ci .set noreorder 643e1051a39Sopenharmony_ci___ 644e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /o32/i); # o32 PIC-ification 645e1051a39Sopenharmony_ci .cpload $pf 646e1051a39Sopenharmony_ci___ 647e1051a39Sopenharmony_ci$code.=<<___; 648e1051a39Sopenharmony_ci $PTR_SUB $sp,$FRAMESIZE 649e1051a39Sopenharmony_ci $REG_S $ra,$FRAMESIZE-1*$SZREG($sp) 650e1051a39Sopenharmony_ci $REG_S $fp,$FRAMESIZE-2*$SZREG($sp) 651e1051a39Sopenharmony_ci $REG_S $s11,$FRAMESIZE-3*$SZREG($sp) 652e1051a39Sopenharmony_ci $REG_S $s10,$FRAMESIZE-4*$SZREG($sp) 653e1051a39Sopenharmony_ci $REG_S $s9,$FRAMESIZE-5*$SZREG($sp) 654e1051a39Sopenharmony_ci $REG_S $s8,$FRAMESIZE-6*$SZREG($sp) 655e1051a39Sopenharmony_ci $REG_S $s7,$FRAMESIZE-7*$SZREG($sp) 656e1051a39Sopenharmony_ci $REG_S $s6,$FRAMESIZE-8*$SZREG($sp) 657e1051a39Sopenharmony_ci $REG_S $s5,$FRAMESIZE-9*$SZREG($sp) 658e1051a39Sopenharmony_ci $REG_S $s4,$FRAMESIZE-10*$SZREG($sp) 659e1051a39Sopenharmony_ci___ 660e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue 661e1051a39Sopenharmony_ci $REG_S \$15,$FRAMESIZE-11*$SZREG($sp) 662e1051a39Sopenharmony_ci $REG_S \$14,$FRAMESIZE-12*$SZREG($sp) 663e1051a39Sopenharmony_ci $REG_S \$13,$FRAMESIZE-13*$SZREG($sp) 664e1051a39Sopenharmony_ci $REG_S \$12,$FRAMESIZE-14*$SZREG($sp) 665e1051a39Sopenharmony_ci $REG_S $gp,$FRAMESIZE-15*$SZREG($sp) 666e1051a39Sopenharmony_ci___ 667e1051a39Sopenharmony_ci$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification 668e1051a39Sopenharmony_ci .cplocal $Tbl 669e1051a39Sopenharmony_ci .cpsetup $pf,$zero,AES_encrypt 670e1051a39Sopenharmony_ci___ 671e1051a39Sopenharmony_ci$code.=<<___; 672e1051a39Sopenharmony_ci .set reorder 673e1051a39Sopenharmony_ci $PTR_LA $Tbl,AES_Te # PIC-ified 'load address' 674e1051a39Sopenharmony_ci 675e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 676e1051a39Sopenharmony_ci lw $s0,0($inp) 677e1051a39Sopenharmony_ci lw $s1,4($inp) 678e1051a39Sopenharmony_ci lw $s2,8($inp) 679e1051a39Sopenharmony_ci lw $s3,12($inp) 680e1051a39Sopenharmony_ci#else 681e1051a39Sopenharmony_ci lwl $s0,0+$MSB($inp) 682e1051a39Sopenharmony_ci lwl $s1,4+$MSB($inp) 683e1051a39Sopenharmony_ci lwl $s2,8+$MSB($inp) 684e1051a39Sopenharmony_ci lwl $s3,12+$MSB($inp) 685e1051a39Sopenharmony_ci lwr $s0,0+$LSB($inp) 686e1051a39Sopenharmony_ci lwr $s1,4+$LSB($inp) 687e1051a39Sopenharmony_ci lwr $s2,8+$LSB($inp) 688e1051a39Sopenharmony_ci lwr $s3,12+$LSB($inp) 689e1051a39Sopenharmony_ci#endif 690e1051a39Sopenharmony_ci 691e1051a39Sopenharmony_ci bal _mips_AES_encrypt 692e1051a39Sopenharmony_ci 693e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 694e1051a39Sopenharmony_ci sw $s0,0($out) 695e1051a39Sopenharmony_ci sw $s1,4($out) 696e1051a39Sopenharmony_ci sw $s2,8($out) 697e1051a39Sopenharmony_ci sw $s3,12($out) 698e1051a39Sopenharmony_ci#else 699e1051a39Sopenharmony_ci swr $s0,0+$LSB($out) 700e1051a39Sopenharmony_ci swr $s1,4+$LSB($out) 701e1051a39Sopenharmony_ci swr $s2,8+$LSB($out) 702e1051a39Sopenharmony_ci swr $s3,12+$LSB($out) 703e1051a39Sopenharmony_ci swl $s0,0+$MSB($out) 704e1051a39Sopenharmony_ci swl $s1,4+$MSB($out) 705e1051a39Sopenharmony_ci swl $s2,8+$MSB($out) 706e1051a39Sopenharmony_ci swl $s3,12+$MSB($out) 707e1051a39Sopenharmony_ci#endif 708e1051a39Sopenharmony_ci 709e1051a39Sopenharmony_ci .set noreorder 710e1051a39Sopenharmony_ci $REG_L $ra,$FRAMESIZE-1*$SZREG($sp) 711e1051a39Sopenharmony_ci $REG_L $fp,$FRAMESIZE-2*$SZREG($sp) 712e1051a39Sopenharmony_ci $REG_L $s11,$FRAMESIZE-3*$SZREG($sp) 713e1051a39Sopenharmony_ci $REG_L $s10,$FRAMESIZE-4*$SZREG($sp) 714e1051a39Sopenharmony_ci $REG_L $s9,$FRAMESIZE-5*$SZREG($sp) 715e1051a39Sopenharmony_ci $REG_L $s8,$FRAMESIZE-6*$SZREG($sp) 716e1051a39Sopenharmony_ci $REG_L $s7,$FRAMESIZE-7*$SZREG($sp) 717e1051a39Sopenharmony_ci $REG_L $s6,$FRAMESIZE-8*$SZREG($sp) 718e1051a39Sopenharmony_ci $REG_L $s5,$FRAMESIZE-9*$SZREG($sp) 719e1051a39Sopenharmony_ci $REG_L $s4,$FRAMESIZE-10*$SZREG($sp) 720e1051a39Sopenharmony_ci___ 721e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); 722e1051a39Sopenharmony_ci $REG_L \$15,$FRAMESIZE-11*$SZREG($sp) 723e1051a39Sopenharmony_ci $REG_L \$14,$FRAMESIZE-12*$SZREG($sp) 724e1051a39Sopenharmony_ci $REG_L \$13,$FRAMESIZE-13*$SZREG($sp) 725e1051a39Sopenharmony_ci $REG_L \$12,$FRAMESIZE-14*$SZREG($sp) 726e1051a39Sopenharmony_ci $REG_L $gp,$FRAMESIZE-15*$SZREG($sp) 727e1051a39Sopenharmony_ci___ 728e1051a39Sopenharmony_ci$code.=<<___; 729e1051a39Sopenharmony_ci jr $ra 730e1051a39Sopenharmony_ci $PTR_ADD $sp,$FRAMESIZE 731e1051a39Sopenharmony_ci.end AES_encrypt 732e1051a39Sopenharmony_ci___ 733e1051a39Sopenharmony_ci 734e1051a39Sopenharmony_ci$code.=<<___; 735e1051a39Sopenharmony_ci.align 5 736e1051a39Sopenharmony_ci.ent _mips_AES_decrypt 737e1051a39Sopenharmony_ci_mips_AES_decrypt: 738e1051a39Sopenharmony_ci .frame $sp,0,$ra 739e1051a39Sopenharmony_ci .set reorder 740e1051a39Sopenharmony_ci lw $t0,0($key) 741e1051a39Sopenharmony_ci lw $t1,4($key) 742e1051a39Sopenharmony_ci lw $t2,8($key) 743e1051a39Sopenharmony_ci lw $t3,12($key) 744e1051a39Sopenharmony_ci lw $cnt,240($key) 745e1051a39Sopenharmony_ci $PTR_ADD $key0,$key,16 746e1051a39Sopenharmony_ci 747e1051a39Sopenharmony_ci xor $s0,$t0 748e1051a39Sopenharmony_ci xor $s1,$t1 749e1051a39Sopenharmony_ci xor $s2,$t2 750e1051a39Sopenharmony_ci xor $s3,$t3 751e1051a39Sopenharmony_ci 752e1051a39Sopenharmony_ci subu $cnt,1 753e1051a39Sopenharmony_ci#if defined(__mips_smartmips) 754e1051a39Sopenharmony_ci ext $i0,$s3,16,8 755e1051a39Sopenharmony_ci.Loop_dec: 756e1051a39Sopenharmony_ci ext $i1,$s0,16,8 757e1051a39Sopenharmony_ci ext $i2,$s1,16,8 758e1051a39Sopenharmony_ci ext $i3,$s2,16,8 759e1051a39Sopenharmony_ci lwxs $t0,$i0($Tbl) # Td1[s3>>16] 760e1051a39Sopenharmony_ci ext $i0,$s2,8,8 761e1051a39Sopenharmony_ci lwxs $t1,$i1($Tbl) # Td1[s0>>16] 762e1051a39Sopenharmony_ci ext $i1,$s3,8,8 763e1051a39Sopenharmony_ci lwxs $t2,$i2($Tbl) # Td1[s1>>16] 764e1051a39Sopenharmony_ci ext $i2,$s0,8,8 765e1051a39Sopenharmony_ci lwxs $t3,$i3($Tbl) # Td1[s2>>16] 766e1051a39Sopenharmony_ci ext $i3,$s1,8,8 767e1051a39Sopenharmony_ci 768e1051a39Sopenharmony_ci lwxs $t4,$i0($Tbl) # Td2[s2>>8] 769e1051a39Sopenharmony_ci ext $i0,$s1,0,8 770e1051a39Sopenharmony_ci lwxs $t5,$i1($Tbl) # Td2[s3>>8] 771e1051a39Sopenharmony_ci ext $i1,$s2,0,8 772e1051a39Sopenharmony_ci lwxs $t6,$i2($Tbl) # Td2[s0>>8] 773e1051a39Sopenharmony_ci ext $i2,$s3,0,8 774e1051a39Sopenharmony_ci lwxs $t7,$i3($Tbl) # Td2[s1>>8] 775e1051a39Sopenharmony_ci ext $i3,$s0,0,8 776e1051a39Sopenharmony_ci 777e1051a39Sopenharmony_ci lwxs $t8,$i0($Tbl) # Td3[s1] 778e1051a39Sopenharmony_ci ext $i0,$s0,24,8 779e1051a39Sopenharmony_ci lwxs $t9,$i1($Tbl) # Td3[s2] 780e1051a39Sopenharmony_ci ext $i1,$s1,24,8 781e1051a39Sopenharmony_ci lwxs $t10,$i2($Tbl) # Td3[s3] 782e1051a39Sopenharmony_ci ext $i2,$s2,24,8 783e1051a39Sopenharmony_ci lwxs $t11,$i3($Tbl) # Td3[s0] 784e1051a39Sopenharmony_ci ext $i3,$s3,24,8 785e1051a39Sopenharmony_ci 786e1051a39Sopenharmony_ci rotr $t0,$t0,8 787e1051a39Sopenharmony_ci rotr $t1,$t1,8 788e1051a39Sopenharmony_ci rotr $t2,$t2,8 789e1051a39Sopenharmony_ci rotr $t3,$t3,8 790e1051a39Sopenharmony_ci 791e1051a39Sopenharmony_ci rotr $t4,$t4,16 792e1051a39Sopenharmony_ci rotr $t5,$t5,16 793e1051a39Sopenharmony_ci rotr $t6,$t6,16 794e1051a39Sopenharmony_ci rotr $t7,$t7,16 795e1051a39Sopenharmony_ci 796e1051a39Sopenharmony_ci xor $t0,$t4 797e1051a39Sopenharmony_ci lwxs $t4,$i0($Tbl) # Td0[s0>>24] 798e1051a39Sopenharmony_ci xor $t1,$t5 799e1051a39Sopenharmony_ci lwxs $t5,$i1($Tbl) # Td0[s1>>24] 800e1051a39Sopenharmony_ci xor $t2,$t6 801e1051a39Sopenharmony_ci lwxs $t6,$i2($Tbl) # Td0[s2>>24] 802e1051a39Sopenharmony_ci xor $t3,$t7 803e1051a39Sopenharmony_ci lwxs $t7,$i3($Tbl) # Td0[s3>>24] 804e1051a39Sopenharmony_ci 805e1051a39Sopenharmony_ci rotr $t8,$t8,24 806e1051a39Sopenharmony_ci lw $s0,0($key0) 807e1051a39Sopenharmony_ci rotr $t9,$t9,24 808e1051a39Sopenharmony_ci lw $s1,4($key0) 809e1051a39Sopenharmony_ci rotr $t10,$t10,24 810e1051a39Sopenharmony_ci lw $s2,8($key0) 811e1051a39Sopenharmony_ci rotr $t11,$t11,24 812e1051a39Sopenharmony_ci lw $s3,12($key0) 813e1051a39Sopenharmony_ci 814e1051a39Sopenharmony_ci xor $t0,$t8 815e1051a39Sopenharmony_ci xor $t1,$t9 816e1051a39Sopenharmony_ci xor $t2,$t10 817e1051a39Sopenharmony_ci xor $t3,$t11 818e1051a39Sopenharmony_ci 819e1051a39Sopenharmony_ci xor $t0,$t4 820e1051a39Sopenharmony_ci xor $t1,$t5 821e1051a39Sopenharmony_ci xor $t2,$t6 822e1051a39Sopenharmony_ci xor $t3,$t7 823e1051a39Sopenharmony_ci 824e1051a39Sopenharmony_ci subu $cnt,1 825e1051a39Sopenharmony_ci $PTR_ADD $key0,16 826e1051a39Sopenharmony_ci xor $s0,$t0 827e1051a39Sopenharmony_ci xor $s1,$t1 828e1051a39Sopenharmony_ci xor $s2,$t2 829e1051a39Sopenharmony_ci xor $s3,$t3 830e1051a39Sopenharmony_ci .set noreorder 831e1051a39Sopenharmony_ci bnez $cnt,.Loop_dec 832e1051a39Sopenharmony_ci ext $i0,$s3,16,8 833e1051a39Sopenharmony_ci 834e1051a39Sopenharmony_ci _xtr $i0,$s3,16-2 835e1051a39Sopenharmony_ci#else 836e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 837e1051a39Sopenharmony_ci move $i0,$Tbl 838e1051a39Sopenharmony_ci move $i1,$Tbl 839e1051a39Sopenharmony_ci move $i2,$Tbl 840e1051a39Sopenharmony_ci move $i3,$Tbl 841e1051a39Sopenharmony_ci ext $t0,$s3,16,8 842e1051a39Sopenharmony_ci.Loop_dec: 843e1051a39Sopenharmony_ci ext $t1,$s0,16,8 844e1051a39Sopenharmony_ci ext $t2,$s1,16,8 845e1051a39Sopenharmony_ci ext $t3,$s2,16,8 846e1051a39Sopenharmony_ci $PTR_INS $i0,$t0,2,8 847e1051a39Sopenharmony_ci $PTR_INS $i1,$t1,2,8 848e1051a39Sopenharmony_ci $PTR_INS $i2,$t2,2,8 849e1051a39Sopenharmony_ci $PTR_INS $i3,$t3,2,8 850e1051a39Sopenharmony_ci lw $t0,0($i0) # Td1[s3>>16] 851e1051a39Sopenharmony_ci ext $t4,$s2,8,8 852e1051a39Sopenharmony_ci lw $t1,0($i1) # Td1[s0>>16] 853e1051a39Sopenharmony_ci ext $t5,$s3,8,8 854e1051a39Sopenharmony_ci lw $t2,0($i2) # Td1[s1>>16] 855e1051a39Sopenharmony_ci ext $t6,$s0,8,8 856e1051a39Sopenharmony_ci lw $t3,0($i3) # Td1[s2>>16] 857e1051a39Sopenharmony_ci ext $t7,$s1,8,8 858e1051a39Sopenharmony_ci $PTR_INS $i0,$t4,2,8 859e1051a39Sopenharmony_ci $PTR_INS $i1,$t5,2,8 860e1051a39Sopenharmony_ci $PTR_INS $i2,$t6,2,8 861e1051a39Sopenharmony_ci $PTR_INS $i3,$t7,2,8 862e1051a39Sopenharmony_ci#else 863e1051a39Sopenharmony_ci _xtr $i0,$s3,16-2 864e1051a39Sopenharmony_ci.Loop_dec: 865e1051a39Sopenharmony_ci _xtr $i1,$s0,16-2 866e1051a39Sopenharmony_ci _xtr $i2,$s1,16-2 867e1051a39Sopenharmony_ci _xtr $i3,$s2,16-2 868e1051a39Sopenharmony_ci and $i0,0x3fc 869e1051a39Sopenharmony_ci and $i1,0x3fc 870e1051a39Sopenharmony_ci and $i2,0x3fc 871e1051a39Sopenharmony_ci and $i3,0x3fc 872e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 873e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 874e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 875e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 876e1051a39Sopenharmony_ci lwl $t0,3($i0) # Td1[s3>>16] 877e1051a39Sopenharmony_ci lwl $t1,3($i1) # Td1[s0>>16] 878e1051a39Sopenharmony_ci lwl $t2,3($i2) # Td1[s1>>16] 879e1051a39Sopenharmony_ci lwl $t3,3($i3) # Td1[s2>>16] 880e1051a39Sopenharmony_ci lwr $t0,2($i0) # Td1[s3>>16] 881e1051a39Sopenharmony_ci _xtr $i0,$s2,8-2 882e1051a39Sopenharmony_ci lwr $t1,2($i1) # Td1[s0>>16] 883e1051a39Sopenharmony_ci _xtr $i1,$s3,8-2 884e1051a39Sopenharmony_ci lwr $t2,2($i2) # Td1[s1>>16] 885e1051a39Sopenharmony_ci _xtr $i2,$s0,8-2 886e1051a39Sopenharmony_ci lwr $t3,2($i3) # Td1[s2>>16] 887e1051a39Sopenharmony_ci _xtr $i3,$s1,8-2 888e1051a39Sopenharmony_ci and $i0,0x3fc 889e1051a39Sopenharmony_ci and $i1,0x3fc 890e1051a39Sopenharmony_ci and $i2,0x3fc 891e1051a39Sopenharmony_ci and $i3,0x3fc 892e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 893e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 894e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 895e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 896e1051a39Sopenharmony_ci#endif 897e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 898e1051a39Sopenharmony_ci rotr $t0,$t0,8 899e1051a39Sopenharmony_ci rotr $t1,$t1,8 900e1051a39Sopenharmony_ci rotr $t2,$t2,8 901e1051a39Sopenharmony_ci rotr $t3,$t3,8 902e1051a39Sopenharmony_ci# if defined(_MIPSEL) 903e1051a39Sopenharmony_ci lw $t4,0($i0) # Td2[s2>>8] 904e1051a39Sopenharmony_ci ext $t8,$s1,0,8 905e1051a39Sopenharmony_ci lw $t5,0($i1) # Td2[s3>>8] 906e1051a39Sopenharmony_ci ext $t9,$s2,0,8 907e1051a39Sopenharmony_ci lw $t6,0($i2) # Td2[s0>>8] 908e1051a39Sopenharmony_ci ext $t10,$s3,0,8 909e1051a39Sopenharmony_ci lw $t7,0($i3) # Td2[s1>>8] 910e1051a39Sopenharmony_ci ext $t11,$s0,0,8 911e1051a39Sopenharmony_ci $PTR_INS $i0,$t8,2,8 912e1051a39Sopenharmony_ci $PTR_INS $i1,$t9,2,8 913e1051a39Sopenharmony_ci $PTR_INS $i2,$t10,2,8 914e1051a39Sopenharmony_ci $PTR_INS $i3,$t11,2,8 915e1051a39Sopenharmony_ci lw $t8,0($i0) # Td3[s1] 916e1051a39Sopenharmony_ci $PTR_INS $i0,$s0,2,8 917e1051a39Sopenharmony_ci lw $t9,0($i1) # Td3[s2] 918e1051a39Sopenharmony_ci $PTR_INS $i1,$s1,2,8 919e1051a39Sopenharmony_ci lw $t10,0($i2) # Td3[s3] 920e1051a39Sopenharmony_ci $PTR_INS $i2,$s2,2,8 921e1051a39Sopenharmony_ci lw $t11,0($i3) # Td3[s0] 922e1051a39Sopenharmony_ci $PTR_INS $i3,$s3,2,8 923e1051a39Sopenharmony_ci#else 924e1051a39Sopenharmony_ci lw $t4,0($i0) # Td2[s2>>8] 925e1051a39Sopenharmony_ci $PTR_INS $i0,$s1,2,8 926e1051a39Sopenharmony_ci lw $t5,0($i1) # Td2[s3>>8] 927e1051a39Sopenharmony_ci $PTR_INS $i1,$s2,2,8 928e1051a39Sopenharmony_ci lw $t6,0($i2) # Td2[s0>>8] 929e1051a39Sopenharmony_ci $PTR_INS $i2,$s3,2,8 930e1051a39Sopenharmony_ci lw $t7,0($i3) # Td2[s1>>8] 931e1051a39Sopenharmony_ci $PTR_INS $i3,$s0,2,8 932e1051a39Sopenharmony_ci 933e1051a39Sopenharmony_ci lw $t8,0($i0) # Td3[s1] 934e1051a39Sopenharmony_ci _xtr $i0,$s0,24-2 935e1051a39Sopenharmony_ci lw $t9,0($i1) # Td3[s2] 936e1051a39Sopenharmony_ci _xtr $i1,$s1,24-2 937e1051a39Sopenharmony_ci lw $t10,0($i2) # Td3[s3] 938e1051a39Sopenharmony_ci _xtr $i2,$s2,24-2 939e1051a39Sopenharmony_ci lw $t11,0($i3) # Td3[s0] 940e1051a39Sopenharmony_ci _xtr $i3,$s3,24-2 941e1051a39Sopenharmony_ci 942e1051a39Sopenharmony_ci and $i0,0x3fc 943e1051a39Sopenharmony_ci and $i1,0x3fc 944e1051a39Sopenharmony_ci and $i2,0x3fc 945e1051a39Sopenharmony_ci and $i3,0x3fc 946e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 947e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 948e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 949e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 950e1051a39Sopenharmony_ci#endif 951e1051a39Sopenharmony_ci rotr $t4,$t4,16 952e1051a39Sopenharmony_ci rotr $t5,$t5,16 953e1051a39Sopenharmony_ci rotr $t6,$t6,16 954e1051a39Sopenharmony_ci rotr $t7,$t7,16 955e1051a39Sopenharmony_ci 956e1051a39Sopenharmony_ci rotr $t8,$t8,24 957e1051a39Sopenharmony_ci rotr $t9,$t9,24 958e1051a39Sopenharmony_ci rotr $t10,$t10,24 959e1051a39Sopenharmony_ci rotr $t11,$t11,24 960e1051a39Sopenharmony_ci#else 961e1051a39Sopenharmony_ci lwl $t4,2($i0) # Td2[s2>>8] 962e1051a39Sopenharmony_ci lwl $t5,2($i1) # Td2[s3>>8] 963e1051a39Sopenharmony_ci lwl $t6,2($i2) # Td2[s0>>8] 964e1051a39Sopenharmony_ci lwl $t7,2($i3) # Td2[s1>>8] 965e1051a39Sopenharmony_ci lwr $t4,1($i0) # Td2[s2>>8] 966e1051a39Sopenharmony_ci _xtr $i0,$s1,0-2 967e1051a39Sopenharmony_ci lwr $t5,1($i1) # Td2[s3>>8] 968e1051a39Sopenharmony_ci _xtr $i1,$s2,0-2 969e1051a39Sopenharmony_ci lwr $t6,1($i2) # Td2[s0>>8] 970e1051a39Sopenharmony_ci _xtr $i2,$s3,0-2 971e1051a39Sopenharmony_ci lwr $t7,1($i3) # Td2[s1>>8] 972e1051a39Sopenharmony_ci _xtr $i3,$s0,0-2 973e1051a39Sopenharmony_ci 974e1051a39Sopenharmony_ci and $i0,0x3fc 975e1051a39Sopenharmony_ci and $i1,0x3fc 976e1051a39Sopenharmony_ci and $i2,0x3fc 977e1051a39Sopenharmony_ci and $i3,0x3fc 978e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 979e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 980e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 981e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 982e1051a39Sopenharmony_ci lwl $t8,1($i0) # Td3[s1] 983e1051a39Sopenharmony_ci lwl $t9,1($i1) # Td3[s2] 984e1051a39Sopenharmony_ci lwl $t10,1($i2) # Td3[s3] 985e1051a39Sopenharmony_ci lwl $t11,1($i3) # Td3[s0] 986e1051a39Sopenharmony_ci lwr $t8,0($i0) # Td3[s1] 987e1051a39Sopenharmony_ci _xtr $i0,$s0,24-2 988e1051a39Sopenharmony_ci lwr $t9,0($i1) # Td3[s2] 989e1051a39Sopenharmony_ci _xtr $i1,$s1,24-2 990e1051a39Sopenharmony_ci lwr $t10,0($i2) # Td3[s3] 991e1051a39Sopenharmony_ci _xtr $i2,$s2,24-2 992e1051a39Sopenharmony_ci lwr $t11,0($i3) # Td3[s0] 993e1051a39Sopenharmony_ci _xtr $i3,$s3,24-2 994e1051a39Sopenharmony_ci 995e1051a39Sopenharmony_ci and $i0,0x3fc 996e1051a39Sopenharmony_ci and $i1,0x3fc 997e1051a39Sopenharmony_ci and $i2,0x3fc 998e1051a39Sopenharmony_ci and $i3,0x3fc 999e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1000e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1001e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1002e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1003e1051a39Sopenharmony_ci#endif 1004e1051a39Sopenharmony_ci 1005e1051a39Sopenharmony_ci xor $t0,$t4 1006e1051a39Sopenharmony_ci lw $t4,0($i0) # Td0[s0>>24] 1007e1051a39Sopenharmony_ci xor $t1,$t5 1008e1051a39Sopenharmony_ci lw $t5,0($i1) # Td0[s1>>24] 1009e1051a39Sopenharmony_ci xor $t2,$t6 1010e1051a39Sopenharmony_ci lw $t6,0($i2) # Td0[s2>>24] 1011e1051a39Sopenharmony_ci xor $t3,$t7 1012e1051a39Sopenharmony_ci lw $t7,0($i3) # Td0[s3>>24] 1013e1051a39Sopenharmony_ci 1014e1051a39Sopenharmony_ci xor $t0,$t8 1015e1051a39Sopenharmony_ci lw $s0,0($key0) 1016e1051a39Sopenharmony_ci xor $t1,$t9 1017e1051a39Sopenharmony_ci lw $s1,4($key0) 1018e1051a39Sopenharmony_ci xor $t2,$t10 1019e1051a39Sopenharmony_ci lw $s2,8($key0) 1020e1051a39Sopenharmony_ci xor $t3,$t11 1021e1051a39Sopenharmony_ci lw $s3,12($key0) 1022e1051a39Sopenharmony_ci 1023e1051a39Sopenharmony_ci xor $t0,$t4 1024e1051a39Sopenharmony_ci xor $t1,$t5 1025e1051a39Sopenharmony_ci xor $t2,$t6 1026e1051a39Sopenharmony_ci xor $t3,$t7 1027e1051a39Sopenharmony_ci 1028e1051a39Sopenharmony_ci subu $cnt,1 1029e1051a39Sopenharmony_ci $PTR_ADD $key0,16 1030e1051a39Sopenharmony_ci xor $s0,$t0 1031e1051a39Sopenharmony_ci xor $s1,$t1 1032e1051a39Sopenharmony_ci xor $s2,$t2 1033e1051a39Sopenharmony_ci xor $s3,$t3 1034e1051a39Sopenharmony_ci .set noreorder 1035e1051a39Sopenharmony_ci bnez $cnt,.Loop_dec 1036e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 1037e1051a39Sopenharmony_ci ext $t0,$s3,16,8 1038e1051a39Sopenharmony_ci#endif 1039e1051a39Sopenharmony_ci 1040e1051a39Sopenharmony_ci _xtr $i0,$s3,16-2 1041e1051a39Sopenharmony_ci#endif 1042e1051a39Sopenharmony_ci 1043e1051a39Sopenharmony_ci .set reorder 1044e1051a39Sopenharmony_ci lw $t4,1024($Tbl) # prefetch Td4 1045e1051a39Sopenharmony_ci _xtr $i0,$s3,16 1046e1051a39Sopenharmony_ci lw $t5,1024+32($Tbl) 1047e1051a39Sopenharmony_ci _xtr $i1,$s0,16 1048e1051a39Sopenharmony_ci lw $t6,1024+64($Tbl) 1049e1051a39Sopenharmony_ci _xtr $i2,$s1,16 1050e1051a39Sopenharmony_ci lw $t7,1024+96($Tbl) 1051e1051a39Sopenharmony_ci _xtr $i3,$s2,16 1052e1051a39Sopenharmony_ci lw $t8,1024+128($Tbl) 1053e1051a39Sopenharmony_ci and $i0,0xff 1054e1051a39Sopenharmony_ci lw $t9,1024+160($Tbl) 1055e1051a39Sopenharmony_ci and $i1,0xff 1056e1051a39Sopenharmony_ci lw $t10,1024+192($Tbl) 1057e1051a39Sopenharmony_ci and $i2,0xff 1058e1051a39Sopenharmony_ci lw $t11,1024+224($Tbl) 1059e1051a39Sopenharmony_ci and $i3,0xff 1060e1051a39Sopenharmony_ci 1061e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1062e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1063e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1064e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1065e1051a39Sopenharmony_ci lbu $t0,1024($i0) # Td4[s3>>16] 1066e1051a39Sopenharmony_ci _xtr $i0,$s2,8 1067e1051a39Sopenharmony_ci lbu $t1,1024($i1) # Td4[s0>>16] 1068e1051a39Sopenharmony_ci _xtr $i1,$s3,8 1069e1051a39Sopenharmony_ci lbu $t2,1024($i2) # Td4[s1>>16] 1070e1051a39Sopenharmony_ci _xtr $i2,$s0,8 1071e1051a39Sopenharmony_ci lbu $t3,1024($i3) # Td4[s2>>16] 1072e1051a39Sopenharmony_ci _xtr $i3,$s1,8 1073e1051a39Sopenharmony_ci 1074e1051a39Sopenharmony_ci and $i0,0xff 1075e1051a39Sopenharmony_ci and $i1,0xff 1076e1051a39Sopenharmony_ci and $i2,0xff 1077e1051a39Sopenharmony_ci and $i3,0xff 1078e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1079e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1080e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1081e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1082e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 1083e1051a39Sopenharmony_ci# if defined(_MIPSEL) 1084e1051a39Sopenharmony_ci lbu $t4,1024($i0) # Td4[s2>>8] 1085e1051a39Sopenharmony_ci $PTR_INS $i0,$s0,0,8 1086e1051a39Sopenharmony_ci lbu $t5,1024($i1) # Td4[s3>>8] 1087e1051a39Sopenharmony_ci $PTR_INS $i1,$s1,0,8 1088e1051a39Sopenharmony_ci lbu $t6,1024($i2) # Td4[s0>>8] 1089e1051a39Sopenharmony_ci $PTR_INS $i2,$s2,0,8 1090e1051a39Sopenharmony_ci lbu $t7,1024($i3) # Td4[s1>>8] 1091e1051a39Sopenharmony_ci $PTR_INS $i3,$s3,0,8 1092e1051a39Sopenharmony_ci 1093e1051a39Sopenharmony_ci lbu $t8,1024($i0) # Td4[s0>>24] 1094e1051a39Sopenharmony_ci _xtr $i0,$s1,0 1095e1051a39Sopenharmony_ci lbu $t9,1024($i1) # Td4[s1>>24] 1096e1051a39Sopenharmony_ci _xtr $i1,$s2,0 1097e1051a39Sopenharmony_ci lbu $t10,1024($i2) # Td4[s2>>24] 1098e1051a39Sopenharmony_ci _xtr $i2,$s3,0 1099e1051a39Sopenharmony_ci lbu $t11,1024($i3) # Td4[s3>>24] 1100e1051a39Sopenharmony_ci _xtr $i3,$s0,0 1101e1051a39Sopenharmony_ci 1102e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1103e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1104e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1105e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1106e1051a39Sopenharmony_ci# else 1107e1051a39Sopenharmony_ci lbu $t4,1024($i0) # Td4[s2>>8] 1108e1051a39Sopenharmony_ci _xtr $i0,$s0,24 1109e1051a39Sopenharmony_ci lbu $t5,1024($i1) # Td4[s3>>8] 1110e1051a39Sopenharmony_ci _xtr $i1,$s1,24 1111e1051a39Sopenharmony_ci lbu $t6,1024($i2) # Td4[s0>>8] 1112e1051a39Sopenharmony_ci _xtr $i2,$s2,24 1113e1051a39Sopenharmony_ci lbu $t7,1024($i3) # Td4[s1>>8] 1114e1051a39Sopenharmony_ci _xtr $i3,$s3,24 1115e1051a39Sopenharmony_ci 1116e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1117e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1118e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1119e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1120e1051a39Sopenharmony_ci lbu $t8,1024($i0) # Td4[s0>>24] 1121e1051a39Sopenharmony_ci $PTR_INS $i0,$s1,0,8 1122e1051a39Sopenharmony_ci lbu $t9,1024($i1) # Td4[s1>>24] 1123e1051a39Sopenharmony_ci $PTR_INS $i1,$s2,0,8 1124e1051a39Sopenharmony_ci lbu $t10,1024($i2) # Td4[s2>>24] 1125e1051a39Sopenharmony_ci $PTR_INS $i2,$s3,0,8 1126e1051a39Sopenharmony_ci lbu $t11,1024($i3) # Td4[s3>>24] 1127e1051a39Sopenharmony_ci $PTR_INS $i3,$s0,0,8 1128e1051a39Sopenharmony_ci# endif 1129e1051a39Sopenharmony_ci _ins $t0,16 1130e1051a39Sopenharmony_ci _ins $t1,16 1131e1051a39Sopenharmony_ci _ins $t2,16 1132e1051a39Sopenharmony_ci _ins $t3,16 1133e1051a39Sopenharmony_ci 1134e1051a39Sopenharmony_ci _ins2 $t0,$t4,8 1135e1051a39Sopenharmony_ci lbu $t4,1024($i0) # Td4[s1] 1136e1051a39Sopenharmony_ci _ins2 $t1,$t5,8 1137e1051a39Sopenharmony_ci lbu $t5,1024($i1) # Td4[s2] 1138e1051a39Sopenharmony_ci _ins2 $t2,$t6,8 1139e1051a39Sopenharmony_ci lbu $t6,1024($i2) # Td4[s3] 1140e1051a39Sopenharmony_ci _ins2 $t3,$t7,8 1141e1051a39Sopenharmony_ci lbu $t7,1024($i3) # Td4[s0] 1142e1051a39Sopenharmony_ci 1143e1051a39Sopenharmony_ci _ins2 $t0,$t8,24 1144e1051a39Sopenharmony_ci lw $s0,0($key0) 1145e1051a39Sopenharmony_ci _ins2 $t1,$t9,24 1146e1051a39Sopenharmony_ci lw $s1,4($key0) 1147e1051a39Sopenharmony_ci _ins2 $t2,$t10,24 1148e1051a39Sopenharmony_ci lw $s2,8($key0) 1149e1051a39Sopenharmony_ci _ins2 $t3,$t11,24 1150e1051a39Sopenharmony_ci lw $s3,12($key0) 1151e1051a39Sopenharmony_ci 1152e1051a39Sopenharmony_ci _ins2 $t0,$t4,0 1153e1051a39Sopenharmony_ci _ins2 $t1,$t5,0 1154e1051a39Sopenharmony_ci _ins2 $t2,$t6,0 1155e1051a39Sopenharmony_ci _ins2 $t3,$t7,0 1156e1051a39Sopenharmony_ci#else 1157e1051a39Sopenharmony_ci lbu $t4,1024($i0) # Td4[s2>>8] 1158e1051a39Sopenharmony_ci _xtr $i0,$s0,24 1159e1051a39Sopenharmony_ci lbu $t5,1024($i1) # Td4[s3>>8] 1160e1051a39Sopenharmony_ci _xtr $i1,$s1,24 1161e1051a39Sopenharmony_ci lbu $t6,1024($i2) # Td4[s0>>8] 1162e1051a39Sopenharmony_ci _xtr $i2,$s2,24 1163e1051a39Sopenharmony_ci lbu $t7,1024($i3) # Td4[s1>>8] 1164e1051a39Sopenharmony_ci _xtr $i3,$s3,24 1165e1051a39Sopenharmony_ci 1166e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1167e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1168e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1169e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1170e1051a39Sopenharmony_ci lbu $t8,1024($i0) # Td4[s0>>24] 1171e1051a39Sopenharmony_ci _xtr $i0,$s1,0 1172e1051a39Sopenharmony_ci lbu $t9,1024($i1) # Td4[s1>>24] 1173e1051a39Sopenharmony_ci _xtr $i1,$s2,0 1174e1051a39Sopenharmony_ci lbu $t10,1024($i2) # Td4[s2>>24] 1175e1051a39Sopenharmony_ci _xtr $i2,$s3,0 1176e1051a39Sopenharmony_ci lbu $t11,1024($i3) # Td4[s3>>24] 1177e1051a39Sopenharmony_ci _xtr $i3,$s0,0 1178e1051a39Sopenharmony_ci 1179e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1180e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1181e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1182e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1183e1051a39Sopenharmony_ci 1184e1051a39Sopenharmony_ci _ins $t0,16 1185e1051a39Sopenharmony_ci _ins $t1,16 1186e1051a39Sopenharmony_ci _ins $t2,16 1187e1051a39Sopenharmony_ci _ins $t3,16 1188e1051a39Sopenharmony_ci 1189e1051a39Sopenharmony_ci _ins $t4,8 1190e1051a39Sopenharmony_ci _ins $t5,8 1191e1051a39Sopenharmony_ci _ins $t6,8 1192e1051a39Sopenharmony_ci _ins $t7,8 1193e1051a39Sopenharmony_ci 1194e1051a39Sopenharmony_ci xor $t0,$t4 1195e1051a39Sopenharmony_ci lbu $t4,1024($i0) # Td4[s1] 1196e1051a39Sopenharmony_ci xor $t1,$t5 1197e1051a39Sopenharmony_ci lbu $t5,1024($i1) # Td4[s2] 1198e1051a39Sopenharmony_ci xor $t2,$t6 1199e1051a39Sopenharmony_ci lbu $t6,1024($i2) # Td4[s3] 1200e1051a39Sopenharmony_ci xor $t3,$t7 1201e1051a39Sopenharmony_ci lbu $t7,1024($i3) # Td4[s0] 1202e1051a39Sopenharmony_ci 1203e1051a39Sopenharmony_ci _ins $t8,24 1204e1051a39Sopenharmony_ci lw $s0,0($key0) 1205e1051a39Sopenharmony_ci _ins $t9,24 1206e1051a39Sopenharmony_ci lw $s1,4($key0) 1207e1051a39Sopenharmony_ci _ins $t10,24 1208e1051a39Sopenharmony_ci lw $s2,8($key0) 1209e1051a39Sopenharmony_ci _ins $t11,24 1210e1051a39Sopenharmony_ci lw $s3,12($key0) 1211e1051a39Sopenharmony_ci 1212e1051a39Sopenharmony_ci xor $t0,$t8 1213e1051a39Sopenharmony_ci xor $t1,$t9 1214e1051a39Sopenharmony_ci xor $t2,$t10 1215e1051a39Sopenharmony_ci xor $t3,$t11 1216e1051a39Sopenharmony_ci 1217e1051a39Sopenharmony_ci _ins $t4,0 1218e1051a39Sopenharmony_ci _ins $t5,0 1219e1051a39Sopenharmony_ci _ins $t6,0 1220e1051a39Sopenharmony_ci _ins $t7,0 1221e1051a39Sopenharmony_ci 1222e1051a39Sopenharmony_ci xor $t0,$t4 1223e1051a39Sopenharmony_ci xor $t1,$t5 1224e1051a39Sopenharmony_ci xor $t2,$t6 1225e1051a39Sopenharmony_ci xor $t3,$t7 1226e1051a39Sopenharmony_ci#endif 1227e1051a39Sopenharmony_ci 1228e1051a39Sopenharmony_ci xor $s0,$t0 1229e1051a39Sopenharmony_ci xor $s1,$t1 1230e1051a39Sopenharmony_ci xor $s2,$t2 1231e1051a39Sopenharmony_ci xor $s3,$t3 1232e1051a39Sopenharmony_ci 1233e1051a39Sopenharmony_ci jr $ra 1234e1051a39Sopenharmony_ci.end _mips_AES_decrypt 1235e1051a39Sopenharmony_ci 1236e1051a39Sopenharmony_ci.align 5 1237e1051a39Sopenharmony_ci.globl AES_decrypt 1238e1051a39Sopenharmony_ci.ent AES_decrypt 1239e1051a39Sopenharmony_ciAES_decrypt: 1240e1051a39Sopenharmony_ci .frame $sp,$FRAMESIZE,$ra 1241e1051a39Sopenharmony_ci .mask $SAVED_REGS_MASK,-$SZREG 1242e1051a39Sopenharmony_ci .set noreorder 1243e1051a39Sopenharmony_ci___ 1244e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /o32/i); # o32 PIC-ification 1245e1051a39Sopenharmony_ci .cpload $pf 1246e1051a39Sopenharmony_ci___ 1247e1051a39Sopenharmony_ci$code.=<<___; 1248e1051a39Sopenharmony_ci $PTR_SUB $sp,$FRAMESIZE 1249e1051a39Sopenharmony_ci $REG_S $ra,$FRAMESIZE-1*$SZREG($sp) 1250e1051a39Sopenharmony_ci $REG_S $fp,$FRAMESIZE-2*$SZREG($sp) 1251e1051a39Sopenharmony_ci $REG_S $s11,$FRAMESIZE-3*$SZREG($sp) 1252e1051a39Sopenharmony_ci $REG_S $s10,$FRAMESIZE-4*$SZREG($sp) 1253e1051a39Sopenharmony_ci $REG_S $s9,$FRAMESIZE-5*$SZREG($sp) 1254e1051a39Sopenharmony_ci $REG_S $s8,$FRAMESIZE-6*$SZREG($sp) 1255e1051a39Sopenharmony_ci $REG_S $s7,$FRAMESIZE-7*$SZREG($sp) 1256e1051a39Sopenharmony_ci $REG_S $s6,$FRAMESIZE-8*$SZREG($sp) 1257e1051a39Sopenharmony_ci $REG_S $s5,$FRAMESIZE-9*$SZREG($sp) 1258e1051a39Sopenharmony_ci $REG_S $s4,$FRAMESIZE-10*$SZREG($sp) 1259e1051a39Sopenharmony_ci___ 1260e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue 1261e1051a39Sopenharmony_ci $REG_S \$15,$FRAMESIZE-11*$SZREG($sp) 1262e1051a39Sopenharmony_ci $REG_S \$14,$FRAMESIZE-12*$SZREG($sp) 1263e1051a39Sopenharmony_ci $REG_S \$13,$FRAMESIZE-13*$SZREG($sp) 1264e1051a39Sopenharmony_ci $REG_S \$12,$FRAMESIZE-14*$SZREG($sp) 1265e1051a39Sopenharmony_ci $REG_S $gp,$FRAMESIZE-15*$SZREG($sp) 1266e1051a39Sopenharmony_ci___ 1267e1051a39Sopenharmony_ci$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification 1268e1051a39Sopenharmony_ci .cplocal $Tbl 1269e1051a39Sopenharmony_ci .cpsetup $pf,$zero,AES_decrypt 1270e1051a39Sopenharmony_ci___ 1271e1051a39Sopenharmony_ci$code.=<<___; 1272e1051a39Sopenharmony_ci .set reorder 1273e1051a39Sopenharmony_ci $PTR_LA $Tbl,AES_Td # PIC-ified 'load address' 1274e1051a39Sopenharmony_ci 1275e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 1276e1051a39Sopenharmony_ci lw $s0,0($inp) 1277e1051a39Sopenharmony_ci lw $s1,4($inp) 1278e1051a39Sopenharmony_ci lw $s2,8($inp) 1279e1051a39Sopenharmony_ci lw $s3,12($inp) 1280e1051a39Sopenharmony_ci#else 1281e1051a39Sopenharmony_ci lwl $s0,0+$MSB($inp) 1282e1051a39Sopenharmony_ci lwl $s1,4+$MSB($inp) 1283e1051a39Sopenharmony_ci lwl $s2,8+$MSB($inp) 1284e1051a39Sopenharmony_ci lwl $s3,12+$MSB($inp) 1285e1051a39Sopenharmony_ci lwr $s0,0+$LSB($inp) 1286e1051a39Sopenharmony_ci lwr $s1,4+$LSB($inp) 1287e1051a39Sopenharmony_ci lwr $s2,8+$LSB($inp) 1288e1051a39Sopenharmony_ci lwr $s3,12+$LSB($inp) 1289e1051a39Sopenharmony_ci#endif 1290e1051a39Sopenharmony_ci 1291e1051a39Sopenharmony_ci bal _mips_AES_decrypt 1292e1051a39Sopenharmony_ci 1293e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 1294e1051a39Sopenharmony_ci sw $s0,0($out) 1295e1051a39Sopenharmony_ci sw $s1,4($out) 1296e1051a39Sopenharmony_ci sw $s2,8($out) 1297e1051a39Sopenharmony_ci sw $s3,12($out) 1298e1051a39Sopenharmony_ci#else 1299e1051a39Sopenharmony_ci swr $s0,0+$LSB($out) 1300e1051a39Sopenharmony_ci swr $s1,4+$LSB($out) 1301e1051a39Sopenharmony_ci swr $s2,8+$LSB($out) 1302e1051a39Sopenharmony_ci swr $s3,12+$LSB($out) 1303e1051a39Sopenharmony_ci swl $s0,0+$MSB($out) 1304e1051a39Sopenharmony_ci swl $s1,4+$MSB($out) 1305e1051a39Sopenharmony_ci swl $s2,8+$MSB($out) 1306e1051a39Sopenharmony_ci swl $s3,12+$MSB($out) 1307e1051a39Sopenharmony_ci#endif 1308e1051a39Sopenharmony_ci 1309e1051a39Sopenharmony_ci .set noreorder 1310e1051a39Sopenharmony_ci $REG_L $ra,$FRAMESIZE-1*$SZREG($sp) 1311e1051a39Sopenharmony_ci $REG_L $fp,$FRAMESIZE-2*$SZREG($sp) 1312e1051a39Sopenharmony_ci $REG_L $s11,$FRAMESIZE-3*$SZREG($sp) 1313e1051a39Sopenharmony_ci $REG_L $s10,$FRAMESIZE-4*$SZREG($sp) 1314e1051a39Sopenharmony_ci $REG_L $s9,$FRAMESIZE-5*$SZREG($sp) 1315e1051a39Sopenharmony_ci $REG_L $s8,$FRAMESIZE-6*$SZREG($sp) 1316e1051a39Sopenharmony_ci $REG_L $s7,$FRAMESIZE-7*$SZREG($sp) 1317e1051a39Sopenharmony_ci $REG_L $s6,$FRAMESIZE-8*$SZREG($sp) 1318e1051a39Sopenharmony_ci $REG_L $s5,$FRAMESIZE-9*$SZREG($sp) 1319e1051a39Sopenharmony_ci $REG_L $s4,$FRAMESIZE-10*$SZREG($sp) 1320e1051a39Sopenharmony_ci___ 1321e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); 1322e1051a39Sopenharmony_ci $REG_L \$15,$FRAMESIZE-11*$SZREG($sp) 1323e1051a39Sopenharmony_ci $REG_L \$14,$FRAMESIZE-12*$SZREG($sp) 1324e1051a39Sopenharmony_ci $REG_L \$13,$FRAMESIZE-13*$SZREG($sp) 1325e1051a39Sopenharmony_ci $REG_L \$12,$FRAMESIZE-14*$SZREG($sp) 1326e1051a39Sopenharmony_ci $REG_L $gp,$FRAMESIZE-15*$SZREG($sp) 1327e1051a39Sopenharmony_ci___ 1328e1051a39Sopenharmony_ci$code.=<<___; 1329e1051a39Sopenharmony_ci jr $ra 1330e1051a39Sopenharmony_ci $PTR_ADD $sp,$FRAMESIZE 1331e1051a39Sopenharmony_ci.end AES_decrypt 1332e1051a39Sopenharmony_ci___ 1333e1051a39Sopenharmony_ci}}} 1334e1051a39Sopenharmony_ci 1335e1051a39Sopenharmony_ci{{{ 1336e1051a39Sopenharmony_cimy $FRAMESIZE=8*$SZREG; 1337e1051a39Sopenharmony_cimy $SAVED_REGS_MASK = ($flavour =~ /nubi/i) ? "0xc000f008" : "0xc0000000"; 1338e1051a39Sopenharmony_ci 1339e1051a39Sopenharmony_cimy ($inp,$bits,$key,$Tbl)=($a0,$a1,$a2,$a3); 1340e1051a39Sopenharmony_cimy ($rk0,$rk1,$rk2,$rk3,$rk4,$rk5,$rk6,$rk7)=($a4,$a5,$a6,$a7,$s0,$s1,$s2,$s3); 1341e1051a39Sopenharmony_cimy ($i0,$i1,$i2,$i3)=($at,$t0,$t1,$t2); 1342e1051a39Sopenharmony_cimy ($rcon,$cnt)=($gp,$fp); 1343e1051a39Sopenharmony_ci 1344e1051a39Sopenharmony_ci$code.=<<___; 1345e1051a39Sopenharmony_ci.align 5 1346e1051a39Sopenharmony_ci.ent _mips_AES_set_encrypt_key 1347e1051a39Sopenharmony_ci_mips_AES_set_encrypt_key: 1348e1051a39Sopenharmony_ci .frame $sp,0,$ra 1349e1051a39Sopenharmony_ci .set noreorder 1350e1051a39Sopenharmony_ci beqz $inp,.Lekey_done 1351e1051a39Sopenharmony_ci li $t0,-1 1352e1051a39Sopenharmony_ci beqz $key,.Lekey_done 1353e1051a39Sopenharmony_ci $PTR_ADD $rcon,$Tbl,256 1354e1051a39Sopenharmony_ci 1355e1051a39Sopenharmony_ci .set reorder 1356e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 1357e1051a39Sopenharmony_ci lw $rk0,0($inp) # load 128 bits 1358e1051a39Sopenharmony_ci lw $rk1,4($inp) 1359e1051a39Sopenharmony_ci lw $rk2,8($inp) 1360e1051a39Sopenharmony_ci lw $rk3,12($inp) 1361e1051a39Sopenharmony_ci#else 1362e1051a39Sopenharmony_ci lwl $rk0,0+$MSB($inp) # load 128 bits 1363e1051a39Sopenharmony_ci lwl $rk1,4+$MSB($inp) 1364e1051a39Sopenharmony_ci lwl $rk2,8+$MSB($inp) 1365e1051a39Sopenharmony_ci lwl $rk3,12+$MSB($inp) 1366e1051a39Sopenharmony_ci lwr $rk0,0+$LSB($inp) 1367e1051a39Sopenharmony_ci lwr $rk1,4+$LSB($inp) 1368e1051a39Sopenharmony_ci lwr $rk2,8+$LSB($inp) 1369e1051a39Sopenharmony_ci lwr $rk3,12+$LSB($inp) 1370e1051a39Sopenharmony_ci#endif 1371e1051a39Sopenharmony_ci li $at,128 1372e1051a39Sopenharmony_ci .set noreorder 1373e1051a39Sopenharmony_ci beq $bits,$at,.L128bits 1374e1051a39Sopenharmony_ci li $cnt,10 1375e1051a39Sopenharmony_ci 1376e1051a39Sopenharmony_ci .set reorder 1377e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 1378e1051a39Sopenharmony_ci lw $rk4,16($inp) # load 192 bits 1379e1051a39Sopenharmony_ci lw $rk5,20($inp) 1380e1051a39Sopenharmony_ci#else 1381e1051a39Sopenharmony_ci lwl $rk4,16+$MSB($inp) # load 192 bits 1382e1051a39Sopenharmony_ci lwl $rk5,20+$MSB($inp) 1383e1051a39Sopenharmony_ci lwr $rk4,16+$LSB($inp) 1384e1051a39Sopenharmony_ci lwr $rk5,20+$LSB($inp) 1385e1051a39Sopenharmony_ci#endif 1386e1051a39Sopenharmony_ci li $at,192 1387e1051a39Sopenharmony_ci .set noreorder 1388e1051a39Sopenharmony_ci beq $bits,$at,.L192bits 1389e1051a39Sopenharmony_ci li $cnt,8 1390e1051a39Sopenharmony_ci 1391e1051a39Sopenharmony_ci .set reorder 1392e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R6) || defined(_MIPS_ARCH_MIPS64R6) 1393e1051a39Sopenharmony_ci lw $rk6,24($inp) # load 256 bits 1394e1051a39Sopenharmony_ci lw $rk7,28($inp) 1395e1051a39Sopenharmony_ci#else 1396e1051a39Sopenharmony_ci lwl $rk6,24+$MSB($inp) # load 256 bits 1397e1051a39Sopenharmony_ci lwl $rk7,28+$MSB($inp) 1398e1051a39Sopenharmony_ci lwr $rk6,24+$LSB($inp) 1399e1051a39Sopenharmony_ci lwr $rk7,28+$LSB($inp) 1400e1051a39Sopenharmony_ci#endif 1401e1051a39Sopenharmony_ci li $at,256 1402e1051a39Sopenharmony_ci .set noreorder 1403e1051a39Sopenharmony_ci beq $bits,$at,.L256bits 1404e1051a39Sopenharmony_ci li $cnt,7 1405e1051a39Sopenharmony_ci 1406e1051a39Sopenharmony_ci b .Lekey_done 1407e1051a39Sopenharmony_ci li $t0,-2 1408e1051a39Sopenharmony_ci 1409e1051a39Sopenharmony_ci.align 4 1410e1051a39Sopenharmony_ci.L128bits: 1411e1051a39Sopenharmony_ci .set reorder 1412e1051a39Sopenharmony_ci srl $i0,$rk3,16 1413e1051a39Sopenharmony_ci srl $i1,$rk3,8 1414e1051a39Sopenharmony_ci and $i0,0xff 1415e1051a39Sopenharmony_ci and $i1,0xff 1416e1051a39Sopenharmony_ci and $i2,$rk3,0xff 1417e1051a39Sopenharmony_ci srl $i3,$rk3,24 1418e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1419e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1420e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1421e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1422e1051a39Sopenharmony_ci lbu $i0,0($i0) 1423e1051a39Sopenharmony_ci lbu $i1,0($i1) 1424e1051a39Sopenharmony_ci lbu $i2,0($i2) 1425e1051a39Sopenharmony_ci lbu $i3,0($i3) 1426e1051a39Sopenharmony_ci 1427e1051a39Sopenharmony_ci sw $rk0,0($key) 1428e1051a39Sopenharmony_ci sw $rk1,4($key) 1429e1051a39Sopenharmony_ci sw $rk2,8($key) 1430e1051a39Sopenharmony_ci sw $rk3,12($key) 1431e1051a39Sopenharmony_ci subu $cnt,1 1432e1051a39Sopenharmony_ci $PTR_ADD $key,16 1433e1051a39Sopenharmony_ci 1434e1051a39Sopenharmony_ci _bias $i0,24 1435e1051a39Sopenharmony_ci _bias $i1,16 1436e1051a39Sopenharmony_ci _bias $i2,8 1437e1051a39Sopenharmony_ci _bias $i3,0 1438e1051a39Sopenharmony_ci 1439e1051a39Sopenharmony_ci xor $rk0,$i0 1440e1051a39Sopenharmony_ci lw $i0,0($rcon) 1441e1051a39Sopenharmony_ci xor $rk0,$i1 1442e1051a39Sopenharmony_ci xor $rk0,$i2 1443e1051a39Sopenharmony_ci xor $rk0,$i3 1444e1051a39Sopenharmony_ci xor $rk0,$i0 1445e1051a39Sopenharmony_ci 1446e1051a39Sopenharmony_ci xor $rk1,$rk0 1447e1051a39Sopenharmony_ci xor $rk2,$rk1 1448e1051a39Sopenharmony_ci xor $rk3,$rk2 1449e1051a39Sopenharmony_ci 1450e1051a39Sopenharmony_ci .set noreorder 1451e1051a39Sopenharmony_ci bnez $cnt,.L128bits 1452e1051a39Sopenharmony_ci $PTR_ADD $rcon,4 1453e1051a39Sopenharmony_ci 1454e1051a39Sopenharmony_ci sw $rk0,0($key) 1455e1051a39Sopenharmony_ci sw $rk1,4($key) 1456e1051a39Sopenharmony_ci sw $rk2,8($key) 1457e1051a39Sopenharmony_ci li $cnt,10 1458e1051a39Sopenharmony_ci sw $rk3,12($key) 1459e1051a39Sopenharmony_ci li $t0,0 1460e1051a39Sopenharmony_ci sw $cnt,80($key) 1461e1051a39Sopenharmony_ci b .Lekey_done 1462e1051a39Sopenharmony_ci $PTR_SUB $key,10*16 1463e1051a39Sopenharmony_ci 1464e1051a39Sopenharmony_ci.align 4 1465e1051a39Sopenharmony_ci.L192bits: 1466e1051a39Sopenharmony_ci .set reorder 1467e1051a39Sopenharmony_ci srl $i0,$rk5,16 1468e1051a39Sopenharmony_ci srl $i1,$rk5,8 1469e1051a39Sopenharmony_ci and $i0,0xff 1470e1051a39Sopenharmony_ci and $i1,0xff 1471e1051a39Sopenharmony_ci and $i2,$rk5,0xff 1472e1051a39Sopenharmony_ci srl $i3,$rk5,24 1473e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1474e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1475e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1476e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1477e1051a39Sopenharmony_ci lbu $i0,0($i0) 1478e1051a39Sopenharmony_ci lbu $i1,0($i1) 1479e1051a39Sopenharmony_ci lbu $i2,0($i2) 1480e1051a39Sopenharmony_ci lbu $i3,0($i3) 1481e1051a39Sopenharmony_ci 1482e1051a39Sopenharmony_ci sw $rk0,0($key) 1483e1051a39Sopenharmony_ci sw $rk1,4($key) 1484e1051a39Sopenharmony_ci sw $rk2,8($key) 1485e1051a39Sopenharmony_ci sw $rk3,12($key) 1486e1051a39Sopenharmony_ci sw $rk4,16($key) 1487e1051a39Sopenharmony_ci sw $rk5,20($key) 1488e1051a39Sopenharmony_ci subu $cnt,1 1489e1051a39Sopenharmony_ci $PTR_ADD $key,24 1490e1051a39Sopenharmony_ci 1491e1051a39Sopenharmony_ci _bias $i0,24 1492e1051a39Sopenharmony_ci _bias $i1,16 1493e1051a39Sopenharmony_ci _bias $i2,8 1494e1051a39Sopenharmony_ci _bias $i3,0 1495e1051a39Sopenharmony_ci 1496e1051a39Sopenharmony_ci xor $rk0,$i0 1497e1051a39Sopenharmony_ci lw $i0,0($rcon) 1498e1051a39Sopenharmony_ci xor $rk0,$i1 1499e1051a39Sopenharmony_ci xor $rk0,$i2 1500e1051a39Sopenharmony_ci xor $rk0,$i3 1501e1051a39Sopenharmony_ci xor $rk0,$i0 1502e1051a39Sopenharmony_ci 1503e1051a39Sopenharmony_ci xor $rk1,$rk0 1504e1051a39Sopenharmony_ci xor $rk2,$rk1 1505e1051a39Sopenharmony_ci xor $rk3,$rk2 1506e1051a39Sopenharmony_ci xor $rk4,$rk3 1507e1051a39Sopenharmony_ci xor $rk5,$rk4 1508e1051a39Sopenharmony_ci 1509e1051a39Sopenharmony_ci .set noreorder 1510e1051a39Sopenharmony_ci bnez $cnt,.L192bits 1511e1051a39Sopenharmony_ci $PTR_ADD $rcon,4 1512e1051a39Sopenharmony_ci 1513e1051a39Sopenharmony_ci sw $rk0,0($key) 1514e1051a39Sopenharmony_ci sw $rk1,4($key) 1515e1051a39Sopenharmony_ci sw $rk2,8($key) 1516e1051a39Sopenharmony_ci li $cnt,12 1517e1051a39Sopenharmony_ci sw $rk3,12($key) 1518e1051a39Sopenharmony_ci li $t0,0 1519e1051a39Sopenharmony_ci sw $cnt,48($key) 1520e1051a39Sopenharmony_ci b .Lekey_done 1521e1051a39Sopenharmony_ci $PTR_SUB $key,12*16 1522e1051a39Sopenharmony_ci 1523e1051a39Sopenharmony_ci.align 4 1524e1051a39Sopenharmony_ci.L256bits: 1525e1051a39Sopenharmony_ci .set reorder 1526e1051a39Sopenharmony_ci srl $i0,$rk7,16 1527e1051a39Sopenharmony_ci srl $i1,$rk7,8 1528e1051a39Sopenharmony_ci and $i0,0xff 1529e1051a39Sopenharmony_ci and $i1,0xff 1530e1051a39Sopenharmony_ci and $i2,$rk7,0xff 1531e1051a39Sopenharmony_ci srl $i3,$rk7,24 1532e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1533e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1534e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1535e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1536e1051a39Sopenharmony_ci lbu $i0,0($i0) 1537e1051a39Sopenharmony_ci lbu $i1,0($i1) 1538e1051a39Sopenharmony_ci lbu $i2,0($i2) 1539e1051a39Sopenharmony_ci lbu $i3,0($i3) 1540e1051a39Sopenharmony_ci 1541e1051a39Sopenharmony_ci sw $rk0,0($key) 1542e1051a39Sopenharmony_ci sw $rk1,4($key) 1543e1051a39Sopenharmony_ci sw $rk2,8($key) 1544e1051a39Sopenharmony_ci sw $rk3,12($key) 1545e1051a39Sopenharmony_ci sw $rk4,16($key) 1546e1051a39Sopenharmony_ci sw $rk5,20($key) 1547e1051a39Sopenharmony_ci sw $rk6,24($key) 1548e1051a39Sopenharmony_ci sw $rk7,28($key) 1549e1051a39Sopenharmony_ci subu $cnt,1 1550e1051a39Sopenharmony_ci 1551e1051a39Sopenharmony_ci _bias $i0,24 1552e1051a39Sopenharmony_ci _bias $i1,16 1553e1051a39Sopenharmony_ci _bias $i2,8 1554e1051a39Sopenharmony_ci _bias $i3,0 1555e1051a39Sopenharmony_ci 1556e1051a39Sopenharmony_ci xor $rk0,$i0 1557e1051a39Sopenharmony_ci lw $i0,0($rcon) 1558e1051a39Sopenharmony_ci xor $rk0,$i1 1559e1051a39Sopenharmony_ci xor $rk0,$i2 1560e1051a39Sopenharmony_ci xor $rk0,$i3 1561e1051a39Sopenharmony_ci xor $rk0,$i0 1562e1051a39Sopenharmony_ci 1563e1051a39Sopenharmony_ci xor $rk1,$rk0 1564e1051a39Sopenharmony_ci xor $rk2,$rk1 1565e1051a39Sopenharmony_ci xor $rk3,$rk2 1566e1051a39Sopenharmony_ci beqz $cnt,.L256bits_done 1567e1051a39Sopenharmony_ci 1568e1051a39Sopenharmony_ci srl $i0,$rk3,24 1569e1051a39Sopenharmony_ci srl $i1,$rk3,16 1570e1051a39Sopenharmony_ci srl $i2,$rk3,8 1571e1051a39Sopenharmony_ci and $i3,$rk3,0xff 1572e1051a39Sopenharmony_ci and $i1,0xff 1573e1051a39Sopenharmony_ci and $i2,0xff 1574e1051a39Sopenharmony_ci $PTR_ADD $i0,$Tbl 1575e1051a39Sopenharmony_ci $PTR_ADD $i1,$Tbl 1576e1051a39Sopenharmony_ci $PTR_ADD $i2,$Tbl 1577e1051a39Sopenharmony_ci $PTR_ADD $i3,$Tbl 1578e1051a39Sopenharmony_ci lbu $i0,0($i0) 1579e1051a39Sopenharmony_ci lbu $i1,0($i1) 1580e1051a39Sopenharmony_ci lbu $i2,0($i2) 1581e1051a39Sopenharmony_ci lbu $i3,0($i3) 1582e1051a39Sopenharmony_ci sll $i0,24 1583e1051a39Sopenharmony_ci sll $i1,16 1584e1051a39Sopenharmony_ci sll $i2,8 1585e1051a39Sopenharmony_ci 1586e1051a39Sopenharmony_ci xor $rk4,$i0 1587e1051a39Sopenharmony_ci xor $rk4,$i1 1588e1051a39Sopenharmony_ci xor $rk4,$i2 1589e1051a39Sopenharmony_ci xor $rk4,$i3 1590e1051a39Sopenharmony_ci 1591e1051a39Sopenharmony_ci xor $rk5,$rk4 1592e1051a39Sopenharmony_ci xor $rk6,$rk5 1593e1051a39Sopenharmony_ci xor $rk7,$rk6 1594e1051a39Sopenharmony_ci 1595e1051a39Sopenharmony_ci $PTR_ADD $key,32 1596e1051a39Sopenharmony_ci .set noreorder 1597e1051a39Sopenharmony_ci b .L256bits 1598e1051a39Sopenharmony_ci $PTR_ADD $rcon,4 1599e1051a39Sopenharmony_ci 1600e1051a39Sopenharmony_ci.L256bits_done: 1601e1051a39Sopenharmony_ci sw $rk0,32($key) 1602e1051a39Sopenharmony_ci sw $rk1,36($key) 1603e1051a39Sopenharmony_ci sw $rk2,40($key) 1604e1051a39Sopenharmony_ci li $cnt,14 1605e1051a39Sopenharmony_ci sw $rk3,44($key) 1606e1051a39Sopenharmony_ci li $t0,0 1607e1051a39Sopenharmony_ci sw $cnt,48($key) 1608e1051a39Sopenharmony_ci $PTR_SUB $key,12*16 1609e1051a39Sopenharmony_ci 1610e1051a39Sopenharmony_ci.Lekey_done: 1611e1051a39Sopenharmony_ci jr $ra 1612e1051a39Sopenharmony_ci nop 1613e1051a39Sopenharmony_ci.end _mips_AES_set_encrypt_key 1614e1051a39Sopenharmony_ci 1615e1051a39Sopenharmony_ci.globl AES_set_encrypt_key 1616e1051a39Sopenharmony_ci.ent AES_set_encrypt_key 1617e1051a39Sopenharmony_ciAES_set_encrypt_key: 1618e1051a39Sopenharmony_ci .frame $sp,$FRAMESIZE,$ra 1619e1051a39Sopenharmony_ci .mask $SAVED_REGS_MASK,-$SZREG 1620e1051a39Sopenharmony_ci .set noreorder 1621e1051a39Sopenharmony_ci___ 1622e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /o32/i); # o32 PIC-ification 1623e1051a39Sopenharmony_ci .cpload $pf 1624e1051a39Sopenharmony_ci___ 1625e1051a39Sopenharmony_ci$code.=<<___; 1626e1051a39Sopenharmony_ci $PTR_SUB $sp,$FRAMESIZE 1627e1051a39Sopenharmony_ci $REG_S $ra,$FRAMESIZE-1*$SZREG($sp) 1628e1051a39Sopenharmony_ci $REG_S $fp,$FRAMESIZE-2*$SZREG($sp) 1629e1051a39Sopenharmony_ci___ 1630e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue 1631e1051a39Sopenharmony_ci $REG_S $s3,$FRAMESIZE-3*$SZREG($sp) 1632e1051a39Sopenharmony_ci $REG_S $s2,$FRAMESIZE-4*$SZREG($sp) 1633e1051a39Sopenharmony_ci $REG_S $s1,$FRAMESIZE-5*$SZREG($sp) 1634e1051a39Sopenharmony_ci $REG_S $s0,$FRAMESIZE-6*$SZREG($sp) 1635e1051a39Sopenharmony_ci $REG_S $gp,$FRAMESIZE-7*$SZREG($sp) 1636e1051a39Sopenharmony_ci___ 1637e1051a39Sopenharmony_ci$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification 1638e1051a39Sopenharmony_ci .cplocal $Tbl 1639e1051a39Sopenharmony_ci .cpsetup $pf,$zero,AES_set_encrypt_key 1640e1051a39Sopenharmony_ci___ 1641e1051a39Sopenharmony_ci$code.=<<___; 1642e1051a39Sopenharmony_ci .set reorder 1643e1051a39Sopenharmony_ci $PTR_LA $Tbl,AES_Te4 # PIC-ified 'load address' 1644e1051a39Sopenharmony_ci 1645e1051a39Sopenharmony_ci bal _mips_AES_set_encrypt_key 1646e1051a39Sopenharmony_ci 1647e1051a39Sopenharmony_ci .set noreorder 1648e1051a39Sopenharmony_ci move $a0,$t0 1649e1051a39Sopenharmony_ci $REG_L $ra,$FRAMESIZE-1*$SZREG($sp) 1650e1051a39Sopenharmony_ci $REG_L $fp,$FRAMESIZE-2*$SZREG($sp) 1651e1051a39Sopenharmony_ci___ 1652e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); 1653e1051a39Sopenharmony_ci $REG_L $s3,$FRAMESIZE-11*$SZREG($sp) 1654e1051a39Sopenharmony_ci $REG_L $s2,$FRAMESIZE-12*$SZREG($sp) 1655e1051a39Sopenharmony_ci $REG_L $s1,$FRAMESIZE-13*$SZREG($sp) 1656e1051a39Sopenharmony_ci $REG_L $s0,$FRAMESIZE-14*$SZREG($sp) 1657e1051a39Sopenharmony_ci $REG_L $gp,$FRAMESIZE-15*$SZREG($sp) 1658e1051a39Sopenharmony_ci___ 1659e1051a39Sopenharmony_ci$code.=<<___; 1660e1051a39Sopenharmony_ci jr $ra 1661e1051a39Sopenharmony_ci $PTR_ADD $sp,$FRAMESIZE 1662e1051a39Sopenharmony_ci.end AES_set_encrypt_key 1663e1051a39Sopenharmony_ci___ 1664e1051a39Sopenharmony_ci 1665e1051a39Sopenharmony_cimy ($head,$tail)=($inp,$bits); 1666e1051a39Sopenharmony_cimy ($tp1,$tp2,$tp4,$tp8,$tp9,$tpb,$tpd,$tpe)=($a4,$a5,$a6,$a7,$s0,$s1,$s2,$s3); 1667e1051a39Sopenharmony_cimy ($m,$x80808080,$x7f7f7f7f,$x1b1b1b1b)=($at,$t0,$t1,$t2); 1668e1051a39Sopenharmony_ci$code.=<<___; 1669e1051a39Sopenharmony_ci.align 5 1670e1051a39Sopenharmony_ci.globl AES_set_decrypt_key 1671e1051a39Sopenharmony_ci.ent AES_set_decrypt_key 1672e1051a39Sopenharmony_ciAES_set_decrypt_key: 1673e1051a39Sopenharmony_ci .frame $sp,$FRAMESIZE,$ra 1674e1051a39Sopenharmony_ci .mask $SAVED_REGS_MASK,-$SZREG 1675e1051a39Sopenharmony_ci .set noreorder 1676e1051a39Sopenharmony_ci___ 1677e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /o32/i); # o32 PIC-ification 1678e1051a39Sopenharmony_ci .cpload $pf 1679e1051a39Sopenharmony_ci___ 1680e1051a39Sopenharmony_ci$code.=<<___; 1681e1051a39Sopenharmony_ci $PTR_SUB $sp,$FRAMESIZE 1682e1051a39Sopenharmony_ci $REG_S $ra,$FRAMESIZE-1*$SZREG($sp) 1683e1051a39Sopenharmony_ci $REG_S $fp,$FRAMESIZE-2*$SZREG($sp) 1684e1051a39Sopenharmony_ci___ 1685e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); # optimize non-nubi prologue 1686e1051a39Sopenharmony_ci $REG_S $s3,$FRAMESIZE-3*$SZREG($sp) 1687e1051a39Sopenharmony_ci $REG_S $s2,$FRAMESIZE-4*$SZREG($sp) 1688e1051a39Sopenharmony_ci $REG_S $s1,$FRAMESIZE-5*$SZREG($sp) 1689e1051a39Sopenharmony_ci $REG_S $s0,$FRAMESIZE-6*$SZREG($sp) 1690e1051a39Sopenharmony_ci $REG_S $gp,$FRAMESIZE-7*$SZREG($sp) 1691e1051a39Sopenharmony_ci___ 1692e1051a39Sopenharmony_ci$code.=<<___ if ($flavour !~ /o32/i); # non-o32 PIC-ification 1693e1051a39Sopenharmony_ci .cplocal $Tbl 1694e1051a39Sopenharmony_ci .cpsetup $pf,$zero,AES_set_decrypt_key 1695e1051a39Sopenharmony_ci___ 1696e1051a39Sopenharmony_ci$code.=<<___; 1697e1051a39Sopenharmony_ci .set reorder 1698e1051a39Sopenharmony_ci $PTR_LA $Tbl,AES_Te4 # PIC-ified 'load address' 1699e1051a39Sopenharmony_ci 1700e1051a39Sopenharmony_ci bal _mips_AES_set_encrypt_key 1701e1051a39Sopenharmony_ci 1702e1051a39Sopenharmony_ci bltz $t0,.Ldkey_done 1703e1051a39Sopenharmony_ci 1704e1051a39Sopenharmony_ci sll $at,$cnt,4 1705e1051a39Sopenharmony_ci $PTR_ADD $head,$key,0 1706e1051a39Sopenharmony_ci $PTR_ADD $tail,$key,$at 1707e1051a39Sopenharmony_ci.align 4 1708e1051a39Sopenharmony_ci.Lswap: 1709e1051a39Sopenharmony_ci lw $rk0,0($head) 1710e1051a39Sopenharmony_ci lw $rk1,4($head) 1711e1051a39Sopenharmony_ci lw $rk2,8($head) 1712e1051a39Sopenharmony_ci lw $rk3,12($head) 1713e1051a39Sopenharmony_ci lw $rk4,0($tail) 1714e1051a39Sopenharmony_ci lw $rk5,4($tail) 1715e1051a39Sopenharmony_ci lw $rk6,8($tail) 1716e1051a39Sopenharmony_ci lw $rk7,12($tail) 1717e1051a39Sopenharmony_ci sw $rk0,0($tail) 1718e1051a39Sopenharmony_ci sw $rk1,4($tail) 1719e1051a39Sopenharmony_ci sw $rk2,8($tail) 1720e1051a39Sopenharmony_ci sw $rk3,12($tail) 1721e1051a39Sopenharmony_ci $PTR_ADD $head,16 1722e1051a39Sopenharmony_ci $PTR_SUB $tail,16 1723e1051a39Sopenharmony_ci sw $rk4,-16($head) 1724e1051a39Sopenharmony_ci sw $rk5,-12($head) 1725e1051a39Sopenharmony_ci sw $rk6,-8($head) 1726e1051a39Sopenharmony_ci sw $rk7,-4($head) 1727e1051a39Sopenharmony_ci bne $head,$tail,.Lswap 1728e1051a39Sopenharmony_ci 1729e1051a39Sopenharmony_ci lw $tp1,16($key) # modulo-scheduled 1730e1051a39Sopenharmony_ci lui $x80808080,0x8080 1731e1051a39Sopenharmony_ci subu $cnt,1 1732e1051a39Sopenharmony_ci or $x80808080,0x8080 1733e1051a39Sopenharmony_ci sll $cnt,2 1734e1051a39Sopenharmony_ci $PTR_ADD $key,16 1735e1051a39Sopenharmony_ci lui $x1b1b1b1b,0x1b1b 1736e1051a39Sopenharmony_ci nor $x7f7f7f7f,$zero,$x80808080 1737e1051a39Sopenharmony_ci or $x1b1b1b1b,0x1b1b 1738e1051a39Sopenharmony_ci.align 4 1739e1051a39Sopenharmony_ci.Lmix: 1740e1051a39Sopenharmony_ci and $m,$tp1,$x80808080 1741e1051a39Sopenharmony_ci and $tp2,$tp1,$x7f7f7f7f 1742e1051a39Sopenharmony_ci srl $tp4,$m,7 1743e1051a39Sopenharmony_ci addu $tp2,$tp2 # tp2<<1 1744e1051a39Sopenharmony_ci subu $m,$tp4 1745e1051a39Sopenharmony_ci and $m,$x1b1b1b1b 1746e1051a39Sopenharmony_ci xor $tp2,$m 1747e1051a39Sopenharmony_ci 1748e1051a39Sopenharmony_ci and $m,$tp2,$x80808080 1749e1051a39Sopenharmony_ci and $tp4,$tp2,$x7f7f7f7f 1750e1051a39Sopenharmony_ci srl $tp8,$m,7 1751e1051a39Sopenharmony_ci addu $tp4,$tp4 # tp4<<1 1752e1051a39Sopenharmony_ci subu $m,$tp8 1753e1051a39Sopenharmony_ci and $m,$x1b1b1b1b 1754e1051a39Sopenharmony_ci xor $tp4,$m 1755e1051a39Sopenharmony_ci 1756e1051a39Sopenharmony_ci and $m,$tp4,$x80808080 1757e1051a39Sopenharmony_ci and $tp8,$tp4,$x7f7f7f7f 1758e1051a39Sopenharmony_ci srl $tp9,$m,7 1759e1051a39Sopenharmony_ci addu $tp8,$tp8 # tp8<<1 1760e1051a39Sopenharmony_ci subu $m,$tp9 1761e1051a39Sopenharmony_ci and $m,$x1b1b1b1b 1762e1051a39Sopenharmony_ci xor $tp8,$m 1763e1051a39Sopenharmony_ci 1764e1051a39Sopenharmony_ci xor $tp9,$tp8,$tp1 1765e1051a39Sopenharmony_ci xor $tpe,$tp8,$tp4 1766e1051a39Sopenharmony_ci xor $tpb,$tp9,$tp2 1767e1051a39Sopenharmony_ci xor $tpd,$tp9,$tp4 1768e1051a39Sopenharmony_ci 1769e1051a39Sopenharmony_ci#if defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2) 1770e1051a39Sopenharmony_ci rotr $tp1,$tpd,16 1771e1051a39Sopenharmony_ci xor $tpe,$tp2 1772e1051a39Sopenharmony_ci rotr $tp2,$tp9,8 1773e1051a39Sopenharmony_ci xor $tpe,$tp1 1774e1051a39Sopenharmony_ci rotr $tp4,$tpb,24 1775e1051a39Sopenharmony_ci xor $tpe,$tp2 1776e1051a39Sopenharmony_ci lw $tp1,4($key) # modulo-scheduled 1777e1051a39Sopenharmony_ci xor $tpe,$tp4 1778e1051a39Sopenharmony_ci#else 1779e1051a39Sopenharmony_ci _ror $tp1,$tpd,16 1780e1051a39Sopenharmony_ci xor $tpe,$tp2 1781e1051a39Sopenharmony_ci _ror $tp2,$tpd,-16 1782e1051a39Sopenharmony_ci xor $tpe,$tp1 1783e1051a39Sopenharmony_ci _ror $tp1,$tp9,8 1784e1051a39Sopenharmony_ci xor $tpe,$tp2 1785e1051a39Sopenharmony_ci _ror $tp2,$tp9,-24 1786e1051a39Sopenharmony_ci xor $tpe,$tp1 1787e1051a39Sopenharmony_ci _ror $tp1,$tpb,24 1788e1051a39Sopenharmony_ci xor $tpe,$tp2 1789e1051a39Sopenharmony_ci _ror $tp2,$tpb,-8 1790e1051a39Sopenharmony_ci xor $tpe,$tp1 1791e1051a39Sopenharmony_ci lw $tp1,4($key) # modulo-scheduled 1792e1051a39Sopenharmony_ci xor $tpe,$tp2 1793e1051a39Sopenharmony_ci#endif 1794e1051a39Sopenharmony_ci subu $cnt,1 1795e1051a39Sopenharmony_ci sw $tpe,0($key) 1796e1051a39Sopenharmony_ci $PTR_ADD $key,4 1797e1051a39Sopenharmony_ci bnez $cnt,.Lmix 1798e1051a39Sopenharmony_ci 1799e1051a39Sopenharmony_ci li $t0,0 1800e1051a39Sopenharmony_ci.Ldkey_done: 1801e1051a39Sopenharmony_ci .set noreorder 1802e1051a39Sopenharmony_ci move $a0,$t0 1803e1051a39Sopenharmony_ci $REG_L $ra,$FRAMESIZE-1*$SZREG($sp) 1804e1051a39Sopenharmony_ci $REG_L $fp,$FRAMESIZE-2*$SZREG($sp) 1805e1051a39Sopenharmony_ci___ 1806e1051a39Sopenharmony_ci$code.=<<___ if ($flavour =~ /nubi/i); 1807e1051a39Sopenharmony_ci $REG_L $s3,$FRAMESIZE-11*$SZREG($sp) 1808e1051a39Sopenharmony_ci $REG_L $s2,$FRAMESIZE-12*$SZREG($sp) 1809e1051a39Sopenharmony_ci $REG_L $s1,$FRAMESIZE-13*$SZREG($sp) 1810e1051a39Sopenharmony_ci $REG_L $s0,$FRAMESIZE-14*$SZREG($sp) 1811e1051a39Sopenharmony_ci $REG_L $gp,$FRAMESIZE-15*$SZREG($sp) 1812e1051a39Sopenharmony_ci___ 1813e1051a39Sopenharmony_ci$code.=<<___; 1814e1051a39Sopenharmony_ci jr $ra 1815e1051a39Sopenharmony_ci $PTR_ADD $sp,$FRAMESIZE 1816e1051a39Sopenharmony_ci.end AES_set_decrypt_key 1817e1051a39Sopenharmony_ci___ 1818e1051a39Sopenharmony_ci}}} 1819e1051a39Sopenharmony_ci 1820e1051a39Sopenharmony_ci###################################################################### 1821e1051a39Sopenharmony_ci# Tables are kept in endian-neutral manner 1822e1051a39Sopenharmony_ci$code.=<<___; 1823e1051a39Sopenharmony_ci.rdata 1824e1051a39Sopenharmony_ci.align 10 1825e1051a39Sopenharmony_ciAES_Te: 1826e1051a39Sopenharmony_ci.byte 0xc6,0x63,0x63,0xa5, 0xf8,0x7c,0x7c,0x84 # Te0 1827e1051a39Sopenharmony_ci.byte 0xee,0x77,0x77,0x99, 0xf6,0x7b,0x7b,0x8d 1828e1051a39Sopenharmony_ci.byte 0xff,0xf2,0xf2,0x0d, 0xd6,0x6b,0x6b,0xbd 1829e1051a39Sopenharmony_ci.byte 0xde,0x6f,0x6f,0xb1, 0x91,0xc5,0xc5,0x54 1830e1051a39Sopenharmony_ci.byte 0x60,0x30,0x30,0x50, 0x02,0x01,0x01,0x03 1831e1051a39Sopenharmony_ci.byte 0xce,0x67,0x67,0xa9, 0x56,0x2b,0x2b,0x7d 1832e1051a39Sopenharmony_ci.byte 0xe7,0xfe,0xfe,0x19, 0xb5,0xd7,0xd7,0x62 1833e1051a39Sopenharmony_ci.byte 0x4d,0xab,0xab,0xe6, 0xec,0x76,0x76,0x9a 1834e1051a39Sopenharmony_ci.byte 0x8f,0xca,0xca,0x45, 0x1f,0x82,0x82,0x9d 1835e1051a39Sopenharmony_ci.byte 0x89,0xc9,0xc9,0x40, 0xfa,0x7d,0x7d,0x87 1836e1051a39Sopenharmony_ci.byte 0xef,0xfa,0xfa,0x15, 0xb2,0x59,0x59,0xeb 1837e1051a39Sopenharmony_ci.byte 0x8e,0x47,0x47,0xc9, 0xfb,0xf0,0xf0,0x0b 1838e1051a39Sopenharmony_ci.byte 0x41,0xad,0xad,0xec, 0xb3,0xd4,0xd4,0x67 1839e1051a39Sopenharmony_ci.byte 0x5f,0xa2,0xa2,0xfd, 0x45,0xaf,0xaf,0xea 1840e1051a39Sopenharmony_ci.byte 0x23,0x9c,0x9c,0xbf, 0x53,0xa4,0xa4,0xf7 1841e1051a39Sopenharmony_ci.byte 0xe4,0x72,0x72,0x96, 0x9b,0xc0,0xc0,0x5b 1842e1051a39Sopenharmony_ci.byte 0x75,0xb7,0xb7,0xc2, 0xe1,0xfd,0xfd,0x1c 1843e1051a39Sopenharmony_ci.byte 0x3d,0x93,0x93,0xae, 0x4c,0x26,0x26,0x6a 1844e1051a39Sopenharmony_ci.byte 0x6c,0x36,0x36,0x5a, 0x7e,0x3f,0x3f,0x41 1845e1051a39Sopenharmony_ci.byte 0xf5,0xf7,0xf7,0x02, 0x83,0xcc,0xcc,0x4f 1846e1051a39Sopenharmony_ci.byte 0x68,0x34,0x34,0x5c, 0x51,0xa5,0xa5,0xf4 1847e1051a39Sopenharmony_ci.byte 0xd1,0xe5,0xe5,0x34, 0xf9,0xf1,0xf1,0x08 1848e1051a39Sopenharmony_ci.byte 0xe2,0x71,0x71,0x93, 0xab,0xd8,0xd8,0x73 1849e1051a39Sopenharmony_ci.byte 0x62,0x31,0x31,0x53, 0x2a,0x15,0x15,0x3f 1850e1051a39Sopenharmony_ci.byte 0x08,0x04,0x04,0x0c, 0x95,0xc7,0xc7,0x52 1851e1051a39Sopenharmony_ci.byte 0x46,0x23,0x23,0x65, 0x9d,0xc3,0xc3,0x5e 1852e1051a39Sopenharmony_ci.byte 0x30,0x18,0x18,0x28, 0x37,0x96,0x96,0xa1 1853e1051a39Sopenharmony_ci.byte 0x0a,0x05,0x05,0x0f, 0x2f,0x9a,0x9a,0xb5 1854e1051a39Sopenharmony_ci.byte 0x0e,0x07,0x07,0x09, 0x24,0x12,0x12,0x36 1855e1051a39Sopenharmony_ci.byte 0x1b,0x80,0x80,0x9b, 0xdf,0xe2,0xe2,0x3d 1856e1051a39Sopenharmony_ci.byte 0xcd,0xeb,0xeb,0x26, 0x4e,0x27,0x27,0x69 1857e1051a39Sopenharmony_ci.byte 0x7f,0xb2,0xb2,0xcd, 0xea,0x75,0x75,0x9f 1858e1051a39Sopenharmony_ci.byte 0x12,0x09,0x09,0x1b, 0x1d,0x83,0x83,0x9e 1859e1051a39Sopenharmony_ci.byte 0x58,0x2c,0x2c,0x74, 0x34,0x1a,0x1a,0x2e 1860e1051a39Sopenharmony_ci.byte 0x36,0x1b,0x1b,0x2d, 0xdc,0x6e,0x6e,0xb2 1861e1051a39Sopenharmony_ci.byte 0xb4,0x5a,0x5a,0xee, 0x5b,0xa0,0xa0,0xfb 1862e1051a39Sopenharmony_ci.byte 0xa4,0x52,0x52,0xf6, 0x76,0x3b,0x3b,0x4d 1863e1051a39Sopenharmony_ci.byte 0xb7,0xd6,0xd6,0x61, 0x7d,0xb3,0xb3,0xce 1864e1051a39Sopenharmony_ci.byte 0x52,0x29,0x29,0x7b, 0xdd,0xe3,0xe3,0x3e 1865e1051a39Sopenharmony_ci.byte 0x5e,0x2f,0x2f,0x71, 0x13,0x84,0x84,0x97 1866e1051a39Sopenharmony_ci.byte 0xa6,0x53,0x53,0xf5, 0xb9,0xd1,0xd1,0x68 1867e1051a39Sopenharmony_ci.byte 0x00,0x00,0x00,0x00, 0xc1,0xed,0xed,0x2c 1868e1051a39Sopenharmony_ci.byte 0x40,0x20,0x20,0x60, 0xe3,0xfc,0xfc,0x1f 1869e1051a39Sopenharmony_ci.byte 0x79,0xb1,0xb1,0xc8, 0xb6,0x5b,0x5b,0xed 1870e1051a39Sopenharmony_ci.byte 0xd4,0x6a,0x6a,0xbe, 0x8d,0xcb,0xcb,0x46 1871e1051a39Sopenharmony_ci.byte 0x67,0xbe,0xbe,0xd9, 0x72,0x39,0x39,0x4b 1872e1051a39Sopenharmony_ci.byte 0x94,0x4a,0x4a,0xde, 0x98,0x4c,0x4c,0xd4 1873e1051a39Sopenharmony_ci.byte 0xb0,0x58,0x58,0xe8, 0x85,0xcf,0xcf,0x4a 1874e1051a39Sopenharmony_ci.byte 0xbb,0xd0,0xd0,0x6b, 0xc5,0xef,0xef,0x2a 1875e1051a39Sopenharmony_ci.byte 0x4f,0xaa,0xaa,0xe5, 0xed,0xfb,0xfb,0x16 1876e1051a39Sopenharmony_ci.byte 0x86,0x43,0x43,0xc5, 0x9a,0x4d,0x4d,0xd7 1877e1051a39Sopenharmony_ci.byte 0x66,0x33,0x33,0x55, 0x11,0x85,0x85,0x94 1878e1051a39Sopenharmony_ci.byte 0x8a,0x45,0x45,0xcf, 0xe9,0xf9,0xf9,0x10 1879e1051a39Sopenharmony_ci.byte 0x04,0x02,0x02,0x06, 0xfe,0x7f,0x7f,0x81 1880e1051a39Sopenharmony_ci.byte 0xa0,0x50,0x50,0xf0, 0x78,0x3c,0x3c,0x44 1881e1051a39Sopenharmony_ci.byte 0x25,0x9f,0x9f,0xba, 0x4b,0xa8,0xa8,0xe3 1882e1051a39Sopenharmony_ci.byte 0xa2,0x51,0x51,0xf3, 0x5d,0xa3,0xa3,0xfe 1883e1051a39Sopenharmony_ci.byte 0x80,0x40,0x40,0xc0, 0x05,0x8f,0x8f,0x8a 1884e1051a39Sopenharmony_ci.byte 0x3f,0x92,0x92,0xad, 0x21,0x9d,0x9d,0xbc 1885e1051a39Sopenharmony_ci.byte 0x70,0x38,0x38,0x48, 0xf1,0xf5,0xf5,0x04 1886e1051a39Sopenharmony_ci.byte 0x63,0xbc,0xbc,0xdf, 0x77,0xb6,0xb6,0xc1 1887e1051a39Sopenharmony_ci.byte 0xaf,0xda,0xda,0x75, 0x42,0x21,0x21,0x63 1888e1051a39Sopenharmony_ci.byte 0x20,0x10,0x10,0x30, 0xe5,0xff,0xff,0x1a 1889e1051a39Sopenharmony_ci.byte 0xfd,0xf3,0xf3,0x0e, 0xbf,0xd2,0xd2,0x6d 1890e1051a39Sopenharmony_ci.byte 0x81,0xcd,0xcd,0x4c, 0x18,0x0c,0x0c,0x14 1891e1051a39Sopenharmony_ci.byte 0x26,0x13,0x13,0x35, 0xc3,0xec,0xec,0x2f 1892e1051a39Sopenharmony_ci.byte 0xbe,0x5f,0x5f,0xe1, 0x35,0x97,0x97,0xa2 1893e1051a39Sopenharmony_ci.byte 0x88,0x44,0x44,0xcc, 0x2e,0x17,0x17,0x39 1894e1051a39Sopenharmony_ci.byte 0x93,0xc4,0xc4,0x57, 0x55,0xa7,0xa7,0xf2 1895e1051a39Sopenharmony_ci.byte 0xfc,0x7e,0x7e,0x82, 0x7a,0x3d,0x3d,0x47 1896e1051a39Sopenharmony_ci.byte 0xc8,0x64,0x64,0xac, 0xba,0x5d,0x5d,0xe7 1897e1051a39Sopenharmony_ci.byte 0x32,0x19,0x19,0x2b, 0xe6,0x73,0x73,0x95 1898e1051a39Sopenharmony_ci.byte 0xc0,0x60,0x60,0xa0, 0x19,0x81,0x81,0x98 1899e1051a39Sopenharmony_ci.byte 0x9e,0x4f,0x4f,0xd1, 0xa3,0xdc,0xdc,0x7f 1900e1051a39Sopenharmony_ci.byte 0x44,0x22,0x22,0x66, 0x54,0x2a,0x2a,0x7e 1901e1051a39Sopenharmony_ci.byte 0x3b,0x90,0x90,0xab, 0x0b,0x88,0x88,0x83 1902e1051a39Sopenharmony_ci.byte 0x8c,0x46,0x46,0xca, 0xc7,0xee,0xee,0x29 1903e1051a39Sopenharmony_ci.byte 0x6b,0xb8,0xb8,0xd3, 0x28,0x14,0x14,0x3c 1904e1051a39Sopenharmony_ci.byte 0xa7,0xde,0xde,0x79, 0xbc,0x5e,0x5e,0xe2 1905e1051a39Sopenharmony_ci.byte 0x16,0x0b,0x0b,0x1d, 0xad,0xdb,0xdb,0x76 1906e1051a39Sopenharmony_ci.byte 0xdb,0xe0,0xe0,0x3b, 0x64,0x32,0x32,0x56 1907e1051a39Sopenharmony_ci.byte 0x74,0x3a,0x3a,0x4e, 0x14,0x0a,0x0a,0x1e 1908e1051a39Sopenharmony_ci.byte 0x92,0x49,0x49,0xdb, 0x0c,0x06,0x06,0x0a 1909e1051a39Sopenharmony_ci.byte 0x48,0x24,0x24,0x6c, 0xb8,0x5c,0x5c,0xe4 1910e1051a39Sopenharmony_ci.byte 0x9f,0xc2,0xc2,0x5d, 0xbd,0xd3,0xd3,0x6e 1911e1051a39Sopenharmony_ci.byte 0x43,0xac,0xac,0xef, 0xc4,0x62,0x62,0xa6 1912e1051a39Sopenharmony_ci.byte 0x39,0x91,0x91,0xa8, 0x31,0x95,0x95,0xa4 1913e1051a39Sopenharmony_ci.byte 0xd3,0xe4,0xe4,0x37, 0xf2,0x79,0x79,0x8b 1914e1051a39Sopenharmony_ci.byte 0xd5,0xe7,0xe7,0x32, 0x8b,0xc8,0xc8,0x43 1915e1051a39Sopenharmony_ci.byte 0x6e,0x37,0x37,0x59, 0xda,0x6d,0x6d,0xb7 1916e1051a39Sopenharmony_ci.byte 0x01,0x8d,0x8d,0x8c, 0xb1,0xd5,0xd5,0x64 1917e1051a39Sopenharmony_ci.byte 0x9c,0x4e,0x4e,0xd2, 0x49,0xa9,0xa9,0xe0 1918e1051a39Sopenharmony_ci.byte 0xd8,0x6c,0x6c,0xb4, 0xac,0x56,0x56,0xfa 1919e1051a39Sopenharmony_ci.byte 0xf3,0xf4,0xf4,0x07, 0xcf,0xea,0xea,0x25 1920e1051a39Sopenharmony_ci.byte 0xca,0x65,0x65,0xaf, 0xf4,0x7a,0x7a,0x8e 1921e1051a39Sopenharmony_ci.byte 0x47,0xae,0xae,0xe9, 0x10,0x08,0x08,0x18 1922e1051a39Sopenharmony_ci.byte 0x6f,0xba,0xba,0xd5, 0xf0,0x78,0x78,0x88 1923e1051a39Sopenharmony_ci.byte 0x4a,0x25,0x25,0x6f, 0x5c,0x2e,0x2e,0x72 1924e1051a39Sopenharmony_ci.byte 0x38,0x1c,0x1c,0x24, 0x57,0xa6,0xa6,0xf1 1925e1051a39Sopenharmony_ci.byte 0x73,0xb4,0xb4,0xc7, 0x97,0xc6,0xc6,0x51 1926e1051a39Sopenharmony_ci.byte 0xcb,0xe8,0xe8,0x23, 0xa1,0xdd,0xdd,0x7c 1927e1051a39Sopenharmony_ci.byte 0xe8,0x74,0x74,0x9c, 0x3e,0x1f,0x1f,0x21 1928e1051a39Sopenharmony_ci.byte 0x96,0x4b,0x4b,0xdd, 0x61,0xbd,0xbd,0xdc 1929e1051a39Sopenharmony_ci.byte 0x0d,0x8b,0x8b,0x86, 0x0f,0x8a,0x8a,0x85 1930e1051a39Sopenharmony_ci.byte 0xe0,0x70,0x70,0x90, 0x7c,0x3e,0x3e,0x42 1931e1051a39Sopenharmony_ci.byte 0x71,0xb5,0xb5,0xc4, 0xcc,0x66,0x66,0xaa 1932e1051a39Sopenharmony_ci.byte 0x90,0x48,0x48,0xd8, 0x06,0x03,0x03,0x05 1933e1051a39Sopenharmony_ci.byte 0xf7,0xf6,0xf6,0x01, 0x1c,0x0e,0x0e,0x12 1934e1051a39Sopenharmony_ci.byte 0xc2,0x61,0x61,0xa3, 0x6a,0x35,0x35,0x5f 1935e1051a39Sopenharmony_ci.byte 0xae,0x57,0x57,0xf9, 0x69,0xb9,0xb9,0xd0 1936e1051a39Sopenharmony_ci.byte 0x17,0x86,0x86,0x91, 0x99,0xc1,0xc1,0x58 1937e1051a39Sopenharmony_ci.byte 0x3a,0x1d,0x1d,0x27, 0x27,0x9e,0x9e,0xb9 1938e1051a39Sopenharmony_ci.byte 0xd9,0xe1,0xe1,0x38, 0xeb,0xf8,0xf8,0x13 1939e1051a39Sopenharmony_ci.byte 0x2b,0x98,0x98,0xb3, 0x22,0x11,0x11,0x33 1940e1051a39Sopenharmony_ci.byte 0xd2,0x69,0x69,0xbb, 0xa9,0xd9,0xd9,0x70 1941e1051a39Sopenharmony_ci.byte 0x07,0x8e,0x8e,0x89, 0x33,0x94,0x94,0xa7 1942e1051a39Sopenharmony_ci.byte 0x2d,0x9b,0x9b,0xb6, 0x3c,0x1e,0x1e,0x22 1943e1051a39Sopenharmony_ci.byte 0x15,0x87,0x87,0x92, 0xc9,0xe9,0xe9,0x20 1944e1051a39Sopenharmony_ci.byte 0x87,0xce,0xce,0x49, 0xaa,0x55,0x55,0xff 1945e1051a39Sopenharmony_ci.byte 0x50,0x28,0x28,0x78, 0xa5,0xdf,0xdf,0x7a 1946e1051a39Sopenharmony_ci.byte 0x03,0x8c,0x8c,0x8f, 0x59,0xa1,0xa1,0xf8 1947e1051a39Sopenharmony_ci.byte 0x09,0x89,0x89,0x80, 0x1a,0x0d,0x0d,0x17 1948e1051a39Sopenharmony_ci.byte 0x65,0xbf,0xbf,0xda, 0xd7,0xe6,0xe6,0x31 1949e1051a39Sopenharmony_ci.byte 0x84,0x42,0x42,0xc6, 0xd0,0x68,0x68,0xb8 1950e1051a39Sopenharmony_ci.byte 0x82,0x41,0x41,0xc3, 0x29,0x99,0x99,0xb0 1951e1051a39Sopenharmony_ci.byte 0x5a,0x2d,0x2d,0x77, 0x1e,0x0f,0x0f,0x11 1952e1051a39Sopenharmony_ci.byte 0x7b,0xb0,0xb0,0xcb, 0xa8,0x54,0x54,0xfc 1953e1051a39Sopenharmony_ci.byte 0x6d,0xbb,0xbb,0xd6, 0x2c,0x16,0x16,0x3a 1954e1051a39Sopenharmony_ci 1955e1051a39Sopenharmony_ciAES_Td: 1956e1051a39Sopenharmony_ci.byte 0x51,0xf4,0xa7,0x50, 0x7e,0x41,0x65,0x53 # Td0 1957e1051a39Sopenharmony_ci.byte 0x1a,0x17,0xa4,0xc3, 0x3a,0x27,0x5e,0x96 1958e1051a39Sopenharmony_ci.byte 0x3b,0xab,0x6b,0xcb, 0x1f,0x9d,0x45,0xf1 1959e1051a39Sopenharmony_ci.byte 0xac,0xfa,0x58,0xab, 0x4b,0xe3,0x03,0x93 1960e1051a39Sopenharmony_ci.byte 0x20,0x30,0xfa,0x55, 0xad,0x76,0x6d,0xf6 1961e1051a39Sopenharmony_ci.byte 0x88,0xcc,0x76,0x91, 0xf5,0x02,0x4c,0x25 1962e1051a39Sopenharmony_ci.byte 0x4f,0xe5,0xd7,0xfc, 0xc5,0x2a,0xcb,0xd7 1963e1051a39Sopenharmony_ci.byte 0x26,0x35,0x44,0x80, 0xb5,0x62,0xa3,0x8f 1964e1051a39Sopenharmony_ci.byte 0xde,0xb1,0x5a,0x49, 0x25,0xba,0x1b,0x67 1965e1051a39Sopenharmony_ci.byte 0x45,0xea,0x0e,0x98, 0x5d,0xfe,0xc0,0xe1 1966e1051a39Sopenharmony_ci.byte 0xc3,0x2f,0x75,0x02, 0x81,0x4c,0xf0,0x12 1967e1051a39Sopenharmony_ci.byte 0x8d,0x46,0x97,0xa3, 0x6b,0xd3,0xf9,0xc6 1968e1051a39Sopenharmony_ci.byte 0x03,0x8f,0x5f,0xe7, 0x15,0x92,0x9c,0x95 1969e1051a39Sopenharmony_ci.byte 0xbf,0x6d,0x7a,0xeb, 0x95,0x52,0x59,0xda 1970e1051a39Sopenharmony_ci.byte 0xd4,0xbe,0x83,0x2d, 0x58,0x74,0x21,0xd3 1971e1051a39Sopenharmony_ci.byte 0x49,0xe0,0x69,0x29, 0x8e,0xc9,0xc8,0x44 1972e1051a39Sopenharmony_ci.byte 0x75,0xc2,0x89,0x6a, 0xf4,0x8e,0x79,0x78 1973e1051a39Sopenharmony_ci.byte 0x99,0x58,0x3e,0x6b, 0x27,0xb9,0x71,0xdd 1974e1051a39Sopenharmony_ci.byte 0xbe,0xe1,0x4f,0xb6, 0xf0,0x88,0xad,0x17 1975e1051a39Sopenharmony_ci.byte 0xc9,0x20,0xac,0x66, 0x7d,0xce,0x3a,0xb4 1976e1051a39Sopenharmony_ci.byte 0x63,0xdf,0x4a,0x18, 0xe5,0x1a,0x31,0x82 1977e1051a39Sopenharmony_ci.byte 0x97,0x51,0x33,0x60, 0x62,0x53,0x7f,0x45 1978e1051a39Sopenharmony_ci.byte 0xb1,0x64,0x77,0xe0, 0xbb,0x6b,0xae,0x84 1979e1051a39Sopenharmony_ci.byte 0xfe,0x81,0xa0,0x1c, 0xf9,0x08,0x2b,0x94 1980e1051a39Sopenharmony_ci.byte 0x70,0x48,0x68,0x58, 0x8f,0x45,0xfd,0x19 1981e1051a39Sopenharmony_ci.byte 0x94,0xde,0x6c,0x87, 0x52,0x7b,0xf8,0xb7 1982e1051a39Sopenharmony_ci.byte 0xab,0x73,0xd3,0x23, 0x72,0x4b,0x02,0xe2 1983e1051a39Sopenharmony_ci.byte 0xe3,0x1f,0x8f,0x57, 0x66,0x55,0xab,0x2a 1984e1051a39Sopenharmony_ci.byte 0xb2,0xeb,0x28,0x07, 0x2f,0xb5,0xc2,0x03 1985e1051a39Sopenharmony_ci.byte 0x86,0xc5,0x7b,0x9a, 0xd3,0x37,0x08,0xa5 1986e1051a39Sopenharmony_ci.byte 0x30,0x28,0x87,0xf2, 0x23,0xbf,0xa5,0xb2 1987e1051a39Sopenharmony_ci.byte 0x02,0x03,0x6a,0xba, 0xed,0x16,0x82,0x5c 1988e1051a39Sopenharmony_ci.byte 0x8a,0xcf,0x1c,0x2b, 0xa7,0x79,0xb4,0x92 1989e1051a39Sopenharmony_ci.byte 0xf3,0x07,0xf2,0xf0, 0x4e,0x69,0xe2,0xa1 1990e1051a39Sopenharmony_ci.byte 0x65,0xda,0xf4,0xcd, 0x06,0x05,0xbe,0xd5 1991e1051a39Sopenharmony_ci.byte 0xd1,0x34,0x62,0x1f, 0xc4,0xa6,0xfe,0x8a 1992e1051a39Sopenharmony_ci.byte 0x34,0x2e,0x53,0x9d, 0xa2,0xf3,0x55,0xa0 1993e1051a39Sopenharmony_ci.byte 0x05,0x8a,0xe1,0x32, 0xa4,0xf6,0xeb,0x75 1994e1051a39Sopenharmony_ci.byte 0x0b,0x83,0xec,0x39, 0x40,0x60,0xef,0xaa 1995e1051a39Sopenharmony_ci.byte 0x5e,0x71,0x9f,0x06, 0xbd,0x6e,0x10,0x51 1996e1051a39Sopenharmony_ci.byte 0x3e,0x21,0x8a,0xf9, 0x96,0xdd,0x06,0x3d 1997e1051a39Sopenharmony_ci.byte 0xdd,0x3e,0x05,0xae, 0x4d,0xe6,0xbd,0x46 1998e1051a39Sopenharmony_ci.byte 0x91,0x54,0x8d,0xb5, 0x71,0xc4,0x5d,0x05 1999e1051a39Sopenharmony_ci.byte 0x04,0x06,0xd4,0x6f, 0x60,0x50,0x15,0xff 2000e1051a39Sopenharmony_ci.byte 0x19,0x98,0xfb,0x24, 0xd6,0xbd,0xe9,0x97 2001e1051a39Sopenharmony_ci.byte 0x89,0x40,0x43,0xcc, 0x67,0xd9,0x9e,0x77 2002e1051a39Sopenharmony_ci.byte 0xb0,0xe8,0x42,0xbd, 0x07,0x89,0x8b,0x88 2003e1051a39Sopenharmony_ci.byte 0xe7,0x19,0x5b,0x38, 0x79,0xc8,0xee,0xdb 2004e1051a39Sopenharmony_ci.byte 0xa1,0x7c,0x0a,0x47, 0x7c,0x42,0x0f,0xe9 2005e1051a39Sopenharmony_ci.byte 0xf8,0x84,0x1e,0xc9, 0x00,0x00,0x00,0x00 2006e1051a39Sopenharmony_ci.byte 0x09,0x80,0x86,0x83, 0x32,0x2b,0xed,0x48 2007e1051a39Sopenharmony_ci.byte 0x1e,0x11,0x70,0xac, 0x6c,0x5a,0x72,0x4e 2008e1051a39Sopenharmony_ci.byte 0xfd,0x0e,0xff,0xfb, 0x0f,0x85,0x38,0x56 2009e1051a39Sopenharmony_ci.byte 0x3d,0xae,0xd5,0x1e, 0x36,0x2d,0x39,0x27 2010e1051a39Sopenharmony_ci.byte 0x0a,0x0f,0xd9,0x64, 0x68,0x5c,0xa6,0x21 2011e1051a39Sopenharmony_ci.byte 0x9b,0x5b,0x54,0xd1, 0x24,0x36,0x2e,0x3a 2012e1051a39Sopenharmony_ci.byte 0x0c,0x0a,0x67,0xb1, 0x93,0x57,0xe7,0x0f 2013e1051a39Sopenharmony_ci.byte 0xb4,0xee,0x96,0xd2, 0x1b,0x9b,0x91,0x9e 2014e1051a39Sopenharmony_ci.byte 0x80,0xc0,0xc5,0x4f, 0x61,0xdc,0x20,0xa2 2015e1051a39Sopenharmony_ci.byte 0x5a,0x77,0x4b,0x69, 0x1c,0x12,0x1a,0x16 2016e1051a39Sopenharmony_ci.byte 0xe2,0x93,0xba,0x0a, 0xc0,0xa0,0x2a,0xe5 2017e1051a39Sopenharmony_ci.byte 0x3c,0x22,0xe0,0x43, 0x12,0x1b,0x17,0x1d 2018e1051a39Sopenharmony_ci.byte 0x0e,0x09,0x0d,0x0b, 0xf2,0x8b,0xc7,0xad 2019e1051a39Sopenharmony_ci.byte 0x2d,0xb6,0xa8,0xb9, 0x14,0x1e,0xa9,0xc8 2020e1051a39Sopenharmony_ci.byte 0x57,0xf1,0x19,0x85, 0xaf,0x75,0x07,0x4c 2021e1051a39Sopenharmony_ci.byte 0xee,0x99,0xdd,0xbb, 0xa3,0x7f,0x60,0xfd 2022e1051a39Sopenharmony_ci.byte 0xf7,0x01,0x26,0x9f, 0x5c,0x72,0xf5,0xbc 2023e1051a39Sopenharmony_ci.byte 0x44,0x66,0x3b,0xc5, 0x5b,0xfb,0x7e,0x34 2024e1051a39Sopenharmony_ci.byte 0x8b,0x43,0x29,0x76, 0xcb,0x23,0xc6,0xdc 2025e1051a39Sopenharmony_ci.byte 0xb6,0xed,0xfc,0x68, 0xb8,0xe4,0xf1,0x63 2026e1051a39Sopenharmony_ci.byte 0xd7,0x31,0xdc,0xca, 0x42,0x63,0x85,0x10 2027e1051a39Sopenharmony_ci.byte 0x13,0x97,0x22,0x40, 0x84,0xc6,0x11,0x20 2028e1051a39Sopenharmony_ci.byte 0x85,0x4a,0x24,0x7d, 0xd2,0xbb,0x3d,0xf8 2029e1051a39Sopenharmony_ci.byte 0xae,0xf9,0x32,0x11, 0xc7,0x29,0xa1,0x6d 2030e1051a39Sopenharmony_ci.byte 0x1d,0x9e,0x2f,0x4b, 0xdc,0xb2,0x30,0xf3 2031e1051a39Sopenharmony_ci.byte 0x0d,0x86,0x52,0xec, 0x77,0xc1,0xe3,0xd0 2032e1051a39Sopenharmony_ci.byte 0x2b,0xb3,0x16,0x6c, 0xa9,0x70,0xb9,0x99 2033e1051a39Sopenharmony_ci.byte 0x11,0x94,0x48,0xfa, 0x47,0xe9,0x64,0x22 2034e1051a39Sopenharmony_ci.byte 0xa8,0xfc,0x8c,0xc4, 0xa0,0xf0,0x3f,0x1a 2035e1051a39Sopenharmony_ci.byte 0x56,0x7d,0x2c,0xd8, 0x22,0x33,0x90,0xef 2036e1051a39Sopenharmony_ci.byte 0x87,0x49,0x4e,0xc7, 0xd9,0x38,0xd1,0xc1 2037e1051a39Sopenharmony_ci.byte 0x8c,0xca,0xa2,0xfe, 0x98,0xd4,0x0b,0x36 2038e1051a39Sopenharmony_ci.byte 0xa6,0xf5,0x81,0xcf, 0xa5,0x7a,0xde,0x28 2039e1051a39Sopenharmony_ci.byte 0xda,0xb7,0x8e,0x26, 0x3f,0xad,0xbf,0xa4 2040e1051a39Sopenharmony_ci.byte 0x2c,0x3a,0x9d,0xe4, 0x50,0x78,0x92,0x0d 2041e1051a39Sopenharmony_ci.byte 0x6a,0x5f,0xcc,0x9b, 0x54,0x7e,0x46,0x62 2042e1051a39Sopenharmony_ci.byte 0xf6,0x8d,0x13,0xc2, 0x90,0xd8,0xb8,0xe8 2043e1051a39Sopenharmony_ci.byte 0x2e,0x39,0xf7,0x5e, 0x82,0xc3,0xaf,0xf5 2044e1051a39Sopenharmony_ci.byte 0x9f,0x5d,0x80,0xbe, 0x69,0xd0,0x93,0x7c 2045e1051a39Sopenharmony_ci.byte 0x6f,0xd5,0x2d,0xa9, 0xcf,0x25,0x12,0xb3 2046e1051a39Sopenharmony_ci.byte 0xc8,0xac,0x99,0x3b, 0x10,0x18,0x7d,0xa7 2047e1051a39Sopenharmony_ci.byte 0xe8,0x9c,0x63,0x6e, 0xdb,0x3b,0xbb,0x7b 2048e1051a39Sopenharmony_ci.byte 0xcd,0x26,0x78,0x09, 0x6e,0x59,0x18,0xf4 2049e1051a39Sopenharmony_ci.byte 0xec,0x9a,0xb7,0x01, 0x83,0x4f,0x9a,0xa8 2050e1051a39Sopenharmony_ci.byte 0xe6,0x95,0x6e,0x65, 0xaa,0xff,0xe6,0x7e 2051e1051a39Sopenharmony_ci.byte 0x21,0xbc,0xcf,0x08, 0xef,0x15,0xe8,0xe6 2052e1051a39Sopenharmony_ci.byte 0xba,0xe7,0x9b,0xd9, 0x4a,0x6f,0x36,0xce 2053e1051a39Sopenharmony_ci.byte 0xea,0x9f,0x09,0xd4, 0x29,0xb0,0x7c,0xd6 2054e1051a39Sopenharmony_ci.byte 0x31,0xa4,0xb2,0xaf, 0x2a,0x3f,0x23,0x31 2055e1051a39Sopenharmony_ci.byte 0xc6,0xa5,0x94,0x30, 0x35,0xa2,0x66,0xc0 2056e1051a39Sopenharmony_ci.byte 0x74,0x4e,0xbc,0x37, 0xfc,0x82,0xca,0xa6 2057e1051a39Sopenharmony_ci.byte 0xe0,0x90,0xd0,0xb0, 0x33,0xa7,0xd8,0x15 2058e1051a39Sopenharmony_ci.byte 0xf1,0x04,0x98,0x4a, 0x41,0xec,0xda,0xf7 2059e1051a39Sopenharmony_ci.byte 0x7f,0xcd,0x50,0x0e, 0x17,0x91,0xf6,0x2f 2060e1051a39Sopenharmony_ci.byte 0x76,0x4d,0xd6,0x8d, 0x43,0xef,0xb0,0x4d 2061e1051a39Sopenharmony_ci.byte 0xcc,0xaa,0x4d,0x54, 0xe4,0x96,0x04,0xdf 2062e1051a39Sopenharmony_ci.byte 0x9e,0xd1,0xb5,0xe3, 0x4c,0x6a,0x88,0x1b 2063e1051a39Sopenharmony_ci.byte 0xc1,0x2c,0x1f,0xb8, 0x46,0x65,0x51,0x7f 2064e1051a39Sopenharmony_ci.byte 0x9d,0x5e,0xea,0x04, 0x01,0x8c,0x35,0x5d 2065e1051a39Sopenharmony_ci.byte 0xfa,0x87,0x74,0x73, 0xfb,0x0b,0x41,0x2e 2066e1051a39Sopenharmony_ci.byte 0xb3,0x67,0x1d,0x5a, 0x92,0xdb,0xd2,0x52 2067e1051a39Sopenharmony_ci.byte 0xe9,0x10,0x56,0x33, 0x6d,0xd6,0x47,0x13 2068e1051a39Sopenharmony_ci.byte 0x9a,0xd7,0x61,0x8c, 0x37,0xa1,0x0c,0x7a 2069e1051a39Sopenharmony_ci.byte 0x59,0xf8,0x14,0x8e, 0xeb,0x13,0x3c,0x89 2070e1051a39Sopenharmony_ci.byte 0xce,0xa9,0x27,0xee, 0xb7,0x61,0xc9,0x35 2071e1051a39Sopenharmony_ci.byte 0xe1,0x1c,0xe5,0xed, 0x7a,0x47,0xb1,0x3c 2072e1051a39Sopenharmony_ci.byte 0x9c,0xd2,0xdf,0x59, 0x55,0xf2,0x73,0x3f 2073e1051a39Sopenharmony_ci.byte 0x18,0x14,0xce,0x79, 0x73,0xc7,0x37,0xbf 2074e1051a39Sopenharmony_ci.byte 0x53,0xf7,0xcd,0xea, 0x5f,0xfd,0xaa,0x5b 2075e1051a39Sopenharmony_ci.byte 0xdf,0x3d,0x6f,0x14, 0x78,0x44,0xdb,0x86 2076e1051a39Sopenharmony_ci.byte 0xca,0xaf,0xf3,0x81, 0xb9,0x68,0xc4,0x3e 2077e1051a39Sopenharmony_ci.byte 0x38,0x24,0x34,0x2c, 0xc2,0xa3,0x40,0x5f 2078e1051a39Sopenharmony_ci.byte 0x16,0x1d,0xc3,0x72, 0xbc,0xe2,0x25,0x0c 2079e1051a39Sopenharmony_ci.byte 0x28,0x3c,0x49,0x8b, 0xff,0x0d,0x95,0x41 2080e1051a39Sopenharmony_ci.byte 0x39,0xa8,0x01,0x71, 0x08,0x0c,0xb3,0xde 2081e1051a39Sopenharmony_ci.byte 0xd8,0xb4,0xe4,0x9c, 0x64,0x56,0xc1,0x90 2082e1051a39Sopenharmony_ci.byte 0x7b,0xcb,0x84,0x61, 0xd5,0x32,0xb6,0x70 2083e1051a39Sopenharmony_ci.byte 0x48,0x6c,0x5c,0x74, 0xd0,0xb8,0x57,0x42 2084e1051a39Sopenharmony_ci 2085e1051a39Sopenharmony_ci.byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38 # Td4 2086e1051a39Sopenharmony_ci.byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb 2087e1051a39Sopenharmony_ci.byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87 2088e1051a39Sopenharmony_ci.byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb 2089e1051a39Sopenharmony_ci.byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d 2090e1051a39Sopenharmony_ci.byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e 2091e1051a39Sopenharmony_ci.byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2 2092e1051a39Sopenharmony_ci.byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 2093e1051a39Sopenharmony_ci.byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16 2094e1051a39Sopenharmony_ci.byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 2095e1051a39Sopenharmony_ci.byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda 2096e1051a39Sopenharmony_ci.byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 2097e1051a39Sopenharmony_ci.byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a 2098e1051a39Sopenharmony_ci.byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 2099e1051a39Sopenharmony_ci.byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02 2100e1051a39Sopenharmony_ci.byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b 2101e1051a39Sopenharmony_ci.byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea 2102e1051a39Sopenharmony_ci.byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 2103e1051a39Sopenharmony_ci.byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85 2104e1051a39Sopenharmony_ci.byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e 2105e1051a39Sopenharmony_ci.byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89 2106e1051a39Sopenharmony_ci.byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b 2107e1051a39Sopenharmony_ci.byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20 2108e1051a39Sopenharmony_ci.byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 2109e1051a39Sopenharmony_ci.byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31 2110e1051a39Sopenharmony_ci.byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f 2111e1051a39Sopenharmony_ci.byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d 2112e1051a39Sopenharmony_ci.byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef 2113e1051a39Sopenharmony_ci.byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0 2114e1051a39Sopenharmony_ci.byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 2115e1051a39Sopenharmony_ci.byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26 2116e1051a39Sopenharmony_ci.byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d 2117e1051a39Sopenharmony_ci 2118e1051a39Sopenharmony_ciAES_Te4: 2119e1051a39Sopenharmony_ci.byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 # Te4 2120e1051a39Sopenharmony_ci.byte 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76 2121e1051a39Sopenharmony_ci.byte 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0 2122e1051a39Sopenharmony_ci.byte 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0 2123e1051a39Sopenharmony_ci.byte 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc 2124e1051a39Sopenharmony_ci.byte 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15 2125e1051a39Sopenharmony_ci.byte 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a 2126e1051a39Sopenharmony_ci.byte 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75 2127e1051a39Sopenharmony_ci.byte 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0 2128e1051a39Sopenharmony_ci.byte 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84 2129e1051a39Sopenharmony_ci.byte 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b 2130e1051a39Sopenharmony_ci.byte 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf 2131e1051a39Sopenharmony_ci.byte 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85 2132e1051a39Sopenharmony_ci.byte 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8 2133e1051a39Sopenharmony_ci.byte 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5 2134e1051a39Sopenharmony_ci.byte 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2 2135e1051a39Sopenharmony_ci.byte 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17 2136e1051a39Sopenharmony_ci.byte 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73 2137e1051a39Sopenharmony_ci.byte 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88 2138e1051a39Sopenharmony_ci.byte 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb 2139e1051a39Sopenharmony_ci.byte 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c 2140e1051a39Sopenharmony_ci.byte 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79 2141e1051a39Sopenharmony_ci.byte 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9 2142e1051a39Sopenharmony_ci.byte 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08 2143e1051a39Sopenharmony_ci.byte 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6 2144e1051a39Sopenharmony_ci.byte 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a 2145e1051a39Sopenharmony_ci.byte 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e 2146e1051a39Sopenharmony_ci.byte 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e 2147e1051a39Sopenharmony_ci.byte 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94 2148e1051a39Sopenharmony_ci.byte 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf 2149e1051a39Sopenharmony_ci.byte 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68 2150e1051a39Sopenharmony_ci.byte 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 2151e1051a39Sopenharmony_ci 2152e1051a39Sopenharmony_ci.byte 0x01,0x00,0x00,0x00, 0x02,0x00,0x00,0x00 # rcon 2153e1051a39Sopenharmony_ci.byte 0x04,0x00,0x00,0x00, 0x08,0x00,0x00,0x00 2154e1051a39Sopenharmony_ci.byte 0x10,0x00,0x00,0x00, 0x20,0x00,0x00,0x00 2155e1051a39Sopenharmony_ci.byte 0x40,0x00,0x00,0x00, 0x80,0x00,0x00,0x00 2156e1051a39Sopenharmony_ci.byte 0x1B,0x00,0x00,0x00, 0x36,0x00,0x00,0x00 2157e1051a39Sopenharmony_ci___ 2158e1051a39Sopenharmony_ci 2159e1051a39Sopenharmony_ciforeach (split("\n",$code)) { 2160e1051a39Sopenharmony_ci s/\`([^\`]*)\`/eval $1/ge; 2161e1051a39Sopenharmony_ci 2162e1051a39Sopenharmony_ci # made-up _instructions, _xtr, _ins, _ror and _bias, cope 2163e1051a39Sopenharmony_ci # with byte order dependencies... 2164e1051a39Sopenharmony_ci if (/^\s+_/) { 2165e1051a39Sopenharmony_ci s/(_[a-z]+\s+)(\$[0-9]+),([^,]+)(#.*)*$/$1$2,$2,$3/; 2166e1051a39Sopenharmony_ci 2167e1051a39Sopenharmony_ci s/_xtr\s+(\$[0-9]+),(\$[0-9]+),([0-9]+(\-2)*)/ 2168e1051a39Sopenharmony_ci sprintf("srl\t$1,$2,%d",$big_endian ? eval($3) 2169e1051a39Sopenharmony_ci : eval("24-$3"))/e or 2170e1051a39Sopenharmony_ci s/_ins\s+(\$[0-9]+),(\$[0-9]+),([0-9]+)/ 2171e1051a39Sopenharmony_ci sprintf("sll\t$1,$2,%d",$big_endian ? eval($3) 2172e1051a39Sopenharmony_ci : eval("24-$3"))/e or 2173e1051a39Sopenharmony_ci s/_ins2\s+(\$[0-9]+),(\$[0-9]+),([0-9]+)/ 2174e1051a39Sopenharmony_ci sprintf("ins\t$1,$2,%d,8",$big_endian ? eval($3) 2175e1051a39Sopenharmony_ci : eval("24-$3"))/e or 2176e1051a39Sopenharmony_ci s/_ror\s+(\$[0-9]+),(\$[0-9]+),(\-?[0-9]+)/ 2177e1051a39Sopenharmony_ci sprintf("srl\t$1,$2,%d",$big_endian ? eval($3) 2178e1051a39Sopenharmony_ci : eval("$3*-1"))/e or 2179e1051a39Sopenharmony_ci s/_bias\s+(\$[0-9]+),(\$[0-9]+),([0-9]+)/ 2180e1051a39Sopenharmony_ci sprintf("sll\t$1,$2,%d",$big_endian ? eval($3) 2181e1051a39Sopenharmony_ci : eval("($3-16)&31"))/e; 2182e1051a39Sopenharmony_ci 2183e1051a39Sopenharmony_ci s/srl\s+(\$[0-9]+),(\$[0-9]+),\-([0-9]+)/ 2184e1051a39Sopenharmony_ci sprintf("sll\t$1,$2,$3")/e or 2185e1051a39Sopenharmony_ci s/srl\s+(\$[0-9]+),(\$[0-9]+),0/ 2186e1051a39Sopenharmony_ci sprintf("and\t$1,$2,0xff")/e or 2187e1051a39Sopenharmony_ci s/(sll\s+\$[0-9]+,\$[0-9]+,0)/#$1/; 2188e1051a39Sopenharmony_ci } 2189e1051a39Sopenharmony_ci 2190e1051a39Sopenharmony_ci # convert lwl/lwr and swr/swl to little-endian order 2191e1051a39Sopenharmony_ci if (!$big_endian && /^\s+[sl]w[lr]\s+/) { 2192e1051a39Sopenharmony_ci s/([sl]wl.*)([0-9]+)\((\$[0-9]+)\)/ 2193e1051a39Sopenharmony_ci sprintf("$1%d($3)",eval("$2-$2%4+($2%4-1)&3"))/e or 2194e1051a39Sopenharmony_ci s/([sl]wr.*)([0-9]+)\((\$[0-9]+)\)/ 2195e1051a39Sopenharmony_ci sprintf("$1%d($3)",eval("$2-$2%4+($2%4+1)&3"))/e; 2196e1051a39Sopenharmony_ci } 2197e1051a39Sopenharmony_ci 2198e1051a39Sopenharmony_ci if (!$big_endian) { 2199e1051a39Sopenharmony_ci s/(rotr\s+\$[0-9]+,\$[0-9]+),([0-9]+)/sprintf("$1,%d",32-$2)/e; 2200e1051a39Sopenharmony_ci s/(ext\s+\$[0-9]+,\$[0-9]+),([0-9]+),8/sprintf("$1,%d,8",24-$2)/e; 2201e1051a39Sopenharmony_ci } 2202e1051a39Sopenharmony_ci 2203e1051a39Sopenharmony_ci print $_,"\n"; 2204e1051a39Sopenharmony_ci} 2205e1051a39Sopenharmony_ci 2206e1051a39Sopenharmony_ciclose STDOUT or die "error closing STDOUT: $!"; 2207