11cb0ef41Sopenharmony_ci#! /usr/bin/env perl
21cb0ef41Sopenharmony_ci# Copyright 2012-2021 The OpenSSL Project Authors. All Rights Reserved.
31cb0ef41Sopenharmony_ci#
41cb0ef41Sopenharmony_ci# Licensed under the Apache License 2.0 (the "License").  You may not use
51cb0ef41Sopenharmony_ci# this file except in compliance with the License.  You can obtain a copy
61cb0ef41Sopenharmony_ci# in the file LICENSE in the source distribution or at
71cb0ef41Sopenharmony_ci# https://www.openssl.org/source/license.html
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci# ====================================================================
111cb0ef41Sopenharmony_ci# Written by David S. Miller and Andy Polyakov.
121cb0ef41Sopenharmony_ci# The module is licensed under 2-clause BSD
131cb0ef41Sopenharmony_ci# license. October 2012. All rights reserved.
141cb0ef41Sopenharmony_ci# ====================================================================
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci######################################################################
171cb0ef41Sopenharmony_ci# Camellia for SPARC T4.
181cb0ef41Sopenharmony_ci#
191cb0ef41Sopenharmony_ci# As with AES below results [for aligned data] are virtually identical
201cb0ef41Sopenharmony_ci# to critical path lengths for 3-cycle instruction latency:
211cb0ef41Sopenharmony_ci#
221cb0ef41Sopenharmony_ci#		128-bit key	192/256-
231cb0ef41Sopenharmony_ci# CBC encrypt	4.14/4.21(*)	5.46/5.52
241cb0ef41Sopenharmony_ci#			 (*) numbers after slash are for
251cb0ef41Sopenharmony_ci#			     misaligned data.
261cb0ef41Sopenharmony_ci#
271cb0ef41Sopenharmony_ci# As with Intel AES-NI, question is if it's possible to improve
281cb0ef41Sopenharmony_ci# performance of parallelizable modes by interleaving round
291cb0ef41Sopenharmony_ci# instructions. In Camellia every instruction is dependent on
301cb0ef41Sopenharmony_ci# previous, which means that there is place for 2 additional ones
311cb0ef41Sopenharmony_ci# in between two dependent. Can we expect 3x performance improvement?
321cb0ef41Sopenharmony_ci# At least one can argue that it should be possible to break 2x
331cb0ef41Sopenharmony_ci# barrier... For some reason not even 2x appears to be possible:
341cb0ef41Sopenharmony_ci#
351cb0ef41Sopenharmony_ci#		128-bit key	192/256-
361cb0ef41Sopenharmony_ci# CBC decrypt	2.21/2.74	2.99/3.40
371cb0ef41Sopenharmony_ci# CTR		2.15/2.68(*)	2.93/3.34
381cb0ef41Sopenharmony_ci#			 (*) numbers after slash are for
391cb0ef41Sopenharmony_ci#			     misaligned data.
401cb0ef41Sopenharmony_ci#
411cb0ef41Sopenharmony_ci# This is for 2x interleave. But compared to 1x interleave CBC decrypt
421cb0ef41Sopenharmony_ci# improved by ... 0% for 128-bit key, and 11% for 192/256-bit one.
431cb0ef41Sopenharmony_ci# So that out-of-order execution logic can take non-interleaved code
441cb0ef41Sopenharmony_ci# to 1.87x, but can't take 2x interleaved one any further. There
451cb0ef41Sopenharmony_ci# surely is some explanation... As result 3x interleave was not even
461cb0ef41Sopenharmony_ci# attempted. Instead an effort was made to share specific modes
471cb0ef41Sopenharmony_ci# implementations with AES module (therefore sparct4_modes.pl).
481cb0ef41Sopenharmony_ci#
491cb0ef41Sopenharmony_ci# To anchor to something else, software C implementation processes
501cb0ef41Sopenharmony_ci# one byte in 38 cycles with 128-bit key on same processor.
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
531cb0ef41Sopenharmony_cipush(@INC,"${dir}","${dir}../../perlasm");
541cb0ef41Sopenharmony_cirequire "sparcv9_modes.pl";
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ci$output = pop and open STDOUT,">$output";
571cb0ef41Sopenharmony_ci
581cb0ef41Sopenharmony_ci$::evp=1;	# if $evp is set to 0, script generates module with
591cb0ef41Sopenharmony_ci# Camellia_[en|de]crypt, Camellia_set_key and Camellia_cbc_encrypt
601cb0ef41Sopenharmony_ci# entry points. These are fully compatible with openssl/camellia.h.
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ci######################################################################
631cb0ef41Sopenharmony_ci# single-round subroutines
641cb0ef41Sopenharmony_ci#
651cb0ef41Sopenharmony_ci{
661cb0ef41Sopenharmony_cimy ($inp,$out,$key,$rounds,$tmp,$mask)=map("%o$_",(0..5));
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ci$code=<<___;
691cb0ef41Sopenharmony_ci#ifndef __ASSEMBLER__
701cb0ef41Sopenharmony_ci# define __ASSEMBLER__ 1
711cb0ef41Sopenharmony_ci#endif
721cb0ef41Sopenharmony_ci#include "crypto/sparc_arch.h"
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ci.text
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ci.globl	cmll_t4_encrypt
771cb0ef41Sopenharmony_ci.align	32
781cb0ef41Sopenharmony_cicmll_t4_encrypt:
791cb0ef41Sopenharmony_ci	andcc		$inp, 7, %g1		! is input aligned?
801cb0ef41Sopenharmony_ci	andn		$inp, 7, $inp
811cb0ef41Sopenharmony_ci
821cb0ef41Sopenharmony_ci	ldx		[$key + 0], %g4
831cb0ef41Sopenharmony_ci	ldx		[$key + 8], %g5
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ci	ldx		[$inp + 0], %o4
861cb0ef41Sopenharmony_ci	bz,pt		%icc, 1f
871cb0ef41Sopenharmony_ci	ldx		[$inp + 8], %o5
881cb0ef41Sopenharmony_ci	ldx		[$inp + 16], $inp
891cb0ef41Sopenharmony_ci	sll		%g1, 3, %g1
901cb0ef41Sopenharmony_ci	sub		%g0, %g1, %o3
911cb0ef41Sopenharmony_ci	sllx		%o4, %g1, %o4
921cb0ef41Sopenharmony_ci	sllx		%o5, %g1, %g1
931cb0ef41Sopenharmony_ci	srlx		%o5, %o3, %o5
941cb0ef41Sopenharmony_ci	srlx		$inp, %o3, %o3
951cb0ef41Sopenharmony_ci	or		%o5, %o4, %o4
961cb0ef41Sopenharmony_ci	or		%o3, %g1, %o5
971cb0ef41Sopenharmony_ci1:
981cb0ef41Sopenharmony_ci	ld		[$key + 272], $rounds	! grandRounds, 3 or 4
991cb0ef41Sopenharmony_ci	ldd		[$key + 16], %f12
1001cb0ef41Sopenharmony_ci	ldd		[$key + 24], %f14
1011cb0ef41Sopenharmony_ci	xor		%g4, %o4, %o4
1021cb0ef41Sopenharmony_ci	xor		%g5, %o5, %o5
1031cb0ef41Sopenharmony_ci	ldd		[$key + 32], %f16
1041cb0ef41Sopenharmony_ci	ldd		[$key + 40], %f18
1051cb0ef41Sopenharmony_ci	movxtod		%o4, %f0
1061cb0ef41Sopenharmony_ci	movxtod		%o5, %f2
1071cb0ef41Sopenharmony_ci	ldd		[$key + 48], %f20
1081cb0ef41Sopenharmony_ci	ldd		[$key + 56], %f22
1091cb0ef41Sopenharmony_ci	sub		$rounds, 1, $rounds
1101cb0ef41Sopenharmony_ci	ldd		[$key + 64], %f24
1111cb0ef41Sopenharmony_ci	ldd		[$key + 72], %f26
1121cb0ef41Sopenharmony_ci	add		$key, 80, $key
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ci.Lenc:
1151cb0ef41Sopenharmony_ci	camellia_f	%f12, %f2, %f0, %f2
1161cb0ef41Sopenharmony_ci	ldd		[$key + 0], %f12
1171cb0ef41Sopenharmony_ci	sub		$rounds,1,$rounds
1181cb0ef41Sopenharmony_ci	camellia_f	%f14, %f0, %f2, %f0
1191cb0ef41Sopenharmony_ci	ldd		[$key + 8], %f14
1201cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
1211cb0ef41Sopenharmony_ci	ldd		[$key + 16], %f16
1221cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
1231cb0ef41Sopenharmony_ci	ldd		[$key + 24], %f18
1241cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
1251cb0ef41Sopenharmony_ci	ldd		[$key + 32], %f20
1261cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
1271cb0ef41Sopenharmony_ci	ldd		[$key + 40], %f22
1281cb0ef41Sopenharmony_ci	camellia_fl	%f24, %f0, %f0
1291cb0ef41Sopenharmony_ci	ldd		[$key + 48], %f24
1301cb0ef41Sopenharmony_ci	camellia_fli	%f26, %f2, %f2
1311cb0ef41Sopenharmony_ci	ldd		[$key + 56], %f26
1321cb0ef41Sopenharmony_ci	brnz,pt		$rounds, .Lenc
1331cb0ef41Sopenharmony_ci	add		$key, 64, $key
1341cb0ef41Sopenharmony_ci
1351cb0ef41Sopenharmony_ci	andcc		$out, 7, $tmp		! is output aligned?
1361cb0ef41Sopenharmony_ci	camellia_f	%f12, %f2, %f0, %f2
1371cb0ef41Sopenharmony_ci	camellia_f	%f14, %f0, %f2, %f0
1381cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
1391cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
1401cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f4
1411cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f4, %f2
1421cb0ef41Sopenharmony_ci	fxor		%f24, %f4, %f0
1431cb0ef41Sopenharmony_ci	fxor		%f26, %f2, %f2
1441cb0ef41Sopenharmony_ci
1451cb0ef41Sopenharmony_ci	bnz,pn		%icc, 2f
1461cb0ef41Sopenharmony_ci	nop
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ci	std		%f0, [$out + 0]
1491cb0ef41Sopenharmony_ci	retl
1501cb0ef41Sopenharmony_ci	std		%f2, [$out + 8]
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_ci2:	alignaddrl	$out, %g0, $out
1531cb0ef41Sopenharmony_ci	mov		0xff, $mask
1541cb0ef41Sopenharmony_ci	srl		$mask, $tmp, $mask
1551cb0ef41Sopenharmony_ci
1561cb0ef41Sopenharmony_ci	faligndata	%f0, %f0, %f4
1571cb0ef41Sopenharmony_ci	faligndata	%f0, %f2, %f6
1581cb0ef41Sopenharmony_ci	faligndata	%f2, %f2, %f8
1591cb0ef41Sopenharmony_ci
1601cb0ef41Sopenharmony_ci	stda		%f4, [$out + $mask]0xc0	! partial store
1611cb0ef41Sopenharmony_ci	std		%f6, [$out + 8]
1621cb0ef41Sopenharmony_ci	add		$out, 16, $out
1631cb0ef41Sopenharmony_ci	orn		%g0, $mask, $mask
1641cb0ef41Sopenharmony_ci	retl
1651cb0ef41Sopenharmony_ci	stda		%f8, [$out + $mask]0xc0	! partial store
1661cb0ef41Sopenharmony_ci.type	cmll_t4_encrypt,#function
1671cb0ef41Sopenharmony_ci.size	cmll_t4_encrypt,.-cmll_t4_encrypt
1681cb0ef41Sopenharmony_ci
1691cb0ef41Sopenharmony_ci.globl	cmll_t4_decrypt
1701cb0ef41Sopenharmony_ci.align	32
1711cb0ef41Sopenharmony_cicmll_t4_decrypt:
1721cb0ef41Sopenharmony_ci	ld		[$key + 272], $rounds	! grandRounds, 3 or 4
1731cb0ef41Sopenharmony_ci	andcc		$inp, 7, %g1		! is input aligned?
1741cb0ef41Sopenharmony_ci	andn		$inp, 7, $inp
1751cb0ef41Sopenharmony_ci
1761cb0ef41Sopenharmony_ci	sll		$rounds, 6, $rounds
1771cb0ef41Sopenharmony_ci	add		$rounds, $key, $key
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci	ldx		[$inp + 0], %o4
1801cb0ef41Sopenharmony_ci	bz,pt		%icc, 1f
1811cb0ef41Sopenharmony_ci	ldx		[$inp + 8], %o5
1821cb0ef41Sopenharmony_ci	ldx		[$inp + 16], $inp
1831cb0ef41Sopenharmony_ci	sll		%g1, 3, %g1
1841cb0ef41Sopenharmony_ci	sub		%g0, %g1, %g4
1851cb0ef41Sopenharmony_ci	sllx		%o4, %g1, %o4
1861cb0ef41Sopenharmony_ci	sllx		%o5, %g1, %g1
1871cb0ef41Sopenharmony_ci	srlx		%o5, %g4, %o5
1881cb0ef41Sopenharmony_ci	srlx		$inp, %g4, %g4
1891cb0ef41Sopenharmony_ci	or		%o5, %o4, %o4
1901cb0ef41Sopenharmony_ci	or		%g4, %g1, %o5
1911cb0ef41Sopenharmony_ci1:
1921cb0ef41Sopenharmony_ci	ldx		[$key + 0], %g4
1931cb0ef41Sopenharmony_ci	ldx		[$key + 8], %g5
1941cb0ef41Sopenharmony_ci	ldd		[$key - 8], %f12
1951cb0ef41Sopenharmony_ci	ldd		[$key - 16], %f14
1961cb0ef41Sopenharmony_ci	xor		%g4, %o4, %o4
1971cb0ef41Sopenharmony_ci	xor		%g5, %o5, %o5
1981cb0ef41Sopenharmony_ci	ldd		[$key - 24], %f16
1991cb0ef41Sopenharmony_ci	ldd		[$key - 32], %f18
2001cb0ef41Sopenharmony_ci	movxtod		%o4, %f0
2011cb0ef41Sopenharmony_ci	movxtod		%o5, %f2
2021cb0ef41Sopenharmony_ci	ldd		[$key - 40], %f20
2031cb0ef41Sopenharmony_ci	ldd		[$key - 48], %f22
2041cb0ef41Sopenharmony_ci	sub		$rounds, 64, $rounds
2051cb0ef41Sopenharmony_ci	ldd		[$key - 56], %f24
2061cb0ef41Sopenharmony_ci	ldd		[$key - 64], %f26
2071cb0ef41Sopenharmony_ci	sub		$key, 64, $key
2081cb0ef41Sopenharmony_ci
2091cb0ef41Sopenharmony_ci.Ldec:
2101cb0ef41Sopenharmony_ci	camellia_f	%f12, %f2, %f0, %f2
2111cb0ef41Sopenharmony_ci	ldd		[$key - 8], %f12
2121cb0ef41Sopenharmony_ci	sub		$rounds, 64, $rounds
2131cb0ef41Sopenharmony_ci	camellia_f	%f14, %f0, %f2, %f0
2141cb0ef41Sopenharmony_ci	ldd		[$key - 16], %f14
2151cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
2161cb0ef41Sopenharmony_ci	ldd		[$key - 24], %f16
2171cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
2181cb0ef41Sopenharmony_ci	ldd		[$key - 32], %f18
2191cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
2201cb0ef41Sopenharmony_ci	ldd		[$key - 40], %f20
2211cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
2221cb0ef41Sopenharmony_ci	ldd		[$key - 48], %f22
2231cb0ef41Sopenharmony_ci	camellia_fl	%f24, %f0, %f0
2241cb0ef41Sopenharmony_ci	ldd		[$key - 56], %f24
2251cb0ef41Sopenharmony_ci	camellia_fli	%f26, %f2, %f2
2261cb0ef41Sopenharmony_ci	ldd		[$key - 64], %f26
2271cb0ef41Sopenharmony_ci	brnz,pt		$rounds, .Ldec
2281cb0ef41Sopenharmony_ci	sub		$key, 64, $key
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_ci	andcc		$out, 7, $tmp		! is output aligned?
2311cb0ef41Sopenharmony_ci	camellia_f	%f12, %f2, %f0, %f2
2321cb0ef41Sopenharmony_ci	camellia_f	%f14, %f0, %f2, %f0
2331cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
2341cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
2351cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f4
2361cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f4, %f2
2371cb0ef41Sopenharmony_ci	fxor		%f26, %f4, %f0
2381cb0ef41Sopenharmony_ci	fxor		%f24, %f2, %f2
2391cb0ef41Sopenharmony_ci
2401cb0ef41Sopenharmony_ci	bnz,pn		%icc, 2f
2411cb0ef41Sopenharmony_ci	nop
2421cb0ef41Sopenharmony_ci
2431cb0ef41Sopenharmony_ci	std		%f0, [$out + 0]
2441cb0ef41Sopenharmony_ci	retl
2451cb0ef41Sopenharmony_ci	std		%f2, [$out + 8]
2461cb0ef41Sopenharmony_ci
2471cb0ef41Sopenharmony_ci2:	alignaddrl	$out, %g0, $out
2481cb0ef41Sopenharmony_ci	mov		0xff, $mask
2491cb0ef41Sopenharmony_ci	srl		$mask, $tmp, $mask
2501cb0ef41Sopenharmony_ci
2511cb0ef41Sopenharmony_ci	faligndata	%f0, %f0, %f4
2521cb0ef41Sopenharmony_ci	faligndata	%f0, %f2, %f6
2531cb0ef41Sopenharmony_ci	faligndata	%f2, %f2, %f8
2541cb0ef41Sopenharmony_ci
2551cb0ef41Sopenharmony_ci	stda		%f4, [$out + $mask]0xc0	! partial store
2561cb0ef41Sopenharmony_ci	std		%f6, [$out + 8]
2571cb0ef41Sopenharmony_ci	add		$out, 16, $out
2581cb0ef41Sopenharmony_ci	orn		%g0, $mask, $mask
2591cb0ef41Sopenharmony_ci	retl
2601cb0ef41Sopenharmony_ci	stda		%f8, [$out + $mask]0xc0	! partial store
2611cb0ef41Sopenharmony_ci.type	cmll_t4_decrypt,#function
2621cb0ef41Sopenharmony_ci.size	cmll_t4_decrypt,.-cmll_t4_decrypt
2631cb0ef41Sopenharmony_ci___
2641cb0ef41Sopenharmony_ci}
2651cb0ef41Sopenharmony_ci
2661cb0ef41Sopenharmony_ci######################################################################
2671cb0ef41Sopenharmony_ci# key setup subroutines
2681cb0ef41Sopenharmony_ci#
2691cb0ef41Sopenharmony_ci{
2701cb0ef41Sopenharmony_cisub ROTL128 {
2711cb0ef41Sopenharmony_ci  my $rot = shift;
2721cb0ef41Sopenharmony_ci
2731cb0ef41Sopenharmony_ci	"srlx	%o4, 64-$rot, %g4\n\t".
2741cb0ef41Sopenharmony_ci	"sllx	%o4, $rot, %o4\n\t".
2751cb0ef41Sopenharmony_ci	"srlx	%o5, 64-$rot, %g5\n\t".
2761cb0ef41Sopenharmony_ci	"sllx	%o5, $rot, %o5\n\t".
2771cb0ef41Sopenharmony_ci	"or	%o4, %g5, %o4\n\t".
2781cb0ef41Sopenharmony_ci	"or	%o5, %g4, %o5";
2791cb0ef41Sopenharmony_ci}
2801cb0ef41Sopenharmony_ci
2811cb0ef41Sopenharmony_cimy ($inp,$bits,$out,$tmp)=map("%o$_",(0..5));
2821cb0ef41Sopenharmony_ci$code.=<<___;
2831cb0ef41Sopenharmony_ci.globl	cmll_t4_set_key
2841cb0ef41Sopenharmony_ci.align	32
2851cb0ef41Sopenharmony_cicmll_t4_set_key:
2861cb0ef41Sopenharmony_ci	and		$inp, 7, $tmp
2871cb0ef41Sopenharmony_ci	alignaddr	$inp, %g0, $inp
2881cb0ef41Sopenharmony_ci	cmp		$bits, 192
2891cb0ef41Sopenharmony_ci	ldd		[$inp + 0], %f0
2901cb0ef41Sopenharmony_ci	bl,pt		%icc,.L128
2911cb0ef41Sopenharmony_ci	ldd		[$inp + 8], %f2
2921cb0ef41Sopenharmony_ci
2931cb0ef41Sopenharmony_ci	be,pt		%icc,.L192
2941cb0ef41Sopenharmony_ci	ldd		[$inp + 16], %f4
2951cb0ef41Sopenharmony_ci
2961cb0ef41Sopenharmony_ci	brz,pt		$tmp, .L256aligned
2971cb0ef41Sopenharmony_ci	ldd		[$inp + 24], %f6
2981cb0ef41Sopenharmony_ci
2991cb0ef41Sopenharmony_ci	ldd		[$inp + 32], %f8
3001cb0ef41Sopenharmony_ci	faligndata	%f0, %f2, %f0
3011cb0ef41Sopenharmony_ci	faligndata	%f2, %f4, %f2
3021cb0ef41Sopenharmony_ci	faligndata	%f4, %f6, %f4
3031cb0ef41Sopenharmony_ci	b		.L256aligned
3041cb0ef41Sopenharmony_ci	faligndata	%f6, %f8, %f6
3051cb0ef41Sopenharmony_ci
3061cb0ef41Sopenharmony_ci.align	16
3071cb0ef41Sopenharmony_ci.L192:
3081cb0ef41Sopenharmony_ci	brz,a,pt	$tmp, .L256aligned
3091cb0ef41Sopenharmony_ci	fnot2		%f4, %f6
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci	ldd		[$inp + 24], %f6
3121cb0ef41Sopenharmony_ci	nop
3131cb0ef41Sopenharmony_ci	faligndata	%f0, %f2, %f0
3141cb0ef41Sopenharmony_ci	faligndata	%f2, %f4, %f2
3151cb0ef41Sopenharmony_ci	faligndata	%f4, %f6, %f4
3161cb0ef41Sopenharmony_ci	fnot2		%f4, %f6
3171cb0ef41Sopenharmony_ci
3181cb0ef41Sopenharmony_ci.L256aligned:
3191cb0ef41Sopenharmony_ci	std		%f0, [$out + 0]		! k[0, 1]
3201cb0ef41Sopenharmony_ci	fsrc2		%f0, %f28
3211cb0ef41Sopenharmony_ci	std		%f2, [$out + 8]		! k[2, 3]
3221cb0ef41Sopenharmony_ci	fsrc2		%f2, %f30
3231cb0ef41Sopenharmony_ci	fxor		%f4, %f0, %f0
3241cb0ef41Sopenharmony_ci	b		.L128key
3251cb0ef41Sopenharmony_ci	fxor		%f6, %f2, %f2
3261cb0ef41Sopenharmony_ci
3271cb0ef41Sopenharmony_ci.align	16
3281cb0ef41Sopenharmony_ci.L128:
3291cb0ef41Sopenharmony_ci	brz,pt		$tmp, .L128aligned
3301cb0ef41Sopenharmony_ci	nop
3311cb0ef41Sopenharmony_ci
3321cb0ef41Sopenharmony_ci	ldd		[$inp + 16], %f4
3331cb0ef41Sopenharmony_ci	nop
3341cb0ef41Sopenharmony_ci	faligndata	%f0, %f2, %f0
3351cb0ef41Sopenharmony_ci	faligndata	%f2, %f4, %f2
3361cb0ef41Sopenharmony_ci
3371cb0ef41Sopenharmony_ci.L128aligned:
3381cb0ef41Sopenharmony_ci	std		%f0, [$out + 0]		! k[0, 1]
3391cb0ef41Sopenharmony_ci	fsrc2		%f0, %f28
3401cb0ef41Sopenharmony_ci	std		%f2, [$out + 8]		! k[2, 3]
3411cb0ef41Sopenharmony_ci	fsrc2		%f2, %f30
3421cb0ef41Sopenharmony_ci
3431cb0ef41Sopenharmony_ci.L128key:
3441cb0ef41Sopenharmony_ci	mov		%o7, %o5
3451cb0ef41Sopenharmony_ci1:	call		.+8
3461cb0ef41Sopenharmony_ci	add		%o7, SIGMA-1b, %o4
3471cb0ef41Sopenharmony_ci	mov		%o5, %o7
3481cb0ef41Sopenharmony_ci
3491cb0ef41Sopenharmony_ci	ldd		[%o4 + 0], %f16
3501cb0ef41Sopenharmony_ci	ldd		[%o4 + 8], %f18
3511cb0ef41Sopenharmony_ci	ldd		[%o4 + 16], %f20
3521cb0ef41Sopenharmony_ci	ldd		[%o4 + 24], %f22
3531cb0ef41Sopenharmony_ci
3541cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
3551cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
3561cb0ef41Sopenharmony_ci	fxor		%f28, %f0, %f0
3571cb0ef41Sopenharmony_ci	fxor		%f30, %f2, %f2
3581cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
3591cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
3601cb0ef41Sopenharmony_ci
3611cb0ef41Sopenharmony_ci	bge,pn		%icc, .L256key
3621cb0ef41Sopenharmony_ci	nop
3631cb0ef41Sopenharmony_ci	std	%f0, [$out + 0x10]	! k[ 4,  5]
3641cb0ef41Sopenharmony_ci	std	%f2, [$out + 0x18]	! k[ 6,  7]
3651cb0ef41Sopenharmony_ci
3661cb0ef41Sopenharmony_ci	movdtox	%f0, %o4
3671cb0ef41Sopenharmony_ci	movdtox	%f2, %o5
3681cb0ef41Sopenharmony_ci	`&ROTL128(15)`
3691cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x30]	! k[12, 13]
3701cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x38]	! k[14, 15]
3711cb0ef41Sopenharmony_ci	`&ROTL128(15)`
3721cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x40]	! k[16, 17]
3731cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x48]	! k[18, 19]
3741cb0ef41Sopenharmony_ci	`&ROTL128(15)`
3751cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x60]	! k[24, 25]
3761cb0ef41Sopenharmony_ci	`&ROTL128(15)`
3771cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x70]	! k[28, 29]
3781cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x78]	! k[30, 31]
3791cb0ef41Sopenharmony_ci	`&ROTL128(34)`
3801cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xa0]	! k[40, 41]
3811cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xa8]	! k[42, 43]
3821cb0ef41Sopenharmony_ci	`&ROTL128(17)`
3831cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xc0]	! k[48, 49]
3841cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xc8]	! k[50, 51]
3851cb0ef41Sopenharmony_ci
3861cb0ef41Sopenharmony_ci	movdtox	%f28, %o4		! k[ 0,  1]
3871cb0ef41Sopenharmony_ci	movdtox	%f30, %o5		! k[ 2,  3]
3881cb0ef41Sopenharmony_ci	`&ROTL128(15)`
3891cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x20]	! k[ 8,  9]
3901cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x28]	! k[10, 11]
3911cb0ef41Sopenharmony_ci	`&ROTL128(30)`
3921cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x50]	! k[20, 21]
3931cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x58]	! k[22, 23]
3941cb0ef41Sopenharmony_ci	`&ROTL128(15)`
3951cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x68]	! k[26, 27]
3961cb0ef41Sopenharmony_ci	`&ROTL128(17)`
3971cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x80]	! k[32, 33]
3981cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x88]	! k[34, 35]
3991cb0ef41Sopenharmony_ci	`&ROTL128(17)`
4001cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x90]	! k[36, 37]
4011cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x98]	! k[38, 39]
4021cb0ef41Sopenharmony_ci	`&ROTL128(17)`
4031cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xb0]	! k[44, 45]
4041cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xb8]	! k[46, 47]
4051cb0ef41Sopenharmony_ci
4061cb0ef41Sopenharmony_ci	mov		3, $tmp
4071cb0ef41Sopenharmony_ci	st		$tmp, [$out + 0x110]
4081cb0ef41Sopenharmony_ci	retl
4091cb0ef41Sopenharmony_ci	xor		%o0, %o0, %o0
4101cb0ef41Sopenharmony_ci
4111cb0ef41Sopenharmony_ci.align	16
4121cb0ef41Sopenharmony_ci.L256key:
4131cb0ef41Sopenharmony_ci	ldd		[%o4 + 32], %f24
4141cb0ef41Sopenharmony_ci	ldd		[%o4 + 40], %f26
4151cb0ef41Sopenharmony_ci
4161cb0ef41Sopenharmony_ci	std		%f0, [$out + 0x30]	! k[12, 13]
4171cb0ef41Sopenharmony_ci	std		%f2, [$out + 0x38]	! k[14, 15]
4181cb0ef41Sopenharmony_ci
4191cb0ef41Sopenharmony_ci	fxor		%f4, %f0, %f0
4201cb0ef41Sopenharmony_ci	fxor		%f6, %f2, %f2
4211cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f2
4221cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f2, %f0
4231cb0ef41Sopenharmony_ci
4241cb0ef41Sopenharmony_ci	std	%f0, [$out + 0x10]	! k[ 4,  5]
4251cb0ef41Sopenharmony_ci	std	%f2, [$out + 0x18]	! k[ 6,  7]
4261cb0ef41Sopenharmony_ci
4271cb0ef41Sopenharmony_ci	movdtox	%f0, %o4
4281cb0ef41Sopenharmony_ci	movdtox	%f2, %o5
4291cb0ef41Sopenharmony_ci	`&ROTL128(30)`
4301cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x50]	! k[20, 21]
4311cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x58]	! k[22, 23]
4321cb0ef41Sopenharmony_ci	`&ROTL128(30)`
4331cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xa0]	! k[40, 41]
4341cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xa8]	! k[42, 43]
4351cb0ef41Sopenharmony_ci	`&ROTL128(51)`
4361cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x100]	! k[64, 65]
4371cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x108]	! k[66, 67]
4381cb0ef41Sopenharmony_ci
4391cb0ef41Sopenharmony_ci	movdtox	%f4, %o4		! k[ 8,  9]
4401cb0ef41Sopenharmony_ci	movdtox	%f6, %o5		! k[10, 11]
4411cb0ef41Sopenharmony_ci	`&ROTL128(15)`
4421cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x20]	! k[ 8,  9]
4431cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x28]	! k[10, 11]
4441cb0ef41Sopenharmony_ci	`&ROTL128(15)`
4451cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x40]	! k[16, 17]
4461cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x48]	! k[18, 19]
4471cb0ef41Sopenharmony_ci	`&ROTL128(30)`
4481cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x90]	! k[36, 37]
4491cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x98]	! k[38, 39]
4501cb0ef41Sopenharmony_ci	`&ROTL128(34)`
4511cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xd0]	! k[52, 53]
4521cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xd8]	! k[54, 55]
4531cb0ef41Sopenharmony_ci	ldx	[$out + 0x30], %o4	! k[12, 13]
4541cb0ef41Sopenharmony_ci	ldx	[$out + 0x38], %o5	! k[14, 15]
4551cb0ef41Sopenharmony_ci	`&ROTL128(15)`
4561cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x30]	! k[12, 13]
4571cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x38]	! k[14, 15]
4581cb0ef41Sopenharmony_ci	`&ROTL128(30)`
4591cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x70]	! k[28, 29]
4601cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x78]	! k[30, 31]
4611cb0ef41Sopenharmony_ci	srlx	%o4, 32, %g4
4621cb0ef41Sopenharmony_ci	srlx	%o5, 32, %g5
4631cb0ef41Sopenharmony_ci	st	%o4, [$out + 0xc0]	! k[48]
4641cb0ef41Sopenharmony_ci	st	%g5, [$out + 0xc4]	! k[49]
4651cb0ef41Sopenharmony_ci	st	%o5, [$out + 0xc8]	! k[50]
4661cb0ef41Sopenharmony_ci	st	%g4, [$out + 0xcc]	! k[51]
4671cb0ef41Sopenharmony_ci	`&ROTL128(49)`
4681cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xe0]	! k[56, 57]
4691cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xe8]	! k[58, 59]
4701cb0ef41Sopenharmony_ci
4711cb0ef41Sopenharmony_ci	movdtox	%f28, %o4		! k[ 0,  1]
4721cb0ef41Sopenharmony_ci	movdtox	%f30, %o5		! k[ 2,  3]
4731cb0ef41Sopenharmony_ci	`&ROTL128(45)`
4741cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x60]	! k[24, 25]
4751cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x68]	! k[26, 27]
4761cb0ef41Sopenharmony_ci	`&ROTL128(15)`
4771cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0x80]	! k[32, 33]
4781cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0x88]	! k[34, 35]
4791cb0ef41Sopenharmony_ci	`&ROTL128(17)`
4801cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xb0]	! k[44, 45]
4811cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xb8]	! k[46, 47]
4821cb0ef41Sopenharmony_ci	`&ROTL128(34)`
4831cb0ef41Sopenharmony_ci	stx	%o4, [$out + 0xf0]	! k[60, 61]
4841cb0ef41Sopenharmony_ci	stx	%o5, [$out + 0xf8]	! k[62, 63]
4851cb0ef41Sopenharmony_ci
4861cb0ef41Sopenharmony_ci	mov		4, $tmp
4871cb0ef41Sopenharmony_ci	st		$tmp, [$out + 0x110]
4881cb0ef41Sopenharmony_ci	retl
4891cb0ef41Sopenharmony_ci	xor		%o0, %o0, %o0
4901cb0ef41Sopenharmony_ci.type	cmll_t4_set_key,#function
4911cb0ef41Sopenharmony_ci.size	cmll_t4_set_key,.-cmll_t4_set_key
4921cb0ef41Sopenharmony_ci.align	32
4931cb0ef41Sopenharmony_ciSIGMA:
4941cb0ef41Sopenharmony_ci	.long	0xa09e667f, 0x3bcc908b, 0xb67ae858, 0x4caa73b2
4951cb0ef41Sopenharmony_ci	.long	0xc6ef372f, 0xe94f82be, 0x54ff53a5, 0xf1d36f1c
4961cb0ef41Sopenharmony_ci	.long	0x10e527fa, 0xde682d1d, 0xb05688c2, 0xb3e6c1fd
4971cb0ef41Sopenharmony_ci.type	SIGMA,#object
4981cb0ef41Sopenharmony_ci.size	SIGMA,.-SIGMA
4991cb0ef41Sopenharmony_ci.asciz	"Camellia for SPARC T4, David S. Miller, Andy Polyakov"
5001cb0ef41Sopenharmony_ci___
5011cb0ef41Sopenharmony_ci}
5021cb0ef41Sopenharmony_ci
5031cb0ef41Sopenharmony_ci{{{
5041cb0ef41Sopenharmony_cimy ($inp,$out,$len,$key,$ivec,$enc)=map("%i$_",(0..5));
5051cb0ef41Sopenharmony_cimy ($ileft,$iright,$ooff,$omask,$ivoff)=map("%l$_",(1..7));
5061cb0ef41Sopenharmony_ci
5071cb0ef41Sopenharmony_ci$code.=<<___;
5081cb0ef41Sopenharmony_ci.align	32
5091cb0ef41Sopenharmony_ci_cmll128_load_enckey:
5101cb0ef41Sopenharmony_ci	ldx		[$key + 0], %g4
5111cb0ef41Sopenharmony_ci	ldx		[$key + 8], %g5
5121cb0ef41Sopenharmony_ci___
5131cb0ef41Sopenharmony_cifor ($i=2; $i<26;$i++) {			# load key schedule
5141cb0ef41Sopenharmony_ci    $code.=<<___;
5151cb0ef41Sopenharmony_ci	ldd		[$key + `8*$i`], %f`12+2*$i`
5161cb0ef41Sopenharmony_ci___
5171cb0ef41Sopenharmony_ci}
5181cb0ef41Sopenharmony_ci$code.=<<___;
5191cb0ef41Sopenharmony_ci	retl
5201cb0ef41Sopenharmony_ci	nop
5211cb0ef41Sopenharmony_ci.type	_cmll128_load_enckey,#function
5221cb0ef41Sopenharmony_ci.size	_cmll128_load_enckey,.-_cmll128_load_enckey
5231cb0ef41Sopenharmony_ci_cmll256_load_enckey=_cmll128_load_enckey
5241cb0ef41Sopenharmony_ci
5251cb0ef41Sopenharmony_ci.align	32
5261cb0ef41Sopenharmony_ci_cmll256_load_deckey:
5271cb0ef41Sopenharmony_ci	ldd		[$key + 64], %f62
5281cb0ef41Sopenharmony_ci	ldd		[$key + 72], %f60
5291cb0ef41Sopenharmony_ci	b		.Load_deckey
5301cb0ef41Sopenharmony_ci	add		$key, 64, $key
5311cb0ef41Sopenharmony_ci_cmll128_load_deckey:
5321cb0ef41Sopenharmony_ci	ldd		[$key + 0], %f60
5331cb0ef41Sopenharmony_ci	ldd		[$key + 8], %f62
5341cb0ef41Sopenharmony_ci.Load_deckey:
5351cb0ef41Sopenharmony_ci___
5361cb0ef41Sopenharmony_cifor ($i=2; $i<24;$i++) {			# load key schedule
5371cb0ef41Sopenharmony_ci    $code.=<<___;
5381cb0ef41Sopenharmony_ci	ldd		[$key + `8*$i`], %f`62-2*$i`
5391cb0ef41Sopenharmony_ci___
5401cb0ef41Sopenharmony_ci}
5411cb0ef41Sopenharmony_ci$code.=<<___;
5421cb0ef41Sopenharmony_ci	ldx		[$key + 192], %g4
5431cb0ef41Sopenharmony_ci	retl
5441cb0ef41Sopenharmony_ci	ldx		[$key + 200], %g5
5451cb0ef41Sopenharmony_ci.type	_cmll256_load_deckey,#function
5461cb0ef41Sopenharmony_ci.size	_cmll256_load_deckey,.-_cmll256_load_deckey
5471cb0ef41Sopenharmony_ci
5481cb0ef41Sopenharmony_ci.align	32
5491cb0ef41Sopenharmony_ci_cmll128_encrypt_1x:
5501cb0ef41Sopenharmony_ci___
5511cb0ef41Sopenharmony_cifor ($i=0; $i<3; $i++) {
5521cb0ef41Sopenharmony_ci    $code.=<<___;
5531cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f2, %f0, %f2
5541cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f0, %f2, %f0
5551cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f2, %f0, %f2
5561cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f0, %f2, %f0
5571cb0ef41Sopenharmony_ci___
5581cb0ef41Sopenharmony_ci$code.=<<___ if ($i<2);
5591cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f2, %f0, %f2
5601cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f0, %f2, %f0
5611cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f0,      %f0
5621cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f2,      %f2
5631cb0ef41Sopenharmony_ci___
5641cb0ef41Sopenharmony_ci}
5651cb0ef41Sopenharmony_ci$code.=<<___;
5661cb0ef41Sopenharmony_ci	camellia_f	%f56, %f2, %f0, %f4
5671cb0ef41Sopenharmony_ci	camellia_f	%f58, %f0, %f4, %f2
5681cb0ef41Sopenharmony_ci	fxor		%f60, %f4, %f0
5691cb0ef41Sopenharmony_ci	retl
5701cb0ef41Sopenharmony_ci	fxor		%f62, %f2, %f2
5711cb0ef41Sopenharmony_ci.type	_cmll128_encrypt_1x,#function
5721cb0ef41Sopenharmony_ci.size	_cmll128_encrypt_1x,.-_cmll128_encrypt_1x
5731cb0ef41Sopenharmony_ci_cmll128_decrypt_1x=_cmll128_encrypt_1x
5741cb0ef41Sopenharmony_ci
5751cb0ef41Sopenharmony_ci.align	32
5761cb0ef41Sopenharmony_ci_cmll128_encrypt_2x:
5771cb0ef41Sopenharmony_ci___
5781cb0ef41Sopenharmony_cifor ($i=0; $i<3; $i++) {
5791cb0ef41Sopenharmony_ci    $code.=<<___;
5801cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f2, %f0, %f2
5811cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f6, %f4, %f6
5821cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f0, %f2, %f0
5831cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f4, %f6, %f4
5841cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f2, %f0, %f2
5851cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f6, %f4, %f6
5861cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f0, %f2, %f0
5871cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f4, %f6, %f4
5881cb0ef41Sopenharmony_ci___
5891cb0ef41Sopenharmony_ci$code.=<<___ if ($i<2);
5901cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f2, %f0, %f2
5911cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f6, %f4, %f6
5921cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f0, %f2, %f0
5931cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f4, %f6, %f4
5941cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f0,      %f0
5951cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f4,      %f4
5961cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f2,      %f2
5971cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f6,      %f6
5981cb0ef41Sopenharmony_ci___
5991cb0ef41Sopenharmony_ci}
6001cb0ef41Sopenharmony_ci$code.=<<___;
6011cb0ef41Sopenharmony_ci	camellia_f	%f56, %f2, %f0, %f8
6021cb0ef41Sopenharmony_ci	camellia_f	%f56, %f6, %f4, %f10
6031cb0ef41Sopenharmony_ci	camellia_f	%f58, %f0, %f8, %f2
6041cb0ef41Sopenharmony_ci	camellia_f	%f58, %f4, %f10, %f6
6051cb0ef41Sopenharmony_ci	fxor		%f60, %f8, %f0
6061cb0ef41Sopenharmony_ci	fxor		%f60, %f10, %f4
6071cb0ef41Sopenharmony_ci	fxor		%f62, %f2, %f2
6081cb0ef41Sopenharmony_ci	retl
6091cb0ef41Sopenharmony_ci	fxor		%f62, %f6, %f6
6101cb0ef41Sopenharmony_ci.type	_cmll128_encrypt_2x,#function
6111cb0ef41Sopenharmony_ci.size	_cmll128_encrypt_2x,.-_cmll128_encrypt_2x
6121cb0ef41Sopenharmony_ci_cmll128_decrypt_2x=_cmll128_encrypt_2x
6131cb0ef41Sopenharmony_ci
6141cb0ef41Sopenharmony_ci.align	32
6151cb0ef41Sopenharmony_ci_cmll256_encrypt_1x:
6161cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
6171cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
6181cb0ef41Sopenharmony_ci	ldd		[$key + 208], %f16
6191cb0ef41Sopenharmony_ci	ldd		[$key + 216], %f18
6201cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
6211cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
6221cb0ef41Sopenharmony_ci	ldd		[$key + 224], %f20
6231cb0ef41Sopenharmony_ci	ldd		[$key + 232], %f22
6241cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f2
6251cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f2, %f0
6261cb0ef41Sopenharmony_ci	ldd		[$key + 240], %f24
6271cb0ef41Sopenharmony_ci	ldd		[$key + 248], %f26
6281cb0ef41Sopenharmony_ci	camellia_fl	%f28, %f0, %f0
6291cb0ef41Sopenharmony_ci	camellia_fli	%f30, %f2, %f2
6301cb0ef41Sopenharmony_ci	ldd		[$key + 256], %f28
6311cb0ef41Sopenharmony_ci	ldd		[$key + 264], %f30
6321cb0ef41Sopenharmony_ci___
6331cb0ef41Sopenharmony_cifor ($i=1; $i<3; $i++) {
6341cb0ef41Sopenharmony_ci    $code.=<<___;
6351cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f2, %f0, %f2
6361cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f0, %f2, %f0
6371cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f2, %f0, %f2
6381cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f0, %f2, %f0
6391cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f2, %f0, %f2
6401cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f0, %f2, %f0
6411cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f0,      %f0
6421cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f2,      %f2
6431cb0ef41Sopenharmony_ci___
6441cb0ef41Sopenharmony_ci}
6451cb0ef41Sopenharmony_ci$code.=<<___;
6461cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
6471cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
6481cb0ef41Sopenharmony_ci	ldd		[$key + 16], %f16
6491cb0ef41Sopenharmony_ci	ldd		[$key + 24], %f18
6501cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
6511cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
6521cb0ef41Sopenharmony_ci	ldd		[$key + 32], %f20
6531cb0ef41Sopenharmony_ci	ldd		[$key + 40], %f22
6541cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f4
6551cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f4, %f2
6561cb0ef41Sopenharmony_ci	ldd		[$key + 48], %f24
6571cb0ef41Sopenharmony_ci	ldd		[$key + 56], %f26
6581cb0ef41Sopenharmony_ci	fxor		%f28, %f4, %f0
6591cb0ef41Sopenharmony_ci	fxor		%f30, %f2, %f2
6601cb0ef41Sopenharmony_ci	ldd		[$key + 64], %f28
6611cb0ef41Sopenharmony_ci	retl
6621cb0ef41Sopenharmony_ci	ldd		[$key + 72], %f30
6631cb0ef41Sopenharmony_ci.type	_cmll256_encrypt_1x,#function
6641cb0ef41Sopenharmony_ci.size	_cmll256_encrypt_1x,.-_cmll256_encrypt_1x
6651cb0ef41Sopenharmony_ci
6661cb0ef41Sopenharmony_ci.align	32
6671cb0ef41Sopenharmony_ci_cmll256_encrypt_2x:
6681cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
6691cb0ef41Sopenharmony_ci	camellia_f	%f16, %f6, %f4, %f6
6701cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
6711cb0ef41Sopenharmony_ci	camellia_f	%f18, %f4, %f6, %f4
6721cb0ef41Sopenharmony_ci	ldd		[$key + 208], %f16
6731cb0ef41Sopenharmony_ci	ldd		[$key + 216], %f18
6741cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
6751cb0ef41Sopenharmony_ci	camellia_f	%f20, %f6, %f4, %f6
6761cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
6771cb0ef41Sopenharmony_ci	camellia_f	%f22, %f4, %f6, %f4
6781cb0ef41Sopenharmony_ci	ldd		[$key + 224], %f20
6791cb0ef41Sopenharmony_ci	ldd		[$key + 232], %f22
6801cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f2
6811cb0ef41Sopenharmony_ci	camellia_f	%f24, %f6, %f4, %f6
6821cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f2, %f0
6831cb0ef41Sopenharmony_ci	camellia_f	%f26, %f4, %f6, %f4
6841cb0ef41Sopenharmony_ci	ldd		[$key + 240], %f24
6851cb0ef41Sopenharmony_ci	ldd		[$key + 248], %f26
6861cb0ef41Sopenharmony_ci	camellia_fl	%f28, %f0, %f0
6871cb0ef41Sopenharmony_ci	camellia_fl	%f28, %f4, %f4
6881cb0ef41Sopenharmony_ci	camellia_fli	%f30, %f2, %f2
6891cb0ef41Sopenharmony_ci	camellia_fli	%f30, %f6, %f6
6901cb0ef41Sopenharmony_ci	ldd		[$key + 256], %f28
6911cb0ef41Sopenharmony_ci	ldd		[$key + 264], %f30
6921cb0ef41Sopenharmony_ci___
6931cb0ef41Sopenharmony_cifor ($i=1; $i<3; $i++) {
6941cb0ef41Sopenharmony_ci    $code.=<<___;
6951cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f2, %f0, %f2
6961cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f6, %f4, %f6
6971cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f0, %f2, %f0
6981cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f4, %f6, %f4
6991cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f2, %f0, %f2
7001cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f6, %f4, %f6
7011cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f0, %f2, %f0
7021cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f4, %f6, %f4
7031cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f2, %f0, %f2
7041cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f6, %f4, %f6
7051cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f0, %f2, %f0
7061cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f4, %f6, %f4
7071cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f0,      %f0
7081cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f4,      %f4
7091cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f2,      %f2
7101cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f6,      %f6
7111cb0ef41Sopenharmony_ci___
7121cb0ef41Sopenharmony_ci}
7131cb0ef41Sopenharmony_ci$code.=<<___;
7141cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
7151cb0ef41Sopenharmony_ci	camellia_f	%f16, %f6, %f4, %f6
7161cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
7171cb0ef41Sopenharmony_ci	camellia_f	%f18, %f4, %f6, %f4
7181cb0ef41Sopenharmony_ci	ldd		[$key + 16], %f16
7191cb0ef41Sopenharmony_ci	ldd		[$key + 24], %f18
7201cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
7211cb0ef41Sopenharmony_ci	camellia_f	%f20, %f6, %f4, %f6
7221cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
7231cb0ef41Sopenharmony_ci	camellia_f	%f22, %f4, %f6, %f4
7241cb0ef41Sopenharmony_ci	ldd		[$key + 32], %f20
7251cb0ef41Sopenharmony_ci	ldd		[$key + 40], %f22
7261cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f8
7271cb0ef41Sopenharmony_ci	camellia_f	%f24, %f6, %f4, %f10
7281cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f8, %f2
7291cb0ef41Sopenharmony_ci	camellia_f	%f26, %f4, %f10, %f6
7301cb0ef41Sopenharmony_ci	ldd		[$key + 48], %f24
7311cb0ef41Sopenharmony_ci	ldd		[$key + 56], %f26
7321cb0ef41Sopenharmony_ci	fxor		%f28, %f8, %f0
7331cb0ef41Sopenharmony_ci	fxor		%f28, %f10, %f4
7341cb0ef41Sopenharmony_ci	fxor		%f30, %f2, %f2
7351cb0ef41Sopenharmony_ci	fxor		%f30, %f6, %f6
7361cb0ef41Sopenharmony_ci	ldd		[$key + 64], %f28
7371cb0ef41Sopenharmony_ci	retl
7381cb0ef41Sopenharmony_ci	ldd		[$key + 72], %f30
7391cb0ef41Sopenharmony_ci.type	_cmll256_encrypt_2x,#function
7401cb0ef41Sopenharmony_ci.size	_cmll256_encrypt_2x,.-_cmll256_encrypt_2x
7411cb0ef41Sopenharmony_ci
7421cb0ef41Sopenharmony_ci.align	32
7431cb0ef41Sopenharmony_ci_cmll256_decrypt_1x:
7441cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
7451cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
7461cb0ef41Sopenharmony_ci	ldd		[$key - 8], %f16
7471cb0ef41Sopenharmony_ci	ldd		[$key - 16], %f18
7481cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
7491cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
7501cb0ef41Sopenharmony_ci	ldd		[$key - 24], %f20
7511cb0ef41Sopenharmony_ci	ldd		[$key - 32], %f22
7521cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f2
7531cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f2, %f0
7541cb0ef41Sopenharmony_ci	ldd		[$key - 40], %f24
7551cb0ef41Sopenharmony_ci	ldd		[$key - 48], %f26
7561cb0ef41Sopenharmony_ci	camellia_fl	%f28, %f0, %f0
7571cb0ef41Sopenharmony_ci	camellia_fli	%f30, %f2, %f2
7581cb0ef41Sopenharmony_ci	ldd		[$key - 56], %f28
7591cb0ef41Sopenharmony_ci	ldd		[$key - 64], %f30
7601cb0ef41Sopenharmony_ci___
7611cb0ef41Sopenharmony_cifor ($i=1; $i<3; $i++) {
7621cb0ef41Sopenharmony_ci    $code.=<<___;
7631cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f2, %f0, %f2
7641cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f0, %f2, %f0
7651cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f2, %f0, %f2
7661cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f0, %f2, %f0
7671cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f2, %f0, %f2
7681cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f0, %f2, %f0
7691cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f0,      %f0
7701cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f2,      %f2
7711cb0ef41Sopenharmony_ci___
7721cb0ef41Sopenharmony_ci}
7731cb0ef41Sopenharmony_ci$code.=<<___;
7741cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
7751cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
7761cb0ef41Sopenharmony_ci	ldd		[$key + 184], %f16
7771cb0ef41Sopenharmony_ci	ldd		[$key + 176], %f18
7781cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
7791cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
7801cb0ef41Sopenharmony_ci	ldd		[$key + 168], %f20
7811cb0ef41Sopenharmony_ci	ldd		[$key + 160], %f22
7821cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f4
7831cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f4, %f2
7841cb0ef41Sopenharmony_ci	ldd		[$key + 152], %f24
7851cb0ef41Sopenharmony_ci	ldd		[$key + 144], %f26
7861cb0ef41Sopenharmony_ci	fxor		%f30, %f4, %f0
7871cb0ef41Sopenharmony_ci	fxor		%f28, %f2, %f2
7881cb0ef41Sopenharmony_ci	ldd		[$key + 136], %f28
7891cb0ef41Sopenharmony_ci	retl
7901cb0ef41Sopenharmony_ci	ldd		[$key + 128], %f30
7911cb0ef41Sopenharmony_ci.type	_cmll256_decrypt_1x,#function
7921cb0ef41Sopenharmony_ci.size	_cmll256_decrypt_1x,.-_cmll256_decrypt_1x
7931cb0ef41Sopenharmony_ci
7941cb0ef41Sopenharmony_ci.align	32
7951cb0ef41Sopenharmony_ci_cmll256_decrypt_2x:
7961cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
7971cb0ef41Sopenharmony_ci	camellia_f	%f16, %f6, %f4, %f6
7981cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
7991cb0ef41Sopenharmony_ci	camellia_f	%f18, %f4, %f6, %f4
8001cb0ef41Sopenharmony_ci	ldd		[$key - 8], %f16
8011cb0ef41Sopenharmony_ci	ldd		[$key - 16], %f18
8021cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
8031cb0ef41Sopenharmony_ci	camellia_f	%f20, %f6, %f4, %f6
8041cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
8051cb0ef41Sopenharmony_ci	camellia_f	%f22, %f4, %f6, %f4
8061cb0ef41Sopenharmony_ci	ldd		[$key - 24], %f20
8071cb0ef41Sopenharmony_ci	ldd		[$key - 32], %f22
8081cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f2
8091cb0ef41Sopenharmony_ci	camellia_f	%f24, %f6, %f4, %f6
8101cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f2, %f0
8111cb0ef41Sopenharmony_ci	camellia_f	%f26, %f4, %f6, %f4
8121cb0ef41Sopenharmony_ci	ldd		[$key - 40], %f24
8131cb0ef41Sopenharmony_ci	ldd		[$key - 48], %f26
8141cb0ef41Sopenharmony_ci	camellia_fl	%f28, %f0, %f0
8151cb0ef41Sopenharmony_ci	camellia_fl	%f28, %f4, %f4
8161cb0ef41Sopenharmony_ci	camellia_fli	%f30, %f2, %f2
8171cb0ef41Sopenharmony_ci	camellia_fli	%f30, %f6, %f6
8181cb0ef41Sopenharmony_ci	ldd		[$key - 56], %f28
8191cb0ef41Sopenharmony_ci	ldd		[$key - 64], %f30
8201cb0ef41Sopenharmony_ci___
8211cb0ef41Sopenharmony_cifor ($i=1; $i<3; $i++) {
8221cb0ef41Sopenharmony_ci    $code.=<<___;
8231cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f2, %f0, %f2
8241cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+0`, %f6, %f4, %f6
8251cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f0, %f2, %f0
8261cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+2`, %f4, %f6, %f4
8271cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f2, %f0, %f2
8281cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+4`, %f6, %f4, %f6
8291cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f0, %f2, %f0
8301cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+6`, %f4, %f6, %f4
8311cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f2, %f0, %f2
8321cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+8`, %f6, %f4, %f6
8331cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f0, %f2, %f0
8341cb0ef41Sopenharmony_ci	camellia_f	%f`16+16*$i+10`, %f4, %f6, %f4
8351cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f0,      %f0
8361cb0ef41Sopenharmony_ci	camellia_fl	%f`16+16*$i+12`, %f4,      %f4
8371cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f2,      %f2
8381cb0ef41Sopenharmony_ci	camellia_fli	%f`16+16*$i+14`, %f6,      %f6
8391cb0ef41Sopenharmony_ci___
8401cb0ef41Sopenharmony_ci}
8411cb0ef41Sopenharmony_ci$code.=<<___;
8421cb0ef41Sopenharmony_ci	camellia_f	%f16, %f2, %f0, %f2
8431cb0ef41Sopenharmony_ci	camellia_f	%f16, %f6, %f4, %f6
8441cb0ef41Sopenharmony_ci	camellia_f	%f18, %f0, %f2, %f0
8451cb0ef41Sopenharmony_ci	camellia_f	%f18, %f4, %f6, %f4
8461cb0ef41Sopenharmony_ci	ldd		[$key + 184], %f16
8471cb0ef41Sopenharmony_ci	ldd		[$key + 176], %f18
8481cb0ef41Sopenharmony_ci	camellia_f	%f20, %f2, %f0, %f2
8491cb0ef41Sopenharmony_ci	camellia_f	%f20, %f6, %f4, %f6
8501cb0ef41Sopenharmony_ci	camellia_f	%f22, %f0, %f2, %f0
8511cb0ef41Sopenharmony_ci	camellia_f	%f22, %f4, %f6, %f4
8521cb0ef41Sopenharmony_ci	ldd		[$key + 168], %f20
8531cb0ef41Sopenharmony_ci	ldd		[$key + 160], %f22
8541cb0ef41Sopenharmony_ci	camellia_f	%f24, %f2, %f0, %f8
8551cb0ef41Sopenharmony_ci	camellia_f	%f24, %f6, %f4, %f10
8561cb0ef41Sopenharmony_ci	camellia_f	%f26, %f0, %f8, %f2
8571cb0ef41Sopenharmony_ci	camellia_f	%f26, %f4, %f10, %f6
8581cb0ef41Sopenharmony_ci	ldd		[$key + 152], %f24
8591cb0ef41Sopenharmony_ci	ldd		[$key + 144], %f26
8601cb0ef41Sopenharmony_ci	fxor		%f30, %f8, %f0
8611cb0ef41Sopenharmony_ci	fxor		%f30, %f10, %f4
8621cb0ef41Sopenharmony_ci	fxor		%f28, %f2, %f2
8631cb0ef41Sopenharmony_ci	fxor		%f28, %f6, %f6
8641cb0ef41Sopenharmony_ci	ldd		[$key + 136], %f28
8651cb0ef41Sopenharmony_ci	retl
8661cb0ef41Sopenharmony_ci	ldd		[$key + 128], %f30
8671cb0ef41Sopenharmony_ci.type	_cmll256_decrypt_2x,#function
8681cb0ef41Sopenharmony_ci.size	_cmll256_decrypt_2x,.-_cmll256_decrypt_2x
8691cb0ef41Sopenharmony_ci___
8701cb0ef41Sopenharmony_ci
8711cb0ef41Sopenharmony_ci&alg_cbc_encrypt_implement("cmll",128);
8721cb0ef41Sopenharmony_ci&alg_cbc_encrypt_implement("cmll",256);
8731cb0ef41Sopenharmony_ci
8741cb0ef41Sopenharmony_ci&alg_cbc_decrypt_implement("cmll",128);
8751cb0ef41Sopenharmony_ci&alg_cbc_decrypt_implement("cmll",256);
8761cb0ef41Sopenharmony_ci
8771cb0ef41Sopenharmony_ciif ($::evp) {
8781cb0ef41Sopenharmony_ci    &alg_ctr32_implement("cmll",128);
8791cb0ef41Sopenharmony_ci    &alg_ctr32_implement("cmll",256);
8801cb0ef41Sopenharmony_ci}
8811cb0ef41Sopenharmony_ci}}}
8821cb0ef41Sopenharmony_ci
8831cb0ef41Sopenharmony_ciif (!$::evp) {
8841cb0ef41Sopenharmony_ci$code.=<<___;
8851cb0ef41Sopenharmony_ci.global	Camellia_encrypt
8861cb0ef41Sopenharmony_ciCamellia_encrypt=cmll_t4_encrypt
8871cb0ef41Sopenharmony_ci.global	Camellia_decrypt
8881cb0ef41Sopenharmony_ciCamellia_decrypt=cmll_t4_decrypt
8891cb0ef41Sopenharmony_ci.global	Camellia_set_key
8901cb0ef41Sopenharmony_ci.align	32
8911cb0ef41Sopenharmony_ciCamellia_set_key:
8921cb0ef41Sopenharmony_ci	andcc		%o2, 7, %g0		! double-check alignment
8931cb0ef41Sopenharmony_ci	bnz,a,pn	%icc, 1f
8941cb0ef41Sopenharmony_ci	mov		-1, %o0
8951cb0ef41Sopenharmony_ci	brz,a,pn	%o0, 1f
8961cb0ef41Sopenharmony_ci	mov		-1, %o0
8971cb0ef41Sopenharmony_ci	brz,a,pn	%o2, 1f
8981cb0ef41Sopenharmony_ci	mov		-1, %o0
8991cb0ef41Sopenharmony_ci	andncc		%o1, 0x1c0, %g0
9001cb0ef41Sopenharmony_ci	bnz,a,pn	%icc, 1f
9011cb0ef41Sopenharmony_ci	mov		-2, %o0
9021cb0ef41Sopenharmony_ci	cmp		%o1, 128
9031cb0ef41Sopenharmony_ci	bl,a,pn		%icc, 1f
9041cb0ef41Sopenharmony_ci	mov		-2, %o0
9051cb0ef41Sopenharmony_ci	b		cmll_t4_set_key
9061cb0ef41Sopenharmony_ci	nop
9071cb0ef41Sopenharmony_ci1:	retl
9081cb0ef41Sopenharmony_ci	nop
9091cb0ef41Sopenharmony_ci.type	Camellia_set_key,#function
9101cb0ef41Sopenharmony_ci.size	Camellia_set_key,.-Camellia_set_key
9111cb0ef41Sopenharmony_ci___
9121cb0ef41Sopenharmony_ci
9131cb0ef41Sopenharmony_cimy ($inp,$out,$len,$key,$ivec,$enc)=map("%o$_",(0..5));
9141cb0ef41Sopenharmony_ci
9151cb0ef41Sopenharmony_ci$code.=<<___;
9161cb0ef41Sopenharmony_ci.globl	Camellia_cbc_encrypt
9171cb0ef41Sopenharmony_ci.align	32
9181cb0ef41Sopenharmony_ciCamellia_cbc_encrypt:
9191cb0ef41Sopenharmony_ci	ld		[$key + 272], %g1
9201cb0ef41Sopenharmony_ci	nop
9211cb0ef41Sopenharmony_ci	brz		$enc, .Lcbc_decrypt
9221cb0ef41Sopenharmony_ci	cmp		%g1, 3
9231cb0ef41Sopenharmony_ci
9241cb0ef41Sopenharmony_ci	be,pt		%icc, cmll128_t4_cbc_encrypt
9251cb0ef41Sopenharmony_ci	nop
9261cb0ef41Sopenharmony_ci	ba		cmll256_t4_cbc_encrypt
9271cb0ef41Sopenharmony_ci	nop
9281cb0ef41Sopenharmony_ci
9291cb0ef41Sopenharmony_ci.Lcbc_decrypt:
9301cb0ef41Sopenharmony_ci	be,pt		%icc, cmll128_t4_cbc_decrypt
9311cb0ef41Sopenharmony_ci	nop
9321cb0ef41Sopenharmony_ci	ba		cmll256_t4_cbc_decrypt
9331cb0ef41Sopenharmony_ci	nop
9341cb0ef41Sopenharmony_ci.type	Camellia_cbc_encrypt,#function
9351cb0ef41Sopenharmony_ci.size	Camellia_cbc_encrypt,.-Camellia_cbc_encrypt
9361cb0ef41Sopenharmony_ci___
9371cb0ef41Sopenharmony_ci}
9381cb0ef41Sopenharmony_ci
9391cb0ef41Sopenharmony_ci&emit_assembler();
9401cb0ef41Sopenharmony_ci
9411cb0ef41Sopenharmony_ciclose STDOUT or die "error closing STDOUT: $!";
942