Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) #! /usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4) # This code is taken from CRYPTOGAMs[1] and is included here using the option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5) # in the license to distribute the code under the GPL. Therefore this program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6) # is free software; you can redistribute it and/or modify it under the terms of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7) # the GNU General Public License version 2 as published by the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) # Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) # [1] https://www.openssl.org/~appro/cryptogams/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) # Copyright (c) 2006-2017, CRYPTOGAMS by <appro@openssl.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) # All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) # Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) # modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) # are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #       * Redistributions of source code must retain copyright notices,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #         this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #       * Redistributions in binary form must reproduce the above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #         copyright notice, this list of conditions and the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #         disclaimer in the documentation and/or other materials
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #         provided with the distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #       * Neither the name of the CRYPTOGAMS nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #         copyright holder and contributors may be used to endorse or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) #         promote products derived from this software without specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #         prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) # ALTERNATIVELY, provided that this notice is retained in full, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) # product may be distributed under the terms of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) # License (GPL), in which case the provisions of the GPL apply INSTEAD OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) # those given above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) # ====================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) # project. The module is, however, dual licensed under OpenSSL and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) # CRYPTOGAMS licenses depending on where you obtain it. For further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) # details see https://www.openssl.org/~appro/cryptogams/.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) # ====================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) # This module implements support for AES instructions as per PowerISA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) # specification version 2.07, first implemented by POWER8 processor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) # The module is endian-agnostic in sense that it supports both big-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) # and little-endian cases. Data alignment in parallelizable modes is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) # handled with VSX loads and stores, which implies MSR.VSX flag being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) # set. It should also be noted that ISA specification doesn't prohibit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) # alignment exceptions for these instructions on page boundaries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) # Initially alignment was handled in pure AltiVec/VMX way [when data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) # is aligned programmatically, which in turn guarantees exception-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) # free execution], but it turned to hamper performance when vcipher
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) # instructions are interleaved. It's reckoned that eventual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) # misalignment penalties at page boundaries are in average lower
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) # than additional overhead in pure AltiVec approach.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) # May 2016
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) # Add XTS subroutine, 9x on little- and 12x improvement on big-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) # systems were measured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) ######################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) # Current large-block performance in cycles per byte processed with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) # 128-bit key (less is better).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #		CBC en-/decrypt	CTR	XTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) # POWER8[le]	3.96/0.72	0.74	1.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) # POWER8[be]	3.75/0.65	0.66	1.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) $flavour = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) if ($flavour =~ /64/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	$SIZE_T	=8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 	$LRSAVE	=2*$SIZE_T;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	$STU	="stdu";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	$POP	="ld";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 	$PUSH	="std";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	$UCMP	="cmpld";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	$SHL	="sldi";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) } elsif ($flavour =~ /32/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	$SIZE_T	=4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 	$LRSAVE	=$SIZE_T;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 	$STU	="stwu";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 	$POP	="lwz";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	$PUSH	="stw";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	$UCMP	="cmplw";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	$SHL	="slwi";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) } else { die "nonsense $flavour"; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) $LITTLE_ENDIAN = ($flavour=~/le$/) ? $SIZE_T : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) ( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) ( $xlate="${dir}../../perlasm/ppc-xlate.pl" and -f $xlate) or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) die "can't locate ppc-xlate.pl";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) $FRAME=8*$SIZE_T;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) $prefix="aes_p8";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) $sp="r1";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) $vrsave="r12";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) {{{	# Key setup procedures						#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) my ($inp,$bits,$out,$ptr,$cnt,$rounds)=map("r$_",(3..8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) my ($zero,$in0,$in1,$key,$rcon,$mask,$tmp)=map("v$_",(0..6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) my ($stage,$outperm,$outmask,$outhead,$outtail)=map("v$_",(7..11));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) .machine	"any"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) .align	7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) rcon:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) .long	0x01000000, 0x01000000, 0x01000000, 0x01000000	?rev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) .long	0x1b000000, 0x1b000000, 0x1b000000, 0x1b000000	?rev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) .long	0x0d0e0f0c, 0x0d0e0f0c, 0x0d0e0f0c, 0x0d0e0f0c	?rev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) .long	0,0,0,0						?asis
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) Lconsts:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	mflr	r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	bcl	20,31,\$+4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 	mflr	$ptr	 #vvvvv "distance between . and rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 	addi	$ptr,$ptr,-0x48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	mtlr	r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 	.long	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 	.byte	0,12,0x14,0,0,0,0,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) .asciz	"AES for PowerISA 2.07, CRYPTOGAMS by <appro\@openssl.org>"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) .globl	.${prefix}_set_encrypt_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) Lset_encrypt_key:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	mflr		r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	$PUSH		r11,$LRSAVE($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	li		$ptr,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	${UCMP}i	$inp,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	beq-		Lenc_key_abort		# if ($inp==0) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	${UCMP}i	$out,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	beq-		Lenc_key_abort		# if ($out==0) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 	li		$ptr,-2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	cmpwi		$bits,128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	blt-		Lenc_key_abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	cmpwi		$bits,256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	bgt-		Lenc_key_abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	andi.		r0,$bits,0x3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	bne-		Lenc_key_abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	lis		r0,0xfff0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	mfspr		$vrsave,256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	bl		Lconsts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	mtlr		r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	neg		r9,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	lvx		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	addi		$inp,$inp,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	lvsr		$key,0,r9		# borrow $key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 	li		r8,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	cmpwi		$bits,192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	lvx		$in1,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	le?vspltisb	$mask,0x0f		# borrow $mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	lvx		$rcon,0,$ptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	le?vxor		$key,$key,$mask		# adjust for byte swap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	lvx		$mask,r8,$ptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	addi		$ptr,$ptr,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	vperm		$in0,$in0,$in1,$key	# align [and byte swap in LE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	li		$cnt,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	vxor		$zero,$zero,$zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	mtctr		$cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 	?lvsr		$outperm,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	vspltisb	$outmask,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	lvx		$outhead,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	?vperm		$outmask,$zero,$outmask,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	blt		Loop128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	addi		$inp,$inp,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 	beq		L192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	addi		$inp,$inp,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 	b		L256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) Loop128:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	vperm		$key,$in0,$in0,$mask	# rotate-n-splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 	vsldoi		$tmp,$zero,$in0,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	vcipherlast	$key,$key,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 	 vadduwm	$rcon,$rcon,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	vxor		$in0,$in0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	bdnz		Loop128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	lvx		$rcon,0,$ptr		# last two round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	vperm		$key,$in0,$in0,$mask	# rotate-n-splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	vsldoi		$tmp,$zero,$in0,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	vcipherlast	$key,$key,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 	 vadduwm	$rcon,$rcon,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 	vxor		$in0,$in0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	vperm		$key,$in0,$in0,$mask	# rotate-n-splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	vsldoi		$tmp,$zero,$in0,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 	vcipherlast	$key,$key,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	vxor		$in0,$in0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	addi		$inp,$out,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	addi		$out,$out,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	li		$rounds,10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	b		Ldone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) L192:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	lvx		$tmp,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	li		$cnt,4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	vperm		$in1,$in1,$tmp,$key	# align [and byte swap in LE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 	vspltisb	$key,8			# borrow $key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 	mtctr		$cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) 	vsububm		$mask,$mask,$key	# adjust the mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) Loop192:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 	vperm		$key,$in1,$in1,$mask	# roate-n-splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	vsldoi		$tmp,$zero,$in0,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 	vcipherlast	$key,$key,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	 vsldoi		$stage,$zero,$in1,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 	vspltw		$tmp,$in0,3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	vxor		$tmp,$tmp,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	vsldoi		$in1,$zero,$in1,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	 vadduwm	$rcon,$rcon,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	vxor		$in1,$in1,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	vxor		$in0,$in0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 	vxor		$in1,$in1,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	 vsldoi		$stage,$stage,$in0,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	vperm		$key,$in1,$in1,$mask	# rotate-n-splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	vsldoi		$tmp,$zero,$in0,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	 vperm		$outtail,$stage,$stage,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	vcipherlast	$key,$key,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	 vsldoi		$stage,$in0,$in1,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	 vperm		$outtail,$stage,$stage,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	vspltw		$tmp,$in0,3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	vxor		$tmp,$tmp,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	vsldoi		$in1,$zero,$in1,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	 vadduwm	$rcon,$rcon,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	vxor		$in1,$in1,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	vxor		$in0,$in0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	vxor		$in1,$in1,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	 addi		$inp,$out,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	bdnz		Loop192
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 	li		$rounds,12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 	addi		$out,$out,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	b		Ldone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) L256:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 	lvx		$tmp,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	li		$cnt,7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	li		$rounds,14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	vperm		$in1,$in1,$tmp,$key	# align [and byte swap in LE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	mtctr		$cnt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) Loop256:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	vperm		$key,$in1,$in1,$mask	# rotate-n-splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	vsldoi		$tmp,$zero,$in0,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	 vperm		$outtail,$in1,$in1,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	vcipherlast	$key,$key,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 	vxor		$in0,$in0,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	 vadduwm	$rcon,$rcon,$rcon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	vxor		$in0,$in0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 	 vperm		$outtail,$in0,$in0,$outperm	# rotate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 	 vsel		$stage,$outhead,$outtail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 	 vmr		$outhead,$outtail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 	 stvx		$stage,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	 addi		$inp,$out,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	 addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	bdz		Ldone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	vspltw		$key,$in0,3		# just splat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	vsldoi		$tmp,$zero,$in1,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 	vsbox		$key,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 	vxor		$in1,$in1,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 	vxor		$in1,$in1,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 	vsldoi		$tmp,$zero,$tmp,12	# >>32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 	vxor		$in1,$in1,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 	vxor		$in1,$in1,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	b		Loop256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) Ldone:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	lvx		$in1,0,$inp		# redundant in aligned case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	vsel		$in1,$outhead,$in1,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	stvx		$in1,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 	li		$ptr,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 	stw		$rounds,0($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) Lenc_key_abort:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 	mr		r3,$ptr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	.byte		0,12,0x14,1,0,0,3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) .size	.${prefix}_set_encrypt_key,.-.${prefix}_set_encrypt_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) .globl	.${prefix}_set_decrypt_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	$STU		$sp,-$FRAME($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	mflr		r10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	$PUSH		r10,$FRAME+$LRSAVE($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 	bl		Lset_encrypt_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 	mtlr		r10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	cmpwi		r3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	bne-		Ldec_key_abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	slwi		$cnt,$rounds,4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 	subi		$inp,$out,240		# first round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 	add		$out,$inp,$cnt		# last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) Ldeckey:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 	lwz		r0, 0($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 	lwz		r6, 4($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	lwz		r7, 8($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	lwz		r8, 12($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 	lwz		r9, 0($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 	lwz		r10,4($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 	lwz		r11,8($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 	lwz		r12,12($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 	stw		r0, 0($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 	stw		r6, 4($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 	stw		r7, 8($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 	stw		r8, 12($out)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	subi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	stw		r9, -16($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	stw		r10,-12($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	stw		r11,-8($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 	stw		r12,-4($inp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	bdnz		Ldeckey
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 	xor		r3,r3,r3		# return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) Ldec_key_abort:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 	addi		$sp,$sp,$FRAME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	.byte		0,12,4,1,0x80,0,3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) .size	.${prefix}_set_decrypt_key,.-.${prefix}_set_decrypt_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) }}}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) {{{	# Single block en- and decrypt procedures			#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) sub gen_block () {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) my $dir = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) my $n   = $dir eq "de" ? "n" : "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) my ($inp,$out,$key,$rounds,$idx)=map("r$_",(3..7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) .globl	.${prefix}_${dir}crypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	lwz		$rounds,240($key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	lis		r0,0xfc00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	mfspr		$vrsave,256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	li		$idx,15			# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 	lvx		v0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 	neg		r11,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 	lvx		v1,$idx,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	lvsl		v2,0,$inp		# inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	le?vspltisb	v4,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	?lvsl		v3,0,r11		# outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	le?vxor		v2,v2,v4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	vperm		v0,v0,v1,v2		# align [and byte swap in LE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	lvx		v1,0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	?lvsl		v5,0,$key		# keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	lvx		v2,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	?vperm		v1,v1,v2,v5		# align round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	vxor		v0,v0,v1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	lvx		v1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) Loop_${dir}c:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	?vperm		v2,v2,v1,v5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	v${n}cipher	v0,v0,v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	lvx		v2,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	?vperm		v1,v1,v2,v5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	v${n}cipher	v0,v0,v1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 	lvx		v1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	bdnz		Loop_${dir}c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	?vperm		v2,v2,v1,v5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	v${n}cipher	v0,v0,v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	lvx		v2,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 	?vperm		v1,v1,v2,v5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 	v${n}cipherlast	v0,v0,v1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 	vspltisb	v2,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	vxor		v1,v1,v1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	li		$idx,15			# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	?vperm		v2,v1,v2,v3		# outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 	le?vxor		v3,v3,v4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 	lvx		v1,0,$out		# outhead
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	vperm		v0,v0,v0,v3		# rotate [and byte swap in LE]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	vsel		v1,v1,v0,v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	lvx		v4,$idx,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	stvx		v1,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	vsel		v0,v0,v4,v2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 	stvx		v0,$idx,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	.byte		0,12,0x14,0,0,0,3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) .size	.${prefix}_${dir}crypt,.-.${prefix}_${dir}crypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) &gen_block("en");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) &gen_block("de");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) }}}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) {{{	# CBC en- and decrypt procedures				#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) my ($inp,$out,$len,$key,$ivp,$enc,$rounds,$idx)=map("r$_",(3..10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) my ($rndkey0,$rndkey1,$inout,$tmp)=		map("v$_",(0..3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) my ($ivec,$inptail,$inpperm,$outhead,$outperm,$outmask,$keyperm)=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 						map("v$_",(4..10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) .globl	.${prefix}_cbc_encrypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	bltlr-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	cmpwi		$enc,0			# test direction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	lis		r0,0xffe0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	mfspr		$vrsave,256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	li		$idx,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	vxor		$rndkey0,$rndkey0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	lvx		$ivec,0,$ivp		# load [unaligned] iv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	lvsl		$inpperm,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	lvx		$inptail,$idx,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 	vperm		$ivec,$ivec,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	neg		r11,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	?lvsl		$keyperm,0,$key		# prepare for unaligned key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	lwz		$rounds,240($key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	lvsr		$inpperm,0,r11		# prepare for unaligned load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	addi		$inp,$inp,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 	?lvsr		$outperm,0,$out		# prepare for unaligned store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	vspltisb	$outmask,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	lvx		$outhead,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	?vperm		$outmask,$rndkey0,$outmask,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	le?vxor		$outperm,$outperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	beq		Lcbc_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) Lcbc_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	vmr		$inout,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	subi		$len,$len,16		# len-=16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 	lvx		$rndkey0,0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	 vperm		$inout,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	vxor		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	vxor		$inout,$inout,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) Loop_cbc_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	vcipher		$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	vcipher		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	bdnz		Loop_cbc_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	vcipher		$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	vcipherlast	$ivec,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	vperm		$tmp,$ivec,$ivec,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	vsel		$inout,$outhead,$tmp,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 	vmr		$outhead,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	stvx		$inout,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	bge		Lcbc_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	b		Lcbc_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) Lcbc_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	${UCMP}i	$len,128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	bge		_aesp8_cbc_decrypt8x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	vmr		$tmp,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	subi		$len,$len,16		# len-=16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	lvx		$rndkey0,0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	 vperm		$tmp,$tmp,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	vxor		$inout,$tmp,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) Loop_cbc_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	vncipher	$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	vncipher	$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	bdnz		Loop_cbc_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	vncipher	$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 	vncipherlast	$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	vxor		$inout,$inout,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	vmr		$ivec,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	vperm		$tmp,$inout,$inout,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	vsel		$inout,$outhead,$tmp,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	vmr		$outhead,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	stvx		$inout,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 	bge		Lcbc_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) Lcbc_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 	addi		$out,$out,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	lvx		$inout,0,$out		# redundant in aligned case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 	vsel		$inout,$outhead,$inout,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 	stvx		$inout,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	neg		$enc,$ivp		# write [unaligned] iv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	li		$idx,15			# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	vxor		$rndkey0,$rndkey0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 	vspltisb	$outmask,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	?lvsl		$outperm,0,$enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 	?vperm		$outmask,$rndkey0,$outmask,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	le?vxor		$outperm,$outperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	lvx		$outhead,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	vperm		$ivec,$ivec,$ivec,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	vsel		$inout,$outhead,$ivec,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	lvx		$inptail,$idx,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	stvx		$inout,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	vsel		$inout,$ivec,$inptail,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	stvx		$inout,$idx,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	.byte		0,12,0x14,0,0,0,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) {{	# Optimized CBC decrypt procedure				#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) my $key_="r11";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) my ($x00,$x10,$x20,$x30,$x40,$x50,$x60,$x70)=map("r$_",(0,8,26..31));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) my ($in0, $in1, $in2, $in3, $in4, $in5, $in6, $in7 )=map("v$_",(0..3,10..13));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) my ($out0,$out1,$out2,$out3,$out4,$out5,$out6,$out7)=map("v$_",(14..21));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) my $rndkey0="v23";	# v24-v25 rotating buffer for first found keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 			# v26-v31 last 6 round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) my ($tmp,$keyperm)=($in3,$in4);	# aliases with "caller", redundant assignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) _aesp8_cbc_decrypt8x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	$STU		$sp,-`($FRAME+21*16+6*$SIZE_T)`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	li		r10,`$FRAME+8*16+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	li		r11,`$FRAME+8*16+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	stvx		v20,r10,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	stvx		v21,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	stvx		v22,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	stvx		v23,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	stvx		v24,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	stvx		v25,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	stvx		v26,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	stvx		v27,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	stvx		v28,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	stvx		v29,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	stvx		v30,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	stvx		v31,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	li		r0,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	stw		$vrsave,`$FRAME+21*16-4`($sp)	# save vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	li		$x10,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	$PUSH		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	li		$x20,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	$PUSH		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	li		$x30,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	$PUSH		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	li		$x40,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	$PUSH		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	li		$x50,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	$PUSH		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	li		$x60,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	$PUSH		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	li		$x70,0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	subi		$rounds,$rounds,3	# -4 in total
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	subi		$len,$len,128		# bias
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	lvx		$rndkey0,$x00,$key	# load key schedule
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 	lvx		v30,$x10,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	addi		$key,$key,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 	lvx		v31,$x00,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	?vperm		$rndkey0,$rndkey0,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	addi		$key_,$sp,$FRAME+15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) Load_cbc_dec_key:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	lvx		v30,$x10,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	addi		$key,$key,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	stvx		v24,$x00,$key_		# off-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 	?vperm		v25,v31,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	lvx		v31,$x00,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	stvx		v25,$x10,$key_		# off-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	bdnz		Load_cbc_dec_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	lvx		v26,$x10,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	lvx		v27,$x20,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	stvx		v24,$x00,$key_		# off-load round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	?vperm		v25,v31,v26,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	lvx		v28,$x30,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	stvx		v25,$x10,$key_		# off-load round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	?vperm		v26,v26,v27,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	lvx		v29,$x40,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	?vperm		v27,v27,v28,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	lvx		v30,$x50,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	?vperm		v28,v28,v29,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	lvx		v31,$x60,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	?vperm		v29,v29,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	lvx		$out0,$x70,$key		# borrow $out0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	?vperm		v30,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	lvx		v24,$x00,$key_		# pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	?vperm		v31,v31,$out0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	lvx		v25,$x10,$key_		# pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 	#lvx		$inptail,0,$inp		# "caller" already did this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	#addi		$inp,$inp,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	subi		$inp,$inp,15		# undo "caller"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	 le?li		$idx,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	lvx_u		$in0,$x00,$inp		# load first 8 "words"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 	 le?lvsl	$inpperm,0,$idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	 le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	 le?vxor	$inpperm,$inpperm,$tmp	# transform for lvx_u/stvx_u
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	 le?vperm	$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 	 le?vperm	$in1,$in1,$in1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	 le?vperm	$in2,$in2,$in2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	vxor		$out0,$in0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	 le?vperm	$in3,$in3,$in3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	vxor		$out1,$in1,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	lvx_u		$in6,$x60,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	 le?vperm	$in4,$in4,$in4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	vxor		$out2,$in2,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	lvx_u		$in7,$x70,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 	addi		$inp,$inp,0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	 le?vperm	$in5,$in5,$in5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	vxor		$out3,$in3,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	 le?vperm	$in6,$in6,$in6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	vxor		$out4,$in4,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	 le?vperm	$in7,$in7,$in7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	vxor		$out5,$in5,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	vxor		$out6,$in6,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	vxor		$out7,$in7,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	b		Loop_cbc_dec8x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) Loop_cbc_dec8x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	vncipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	vncipher	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	vncipher	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	vncipher	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	vncipher	$out6,$out6,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	vncipher	$out7,$out7,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	bdnz		Loop_cbc_dec8x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	subic		$len,$len,128		# $len-=128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	vncipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	vncipher	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	vncipher	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	subfe.		r0,r0,r0		# borrow?-1:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 	vncipher	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	vncipher	$out6,$out6,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	vncipher	$out7,$out7,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	and		r0,r0,$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	vncipher	$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	vncipher	$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	vncipher	$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	vncipher	$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	vncipher	$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	vncipher	$out5,$out5,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	vncipher	$out6,$out6,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 	vncipher	$out7,$out7,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	add		$inp,$inp,r0		# $inp is adjusted in such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 						# way that at exit from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 						# loop inX-in7 are loaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 						# with last "words"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	vncipher	$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	vncipher	$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	vncipher	$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	vncipher	$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	vncipher	$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	vncipher	$out5,$out5,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 	vncipher	$out6,$out6,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	vncipher	$out7,$out7,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 	vncipher	$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	vncipher	$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 	vncipher	$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 	vncipher	$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	vncipher	$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	vncipher	$out5,$out5,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	vncipher	$out6,$out6,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 	vncipher	$out7,$out7,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	vncipher	$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	vncipher	$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 	vncipher	$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	vncipher	$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	vncipher	$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	vncipher	$out5,$out5,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	vncipher	$out6,$out6,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	vncipher	$out7,$out7,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	vncipher	$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	 vxor		$ivec,$ivec,v31		# xor with last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 	vncipher	$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	 vxor		$in0,$in0,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 	vncipher	$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	 vxor		$in1,$in1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	vncipher	$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	 vxor		$in2,$in2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	vncipher	$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	 vxor		$in3,$in3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	vncipher	$out5,$out5,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	 vxor		$in4,$in4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	vncipher	$out6,$out6,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	 vxor		$in5,$in5,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	vncipher	$out7,$out7,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	 vxor		$in6,$in6,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	vncipherlast	$out0,$out0,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	vncipherlast	$out1,$out1,$in0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	 lvx_u		$in0,$x00,$inp		# load next input block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 	vncipherlast	$out2,$out2,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	 lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	vncipherlast	$out3,$out3,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	 le?vperm	$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 	 lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	vncipherlast	$out4,$out4,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	 le?vperm	$in1,$in1,$in1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 	 lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	vncipherlast	$out5,$out5,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	 le?vperm	$in2,$in2,$in2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	 lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	vncipherlast	$out6,$out6,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	 le?vperm	$in3,$in3,$in3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	 lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	 le?vperm	$in4,$in4,$in4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 	 lvx_u		$in6,$x60,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	 le?vperm	$in5,$in5,$in5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	 lvx_u		$in7,$x70,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 	 addi		$inp,$inp,0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 	 le?vperm	$in6,$in6,$in6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	 vxor		$out0,$in0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 	 le?vperm	$in7,$in7,$in7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	 vxor		$out1,$in1,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 	 vxor		$out2,$in2,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	 vxor		$out3,$in3,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 	 vxor		$out4,$in4,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 	stvx_u		$out5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	 vxor		$out5,$in5,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	stvx_u		$out6,$x60,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	 vxor		$out6,$in6,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	stvx_u		$out7,$x70,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	addi		$out,$out,0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	 vxor		$out7,$in7,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	beq		Loop_cbc_dec8x		# did $len-=128 borrow?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 	addic.		$len,$len,128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	beq		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) Loop_cbc_dec8x_tail:				# up to 7 "words" tail...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 	vncipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	vncipher	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) 	vncipher	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	vncipher	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	vncipher	$out6,$out6,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	vncipher	$out7,$out7,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	bdnz		Loop_cbc_dec8x_tail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	vncipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	vncipher	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	vncipher	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 	vncipher	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	vncipher	$out6,$out6,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	vncipher	$out7,$out7,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	vncipher	$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	vncipher	$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	vncipher	$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	vncipher	$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	vncipher	$out5,$out5,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	vncipher	$out6,$out6,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	vncipher	$out7,$out7,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	vncipher	$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 	vncipher	$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	vncipher	$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 	vncipher	$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 	vncipher	$out5,$out5,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 	vncipher	$out6,$out6,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 	vncipher	$out7,$out7,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	vncipher	$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	vncipher	$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	vncipher	$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	vncipher	$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	vncipher	$out5,$out5,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	vncipher	$out6,$out6,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	vncipher	$out7,$out7,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 	vncipher	$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	vncipher	$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	vncipher	$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	vncipher	$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 	vncipher	$out5,$out5,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 	vncipher	$out6,$out6,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	vncipher	$out7,$out7,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	vncipher	$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	 vxor		$ivec,$ivec,v31		# last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	vncipher	$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	 vxor		$in1,$in1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	vncipher	$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	 vxor		$in2,$in2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	vncipher	$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	 vxor		$in3,$in3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	vncipher	$out5,$out5,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	 vxor		$in4,$in4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 	vncipher	$out6,$out6,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 	 vxor		$in5,$in5,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 	vncipher	$out7,$out7,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 	 vxor		$in6,$in6,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 	cmplwi		$len,32			# switch($len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 	blt		Lcbc_dec8x_one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 	beq		Lcbc_dec8x_two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 	cmplwi		$len,64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 	blt		Lcbc_dec8x_three
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 	beq		Lcbc_dec8x_four
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 	cmplwi		$len,96
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 	blt		Lcbc_dec8x_five
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 	beq		Lcbc_dec8x_six
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) Lcbc_dec8x_seven:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	vncipherlast	$out1,$out1,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 	vncipherlast	$out2,$out2,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 	vncipherlast	$out3,$out3,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	vncipherlast	$out4,$out4,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	vncipherlast	$out5,$out5,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	vncipherlast	$out6,$out6,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	stvx_u		$out1,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	stvx_u		$out2,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 	stvx_u		$out3,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	stvx_u		$out4,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 	stvx_u		$out5,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 	stvx_u		$out6,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	stvx_u		$out7,$x60,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 	addi		$out,$out,0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	b		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) Lcbc_dec8x_six:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 	vncipherlast	$out2,$out2,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 	vncipherlast	$out3,$out3,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 	vncipherlast	$out4,$out4,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 	vncipherlast	$out5,$out5,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 	vncipherlast	$out6,$out6,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) 	stvx_u		$out2,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) 	stvx_u		$out3,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) 	stvx_u		$out4,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) 	stvx_u		$out5,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	stvx_u		$out6,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	stvx_u		$out7,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	addi		$out,$out,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 	b		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) Lcbc_dec8x_five:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	vncipherlast	$out3,$out3,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	vncipherlast	$out4,$out4,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	vncipherlast	$out5,$out5,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	vncipherlast	$out6,$out6,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	stvx_u		$out3,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	stvx_u		$out4,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	stvx_u		$out5,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	stvx_u		$out6,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	stvx_u		$out7,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 	addi		$out,$out,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 	b		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) Lcbc_dec8x_four:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	vncipherlast	$out4,$out4,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 	vncipherlast	$out5,$out5,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	vncipherlast	$out6,$out6,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	stvx_u		$out4,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 	stvx_u		$out5,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	stvx_u		$out6,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) 	stvx_u		$out7,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 	addi		$out,$out,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) 	b		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) Lcbc_dec8x_three:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 	vncipherlast	$out5,$out5,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) 	vncipherlast	$out6,$out6,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	stvx_u		$out5,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	stvx_u		$out6,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	stvx_u		$out7,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	addi		$out,$out,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	b		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) Lcbc_dec8x_two:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	vncipherlast	$out6,$out6,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	vncipherlast	$out7,$out7,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	stvx_u		$out6,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	stvx_u		$out7,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 	addi		$out,$out,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	b		Lcbc_dec8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) Lcbc_dec8x_one:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	vncipherlast	$out7,$out7,$ivec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	vmr		$ivec,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 	stvx_u		$out7,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	addi		$out,$out,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) Lcbc_dec8x_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 	le?vperm	$ivec,$ivec,$ivec,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 	stvx_u		$ivec,0,$ivp		# write [unaligned] iv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	li		r10,`$FRAME+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 	li		r11,`$FRAME+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 	stvx		$inpperm,r10,$sp	# wipe copies of round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 	stvx		$inpperm,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	stvx		$inpperm,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 	stvx		$inpperm,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 	lvx		v20,r10,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 	lvx		v21,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 	lvx		v22,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	lvx		v23,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	lvx		v24,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 	lvx		v25,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 	lvx		v26,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 	lvx		v27,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 	lvx		v28,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 	lvx		v29,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 	lvx		v30,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 	lvx		v31,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 	$POP		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 	$POP		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 	$POP		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 	$POP		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	$POP		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) 	$POP		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	addi		$sp,$sp,`$FRAME+21*16+6*$SIZE_T`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	.byte		0,12,0x14,0,0x80,6,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) .size	.${prefix}_cbc_encrypt,.-.${prefix}_cbc_encrypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) }}	}}}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) {{{	# CTR procedure[s]						#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) ####################### WARNING: Here be dragons! #######################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) # This code is written as 'ctr32', based on a 32-bit counter used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) # upstream. The kernel does *not* use a 32-bit counter. The kernel uses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) # a 128-bit counter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) # This leads to subtle changes from the upstream code: the counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) # is incremented with vaddu_q_m rather than vaddu_w_m. This occurs in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) # both the bulk (8 blocks at a time) path, and in the individual block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) # path. Be aware of this when doing updates.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) # See:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) # 1d4aa0b4c181 ("crypto: vmx - Fixing AES-CTR counter bug")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) # 009b30ac7444 ("crypto: vmx - CTR: always increment IV as quadword")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) # https://github.com/openssl/openssl/pull/8942
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) my ($inp,$out,$len,$key,$ivp,$x10,$rounds,$idx)=map("r$_",(3..10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) my ($rndkey0,$rndkey1,$inout,$tmp)=		map("v$_",(0..3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) my ($ivec,$inptail,$inpperm,$outhead,$outperm,$outmask,$keyperm,$one)=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 						map("v$_",(4..11));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) my $dat=$tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) .globl	.${prefix}_ctr32_encrypt_blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	${UCMP}i	$len,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	bltlr-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	lis		r0,0xfff0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 	mfspr		$vrsave,256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	li		$idx,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	vxor		$rndkey0,$rndkey0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 	lvx		$ivec,0,$ivp		# load [unaligned] iv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	lvsl		$inpperm,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 	lvx		$inptail,$idx,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	 vspltisb	$one,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 	vperm		$ivec,$ivec,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 	 vsldoi		$one,$rndkey0,$one,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 	neg		r11,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 	?lvsl		$keyperm,0,$key		# prepare for unaligned key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 	lwz		$rounds,240($key)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 	lvsr		$inpperm,0,r11		# prepare for unaligned load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 	addi		$inp,$inp,15		# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 	${UCMP}i	$len,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	bge		_aesp8_ctr32_encrypt8x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 	?lvsr		$outperm,0,$out		# prepare for unaligned store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	vspltisb	$outmask,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	lvx		$outhead,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	?vperm		$outmask,$rndkey0,$outmask,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	le?vxor		$outperm,$outperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 	lvx		$rndkey0,0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	vxor		$inout,$ivec,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 	lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 	b		Loop_ctr32_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) Loop_ctr32_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 	vcipher		$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 	vcipher		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 	lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	bdnz		Loop_ctr32_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	vadduqm		$ivec,$ivec,$one	# Kernel change for 128-bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	 vmr		$dat,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	 lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	 addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	 subic.		$len,$len,1		# blocks--
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 	vcipher		$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 	lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 	 vperm		$dat,$dat,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 	 li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 	?vperm		$rndkey1,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	 lvx		$rndkey0,0,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 	vxor		$dat,$dat,$rndkey1	# last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 	vcipherlast	$inout,$inout,$dat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	 lvx		$rndkey1,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 	 addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	vperm		$inout,$inout,$inout,$outperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	vsel		$dat,$outhead,$inout,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	 mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	 ?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	vmr		$outhead,$inout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 	 vxor		$inout,$ivec,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	 lvx		$rndkey0,$idx,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	 addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 	stvx		$dat,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	bne		Loop_ctr32_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	addi		$out,$out,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 	lvx		$inout,0,$out		# redundant in aligned case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	vsel		$inout,$outhead,$inout,$outmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	stvx		$inout,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 	.byte		0,12,0x14,0,0,0,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) {{	# Optimized CTR procedure					#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) my $key_="r11";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) my ($x00,$x10,$x20,$x30,$x40,$x50,$x60,$x70)=map("r$_",(0,8,26..31));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) my ($in0, $in1, $in2, $in3, $in4, $in5, $in6, $in7 )=map("v$_",(0..3,10,12..14));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) my ($out0,$out1,$out2,$out3,$out4,$out5,$out6,$out7)=map("v$_",(15..22));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) my $rndkey0="v23";	# v24-v25 rotating buffer for first found keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 			# v26-v31 last 6 round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) my ($tmp,$keyperm)=($in3,$in4);	# aliases with "caller", redundant assignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) my ($two,$three,$four)=($outhead,$outperm,$outmask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) _aesp8_ctr32_encrypt8x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 	$STU		$sp,-`($FRAME+21*16+6*$SIZE_T)`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 	li		r10,`$FRAME+8*16+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 	li		r11,`$FRAME+8*16+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 	stvx		v20,r10,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 	stvx		v21,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	stvx		v22,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 	stvx		v23,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 	stvx		v24,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 	stvx		v25,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 	stvx		v26,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 	stvx		v27,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 	stvx		v28,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 	stvx		v29,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 	stvx		v30,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 	stvx		v31,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	li		r0,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 	stw		$vrsave,`$FRAME+21*16-4`($sp)	# save vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 	li		$x10,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	$PUSH		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	li		$x20,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 	$PUSH		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 	li		$x30,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) 	$PUSH		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 	li		$x40,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 	$PUSH		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 	li		$x50,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) 	$PUSH		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 	li		$x60,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 	$PUSH		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 	li		$x70,0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 	subi		$rounds,$rounds,3	# -4 in total
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 	lvx		$rndkey0,$x00,$key	# load key schedule
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 	lvx		v30,$x10,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 	addi		$key,$key,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 	lvx		v31,$x00,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	?vperm		$rndkey0,$rndkey0,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 	addi		$key_,$sp,$FRAME+15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) Load_ctr32_enc_key:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 	lvx		v30,$x10,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 	addi		$key,$key,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 	stvx		v24,$x00,$key_		# off-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	?vperm		v25,v31,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 	lvx		v31,$x00,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) 	stvx		v25,$x10,$key_		# off-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) 	bdnz		Load_ctr32_enc_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) 	lvx		v26,$x10,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) 	lvx		v27,$x20,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 	stvx		v24,$x00,$key_		# off-load round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 	?vperm		v25,v31,v26,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) 	lvx		v28,$x30,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 	stvx		v25,$x10,$key_		# off-load round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) 	?vperm		v26,v26,v27,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 	lvx		v29,$x40,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 	?vperm		v27,v27,v28,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 	lvx		v30,$x50,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	?vperm		v28,v28,v29,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 	lvx		v31,$x60,$key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) 	?vperm		v29,v29,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 	lvx		$out0,$x70,$key		# borrow $out0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) 	?vperm		v30,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) 	lvx		v24,$x00,$key_		# pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 	?vperm		v31,v31,$out0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 	lvx		v25,$x10,$key_		# pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 	vadduqm		$two,$one,$one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 	subi		$inp,$inp,15		# undo "caller"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	$SHL		$len,$len,4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 	vadduqm		$out1,$ivec,$one	# counter values ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) 	vadduqm		$out2,$ivec,$two	# (do all ctr adds as 128-bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) 	vxor		$out0,$ivec,$rndkey0	# ... xored with rndkey[0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) 	 le?li		$idx,8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) 	vadduqm		$out3,$out1,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) 	vxor		$out1,$out1,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 	 le?lvsl	$inpperm,0,$idx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 	vadduqm		$out4,$out2,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 	vxor		$out2,$out2,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) 	 le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 	vadduqm		$out5,$out3,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	vxor		$out3,$out3,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 	 le?vxor	$inpperm,$inpperm,$tmp	# transform for lvx_u/stvx_u
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 	vadduqm		$out6,$out4,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 	vxor		$out4,$out4,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	vadduqm		$out7,$out5,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 	vxor		$out5,$out5,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 	vadduqm		$ivec,$out6,$two	# next counter value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	vxor		$out6,$out6,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 	vxor		$out7,$out7,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 	b		Loop_ctr32_enc8x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) Loop_ctr32_enc8x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 	vcipher 	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 	vcipher 	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 	vcipher 	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 	vcipher 	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	vcipher 	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 	vcipher 	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 	vcipher 	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 	vcipher 	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) Loop_ctr32_enc8x_middle:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 	vcipher 	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 	vcipher 	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 	vcipher 	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) 	vcipher 	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 	vcipher 	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) 	vcipher 	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 	vcipher 	$out6,$out6,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) 	vcipher 	$out7,$out7,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) 	bdnz		Loop_ctr32_enc8x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) 	subic		r11,$len,256		# $len-256, borrow $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	vcipher 	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 	vcipher 	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 	vcipher 	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	vcipher 	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 	vcipher 	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) 	vcipher 	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) 	vcipher 	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) 	vcipher 	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) 	subfe		r0,r0,r0		# borrow?-1:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) 	vcipher 	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 	vcipher 	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 	vcipher 	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 	vcipher 	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) 	vcipher 	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 	vcipher		$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 	vcipher		$out6,$out6,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 	vcipher		$out7,$out7,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	and		r0,r0,r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 	vcipher		$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 	vcipher		$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) 	vcipher		$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) 	vcipher		$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 	vcipher		$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) 	vcipher		$out5,$out5,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) 	vcipher		$out6,$out6,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 	vcipher		$out7,$out7,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) 	subic		$len,$len,129		# $len-=129
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 	vcipher		$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) 	addi		$len,$len,1		# $len-=128 really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) 	vcipher		$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) 	vcipher		$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) 	vcipher		$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 	vcipher		$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) 	vcipher		$out5,$out5,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 	vcipher		$out6,$out6,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) 	vcipher		$out7,$out7,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) 	vcipher		$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) 	 lvx_u		$in0,$x00,$inp		# load input
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) 	vcipher		$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) 	 lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) 	vcipher		$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) 	 lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) 	vcipher		$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) 	 lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) 	vcipher		$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) 	 lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) 	vcipher		$out5,$out5,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) 	 lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) 	vcipher		$out6,$out6,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) 	 lvx_u		$in6,$x60,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) 	vcipher		$out7,$out7,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) 	 lvx_u		$in7,$x70,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) 	 addi		$inp,$inp,0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) 	vcipher		$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) 	 le?vperm	$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) 	vcipher		$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) 	 le?vperm	$in1,$in1,$in1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) 	vcipher		$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) 	 le?vperm	$in2,$in2,$in2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) 	vcipher		$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) 	 le?vperm	$in3,$in3,$in3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) 	vcipher		$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) 	 le?vperm	$in4,$in4,$in4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641) 	vcipher		$out5,$out5,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) 	 le?vperm	$in5,$in5,$in5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) 	vcipher		$out6,$out6,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) 	 le?vperm	$in6,$in6,$in6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) 	vcipher		$out7,$out7,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) 	 le?vperm	$in7,$in7,$in7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) 	add		$inp,$inp,r0		# $inp is adjusted in such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) 						# way that at exit from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) 						# loop inX-in7 are loaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) 						# with last "words"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) 	subfe.		r0,r0,r0		# borrow?-1:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) 	vcipher		$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) 	 vxor		$in0,$in0,v31		# xor with last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) 	vcipher		$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) 	 vxor		$in1,$in1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) 	vcipher		$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) 	 vxor		$in2,$in2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) 	vcipher		$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) 	 vxor		$in3,$in3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) 	vcipher		$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) 	 vxor		$in4,$in4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) 	vcipher		$out5,$out5,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) 	 vxor		$in5,$in5,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) 	vcipher		$out6,$out6,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) 	 vxor		$in6,$in6,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) 	vcipher		$out7,$out7,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) 	 vxor		$in7,$in7,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) 	bne		Lctr32_enc8x_break	# did $len-129 borrow?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) 	vcipherlast	$in0,$out0,$in0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) 	vcipherlast	$in1,$out1,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) 	 vadduqm	$out1,$ivec,$one	# counter values ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) 	vcipherlast	$in2,$out2,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) 	 vadduqm	$out2,$ivec,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) 	 vxor		$out0,$ivec,$rndkey0	# ... xored with rndkey[0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) 	vcipherlast	$in3,$out3,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) 	 vadduqm	$out3,$out1,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) 	 vxor		$out1,$out1,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) 	vcipherlast	$in4,$out4,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) 	 vadduqm	$out4,$out2,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) 	 vxor		$out2,$out2,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) 	vcipherlast	$in5,$out5,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) 	 vadduqm	$out5,$out3,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) 	 vxor		$out3,$out3,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) 	vcipherlast	$in6,$out6,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) 	 vadduqm	$out6,$out4,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) 	 vxor		$out4,$out4,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) 	vcipherlast	$in7,$out7,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) 	 vadduqm	$out7,$out5,$two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) 	 vxor		$out5,$out5,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) 	le?vperm	$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) 	 vadduqm	$ivec,$out6,$two	# next counter value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) 	 vxor		$out6,$out6,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) 	le?vperm	$in1,$in1,$in1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) 	 vxor		$out7,$out7,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) 	 vcipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) 	stvx_u		$in0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) 	le?vperm	$in2,$in2,$in2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) 	 vcipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) 	stvx_u		$in1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) 	le?vperm	$in3,$in3,$in3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) 	 vcipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) 	stvx_u		$in2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) 	le?vperm	$in4,$in4,$in4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) 	 vcipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) 	stvx_u		$in3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) 	le?vperm	$in5,$in5,$in5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) 	 vcipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) 	stvx_u		$in4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) 	le?vperm	$in6,$in6,$in6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) 	 vcipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) 	stvx_u		$in5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) 	le?vperm	$in7,$in7,$in7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) 	 vcipher	$out6,$out6,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) 	stvx_u		$in6,$x60,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) 	 vcipher	$out7,$out7,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) 	stvx_u		$in7,$x70,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) 	addi		$out,$out,0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) 	b		Loop_ctr32_enc8x_middle
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) Lctr32_enc8x_break:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) 	cmpwi		$len,-0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) 	blt		Lctr32_enc8x_one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) 	beq		Lctr32_enc8x_two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) 	cmpwi		$len,-0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) 	blt		Lctr32_enc8x_three
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) 	beq		Lctr32_enc8x_four
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) 	cmpwi		$len,-0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) 	blt		Lctr32_enc8x_five
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) 	beq		Lctr32_enc8x_six
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) 	cmpwi		$len,0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) 	blt		Lctr32_enc8x_seven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) Lctr32_enc8x_eight:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) 	vcipherlast	$out0,$out0,$in0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) 	vcipherlast	$out1,$out1,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) 	vcipherlast	$out2,$out2,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) 	vcipherlast	$out3,$out3,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) 	vcipherlast	$out4,$out4,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) 	vcipherlast	$out5,$out5,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) 	vcipherlast	$out6,$out6,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) 	vcipherlast	$out7,$out7,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) 	stvx_u		$out5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) 	le?vperm	$out7,$out7,$out7,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) 	stvx_u		$out6,$x60,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) 	stvx_u		$out7,$x70,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) 	addi		$out,$out,0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) Lctr32_enc8x_seven:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) 	vcipherlast	$out0,$out0,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) 	vcipherlast	$out1,$out1,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) 	vcipherlast	$out2,$out2,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) 	vcipherlast	$out3,$out3,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) 	vcipherlast	$out4,$out4,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) 	vcipherlast	$out5,$out5,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) 	vcipherlast	$out6,$out6,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) 	le?vperm	$out6,$out6,$out6,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) 	stvx_u		$out5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) 	stvx_u		$out6,$x60,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) 	addi		$out,$out,0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) Lctr32_enc8x_six:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) 	vcipherlast	$out0,$out0,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) 	vcipherlast	$out1,$out1,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) 	vcipherlast	$out2,$out2,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) 	vcipherlast	$out3,$out3,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) 	vcipherlast	$out4,$out4,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) 	vcipherlast	$out5,$out5,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) 	le?vperm	$out5,$out5,$out5,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) 	stvx_u		$out5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) 	addi		$out,$out,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) Lctr32_enc8x_five:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) 	vcipherlast	$out0,$out0,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) 	vcipherlast	$out1,$out1,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) 	vcipherlast	$out2,$out2,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) 	vcipherlast	$out3,$out3,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) 	vcipherlast	$out4,$out4,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) 	le?vperm	$out4,$out4,$out4,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) 	addi		$out,$out,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) Lctr32_enc8x_four:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) 	vcipherlast	$out0,$out0,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) 	vcipherlast	$out1,$out1,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) 	vcipherlast	$out2,$out2,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) 	vcipherlast	$out3,$out3,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) 	le?vperm	$out3,$out3,$out3,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) 	addi		$out,$out,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) Lctr32_enc8x_three:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) 	vcipherlast	$out0,$out0,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) 	vcipherlast	$out1,$out1,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) 	vcipherlast	$out2,$out2,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) 	le?vperm	$out2,$out2,$out2,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) 	addi		$out,$out,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) Lctr32_enc8x_two:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) 	vcipherlast	$out0,$out0,$in6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) 	vcipherlast	$out1,$out1,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) 	le?vperm	$out1,$out1,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) 	stvx_u		$out0,$x00,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) 	addi		$out,$out,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) 	b		Lctr32_enc8x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) Lctr32_enc8x_one:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) 	vcipherlast	$out0,$out0,$in7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) 	le?vperm	$out0,$out0,$out0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) 	stvx_u		$out0,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) 	addi		$out,$out,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) Lctr32_enc8x_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) 	li		r10,`$FRAME+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) 	li		r11,`$FRAME+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) 	stvx		$inpperm,r10,$sp	# wipe copies of round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) 	stvx		$inpperm,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) 	stvx		$inpperm,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) 	stvx		$inpperm,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) 	stvx		$inpperm,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) 	lvx		v20,r10,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) 	lvx		v21,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) 	lvx		v22,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) 	lvx		v23,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) 	lvx		v24,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) 	lvx		v25,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) 	lvx		v26,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) 	lvx		v27,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) 	lvx		v28,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) 	lvx		v29,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) 	lvx		v30,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) 	lvx		v31,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) 	$POP		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) 	$POP		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) 	$POP		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) 	$POP		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) 	$POP		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) 	$POP		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) 	addi		$sp,$sp,`$FRAME+21*16+6*$SIZE_T`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) 	.byte		0,12,0x14,0,0x80,6,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) .size	.${prefix}_ctr32_encrypt_blocks,.-.${prefix}_ctr32_encrypt_blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) }}	}}}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) {{{	# XTS procedures						#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) # int aes_p8_xts_[en|de]crypt(const char *inp, char *out, size_t len,	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) #                             const AES_KEY *key1, const AES_KEY *key2,	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) #                             [const] unsigned char iv[16]);		#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) # If $key2 is NULL, then a "tweak chaining" mode is engaged, in which	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) # input tweak value is assumed to be encrypted already, and last tweak	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) # value, one suitable for consecutive call on same chunk of data, is	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) # written back to original buffer. In addition, in "tweak chaining"	#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) # mode only complete input blocks are processed.			#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) my ($inp,$out,$len,$key1,$key2,$ivp,$rounds,$idx) =	map("r$_",(3..10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) my ($rndkey0,$rndkey1,$inout) =				map("v$_",(0..2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) my ($output,$inptail,$inpperm,$leperm,$keyperm) =	map("v$_",(3..7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) my ($tweak,$seven,$eighty7,$tmp,$tweak1) =		map("v$_",(8..12));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) my $taillen = $key2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972)    ($inp,$idx) = ($idx,$inp);				# reassign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) .globl	.${prefix}_xts_encrypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) 	mr		$inp,r3				# reassign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) 	li		r3,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) 	bltlr-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) 	lis		r0,0xfff0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) 	mfspr		r12,256				# save vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) 	li		r11,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) 	vspltisb	$seven,0x07			# 0x070707..07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) 	le?lvsl		$leperm,r11,r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) 	le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) 	le?vxor		$leperm,$leperm,$seven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) 	li		$idx,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) 	lvx		$tweak,0,$ivp			# load [unaligned] iv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) 	lvsl		$inpperm,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) 	lvx		$inptail,$idx,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) 	vperm		$tweak,$tweak,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) 	neg		r11,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) 	lvsr		$inpperm,0,r11			# prepare for unaligned load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) 	lvx		$inout,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) 	addi		$inp,$inp,15			# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) 	${UCMP}i	$key2,0				# key2==NULL?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) 	beq		Lxts_enc_no_key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) 	?lvsl		$keyperm,0,$key2		# prepare for unaligned key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) 	lwz		$rounds,240($key2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) 	lvx		$rndkey0,0,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) 	lvx		$rndkey1,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) 	vxor		$tweak,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) 	lvx		$rndkey0,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) Ltweak_xts_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) 	vcipher		$tweak,$tweak,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) 	lvx		$rndkey1,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028) 	vcipher		$tweak,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) 	lvx		$rndkey0,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) 	bdnz		Ltweak_xts_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) 	vcipher		$tweak,$tweak,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) 	lvx		$rndkey1,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) 	vcipherlast	$tweak,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) 	li		$ivp,0				# don't chain the tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) 	b		Lxts_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) Lxts_enc_no_key2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) 	li		$idx,-16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) 	and		$len,$len,$idx			# in "tweak chaining"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) 							# mode only complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) 							# blocks are processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) Lxts_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) 	?lvsl		$keyperm,0,$key1		# prepare for unaligned key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) 	lwz		$rounds,240($key1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) 	vslb		$eighty7,$seven,$seven		# 0x808080..80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) 	vor		$eighty7,$eighty7,$seven	# 0x878787..87
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) 	vspltisb	$tmp,1				# 0x010101..01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) 	vsldoi		$eighty7,$eighty7,$tmp,15	# 0x870101..01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) 	${UCMP}i	$len,96
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) 	bge		_aesp8_xts_encrypt6x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) 	andi.		$taillen,$len,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) 	subic		r0,$len,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) 	subi		$taillen,$taillen,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) 	subfe		r0,r0,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) 	and		r0,r0,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) 	add		$inp,$inp,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) 	lvx		$rndkey0,0,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) 	vperm		$inout,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) 	vxor		$inout,$inout,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) 	vxor		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) 	b		Loop_xts_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) Loop_xts_enc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) 	vcipher		$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) 	vcipher		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) 	bdnz		Loop_xts_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) 	vcipher		$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) 	vxor		$rndkey0,$rndkey0,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) 	vcipherlast	$output,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) 	le?vperm	$tmp,$output,$output,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) 	be?nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) 	le?stvx_u	$tmp,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) 	be?stvx_u	$output,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) 	addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) 	subic.		$len,$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) 	beq		Lxts_enc_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) 	vmr		$inout,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) 	lvx		$rndkey0,0,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) 	subic		r0,$len,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) 	subfe		r0,r0,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) 	and		r0,r0,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) 	add		$inp,$inp,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) 	vsrab		$tmp,$tweak,$seven		# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) 	vperm		$inout,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133) 	vxor		$inout,$inout,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) 	vxor		$output,$output,$rndkey0	# just in case $len<16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) 	vxor		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) 	bge		Loop_xts_enc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) 	vxor		$output,$output,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) 	lvsr		$inpperm,0,$len			# $inpperm is no longer needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) 	vxor		$inptail,$inptail,$inptail	# $inptail is no longer needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146) 	vspltisb	$tmp,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) 	vperm		$inptail,$inptail,$tmp,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) 	vsel		$inout,$inout,$output,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) 	subi		r11,$out,17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) 	subi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) 	mtctr		$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) 	li		$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154) Loop_xts_enc_steal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) 	lbzu		r0,1(r11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) 	stb		r0,16(r11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) 	bdnz		Loop_xts_enc_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) 	b		Loop_xts_enc			# one more time...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) Lxts_enc_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) 	${UCMP}i	$ivp,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) 	beq		Lxts_enc_ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) 	vsrab		$tmp,$tweak,$seven		# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) 	le?vperm	$tweak,$tweak,$tweak,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) 	stvx_u		$tweak,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) Lxts_enc_ret:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) 	mtspr		256,r12				# restore vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) 	li		r3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) 	.byte		0,12,0x04,0,0x80,6,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) .size	.${prefix}_xts_encrypt,.-.${prefix}_xts_encrypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) .globl	.${prefix}_xts_decrypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) 	mr		$inp,r3				# reassign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) 	li		r3,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) 	bltlr-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) 	lis		r0,0xfff8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) 	mfspr		r12,256				# save vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) 	li		r11,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) 	andi.		r0,$len,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) 	neg		r0,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) 	andi.		r0,r0,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) 	sub		$len,$len,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) 	vspltisb	$seven,0x07			# 0x070707..07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) 	le?lvsl		$leperm,r11,r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202) 	le?vspltisb	$tmp,0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) 	le?vxor		$leperm,$leperm,$seven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) 	li		$idx,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) 	lvx		$tweak,0,$ivp			# load [unaligned] iv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) 	lvsl		$inpperm,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) 	lvx		$inptail,$idx,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) 	vperm		$tweak,$tweak,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) 	neg		r11,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) 	lvsr		$inpperm,0,r11			# prepare for unaligned load
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) 	lvx		$inout,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215) 	addi		$inp,$inp,15			# 15 is not typo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) 	le?vxor		$inpperm,$inpperm,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) 	${UCMP}i	$key2,0				# key2==NULL?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) 	beq		Lxts_dec_no_key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) 	?lvsl		$keyperm,0,$key2		# prepare for unaligned key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) 	lwz		$rounds,240($key2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) 	lvx		$rndkey0,0,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228) 	lvx		$rndkey1,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) 	vxor		$tweak,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) 	lvx		$rndkey0,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) Ltweak_xts_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) 	vcipher		$tweak,$tweak,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) 	lvx		$rndkey1,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) 	vcipher		$tweak,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243) 	lvx		$rndkey0,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) 	bdnz		Ltweak_xts_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) 	vcipher		$tweak,$tweak,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) 	lvx		$rndkey1,$idx,$key2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) 	vcipherlast	$tweak,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) 	li		$ivp,0				# don't chain the tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) 	b		Lxts_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) Lxts_dec_no_key2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) 	neg		$idx,$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) 	andi.		$idx,$idx,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) 	add		$len,$len,$idx			# in "tweak chaining"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) 							# mode only complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) 							# blocks are processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) Lxts_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) 	?lvsl		$keyperm,0,$key1		# prepare for unaligned key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) 	lwz		$rounds,240($key1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) 	srwi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) 	subi		$rounds,$rounds,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272) 	vslb		$eighty7,$seven,$seven		# 0x808080..80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) 	vor		$eighty7,$eighty7,$seven	# 0x878787..87
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) 	vspltisb	$tmp,1				# 0x010101..01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) 	vsldoi		$eighty7,$eighty7,$tmp,15	# 0x870101..01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) 	${UCMP}i	$len,96
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) 	bge		_aesp8_xts_decrypt6x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) 	lvx		$rndkey0,0,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) 	vperm		$inout,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) 	vxor		$inout,$inout,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) 	vxor		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) 	blt		Ltail_xts_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) 	be?b		Loop_xts_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) Loop_xts_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) 	vncipher	$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) 	vncipher	$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) 	bdnz		Loop_xts_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) 	vncipher	$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) 	vxor		$rndkey0,$rndkey0,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) 	vncipherlast	$output,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) 	le?vperm	$tmp,$output,$output,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) 	be?nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) 	le?stvx_u	$tmp,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) 	be?stvx_u	$output,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) 	addi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) 	subic.		$len,$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) 	beq		Lxts_dec_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) 	vmr		$inout,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) 	addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) 	lvx		$rndkey0,0,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) 	vsrab		$tmp,$tweak,$seven		# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) 	vperm		$inout,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) 	vxor		$inout,$inout,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) 	vxor		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) 	${UCMP}i	$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) 	bge		Loop_xts_dec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) Ltail_xts_dec:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) 	vsrab		$tmp,$tweak,$seven		# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350) 	vaddubm		$tweak1,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) 	vxor		$tweak1,$tweak1,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) 	subi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) 	add		$inp,$inp,$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) 	vxor		$inout,$inout,$tweak		# :-(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) 	vxor		$inout,$inout,$tweak1		# :-)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361) Loop_xts_dec_short:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) 	vncipher	$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) 	vncipher	$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) 	bdnz		Loop_xts_dec_short
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) 	?vperm		$rndkey1,$rndkey1,$rndkey0,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373) 	vncipher	$inout,$inout,$rndkey1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) 	li		$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) 	vxor		$rndkey0,$rndkey0,$tweak1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) 	vncipherlast	$output,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) 	le?vperm	$tmp,$output,$output,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) 	be?nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) 	le?stvx_u	$tmp,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383) 	be?stvx_u	$output,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) 	vmr		$inout,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) 	lvx		$inptail,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) 	#addi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) 	lvx		$rndkey0,0,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) 	lvx		$rndkey1,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) 	vperm		$inout,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) 	?vperm		$rndkey0,$rndkey0,$rndkey1,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) 	lvsr		$inpperm,0,$len			# $inpperm is no longer needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) 	vxor		$inptail,$inptail,$inptail	# $inptail is no longer needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) 	vspltisb	$tmp,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397) 	vperm		$inptail,$inptail,$tmp,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) 	vsel		$inout,$inout,$output,$inptail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) 	vxor		$rndkey0,$rndkey0,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) 	vxor		$inout,$inout,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) 	lvx		$rndkey0,$idx,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) 	addi		$idx,$idx,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) 	subi		r11,$out,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) 	mtctr		$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) 	li		$len,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) Loop_xts_dec_steal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) 	lbzu		r0,1(r11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) 	stb		r0,16(r11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) 	bdnz		Loop_xts_dec_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) 	b		Loop_xts_dec			# one more time...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416) Lxts_dec_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) 	${UCMP}i	$ivp,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) 	beq		Lxts_dec_ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) 	vsrab		$tmp,$tweak,$seven		# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) 	le?vperm	$tweak,$tweak,$tweak,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) 	stvx_u		$tweak,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) Lxts_dec_ret:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) 	mtspr		256,r12				# restore vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) 	li		r3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) 	.byte		0,12,0x04,0,0x80,6,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) .size	.${prefix}_xts_decrypt,.-.${prefix}_xts_decrypt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438) #########################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) {{	# Optimized XTS procedures					#
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) my $key_=$key2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) my ($x00,$x10,$x20,$x30,$x40,$x50,$x60,$x70)=map("r$_",(0,3,26..31));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442)     $x00=0 if ($flavour =~ /osx/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) my ($in0,  $in1,  $in2,  $in3,  $in4,  $in5 )=map("v$_",(0..5));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) my ($out0, $out1, $out2, $out3, $out4, $out5)=map("v$_",(7,12..16));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) my ($twk0, $twk1, $twk2, $twk3, $twk4, $twk5)=map("v$_",(17..22));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) my $rndkey0="v23";	# v24-v25 rotating buffer for first found keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) 			# v26-v31 last 6 round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) my ($keyperm)=($out0);	# aliases with "caller", redundant assignment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) my $taillen=$x70;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) $code.=<<___;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) _aesp8_xts_encrypt6x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) 	$STU		$sp,-`($FRAME+21*16+6*$SIZE_T)`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) 	mflr		r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) 	li		r7,`$FRAME+8*16+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) 	li		r3,`$FRAME+8*16+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) 	$PUSH		r11,`$FRAME+21*16+6*$SIZE_T+$LRSAVE`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) 	stvx		v20,r7,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) 	stvx		v21,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) 	stvx		v22,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) 	stvx		v23,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) 	stvx		v24,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) 	stvx		v25,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) 	stvx		v26,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) 	stvx		v27,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) 	stvx		v28,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) 	stvx		v29,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) 	stvx		v30,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) 	stvx		v31,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) 	li		r0,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482) 	stw		$vrsave,`$FRAME+21*16-4`($sp)	# save vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) 	li		$x10,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) 	$PUSH		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) 	li		$x20,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) 	$PUSH		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) 	li		$x30,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) 	$PUSH		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) 	li		$x40,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) 	$PUSH		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) 	li		$x50,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) 	$PUSH		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493) 	li		$x60,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) 	$PUSH		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) 	li		$x70,0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) 	subi		$rounds,$rounds,3	# -4 in total
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) 	lvx		$rndkey0,$x00,$key1	# load key schedule
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501) 	lvx		v30,$x10,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502) 	addi		$key1,$key1,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) 	lvx		v31,$x00,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) 	?vperm		$rndkey0,$rndkey0,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) 	addi		$key_,$sp,$FRAME+15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) Load_xts_enc_key:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) 	lvx		v30,$x10,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) 	addi		$key1,$key1,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) 	stvx		v24,$x00,$key_		# off-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) 	?vperm		v25,v31,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514) 	lvx		v31,$x00,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) 	stvx		v25,$x10,$key_		# off-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) 	bdnz		Load_xts_enc_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) 	lvx		v26,$x10,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) 	lvx		v27,$x20,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) 	stvx		v24,$x00,$key_		# off-load round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) 	?vperm		v25,v31,v26,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) 	lvx		v28,$x30,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) 	stvx		v25,$x10,$key_		# off-load round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) 	?vperm		v26,v26,v27,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) 	lvx		v29,$x40,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) 	?vperm		v27,v27,v28,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) 	lvx		v30,$x50,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) 	?vperm		v28,v28,v29,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) 	lvx		v31,$x60,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) 	?vperm		v29,v29,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) 	lvx		$twk5,$x70,$key1	# borrow $twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) 	?vperm		v30,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) 	lvx		v24,$x00,$key_		# pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) 	?vperm		v31,v31,$twk5,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538) 	lvx		v25,$x10,$key_		# pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) 	 vperm		$in0,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) 	 subi		$inp,$inp,31		# undo "caller"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) 	vxor		$twk0,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) 	 vxor		$out0,$in0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) 	 lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) 	vxor		$twk1,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) 	 le?vperm	$in1,$in1,$in1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) 	 vxor		$out1,$in1,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) 	 lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) 	 andi.		$taillen,$len,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) 	vxor		$twk2,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) 	 le?vperm	$in2,$in2,$in2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568) 	 vxor		$out2,$in2,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) 	 lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) 	 sub		$len,$len,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) 	vxor		$twk3,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2577) 	 le?vperm	$in3,$in3,$in3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2578) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2579) 	 vxor		$out3,$in3,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2580) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2581) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2582) 	 lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2583) 	 subi		$len,$len,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2584) 	vxor		$twk4,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2585) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2586) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2587) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2588) 	 le?vperm	$in4,$in4,$in4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2589) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2590) 	 vxor		$out4,$in4,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2591) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2593) 	 lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2594) 	 addi		$inp,$inp,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2595) 	vxor		$twk5,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2596) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2597) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2598) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2599) 	 le?vperm	$in5,$in5,$in5,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2600) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2601) 	 vxor		$out5,$in5,$twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2602) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2604) 	vxor		v31,v31,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2605) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2606) 	b		Loop_xts_enc6x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2608) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2609) Loop_xts_enc6x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2610) 	vcipher		$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2611) 	vcipher		$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2612) 	vcipher		$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2613) 	vcipher		$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2614) 	vcipher		$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2615) 	vcipher		$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2616) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2617) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2619) 	vcipher		$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2620) 	vcipher		$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2621) 	vcipher		$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2622) 	vcipher		$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2623) 	vcipher		$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2624) 	vcipher		$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2625) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2626) 	bdnz		Loop_xts_enc6x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2628) 	subic		$len,$len,96		# $len-=96
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2629) 	 vxor		$in0,$twk0,v31		# xor with last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2630) 	vcipher		$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2631) 	vcipher		$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2632) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2633) 	 vxor		$twk0,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2634) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2635) 	vcipher		$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2636) 	vcipher		$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2637) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2638) 	vcipher		$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2639) 	vcipher		$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2641) 	subfe.		r0,r0,r0		# borrow?-1:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2642) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2643) 	vcipher		$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2644) 	vcipher		$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2645) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2646) 	vcipher		$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2647) 	vcipher		$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2648) 	 vxor		$in1,$twk1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2649) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2650) 	 vxor		$twk1,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2651) 	vcipher		$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2652) 	vcipher		$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2654) 	and		r0,r0,$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2655) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2656) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2657) 	vcipher		$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2658) 	vcipher		$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2659) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2660) 	vcipher		$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2661) 	vcipher		$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2662) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2663) 	vcipher		$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2664) 	vcipher		$out5,$out5,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2666) 	add		$inp,$inp,r0		# $inp is adjusted in such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2667) 						# way that at exit from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2668) 						# loop inX-in5 are loaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2669) 						# with last "words"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2670) 	 vxor		$in2,$twk2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2671) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2672) 	 vxor		$twk2,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2673) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2674) 	vcipher		$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2675) 	vcipher		$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2676) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2677) 	vcipher		$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2678) 	vcipher		$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2679) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2680) 	vcipher		$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2681) 	vcipher		$out5,$out5,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2683) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2684) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2685) 	vcipher		$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2686) 	vcipher		$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2687) 	 vxor		$in3,$twk3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2688) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2689) 	 vxor		$twk3,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2690) 	vcipher		$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2691) 	vcipher		$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2692) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2693) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2694) 	vcipher		$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2695) 	vcipher		$out5,$out5,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2696) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2697) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2699) 	vcipher		$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2700) 	vcipher		$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2701) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2702) 	vcipher		$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2703) 	vcipher		$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2704) 	 vxor		$in4,$twk4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2705) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2706) 	 vxor		$twk4,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2707) 	vcipher		$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2708) 	vcipher		$out5,$out5,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2709) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2710) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2711) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2713) 	vcipher		$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2714) 	vcipher		$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2715) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2716) 	vcipher		$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2717) 	vcipher		$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2718) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2719) 	vcipher		$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2720) 	vcipher		$out5,$out5,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2721) 	 vxor		$in5,$twk5,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2722) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2723) 	 vxor		$twk5,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2724) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2725) 	vcipherlast	$out0,$out0,$in0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2726) 	 lvx_u		$in0,$x00,$inp		# load next input block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2727) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2728) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2729) 	vcipherlast	$out1,$out1,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2730) 	 lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2731) 	vcipherlast	$out2,$out2,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2732) 	 le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2733) 	 lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2734) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2735) 	vcipherlast	$out3,$out3,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2736) 	 le?vperm	$in1,$in1,$in1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2737) 	 lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2738) 	vcipherlast	$out4,$out4,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2739) 	 le?vperm	$in2,$in2,$in2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2740) 	 lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2741) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2742) 	vcipherlast	$tmp,$out5,$in5		# last block might be needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2743) 						# in stealing mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2744) 	 le?vperm	$in3,$in3,$in3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2745) 	 lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2746) 	 addi		$inp,$inp,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2747) 	 le?vperm	$in4,$in4,$in4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2748) 	 le?vperm	$in5,$in5,$in5,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2750) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2751) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2752) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2753) 	 vxor		$out0,$in0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2754) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2755) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2756) 	 vxor		$out1,$in1,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2757) 	le?vperm	$out3,$out3,$out3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2758) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2759) 	 vxor		$out2,$in2,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2760) 	le?vperm	$out4,$out4,$out4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2761) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2762) 	 vxor		$out3,$in3,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2763) 	le?vperm	$out5,$tmp,$tmp,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2764) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2765) 	 vxor		$out4,$in4,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2766) 	le?stvx_u	$out5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2767) 	be?stvx_u	$tmp, $x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2768) 	 vxor		$out5,$in5,$twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2769) 	addi		$out,$out,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2771) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2772) 	beq		Loop_xts_enc6x		# did $len-=96 borrow?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2774) 	addic.		$len,$len,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2775) 	beq		Lxts_enc6x_zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2776) 	cmpwi		$len,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2777) 	blt		Lxts_enc6x_one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2778) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2779) 	beq		Lxts_enc6x_two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2780) 	cmpwi		$len,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2781) 	blt		Lxts_enc6x_three
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2782) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2783) 	beq		Lxts_enc6x_four
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2785) Lxts_enc6x_five:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2786) 	vxor		$out0,$in1,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2787) 	vxor		$out1,$in2,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2788) 	vxor		$out2,$in3,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2789) 	vxor		$out3,$in4,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2790) 	vxor		$out4,$in5,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2791) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2792) 	bl		_aesp8_xts_enc5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2794) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2795) 	vmr		$twk0,$twk5		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2796) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2797) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2798) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2799) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2800) 	le?vperm	$out3,$out3,$out3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2801) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2802) 	vxor		$tmp,$out4,$twk5	# last block prep for stealing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2803) 	le?vperm	$out4,$out4,$out4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2804) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2805) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2806) 	addi		$out,$out,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2807) 	bne		Lxts_enc6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2808) 	b		Lxts_enc6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2810) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2811) Lxts_enc6x_four:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2812) 	vxor		$out0,$in2,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2813) 	vxor		$out1,$in3,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2814) 	vxor		$out2,$in4,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2815) 	vxor		$out3,$in5,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2816) 	vxor		$out4,$out4,$out4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2817) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2818) 	bl		_aesp8_xts_enc5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2819) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2820) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2821) 	vmr		$twk0,$twk4		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2822) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2823) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2824) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2825) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2826) 	vxor		$tmp,$out3,$twk4	# last block prep for stealing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2827) 	le?vperm	$out3,$out3,$out3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2828) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2829) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2830) 	addi		$out,$out,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2831) 	bne		Lxts_enc6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2832) 	b		Lxts_enc6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2833) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2834) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2835) Lxts_enc6x_three:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2836) 	vxor		$out0,$in3,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2837) 	vxor		$out1,$in4,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2838) 	vxor		$out2,$in5,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2839) 	vxor		$out3,$out3,$out3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2840) 	vxor		$out4,$out4,$out4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2842) 	bl		_aesp8_xts_enc5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2844) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2845) 	vmr		$twk0,$twk3		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2846) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2847) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2848) 	vxor		$tmp,$out2,$twk3	# last block prep for stealing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2849) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2850) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2851) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2852) 	addi		$out,$out,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2853) 	bne		Lxts_enc6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2854) 	b		Lxts_enc6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2856) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2857) Lxts_enc6x_two:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2858) 	vxor		$out0,$in4,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2859) 	vxor		$out1,$in5,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2860) 	vxor		$out2,$out2,$out2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2861) 	vxor		$out3,$out3,$out3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2862) 	vxor		$out4,$out4,$out4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2864) 	bl		_aesp8_xts_enc5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2865) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2866) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2867) 	vmr		$twk0,$twk2		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2868) 	vxor		$tmp,$out1,$twk2	# last block prep for stealing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2869) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2870) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2871) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2872) 	addi		$out,$out,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2873) 	bne		Lxts_enc6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2874) 	b		Lxts_enc6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2876) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2877) Lxts_enc6x_one:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2878) 	vxor		$out0,$in5,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2879) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2880) Loop_xts_enc1x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2881) 	vcipher		$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2882) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2883) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2884) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2885) 	vcipher		$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2886) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2887) 	bdnz		Loop_xts_enc1x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2889) 	add		$inp,$inp,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2890) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2891) 	vcipher		$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2893) 	subi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2894) 	vcipher		$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2895) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2896) 	lvsr		$inpperm,0,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2897) 	vcipher		$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2898) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2899) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2900) 	vcipher		$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2901) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2902) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2903) 	vcipher		$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2904) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2906) 	vcipher		$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2907) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2908) 	 vxor		$twk0,$twk0,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2910) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2911) 	vcipher		$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2913) 	vperm		$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2914) 	vcipherlast	$out0,$out0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2916) 	vmr		$twk0,$twk1		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2917) 	vxor		$tmp,$out0,$twk1	# last block prep for stealing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2918) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2919) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2920) 	addi		$out,$out,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2921) 	bne		Lxts_enc6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2922) 	b		Lxts_enc6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2923) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2924) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2925) Lxts_enc6x_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2926) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2927) 	beq		Lxts_enc6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2929) 	add		$inp,$inp,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2930) 	subi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2931) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2932) 	lvsr		$inpperm,0,$taillen	# $in5 is no more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2933) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2934) 	vperm		$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2935) 	vxor		$tmp,$tmp,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2936) Lxts_enc6x_steal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2937) 	vxor		$in0,$in0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2938) 	vxor		$out0,$out0,$out0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2939) 	vspltisb	$out1,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2940) 	vperm		$out0,$out0,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2941) 	vsel		$out0,$in0,$tmp,$out0	# $tmp is last block, remember?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2942) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2943) 	subi		r30,$out,17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2944) 	subi		$out,$out,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2945) 	mtctr		$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2946) Loop_xts_enc6x_steal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2947) 	lbzu		r0,1(r30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2948) 	stb		r0,16(r30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2949) 	bdnz		Loop_xts_enc6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2950) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2951) 	li		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2952) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2953) 	b		Loop_xts_enc1x		# one more time...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2954) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2955) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2956) Lxts_enc6x_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2957) 	${UCMP}i	$ivp,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2958) 	beq		Lxts_enc6x_ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2960) 	vxor		$tweak,$twk0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2961) 	le?vperm	$tweak,$tweak,$tweak,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2962) 	stvx_u		$tweak,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2963) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2964) Lxts_enc6x_ret:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2965) 	mtlr		r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2966) 	li		r10,`$FRAME+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2967) 	li		r11,`$FRAME+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2968) 	stvx		$seven,r10,$sp		# wipe copies of round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2969) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2970) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2971) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2972) 	stvx		$seven,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2973) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2974) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2975) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2976) 	stvx		$seven,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2977) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2978) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2979) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2980) 	stvx		$seven,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2981) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2982) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2983) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2984) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2985) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2986) 	lvx		v20,r10,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2987) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2988) 	lvx		v21,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2989) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2990) 	lvx		v22,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2991) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2992) 	lvx		v23,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2993) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2994) 	lvx		v24,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2995) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2996) 	lvx		v25,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2997) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2998) 	lvx		v26,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2999) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3000) 	lvx		v27,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3001) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3002) 	lvx		v28,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3003) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3004) 	lvx		v29,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3005) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3006) 	lvx		v30,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3007) 	lvx		v31,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3008) 	$POP		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3009) 	$POP		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3010) 	$POP		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3011) 	$POP		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3012) 	$POP		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3013) 	$POP		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3014) 	addi		$sp,$sp,`$FRAME+21*16+6*$SIZE_T`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3015) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3016) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3017) 	.byte		0,12,0x04,1,0x80,6,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3018) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3020) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3021) _aesp8_xts_enc5x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3022) 	vcipher		$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3023) 	vcipher		$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3024) 	vcipher		$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3025) 	vcipher		$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3026) 	vcipher		$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3027) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3028) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3029) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3030) 	vcipher		$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3031) 	vcipher		$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3032) 	vcipher		$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3033) 	vcipher		$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3034) 	vcipher		$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3035) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3036) 	bdnz		_aesp8_xts_enc5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3037) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3038) 	add		$inp,$inp,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3039) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3040) 	vcipher		$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3041) 	vcipher		$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3042) 	vcipher		$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3043) 	vcipher		$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3044) 	vcipher		$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3045) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3046) 	subi		$inp,$inp,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3047) 	vcipher		$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3048) 	vcipher		$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3049) 	vcipher		$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3050) 	vcipher		$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3051) 	vcipher		$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3052) 	 vxor		$twk0,$twk0,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3053) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3054) 	vcipher		$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3055) 	lvsr		$inpperm,r0,$taillen	# $in5 is no more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3056) 	vcipher		$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3057) 	vcipher		$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3058) 	vcipher		$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3059) 	vcipher		$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3060) 	 vxor		$in1,$twk1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3061) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3062) 	vcipher		$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3063) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3064) 	vcipher		$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3065) 	vcipher		$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3066) 	vcipher		$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3067) 	vcipher		$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3068) 	 vxor		$in2,$twk2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3069) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3070) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3071) 	vcipher		$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3072) 	vcipher		$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3073) 	vcipher		$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3074) 	vcipher		$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3075) 	vcipher		$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3076) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3077) 	 vxor		$in3,$twk3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3078) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3079) 	vcipher		$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3080) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3081) 	vcipher		$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3082) 	vcipher		$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3083) 	vcipher		$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3084) 	vcipher		$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3085) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3086) 	 vxor		$in4,$twk4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3087) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3088) 	vcipher		$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3089) 	vperm		$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3090) 	vcipher		$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3091) 	vcipher		$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3092) 	vcipher		$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3093) 	vcipher		$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3094) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3095) 	vcipherlast	$out0,$out0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3096) 	vcipherlast	$out1,$out1,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3097) 	vcipherlast	$out2,$out2,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3098) 	vcipherlast	$out3,$out3,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3099) 	vcipherlast	$out4,$out4,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3100) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3101)         .long   	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3102)         .byte   	0,12,0x14,0,0,0,0,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3104) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3105) _aesp8_xts_decrypt6x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3106) 	$STU		$sp,-`($FRAME+21*16+6*$SIZE_T)`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3107) 	mflr		r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3108) 	li		r7,`$FRAME+8*16+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3109) 	li		r3,`$FRAME+8*16+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3110) 	$PUSH		r11,`$FRAME+21*16+6*$SIZE_T+$LRSAVE`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3111) 	stvx		v20,r7,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3112) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3113) 	stvx		v21,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3114) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3115) 	stvx		v22,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3116) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3117) 	stvx		v23,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3118) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3119) 	stvx		v24,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3120) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3121) 	stvx		v25,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3122) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3123) 	stvx		v26,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3124) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3125) 	stvx		v27,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3126) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3127) 	stvx		v28,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3128) 	addi		r7,r7,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3129) 	stvx		v29,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3130) 	addi		r3,r3,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3131) 	stvx		v30,r7,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3132) 	stvx		v31,r3,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3133) 	li		r0,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3134) 	stw		$vrsave,`$FRAME+21*16-4`($sp)	# save vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3135) 	li		$x10,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3136) 	$PUSH		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3137) 	li		$x20,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3138) 	$PUSH		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3139) 	li		$x30,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3140) 	$PUSH		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3141) 	li		$x40,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3142) 	$PUSH		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3143) 	li		$x50,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3144) 	$PUSH		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3145) 	li		$x60,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3146) 	$PUSH		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3147) 	li		$x70,0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3148) 	mtspr		256,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3150) 	subi		$rounds,$rounds,3	# -4 in total
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3152) 	lvx		$rndkey0,$x00,$key1	# load key schedule
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3153) 	lvx		v30,$x10,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3154) 	addi		$key1,$key1,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3155) 	lvx		v31,$x00,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3156) 	?vperm		$rndkey0,$rndkey0,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3157) 	addi		$key_,$sp,$FRAME+15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3158) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3160) Load_xts_dec_key:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3161) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3162) 	lvx		v30,$x10,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3163) 	addi		$key1,$key1,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3164) 	stvx		v24,$x00,$key_		# off-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3165) 	?vperm		v25,v31,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3166) 	lvx		v31,$x00,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3167) 	stvx		v25,$x10,$key_		# off-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3168) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3169) 	bdnz		Load_xts_dec_key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3171) 	lvx		v26,$x10,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3172) 	?vperm		v24,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3173) 	lvx		v27,$x20,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3174) 	stvx		v24,$x00,$key_		# off-load round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3175) 	?vperm		v25,v31,v26,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3176) 	lvx		v28,$x30,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3177) 	stvx		v25,$x10,$key_		# off-load round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3178) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3179) 	?vperm		v26,v26,v27,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3180) 	lvx		v29,$x40,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3181) 	?vperm		v27,v27,v28,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3182) 	lvx		v30,$x50,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3183) 	?vperm		v28,v28,v29,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3184) 	lvx		v31,$x60,$key1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3185) 	?vperm		v29,v29,v30,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3186) 	lvx		$twk5,$x70,$key1	# borrow $twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3187) 	?vperm		v30,v30,v31,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3188) 	lvx		v24,$x00,$key_		# pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3189) 	?vperm		v31,v31,$twk5,$keyperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3190) 	lvx		v25,$x10,$key_		# pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3192) 	 vperm		$in0,$inout,$inptail,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3193) 	 subi		$inp,$inp,31		# undo "caller"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3194) 	vxor		$twk0,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3195) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3196) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3197) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3198) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3199) 	 vxor		$out0,$in0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3200) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3202) 	 lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3203) 	vxor		$twk1,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3204) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3205) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3206) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3207) 	 le?vperm	$in1,$in1,$in1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3208) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3209) 	 vxor		$out1,$in1,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3210) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3212) 	 lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3213) 	 andi.		$taillen,$len,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3214) 	vxor		$twk2,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3215) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3216) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3217) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3218) 	 le?vperm	$in2,$in2,$in2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3219) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3220) 	 vxor		$out2,$in2,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3221) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3223) 	 lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3224) 	 sub		$len,$len,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3225) 	vxor		$twk3,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3226) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3227) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3228) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3229) 	 le?vperm	$in3,$in3,$in3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3230) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3231) 	 vxor		$out3,$in3,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3232) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3234) 	 lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3235) 	 subi		$len,$len,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3236) 	vxor		$twk4,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3237) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3238) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3239) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3240) 	 le?vperm	$in4,$in4,$in4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3241) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3242) 	 vxor		$out4,$in4,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3243) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3245) 	 lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3246) 	 addi		$inp,$inp,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3247) 	vxor		$twk5,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3248) 	vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3249) 	vaddubm		$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3250) 	vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3251) 	 le?vperm	$in5,$in5,$in5,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3252) 	vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3253) 	 vxor		$out5,$in5,$twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3254) 	vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3256) 	vxor		v31,v31,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3257) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3258) 	b		Loop_xts_dec6x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3260) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3261) Loop_xts_dec6x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3262) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3263) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3264) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3265) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3266) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3267) 	vncipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3268) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3269) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3271) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3272) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3273) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3274) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3275) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3276) 	vncipher	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3277) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3278) 	bdnz		Loop_xts_dec6x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3280) 	subic		$len,$len,96		# $len-=96
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3281) 	 vxor		$in0,$twk0,v31		# xor with last round key
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3282) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3283) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3284) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3285) 	 vxor		$twk0,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3286) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3287) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3288) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3289) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3290) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3291) 	vncipher	$out5,$out5,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3293) 	subfe.		r0,r0,r0		# borrow?-1:0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3294) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3295) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3296) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3297) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3298) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3299) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3300) 	 vxor		$in1,$twk1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3301) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3302) 	 vxor		$twk1,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3303) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3304) 	vncipher	$out5,$out5,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3306) 	and		r0,r0,$len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3307) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3308) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3309) 	vncipher	$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3310) 	vncipher	$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3311) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3312) 	vncipher	$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3313) 	vncipher	$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3314) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3315) 	vncipher	$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3316) 	vncipher	$out5,$out5,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3318) 	add		$inp,$inp,r0		# $inp is adjusted in such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3319) 						# way that at exit from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3320) 						# loop inX-in5 are loaded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3321) 						# with last "words"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3322) 	 vxor		$in2,$twk2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3323) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3324) 	 vxor		$twk2,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3325) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3326) 	vncipher	$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3327) 	vncipher	$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3328) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3329) 	vncipher	$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3330) 	vncipher	$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3331) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3332) 	vncipher	$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3333) 	vncipher	$out5,$out5,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3335) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3336) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3337) 	vncipher	$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3338) 	vncipher	$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3339) 	 vxor		$in3,$twk3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3340) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3341) 	 vxor		$twk3,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3342) 	vncipher	$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3343) 	vncipher	$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3344) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3345) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3346) 	vncipher	$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3347) 	vncipher	$out5,$out5,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3348) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3349) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3351) 	vncipher	$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3352) 	vncipher	$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3353) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3354) 	vncipher	$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3355) 	vncipher	$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3356) 	 vxor		$in4,$twk4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3357) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3358) 	 vxor		$twk4,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3359) 	vncipher	$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3360) 	vncipher	$out5,$out5,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3361) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3362) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3363) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3365) 	vncipher	$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3366) 	vncipher	$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3367) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3368) 	vncipher	$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3369) 	vncipher	$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3370) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3371) 	vncipher	$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3372) 	vncipher	$out5,$out5,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3373) 	 vxor		$in5,$twk5,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3374) 	 vsrab		$tmp,$tweak,$seven	# next tweak value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3375) 	 vxor		$twk5,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3377) 	vncipherlast	$out0,$out0,$in0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3378) 	 lvx_u		$in0,$x00,$inp		# load next input block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3379) 	 vaddubm	$tweak,$tweak,$tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3380) 	 vsldoi		$tmp,$tmp,$tmp,15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3381) 	vncipherlast	$out1,$out1,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3382) 	 lvx_u		$in1,$x10,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3383) 	vncipherlast	$out2,$out2,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3384) 	 le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3385) 	 lvx_u		$in2,$x20,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3386) 	 vand		$tmp,$tmp,$eighty7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3387) 	vncipherlast	$out3,$out3,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3388) 	 le?vperm	$in1,$in1,$in1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3389) 	 lvx_u		$in3,$x30,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3390) 	vncipherlast	$out4,$out4,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3391) 	 le?vperm	$in2,$in2,$in2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3392) 	 lvx_u		$in4,$x40,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3393) 	 vxor		$tweak,$tweak,$tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3394) 	vncipherlast	$out5,$out5,$in5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3395) 	 le?vperm	$in3,$in3,$in3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3396) 	 lvx_u		$in5,$x50,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3397) 	 addi		$inp,$inp,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3398) 	 le?vperm	$in4,$in4,$in4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3399) 	 le?vperm	$in5,$in5,$in5,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3401) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3402) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3403) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3404) 	 vxor		$out0,$in0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3405) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3406) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3407) 	 vxor		$out1,$in1,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3408) 	le?vperm	$out3,$out3,$out3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3409) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3410) 	 vxor		$out2,$in2,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3411) 	le?vperm	$out4,$out4,$out4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3412) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3413) 	 vxor		$out3,$in3,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3414) 	le?vperm	$out5,$out5,$out5,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3415) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3416) 	 vxor		$out4,$in4,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3417) 	stvx_u		$out5,$x50,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3418) 	 vxor		$out5,$in5,$twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3419) 	addi		$out,$out,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3421) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3422) 	beq		Loop_xts_dec6x		# did $len-=96 borrow?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3424) 	addic.		$len,$len,0x60
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3425) 	beq		Lxts_dec6x_zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3426) 	cmpwi		$len,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3427) 	blt		Lxts_dec6x_one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3428) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3429) 	beq		Lxts_dec6x_two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3430) 	cmpwi		$len,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3431) 	blt		Lxts_dec6x_three
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3432) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3433) 	beq		Lxts_dec6x_four
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3435) Lxts_dec6x_five:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3436) 	vxor		$out0,$in1,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3437) 	vxor		$out1,$in2,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3438) 	vxor		$out2,$in3,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3439) 	vxor		$out3,$in4,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3440) 	vxor		$out4,$in5,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3442) 	bl		_aesp8_xts_dec5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3444) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3445) 	vmr		$twk0,$twk5		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3446) 	vxor		$twk1,$tweak,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3447) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3448) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3449) 	vxor		$out0,$in0,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3450) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3451) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3452) 	le?vperm	$out3,$out3,$out3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3453) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3454) 	le?vperm	$out4,$out4,$out4,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3455) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3456) 	stvx_u		$out4,$x40,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3457) 	addi		$out,$out,0x50
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3458) 	bne		Lxts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3459) 	b		Lxts_dec6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3461) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3462) Lxts_dec6x_four:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3463) 	vxor		$out0,$in2,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3464) 	vxor		$out1,$in3,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3465) 	vxor		$out2,$in4,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3466) 	vxor		$out3,$in5,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3467) 	vxor		$out4,$out4,$out4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3469) 	bl		_aesp8_xts_dec5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3471) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3472) 	vmr		$twk0,$twk4		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3473) 	vmr		$twk1,$twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3474) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3475) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3476) 	vxor		$out0,$in0,$twk5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3477) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3478) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3479) 	le?vperm	$out3,$out3,$out3,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3480) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3481) 	stvx_u		$out3,$x30,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3482) 	addi		$out,$out,0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3483) 	bne		Lxts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3484) 	b		Lxts_dec6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3485) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3486) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3487) Lxts_dec6x_three:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3488) 	vxor		$out0,$in3,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3489) 	vxor		$out1,$in4,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3490) 	vxor		$out2,$in5,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3491) 	vxor		$out3,$out3,$out3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3492) 	vxor		$out4,$out4,$out4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3494) 	bl		_aesp8_xts_dec5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3496) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3497) 	vmr		$twk0,$twk3		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3498) 	vmr		$twk1,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3499) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3500) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3501) 	vxor		$out0,$in0,$twk4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3502) 	le?vperm	$out2,$out2,$out2,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3503) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3504) 	stvx_u		$out2,$x20,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3505) 	addi		$out,$out,0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3506) 	bne		Lxts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3507) 	b		Lxts_dec6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3508) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3509) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3510) Lxts_dec6x_two:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3511) 	vxor		$out0,$in4,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3512) 	vxor		$out1,$in5,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3513) 	vxor		$out2,$out2,$out2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3514) 	vxor		$out3,$out3,$out3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3515) 	vxor		$out4,$out4,$out4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3516) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3517) 	bl		_aesp8_xts_dec5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3519) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3520) 	vmr		$twk0,$twk2		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3521) 	vmr		$twk1,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3522) 	le?vperm	$out1,$out1,$out1,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3523) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3524) 	vxor		$out0,$in0,$twk3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3525) 	stvx_u		$out1,$x10,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3526) 	addi		$out,$out,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3527) 	bne		Lxts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3528) 	b		Lxts_dec6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3530) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3531) Lxts_dec6x_one:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3532) 	vxor		$out0,$in5,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3533) 	nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3534) Loop_xts_dec1x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3535) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3536) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3537) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3539) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3540) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3541) 	bdnz		Loop_xts_dec1x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3543) 	subi		r0,$taillen,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3544) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3546) 	andi.		r0,r0,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3547) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3548) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3550) 	sub		$inp,$inp,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3551) 	vncipher	$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3553) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3554) 	vncipher	$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3556) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3557) 	vncipher	$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3558) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3560) 	vncipher	$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3561) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3562) 	 vxor		$twk0,$twk0,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3564) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3565) 	vncipher	$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3567) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3568) 	vncipherlast	$out0,$out0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3570) 	vmr		$twk0,$twk1		# unused tweak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3571) 	vmr		$twk1,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3572) 	le?vperm	$out0,$out0,$out0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3573) 	stvx_u		$out0,$x00,$out		# store output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3574) 	addi		$out,$out,0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3575) 	vxor		$out0,$in0,$twk2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3576) 	bne		Lxts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3577) 	b		Lxts_dec6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3579) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3580) Lxts_dec6x_zero:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3581) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3582) 	beq		Lxts_dec6x_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3583) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3584) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3585) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3586) 	vxor		$out0,$in0,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3587) Lxts_dec6x_steal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3588) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3589) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3590) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3592) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3593) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3594) 	bdnz		Lxts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3595) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3596) 	add		$inp,$inp,$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3597) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3599) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3600) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3601) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3602) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3603) 	vncipher	$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3605) 	lvsr		$inpperm,0,$taillen	# $in5 is no more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3606) 	vncipher	$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3607) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3608) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3609) 	vncipher	$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3610) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3612) 	vncipher	$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3613) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3614) 	 vxor		$twk1,$twk1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3616) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3617) 	vncipher	$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3618) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3619) 	vperm		$in0,$in0,$in0,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3620) 	vncipherlast	$tmp,$out0,$twk1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3622) 	le?vperm	$out0,$tmp,$tmp,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3623) 	le?stvx_u	$out0,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3624) 	be?stvx_u	$tmp,0,$out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3625) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3626) 	vxor		$out0,$out0,$out0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3627) 	vspltisb	$out1,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3628) 	vperm		$out0,$out0,$out1,$inpperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3629) 	vsel		$out0,$in0,$tmp,$out0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3630) 	vxor		$out0,$out0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3632) 	subi		r30,$out,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3633) 	mtctr		$taillen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3634) Loop_xts_dec6x_steal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3635) 	lbzu		r0,1(r30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3636) 	stb		r0,16(r30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3637) 	bdnz		Loop_xts_dec6x_steal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3639) 	li		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3640) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3641) 	b		Loop_xts_dec1x		# one more time...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3642) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3643) .align	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3644) Lxts_dec6x_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3645) 	${UCMP}i	$ivp,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3646) 	beq		Lxts_dec6x_ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3648) 	vxor		$tweak,$twk0,$rndkey0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3649) 	le?vperm	$tweak,$tweak,$tweak,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3650) 	stvx_u		$tweak,0,$ivp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3652) Lxts_dec6x_ret:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3653) 	mtlr		r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3654) 	li		r10,`$FRAME+15`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3655) 	li		r11,`$FRAME+31`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3656) 	stvx		$seven,r10,$sp		# wipe copies of round keys
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3657) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3658) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3659) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3660) 	stvx		$seven,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3661) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3662) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3663) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3664) 	stvx		$seven,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3665) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3666) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3667) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3668) 	stvx		$seven,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3669) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3670) 	stvx		$seven,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3671) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3672) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3673) 	mtspr		256,$vrsave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3674) 	lvx		v20,r10,$sp		# ABI says so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3675) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3676) 	lvx		v21,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3677) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3678) 	lvx		v22,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3679) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3680) 	lvx		v23,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3681) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3682) 	lvx		v24,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3683) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3684) 	lvx		v25,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3685) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3686) 	lvx		v26,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3687) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3688) 	lvx		v27,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3689) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3690) 	lvx		v28,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3691) 	addi		r10,r10,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3692) 	lvx		v29,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3693) 	addi		r11,r11,32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3694) 	lvx		v30,r10,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3695) 	lvx		v31,r11,$sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3696) 	$POP		r26,`$FRAME+21*16+0*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3697) 	$POP		r27,`$FRAME+21*16+1*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3698) 	$POP		r28,`$FRAME+21*16+2*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3699) 	$POP		r29,`$FRAME+21*16+3*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3700) 	$POP		r30,`$FRAME+21*16+4*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3701) 	$POP		r31,`$FRAME+21*16+5*$SIZE_T`($sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3702) 	addi		$sp,$sp,`$FRAME+21*16+6*$SIZE_T`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3703) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3704) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3705) 	.byte		0,12,0x04,1,0x80,6,6,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3706) 	.long		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3708) .align	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3709) _aesp8_xts_dec5x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3710) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3711) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3712) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3713) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3714) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3715) 	lvx		v24,$x20,$key_		# round[3]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3716) 	addi		$key_,$key_,0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3717) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3718) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3719) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3720) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3721) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3722) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3723) 	lvx		v25,$x10,$key_		# round[4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3724) 	bdnz		_aesp8_xts_dec5x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3726) 	subi		r0,$taillen,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3727) 	vncipher	$out0,$out0,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3728) 	vncipher	$out1,$out1,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3729) 	vncipher	$out2,$out2,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3730) 	vncipher	$out3,$out3,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3731) 	vncipher	$out4,$out4,v24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3732) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3733) 	andi.		r0,r0,16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3734) 	cmpwi		$taillen,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3735) 	vncipher	$out0,$out0,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3736) 	vncipher	$out1,$out1,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3737) 	vncipher	$out2,$out2,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3738) 	vncipher	$out3,$out3,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3739) 	vncipher	$out4,$out4,v25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3740) 	 vxor		$twk0,$twk0,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3741) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3742) 	sub		$inp,$inp,r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3743) 	vncipher	$out0,$out0,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3744) 	vncipher	$out1,$out1,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3745) 	vncipher	$out2,$out2,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3746) 	vncipher	$out3,$out3,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3747) 	vncipher	$out4,$out4,v26
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3748) 	 vxor		$in1,$twk1,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3750) 	vncipher	$out0,$out0,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3751) 	lvx_u		$in0,0,$inp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3752) 	vncipher	$out1,$out1,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3753) 	vncipher	$out2,$out2,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3754) 	vncipher	$out3,$out3,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3755) 	vncipher	$out4,$out4,v27
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3756) 	 vxor		$in2,$twk2,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3758) 	addi		$key_,$sp,$FRAME+15	# rewind $key_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3759) 	vncipher	$out0,$out0,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3760) 	vncipher	$out1,$out1,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3761) 	vncipher	$out2,$out2,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3762) 	vncipher	$out3,$out3,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3763) 	vncipher	$out4,$out4,v28
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3764) 	lvx		v24,$x00,$key_		# re-pre-load round[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3765) 	 vxor		$in3,$twk3,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3766) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3767) 	vncipher	$out0,$out0,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3768) 	le?vperm	$in0,$in0,$in0,$leperm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3769) 	vncipher	$out1,$out1,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3770) 	vncipher	$out2,$out2,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3771) 	vncipher	$out3,$out3,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3772) 	vncipher	$out4,$out4,v29
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3773) 	lvx		v25,$x10,$key_		# re-pre-load round[2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3774) 	 vxor		$in4,$twk4,v31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3775) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3776) 	vncipher	$out0,$out0,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3777) 	vncipher	$out1,$out1,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3778) 	vncipher	$out2,$out2,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3779) 	vncipher	$out3,$out3,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3780) 	vncipher	$out4,$out4,v30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3781) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3782) 	vncipherlast	$out0,$out0,$twk0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3783) 	vncipherlast	$out1,$out1,$in1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3784) 	vncipherlast	$out2,$out2,$in2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3785) 	vncipherlast	$out3,$out3,$in3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3786) 	vncipherlast	$out4,$out4,$in4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3787) 	mtctr		$rounds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3788) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3789)         .long   	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3790)         .byte   	0,12,0x14,0,0,0,0,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3791) ___
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3792) }}	}}}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3793) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3794) my $consts=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3795) foreach(split("\n",$code)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3796)         s/\`([^\`]*)\`/eval($1)/geo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3798) 	# constants table endian-specific conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3799) 	if ($consts && m/\.(long|byte)\s+(.+)\s+(\?[a-z]*)$/o) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3800) 	    my $conv=$3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3801) 	    my @bytes=();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3803) 	    # convert to endian-agnostic format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3804) 	    if ($1 eq "long") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3805) 	      foreach (split(/,\s*/,$2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3806) 		my $l = /^0/?oct:int;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3807) 		push @bytes,($l>>24)&0xff,($l>>16)&0xff,($l>>8)&0xff,$l&0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3808) 	      }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3809) 	    } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3810) 		@bytes = map(/^0/?oct:int,split(/,\s*/,$2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3811) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3813) 	    # little-endian conversion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3814) 	    if ($flavour =~ /le$/o) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3815) 		SWITCH: for($conv)  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3816) 		    /\?inv/ && do   { @bytes=map($_^0xf,@bytes); last; };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3817) 		    /\?rev/ && do   { @bytes=reverse(@bytes);    last; };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3818) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3819) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3821) 	    #emit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3822) 	    print ".byte\t",join(',',map (sprintf("0x%02x",$_),@bytes)),"\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3823) 	    next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3824) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3825) 	$consts=0 if (m/Lconsts:/o);	# end of table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3826) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3827) 	# instructions prefixed with '?' are endian-specific and need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3828) 	# to be adjusted accordingly...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3829) 	if ($flavour =~ /le$/o) {	# little-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3830) 	    s/le\?//o		or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3831) 	    s/be\?/#be#/o	or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3832) 	    s/\?lvsr/lvsl/o	or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3833) 	    s/\?lvsl/lvsr/o	or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3834) 	    s/\?(vperm\s+v[0-9]+,\s*)(v[0-9]+,\s*)(v[0-9]+,\s*)(v[0-9]+)/$1$3$2$4/o or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3835) 	    s/\?(vsldoi\s+v[0-9]+,\s*)(v[0-9]+,)\s*(v[0-9]+,\s*)([0-9]+)/$1$3$2 16-$4/o or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3836) 	    s/\?(vspltw\s+v[0-9]+,\s*)(v[0-9]+,)\s*([0-9])/$1$2 3-$3/o;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3837) 	} else {			# big-endian
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3838) 	    s/le\?/#le#/o	or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3839) 	    s/be\?//o		or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3840) 	    s/\?([a-z]+)/$1/o;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3841) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3842) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3843)         print $_,"\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3846) close STDOUT;