3 # ====================================================================
4 # Written by David S. Miller <davem@devemloft.net> and Andy Polyakov
5 # <appro@openssl.org>. The module is licensed under 2-clause BSD
6 # license. October 2012. All rights reserved.
7 # ====================================================================
9 ######################################################################
12 # AES round instructions complete in 3 cycles and can be issued every
13 # cycle. It means that round calculations should take 4*rounds cycles,
14 # because any given round instruction depends on result of *both*
15 # previous instructions:
23 # Provided that fxor [with IV] takes 3 cycles to complete, critical
24 # path length for CBC encrypt would be 3+4*rounds, or in other words
25 # it should process one byte in at least (3+4*rounds)/16 cycles. This
26 # estimate doesn't account for "collateral" instructions, such as
27 # fetching input from memory, xor-ing it with zero-round key and
28 # storing the result. Yet, *measured* performance [for data aligned
29 # at 64-bit boundary!] deviates from this equation by less than 0.5%:
31 # 128-bit key 192- 256-
32 # CBC encrypt 2.70/2.90(*) 3.20/3.40 3.70/3.90
33 # (*) numbers after slash are for
36 # Out-of-order execution logic managed to fully overlap "collateral"
37 # instructions with those on critical path. Amazing!
39 # As with Intel AES-NI, question is if it's possible to improve
40 # performance of parallelizeable modes by interleaving round
41 # instructions. Provided round instruction latency and throughput
42 # optimal interleave factor is 2. But can we expect 2x performance
43 # improvement? Well, as round instructions can be issued one per
44 # cycle, they don't saturate the 2-way issue pipeline and therefore
45 # there is room for "collateral" calculations... Yet, 2x speed-up
46 # over CBC encrypt remains unattaintable:
48 # 128-bit key 192- 256-
49 # CBC decrypt 1.64/2.11 1.89/2.37 2.23/2.61
50 # CTR 1.64/2.08(*) 1.89/2.33 2.23/2.61
51 # (*) numbers after slash are for
54 # Estimates based on amount of instructions under assumption that
55 # round instructions are not pairable with any other instruction
56 # suggest that latter is the actual case and pipeline runs
57 # underutilized. It should be noted that T4 out-of-order execution
58 # logic is so capable that performance gain from 2x interleave is
59 # not even impressive, ~7-13% over non-interleaved code, largest
62 # To anchor to something else, software implementation processes
63 # one byte in 29 cycles with 128-bit key on same processor. Intel
64 # Sandy Bridge encrypts byte in 5.07 cycles in CBC mode and decrypts
65 # in 0.93, naturally with AES-NI.
67 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
68 push(@INC,"${dir}","${dir}../../perlasm");
69 require "sparcv9_modes.pl";
72 open STDOUT,">$output";
74 $::evp=1; # if $evp is set to 0, script generates module with
75 # AES_[en|de]crypt, AES_set_[en|de]crypt_key and AES_cbc_encrypt entry
76 # points. These however are not fully compatible with openssl/aes.h,
77 # because they expect AES_KEY to be aligned at 64-bit boundary. When
78 # used through EVP, alignment is arranged at EVP layer. Second thing
79 # that is arranged by EVP is at least 32-bit alignment of IV.
81 ######################################################################
82 # single-round subroutines
85 my ($inp,$out,$key,$rounds,$tmp,$mask)=map("%o$_",(0..5));
88 #include "sparc_arch.h"
91 .register %g2,#scratch
92 .register %g3,#scratch
100 andcc $inp, 7, %g1 ! is input aligned?
109 ldx [$inp + 16], $inp
119 ld [$key + 240], $rounds
120 ldd [$key + 16], %f12
121 ldd [$key + 24], %f14
126 srl $rounds, 1, $rounds
127 ldd [$key + 32], %f16
128 sub $rounds, 1, $rounds
129 ldd [$key + 40], %f18
133 aes_eround01 %f12, %f0, %f2, %f4
134 aes_eround23 %f14, %f0, %f2, %f2
137 sub $rounds,1,$rounds
138 aes_eround01 %f16, %f4, %f2, %f0
139 aes_eround23 %f18, %f4, %f2, %f2
140 ldd [$key + 16], %f16
141 ldd [$key + 24], %f18
142 brnz,pt $rounds, .Lenc
145 andcc $out, 7, $tmp ! is output aligned?
146 aes_eround01 %f12, %f0, %f2, %f4
147 aes_eround23 %f14, %f0, %f2, %f2
148 aes_eround01_l %f16, %f4, %f2, %f0
149 aes_eround23_l %f18, %f4, %f2, %f2
158 2: alignaddrl $out, %g0, $out
160 srl $mask, $tmp, $mask
162 faligndata %f0, %f0, %f4
163 faligndata %f0, %f2, %f6
164 faligndata %f2, %f2, %f8
166 stda %f4, [$out + $mask]0xc0 ! partial store
169 orn %g0, $mask, $mask
171 stda %f8, [$out + $mask]0xc0 ! partial store
172 .type aes_t4_encrypt,#function
173 .size aes_t4_encrypt,.-aes_t4_encrypt
175 .globl aes_t4_decrypt
178 andcc $inp, 7, %g1 ! is input aligned?
187 ldx [$inp + 16], $inp
197 ld [$key + 240], $rounds
198 ldd [$key + 16], %f12
199 ldd [$key + 24], %f14
204 srl $rounds, 1, $rounds
205 ldd [$key + 32], %f16
206 sub $rounds, 1, $rounds
207 ldd [$key + 40], %f18
211 aes_dround01 %f12, %f0, %f2, %f4
212 aes_dround23 %f14, %f0, %f2, %f2
215 sub $rounds,1,$rounds
216 aes_dround01 %f16, %f4, %f2, %f0
217 aes_dround23 %f18, %f4, %f2, %f2
218 ldd [$key + 16], %f16
219 ldd [$key + 24], %f18
220 brnz,pt $rounds, .Ldec
223 andcc $out, 7, $tmp ! is output aligned?
224 aes_dround01 %f12, %f0, %f2, %f4
225 aes_dround23 %f14, %f0, %f2, %f2
226 aes_dround01_l %f16, %f4, %f2, %f0
227 aes_dround23_l %f18, %f4, %f2, %f2
236 2: alignaddrl $out, %g0, $out
238 srl $mask, $tmp, $mask
240 faligndata %f0, %f0, %f4
241 faligndata %f0, %f2, %f6
242 faligndata %f2, %f2, %f8
244 stda %f4, [$out + $mask]0xc0 ! partial store
247 orn %g0, $mask, $mask
249 stda %f8, [$out + $mask]0xc0 ! partial store
250 .type aes_t4_decrypt,#function
251 .size aes_t4_decrypt,.-aes_t4_decrypt
255 ######################################################################
256 # key setup subroutines
259 my ($inp,$bits,$out,$tmp)=map("%o$_",(0..5));
261 .globl aes_t4_set_encrypt_key
263 aes_t4_set_encrypt_key:
266 alignaddr $inp, %g0, $inp
274 brz,pt $tmp, .L256aligned
278 faligndata %f0, %f2, %f0
279 faligndata %f2, %f4, %f2
280 faligndata %f4, %f6, %f4
281 faligndata %f6, %f8, %f6
284 for ($i=0; $i<6; $i++) {
286 std %f0, [$out + `32*$i+0`]
287 aes_kexpand1 %f0, %f6, $i, %f0
288 std %f2, [$out + `32*$i+8`]
289 aes_kexpand2 %f2, %f0, %f2
290 std %f4, [$out + `32*$i+16`]
291 aes_kexpand0 %f4, %f2, %f4
292 std %f6, [$out + `32*$i+24`]
293 aes_kexpand2 %f6, %f4, %f6
297 std %f0, [$out + `32*$i+0`]
298 aes_kexpand1 %f0, %f6, $i, %f0
299 std %f2, [$out + `32*$i+8`]
300 aes_kexpand2 %f2, %f0, %f2
301 std %f4, [$out + `32*$i+16`]
302 std %f6, [$out + `32*$i+24`]
303 std %f0, [$out + `32*$i+32`]
304 std %f2, [$out + `32*$i+40`]
307 st $tmp, [$out + 240]
313 brz,pt $tmp, .L192aligned
317 faligndata %f0, %f2, %f0
318 faligndata %f2, %f4, %f2
319 faligndata %f4, %f6, %f4
322 for ($i=0; $i<7; $i++) {
324 std %f0, [$out + `24*$i+0`]
325 aes_kexpand1 %f0, %f4, $i, %f0
326 std %f2, [$out + `24*$i+8`]
327 aes_kexpand2 %f2, %f0, %f2
328 std %f4, [$out + `24*$i+16`]
329 aes_kexpand2 %f4, %f2, %f4
333 std %f0, [$out + `24*$i+0`]
334 aes_kexpand1 %f0, %f4, $i, %f0
335 std %f2, [$out + `24*$i+8`]
336 aes_kexpand2 %f2, %f0, %f2
337 std %f4, [$out + `24*$i+16`]
338 std %f0, [$out + `24*$i+24`]
339 std %f2, [$out + `24*$i+32`]
342 st $tmp, [$out + 240]
348 brz,pt $tmp, .L128aligned
352 faligndata %f0, %f2, %f0
353 faligndata %f2, %f4, %f2
356 for ($i=0; $i<10; $i++) {
358 std %f0, [$out + `16*$i+0`]
359 aes_kexpand1 %f0, %f2, $i, %f0
360 std %f2, [$out + `16*$i+8`]
361 aes_kexpand2 %f2, %f0, %f2
365 std %f0, [$out + `16*$i+0`]
366 std %f2, [$out + `16*$i+8`]
369 st $tmp, [$out + 240]
372 .type aes_t4_set_encrypt_key,#function
373 .size aes_t4_set_encrypt_key,.-aes_t4_set_encrypt_key
375 .globl aes_t4_set_decrypt_key
377 aes_t4_set_decrypt_key:
379 call .Lset_encrypt_key
383 sll $tmp, 4, $inp ! $tmp is number of rounds
385 add $out, $inp, $inp ! $inp=$out+16*rounds
386 srl $tmp, 2, $tmp ! $tmp=(rounds+2)/4
395 ldd [$inp - 16], %f12
404 std %f12, [$out + 16]
405 std %f14, [$out + 24]
407 brnz $tmp, .Lkey_flip
412 .type aes_t4_set_decrypt_key,#function
413 .size aes_t4_set_decrypt_key,.-aes_t4_set_decrypt_key
418 my ($inp,$out,$len,$key,$ivec,$enc)=map("%i$_",(0..5));
419 my ($ileft,$iright,$ooff,$omask,$ivoff)=map("%l$_",(1..7));
425 for ($i=0; $i<4; $i++) {
427 aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
428 aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
429 aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
430 aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
434 aes_eround01 %f48, %f0, %f2, %f4
435 aes_eround23 %f50, %f0, %f2, %f2
436 aes_eround01_l %f52, %f4, %f2, %f0
438 aes_eround23_l %f54, %f4, %f2, %f2
439 .type _aes128_encrypt_1x,#function
440 .size _aes128_encrypt_1x,.-_aes128_encrypt_1x
445 for ($i=0; $i<4; $i++) {
447 aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
448 aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
449 aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
450 aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
451 aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
452 aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
453 aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
454 aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
458 aes_eround01 %f48, %f0, %f2, %f8
459 aes_eround23 %f50, %f0, %f2, %f2
460 aes_eround01 %f48, %f4, %f6, %f10
461 aes_eround23 %f50, %f4, %f6, %f6
462 aes_eround01_l %f52, %f8, %f2, %f0
463 aes_eround23_l %f54, %f8, %f2, %f2
464 aes_eround01_l %f52, %f10, %f6, %f4
466 aes_eround23_l %f54, %f10, %f6, %f6
467 .type _aes128_encrypt_2x,#function
468 .size _aes128_encrypt_2x,.-_aes128_encrypt_2x
475 for ($i=2; $i<22;$i++) { # load key schedule
477 ldd [$key + `8*$i`], %f`12+2*$i`
483 .type _aes128_loadkey,#function
484 .size _aes128_loadkey,.-_aes128_loadkey
485 _aes128_load_enckey=_aes128_loadkey
486 _aes128_load_deckey=_aes128_loadkey
490 &alg_cbc_encrypt_implement("aes",128);
492 &alg_ctr32_implement("aes",128);
493 &alg_xts_implement("aes",128,"en");
494 &alg_xts_implement("aes",128,"de");
496 &alg_cbc_decrypt_implement("aes",128);
502 for ($i=0; $i<4; $i++) {
504 aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
505 aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
506 aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
507 aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
511 aes_dround01 %f48, %f0, %f2, %f4
512 aes_dround23 %f50, %f0, %f2, %f2
513 aes_dround01_l %f52, %f4, %f2, %f0
515 aes_dround23_l %f54, %f4, %f2, %f2
516 .type _aes128_decrypt_1x,#function
517 .size _aes128_decrypt_1x,.-_aes128_decrypt_1x
522 for ($i=0; $i<4; $i++) {
524 aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
525 aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
526 aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
527 aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
528 aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
529 aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
530 aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
531 aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
535 aes_dround01 %f48, %f0, %f2, %f8
536 aes_dround23 %f50, %f0, %f2, %f2
537 aes_dround01 %f48, %f4, %f6, %f10
538 aes_dround23 %f50, %f4, %f6, %f6
539 aes_dround01_l %f52, %f8, %f2, %f0
540 aes_dround23_l %f54, %f8, %f2, %f2
541 aes_dround01_l %f52, %f10, %f6, %f4
543 aes_dround23_l %f54, %f10, %f6, %f6
544 .type _aes128_decrypt_2x,#function
545 .size _aes128_decrypt_2x,.-_aes128_decrypt_2x
552 for ($i=0; $i<5; $i++) {
554 aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
555 aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
556 aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
557 aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
561 aes_eround01 %f56, %f0, %f2, %f4
562 aes_eround23 %f58, %f0, %f2, %f2
563 aes_eround01_l %f60, %f4, %f2, %f0
565 aes_eround23_l %f62, %f4, %f2, %f2
566 .type _aes192_encrypt_1x,#function
567 .size _aes192_encrypt_1x,.-_aes192_encrypt_1x
572 for ($i=0; $i<5; $i++) {
574 aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
575 aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
576 aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
577 aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
578 aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
579 aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
580 aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
581 aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
585 aes_eround01 %f56, %f0, %f2, %f8
586 aes_eround23 %f58, %f0, %f2, %f2
587 aes_eround01 %f56, %f4, %f6, %f10
588 aes_eround23 %f58, %f4, %f6, %f6
589 aes_eround01_l %f60, %f8, %f2, %f0
590 aes_eround23_l %f62, %f8, %f2, %f2
591 aes_eround01_l %f60, %f10, %f6, %f4
593 aes_eround23_l %f62, %f10, %f6, %f6
594 .type _aes192_encrypt_2x,#function
595 .size _aes192_encrypt_2x,.-_aes192_encrypt_2x
599 aes_eround01 %f16, %f0, %f2, %f4
600 aes_eround23 %f18, %f0, %f2, %f2
601 ldd [$key + 208], %f16
602 ldd [$key + 216], %f18
603 aes_eround01 %f20, %f4, %f2, %f0
604 aes_eround23 %f22, %f4, %f2, %f2
605 ldd [$key + 224], %f20
606 ldd [$key + 232], %f22
608 for ($i=1; $i<6; $i++) {
610 aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f4
611 aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
612 aes_eround01 %f`16+8*$i+4`, %f4, %f2, %f0
613 aes_eround23 %f`16+8*$i+6`, %f4, %f2, %f2
617 aes_eround01 %f16, %f0, %f2, %f4
618 aes_eround23 %f18, %f0, %f2, %f2
619 ldd [$key + 16], %f16
620 ldd [$key + 24], %f18
621 aes_eround01_l %f20, %f4, %f2, %f0
622 aes_eround23_l %f22, %f4, %f2, %f2
623 ldd [$key + 32], %f20
625 ldd [$key + 40], %f22
626 .type _aes256_encrypt_1x,#function
627 .size _aes256_encrypt_1x,.-_aes256_encrypt_1x
631 aes_eround01 %f16, %f0, %f2, %f8
632 aes_eround23 %f18, %f0, %f2, %f2
633 aes_eround01 %f16, %f4, %f6, %f10
634 aes_eround23 %f18, %f4, %f6, %f6
635 ldd [$key + 208], %f16
636 ldd [$key + 216], %f18
637 aes_eround01 %f20, %f8, %f2, %f0
638 aes_eround23 %f22, %f8, %f2, %f2
639 aes_eround01 %f20, %f10, %f6, %f4
640 aes_eround23 %f22, %f10, %f6, %f6
641 ldd [$key + 224], %f20
642 ldd [$key + 232], %f22
644 for ($i=1; $i<6; $i++) {
646 aes_eround01 %f`16+8*$i+0`, %f0, %f2, %f8
647 aes_eround23 %f`16+8*$i+2`, %f0, %f2, %f2
648 aes_eround01 %f`16+8*$i+0`, %f4, %f6, %f10
649 aes_eround23 %f`16+8*$i+2`, %f4, %f6, %f6
650 aes_eround01 %f`16+8*$i+4`, %f8, %f2, %f0
651 aes_eround23 %f`16+8*$i+6`, %f8, %f2, %f2
652 aes_eround01 %f`16+8*$i+4`, %f10, %f6, %f4
653 aes_eround23 %f`16+8*$i+6`, %f10, %f6, %f6
657 aes_eround01 %f16, %f0, %f2, %f8
658 aes_eround23 %f18, %f0, %f2, %f2
659 aes_eround01 %f16, %f4, %f6, %f10
660 aes_eround23 %f18, %f4, %f6, %f6
661 ldd [$key + 16], %f16
662 ldd [$key + 24], %f18
663 aes_eround01_l %f20, %f8, %f2, %f0
664 aes_eround23_l %f22, %f8, %f2, %f2
665 aes_eround01_l %f20, %f10, %f6, %f4
666 aes_eround23_l %f22, %f10, %f6, %f6
667 ldd [$key + 32], %f20
669 ldd [$key + 40], %f22
670 .type _aes256_encrypt_2x,#function
671 .size _aes256_encrypt_2x,.-_aes256_encrypt_2x
678 for ($i=2; $i<26;$i++) { # load key schedule
680 ldd [$key + `8*$i`], %f`12+2*$i`
686 .type _aes192_loadkey,#function
687 .size _aes192_loadkey,.-_aes192_loadkey
688 _aes256_loadkey=_aes192_loadkey
689 _aes192_load_enckey=_aes192_loadkey
690 _aes192_load_deckey=_aes192_loadkey
691 _aes256_load_enckey=_aes192_loadkey
692 _aes256_load_deckey=_aes192_loadkey
695 &alg_cbc_encrypt_implement("aes",256);
696 &alg_cbc_encrypt_implement("aes",192);
698 &alg_ctr32_implement("aes",256);
699 &alg_xts_implement("aes",256,"en");
700 &alg_xts_implement("aes",256,"de");
701 &alg_ctr32_implement("aes",192);
703 &alg_cbc_decrypt_implement("aes",192);
704 &alg_cbc_decrypt_implement("aes",256);
709 aes_dround01 %f16, %f0, %f2, %f4
710 aes_dround23 %f18, %f0, %f2, %f2
711 ldd [$key + 208], %f16
712 ldd [$key + 216], %f18
713 aes_dround01 %f20, %f4, %f2, %f0
714 aes_dround23 %f22, %f4, %f2, %f2
715 ldd [$key + 224], %f20
716 ldd [$key + 232], %f22
718 for ($i=1; $i<6; $i++) {
720 aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
721 aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
722 aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
723 aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
727 aes_dround01 %f16, %f0, %f2, %f4
728 aes_dround23 %f18, %f0, %f2, %f2
729 ldd [$key + 16], %f16
730 ldd [$key + 24], %f18
731 aes_dround01_l %f20, %f4, %f2, %f0
732 aes_dround23_l %f22, %f4, %f2, %f2
733 ldd [$key + 32], %f20
735 ldd [$key + 40], %f22
736 .type _aes256_decrypt_1x,#function
737 .size _aes256_decrypt_1x,.-_aes256_decrypt_1x
741 aes_dround01 %f16, %f0, %f2, %f8
742 aes_dround23 %f18, %f0, %f2, %f2
743 aes_dround01 %f16, %f4, %f6, %f10
744 aes_dround23 %f18, %f4, %f6, %f6
745 ldd [$key + 208], %f16
746 ldd [$key + 216], %f18
747 aes_dround01 %f20, %f8, %f2, %f0
748 aes_dround23 %f22, %f8, %f2, %f2
749 aes_dround01 %f20, %f10, %f6, %f4
750 aes_dround23 %f22, %f10, %f6, %f6
751 ldd [$key + 224], %f20
752 ldd [$key + 232], %f22
754 for ($i=1; $i<6; $i++) {
756 aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
757 aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
758 aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
759 aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
760 aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
761 aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
762 aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
763 aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
767 aes_dround01 %f16, %f0, %f2, %f8
768 aes_dround23 %f18, %f0, %f2, %f2
769 aes_dround01 %f16, %f4, %f6, %f10
770 aes_dround23 %f18, %f4, %f6, %f6
771 ldd [$key + 16], %f16
772 ldd [$key + 24], %f18
773 aes_dround01_l %f20, %f8, %f2, %f0
774 aes_dround23_l %f22, %f8, %f2, %f2
775 aes_dround01_l %f20, %f10, %f6, %f4
776 aes_dround23_l %f22, %f10, %f6, %f6
777 ldd [$key + 32], %f20
779 ldd [$key + 40], %f22
780 .type _aes256_decrypt_2x,#function
781 .size _aes256_decrypt_2x,.-_aes256_decrypt_2x
786 for ($i=0; $i<5; $i++) {
788 aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f4
789 aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
790 aes_dround01 %f`16+8*$i+4`, %f4, %f2, %f0
791 aes_dround23 %f`16+8*$i+6`, %f4, %f2, %f2
795 aes_dround01 %f56, %f0, %f2, %f4
796 aes_dround23 %f58, %f0, %f2, %f2
797 aes_dround01_l %f60, %f4, %f2, %f0
799 aes_dround23_l %f62, %f4, %f2, %f2
800 .type _aes192_decrypt_1x,#function
801 .size _aes192_decrypt_1x,.-_aes192_decrypt_1x
806 for ($i=0; $i<5; $i++) {
808 aes_dround01 %f`16+8*$i+0`, %f0, %f2, %f8
809 aes_dround23 %f`16+8*$i+2`, %f0, %f2, %f2
810 aes_dround01 %f`16+8*$i+0`, %f4, %f6, %f10
811 aes_dround23 %f`16+8*$i+2`, %f4, %f6, %f6
812 aes_dround01 %f`16+8*$i+4`, %f8, %f2, %f0
813 aes_dround23 %f`16+8*$i+6`, %f8, %f2, %f2
814 aes_dround01 %f`16+8*$i+4`, %f10, %f6, %f4
815 aes_dround23 %f`16+8*$i+6`, %f10, %f6, %f6
819 aes_dround01 %f56, %f0, %f2, %f8
820 aes_dround23 %f58, %f0, %f2, %f2
821 aes_dround01 %f56, %f4, %f6, %f10
822 aes_dround23 %f58, %f4, %f6, %f6
823 aes_dround01_l %f60, %f8, %f2, %f0
824 aes_dround23_l %f62, %f8, %f2, %f2
825 aes_dround01_l %f60, %f10, %f6, %f4
827 aes_dround23_l %f62, %f10, %f6, %f6
828 .type _aes192_decrypt_2x,#function
829 .size _aes192_decrypt_2x,.-_aes192_decrypt_2x
836 AES_encrypt=aes_t4_encrypt
838 AES_decrypt=aes_t4_decrypt
839 .global AES_set_encrypt_key
842 andcc %o2, 7, %g0 ! check alignment
849 andncc %o1, 0x1c0, %g0
855 b aes_t4_set_encrypt_key
859 .type AES_set_encrypt_key,#function
860 .size AES_set_encrypt_key,.-AES_set_encrypt_key
862 .global AES_set_decrypt_key
865 andcc %o2, 7, %g0 ! check alignment
872 andncc %o1, 0x1c0, %g0
878 b aes_t4_set_decrypt_key
882 .type AES_set_decrypt_key,#function
883 .size AES_set_decrypt_key,.-AES_set_decrypt_key
886 my ($inp,$out,$len,$key,$ivec,$enc)=map("%o$_",(0..5));
889 .globl AES_cbc_encrypt
894 brz $enc, .Lcbc_decrypt
897 bl,pt %icc, aes128_t4_cbc_encrypt
899 be,pn %icc, aes192_t4_cbc_encrypt
901 ba aes256_t4_cbc_encrypt
905 bl,pt %icc, aes128_t4_cbc_decrypt
907 be,pn %icc, aes192_t4_cbc_decrypt
909 ba aes256_t4_cbc_decrypt
911 .type AES_cbc_encrypt,#function
912 .size AES_cbc_encrypt,.-AES_cbc_encrypt
916 .asciz "AES for SPARC T4, David S. Miller, Andy Polyakov"