2 ! des_enc.S (generated from des_enc.m4)
4 ! UltraSPARC assembler version of the LibDES/SSLeay/OpenSSL des_enc.c file.
6 ! Version 1.0. 32-bit version.
10 ! Version 2.0. 32/64-bit, PIC-ification, blended CPU adaptation
15 ! Assembler version: Copyright Svend Olaf Mikkelsen.
17 ! Original C code: Copyright Eric A. Young.
19 ! This code can be freely used by LibDES/SSLeay/OpenSSL users.
21 ! The LibDES/SSLeay/OpenSSL copyright notices must be respected.
23 ! This version can be redistributed.
25 ! To expand the m4 macros: m4 -B 8192 des_enc.m4 > des_enc.S
27 ! Global registers 1 to 5 are used. This is the same as done by the
28 ! cc compiler. The UltraSPARC load/store little endian feature is used.
30 ! Instruction grouping often refers to one CPU cycle.
32 ! Assemble through gcc: gcc -c -mcpu=ultrasparc -o des_enc.o des_enc.S
34 ! Assemble through cc: cc -c -xarch=v8plusa -o des_enc.o des_enc.S
36 ! Performance improvement according to './apps/openssl speed des'
39 ! 23% faster than cc-5.2 -xarch=v8plus -xO5
40 ! 115% faster than gcc-3.2.1 -m32 -mcpu=ultrasparc -O5
42 ! 50% faster than cc-5.2 -xarch=v9 -xO5
43 ! 100% faster than gcc-3.2.1 -m64 -mcpu=ultrasparc -O5
46 .ident "des_enc.m4 2.1"
47 .file "des_enc-sparc.S"
49 #if defined(__SUNPRO_C) && defined(__sparcv9)
50 # define ABI64 /* They've said -xarch=v9 at command line */
51 #elif defined(__GNUC__) && defined(__arch64__)
52 # define ABI64 /* They've said -m64 at command line */
56 .register %g2,#scratch
57 .register %g3,#scratch
122 ! The logic used in initial and final permutations is the same as in
123 ! the C code. The permutations are done with a clever , xor, and
126 ! The macro also loads address sbox 1 to 5 to global 1 to 5, address
127 ! sbox 6 to local6, and addres sbox 8 to out3.
129 ! Rotates the halfs 3 left to bring the sbox bits in convenient positions.
131 ! Loads key first round from address in parameter 5 to out0, out1.
133 ! After the the original LibDES initial permutation, the resulting left
134 ! is in the variable initially used for right and vice versa. The macro
135 ! implements the possibility to keep the halfs in the original registers.
139 ! parameter 3 result left (modify in first round)
140 ! parameter 4 result right (use in first round)
141 ! parameter 5 key address
142 ! parameter 6 1/2 for include encryption/decryption
143 ! parameter 7 1 for move in1 to in3
144 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
145 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
152 ! The logic used in the DES rounds is the same as in the C code,
153 ! except that calculations for sbox 1 and sbox 5 begin before
154 ! the previous round is finished.
156 ! In each round one half (work) is modified based on key and the
159 ! In this version we do two rounds in a loop repeated 7 times
160 ! and two rounds seperately.
162 ! One half has the bits for the sboxes in the following positions:
164 ! 777777xx555555xx333333xx111111xx
166 ! 88xx666666xx444444xx222222xx8888
168 ! The bits for each sbox are xor-ed with the key bits for that box.
169 ! The above xx bits are cleared, and the result used for lookup in
170 ! the sbox table. Each sbox entry contains the 4 output bits permuted
171 ! into 32 bits according to the P permutation.
173 ! In the description of DES, left and right are switched after
174 ! each round, except after last round. In this code the original
175 ! left and right are kept in the same register in all rounds, meaning
176 ! that after the 16 rounds the result for right is in the register
177 ! originally used for left.
179 ! parameter 1 first work (left in first round)
180 ! parameter 2 first use (right in first round)
181 ! parameter 3 enc/dec 1/-1
182 ! parameter 4 loop label
183 ! parameter 5 key address register
184 ! parameter 6 optional address for key next encryption/decryption
185 ! parameter 7 not empty for include retl
187 ! also compares in2 to 8
194 ! parameter 1 right (original left)
195 ! parameter 2 left (original right)
196 ! parameter 3 1 for optional store to [in0]
197 ! parameter 4 1 for load input/output address to local5/7
199 ! The final permutation logic switches the halfes, meaning that
200 ! left and right ends up the the registers originally used.
207 ! Does initial permutation for next block mixed with
208 ! final permutation for current block.
210 ! parameter 1 original left
211 ! parameter 2 original right
212 ! parameter 3 left ip
213 ! parameter 4 right ip
214 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
217 ! also adds -8 to length in2 and loads loop counter to out4
225 ! parameter 1 address
226 ! parameter 2 destination left
227 ! parameter 3 destination right
228 ! parameter 4 temporar
234 ! load_little_endian_inc
236 ! parameter 1 address
237 ! parameter 2 destination left
238 ! parameter 3 destination right
239 ! parameter 4 temporar
249 ! Loads 1 to 7 bytes little endian
250 ! Remaining bytes are zeroed.
252 ! parameter 1 address
254 ! parameter 3 destination register left
255 ! parameter 4 destination register right
259 ! parameter 8 return label
264 ! store_little_endian
266 ! parameter 1 address
267 ! parameter 2 source left
268 ! parameter 3 source right
269 ! parameter 4 temporar
276 ! Stores 1 to 7 bytes little endian
278 ! parameter 1 address
280 ! parameter 3 source register left
281 ! parameter 4 source register right
285 ! parameter 8 return label
301 ! loads key next encryption/decryption first round from [in4]
306 ! in5 out5 1 .des_enc.1 in3 in4 retl
308 xor out5, out0, local1
310 ld [out2+284], local5 ! 0x0000FC00
312 and local1, 252, local1
317 ! local6 is address sbox 6
318 ! out3 is address sbox 8
319 ! out4 is loop counter
321 ld [global1+local1], local1
322 xor out5, out1, out1 ! 8642
323 xor out5, out0, out0 ! 7531
324 ! fmovs %f0, %f0 ! fxor used for alignment
326 srl out1, 4, local0 ! rotate 4 right
327 and out0, local5, local3 ! 3
330 ld [in3+1*8], local7 ! key 7531 next round
331 srl local3, 8, local3 ! 3
332 and local0, 252, local2 ! 2
335 ld [global3+local3],local3 ! 3
336 sll out1, 28, out1 ! rotate
337 xor in5, local1, in5 ! 1 finished, local1 now sbox 7
339 ld [global2+local2], local2 ! 2
340 srl out0, 24, local1 ! 7
341 or out1, local0, out1 ! rotate
343 ldub [out2+local1], local1 ! 7 (and 0xFC)
344 srl out1, 24, local0 ! 8
345 and out1, local5, local4 ! 4
347 ldub [out2+local0], local0 ! 8 (and 0xFC)
348 srl local4, 8, local4 ! 4
349 xor in5, local2, in5 ! 2 finished local2 now sbox 6
351 ld [global4+local4],local4 ! 4
352 srl out1, 16, local2 ! 6
353 xor in5, local3, in5 ! 3 finished local3 now sbox 5
355 ld [out3+local0],local0 ! 8
356 and local2, 252, local2 ! 6
357 add global1, 1536, local5 ! address sbox 7
359 ld [local6+local2], local2 ! 6
360 srl out0, 16, local3 ! 5
361 xor in5, local4, in5 ! 4 finished
363 ld [local5+local1],local1 ! 7
364 and local3, 252, local3 ! 5
365 xor in5, local0, in5 ! 8 finished
367 ld [global5+local3],local3 ! 5
368 xor in5, local2, in5 ! 6 finished
371 ld [in3+1*8+4], out0 ! key 8642 next round
372 xor in5, local7, local2 ! sbox 5 next round
373 xor in5, local1, in5 ! 7 finished
375 srl local2, 16, local2 ! sbox 5 next round
376 xor in5, local3, in5 ! 5 finished
378 ld [in3+1*16+4], out1 ! key 8642 next round again
379 and local2, 252, local2 ! sbox5 next round
381 xor in5, local7, local7 ! 7531
383 ld [global5+local2], local2 ! 5
384 srl local7, 24, local3 ! 7
385 xor in5, out0, out0 ! 8642
387 ldub [out2+local3], local3 ! 7 (and 0xFC)
388 srl out0, 4, local0 ! rotate 4 right
389 and local7, 252, local1 ! 1
391 sll out0, 28, out0 ! rotate
392 xor out5, local2, out5 ! 5 finished local2 used
394 srl local0, 8, local4 ! 4
395 and local0, 252, local2 ! 2
396 ld [local5+local3], local3 ! 7
398 srl local0, 16, local5 ! 6
399 or out0, local0, out0 ! rotate
400 ld [global2+local2], local2 ! 2
403 ld [in3+1*16], out0 ! key 7531 next round
404 and local4, 252, local4 ! 4
406 and local5, 252, local5 ! 6
407 ld [global4+local4], local4 ! 4
408 xor out5, local3, out5 ! 7 finished local3 used
410 and local0, 252, local0 ! 8
411 ld [local6+local5], local5 ! 6
412 xor out5, local2, out5 ! 2 finished local2 now sbox 3
414 srl local7, 8, local2 ! 3 start
415 ld [out3+local0], local0 ! 8
416 xor out5, local4, out5 ! 4 finished
418 and local2, 252, local2 ! 3
419 ld [global1+local1], local1 ! 1
420 xor out5, local5, out5 ! 6 finished local5 used
422 ld [global3+local2], local2 ! 3
423 xor out5, local0, out5 ! 8 finished
424 add in3, 1*16, in3 ! enc add 8, dec add -8 to key pointer
426 ld [out2+284], local5 ! 0x0000FC00
427 xor out5, out0, local4 ! sbox 1 next round
428 xor out5, local1, out5 ! 1 finished
430 xor out5, local2, out5 ! 3 finished
432 bne,pt %icc, .des_enc.1
436 and local4, 252, local1 ! sbox 1 next round
440 ld [global1+local1], local1
444 srl out1, 4, local0 ! rotate
445 and out0, local5, local3
447 ld [in3+1*8], local7 ! key 7531
448 srl local3, 8, local3
449 and local0, 252, local2
451 ld [global3+local3],local3
452 sll out1, 28, out1 ! rotate
453 xor in5, local1, in5 ! 1 finished, local1 now sbox 7
455 ld [global2+local2], local2
457 or out1, local0, out1 ! rotate
459 ldub [out2+local1], local1
461 and out1, local5, local4
463 ldub [out2+local0], local0
464 srl local4, 8, local4
465 xor in5, local2, in5 ! 2 finished local2 now sbox 6
467 ld [global4+local4],local4
469 xor in5, local3, in5 ! 3 finished local3 now sbox 5
471 ld [out3+local0],local0
472 and local2, 252, local2
473 add global1, 1536, local5 ! address sbox 7
475 ld [local6+local2], local2
477 xor in5, local4, in5 ! 4 finished
479 ld [local5+local1],local1
480 and local3, 252, local3
483 ld [global5+local3],local3
484 xor in5, local2, in5 ! 6 finished
487 ld [out2+280], out4 ! loop counter
488 xor in5, local7, local2 ! sbox 5 next round
489 xor in5, local1, in5 ! 7 finished
492 srl local2, 16, local2 ! sbox 5 next round
493 xor in5, local3, in5 ! 5 finished
495 and local2, 252, local2
496 ! next round (two rounds more)
497 xor in5, local7, local7 ! 7531
499 ld [global5+local2], local2
500 srl local7, 24, local3
501 xor in5, out0, out0 ! 8642
503 ldub [out2+local3], local3
504 srl out0, 4, local0 ! rotate
505 and local7, 252, local1
507 sll out0, 28, out0 ! rotate
508 xor out5, local2, out5 ! 5 finished local2 used
510 srl local0, 8, local4
511 and local0, 252, local2
512 ld [local5+local3], local3
514 srl local0, 16, local5
515 or out0, local0, out0 ! rotate
516 ld [global2+local2], local2
519 ld [in4], out0 ! key next encryption/decryption
520 and local4, 252, local4
522 and local5, 252, local5
523 ld [global4+local4], local4
524 xor out5, local3, out5 ! 7 finished local3 used
526 and local0, 252, local0
527 ld [local6+local5], local5
528 xor out5, local2, out5 ! 2 finished local2 now sbox 3
530 srl local7, 8, local2 ! 3 start
531 ld [out3+local0], local0
532 xor out5, local4, out5
534 and local2, 252, local2
535 ld [global1+local1], local1
536 xor out5, local5, out5 ! 6 finished local5 used
538 ld [global3+local2], local2
540 xor out5, local0, out5
542 ld [in4+4], out1 ! key next encryption/decryption
544 xor out5, local1, out5
547 xor out5, local2, out5
555 ! implemented with out5 as first parameter to avoid
556 ! register exchange in ede modes
559 ! loads key next encryption/decryption first round from [in3]
564 ! out5 in5 -1 .des_dec.1 in4 in3 retl
566 xor in5, out0, local1
568 ld [out2+284], local5 ! 0x0000FC00
570 and local1, 252, local1
575 ! local6 is address sbox 6
576 ! out3 is address sbox 8
577 ! out4 is loop counter
579 ld [global1+local1], local1
580 xor in5, out1, out1 ! 8642
581 xor in5, out0, out0 ! 7531
582 ! fmovs %f0, %f0 ! fxor used for alignment
584 srl out1, 4, local0 ! rotate 4 right
585 and out0, local5, local3 ! 3
588 ld [in4+-1*8], local7 ! key 7531 next round
589 srl local3, 8, local3 ! 3
590 and local0, 252, local2 ! 2
593 ld [global3+local3],local3 ! 3
594 sll out1, 28, out1 ! rotate
595 xor out5, local1, out5 ! 1 finished, local1 now sbox 7
597 ld [global2+local2], local2 ! 2
598 srl out0, 24, local1 ! 7
599 or out1, local0, out1 ! rotate
601 ldub [out2+local1], local1 ! 7 (and 0xFC)
602 srl out1, 24, local0 ! 8
603 and out1, local5, local4 ! 4
605 ldub [out2+local0], local0 ! 8 (and 0xFC)
606 srl local4, 8, local4 ! 4
607 xor out5, local2, out5 ! 2 finished local2 now sbox 6
609 ld [global4+local4],local4 ! 4
610 srl out1, 16, local2 ! 6
611 xor out5, local3, out5 ! 3 finished local3 now sbox 5
613 ld [out3+local0],local0 ! 8
614 and local2, 252, local2 ! 6
615 add global1, 1536, local5 ! address sbox 7
617 ld [local6+local2], local2 ! 6
618 srl out0, 16, local3 ! 5
619 xor out5, local4, out5 ! 4 finished
621 ld [local5+local1],local1 ! 7
622 and local3, 252, local3 ! 5
623 xor out5, local0, out5 ! 8 finished
625 ld [global5+local3],local3 ! 5
626 xor out5, local2, out5 ! 6 finished
629 ld [in4+-1*8+4], out0 ! key 8642 next round
630 xor out5, local7, local2 ! sbox 5 next round
631 xor out5, local1, out5 ! 7 finished
633 srl local2, 16, local2 ! sbox 5 next round
634 xor out5, local3, out5 ! 5 finished
636 ld [in4+-1*16+4], out1 ! key 8642 next round again
637 and local2, 252, local2 ! sbox5 next round
639 xor out5, local7, local7 ! 7531
641 ld [global5+local2], local2 ! 5
642 srl local7, 24, local3 ! 7
643 xor out5, out0, out0 ! 8642
645 ldub [out2+local3], local3 ! 7 (and 0xFC)
646 srl out0, 4, local0 ! rotate 4 right
647 and local7, 252, local1 ! 1
649 sll out0, 28, out0 ! rotate
650 xor in5, local2, in5 ! 5 finished local2 used
652 srl local0, 8, local4 ! 4
653 and local0, 252, local2 ! 2
654 ld [local5+local3], local3 ! 7
656 srl local0, 16, local5 ! 6
657 or out0, local0, out0 ! rotate
658 ld [global2+local2], local2 ! 2
661 ld [in4+-1*16], out0 ! key 7531 next round
662 and local4, 252, local4 ! 4
664 and local5, 252, local5 ! 6
665 ld [global4+local4], local4 ! 4
666 xor in5, local3, in5 ! 7 finished local3 used
668 and local0, 252, local0 ! 8
669 ld [local6+local5], local5 ! 6
670 xor in5, local2, in5 ! 2 finished local2 now sbox 3
672 srl local7, 8, local2 ! 3 start
673 ld [out3+local0], local0 ! 8
674 xor in5, local4, in5 ! 4 finished
676 and local2, 252, local2 ! 3
677 ld [global1+local1], local1 ! 1
678 xor in5, local5, in5 ! 6 finished local5 used
680 ld [global3+local2], local2 ! 3
681 xor in5, local0, in5 ! 8 finished
682 add in4, -1*16, in4 ! enc add 8, dec add -8 to key pointer
684 ld [out2+284], local5 ! 0x0000FC00
685 xor in5, out0, local4 ! sbox 1 next round
686 xor in5, local1, in5 ! 1 finished
688 xor in5, local2, in5 ! 3 finished
690 bne,pt %icc, .des_dec.1
694 and local4, 252, local1 ! sbox 1 next round
698 ld [global1+local1], local1
702 srl out1, 4, local0 ! rotate
703 and out0, local5, local3
705 ld [in4+-1*8], local7 ! key 7531
706 srl local3, 8, local3
707 and local0, 252, local2
709 ld [global3+local3],local3
710 sll out1, 28, out1 ! rotate
711 xor out5, local1, out5 ! 1 finished, local1 now sbox 7
713 ld [global2+local2], local2
715 or out1, local0, out1 ! rotate
717 ldub [out2+local1], local1
719 and out1, local5, local4
721 ldub [out2+local0], local0
722 srl local4, 8, local4
723 xor out5, local2, out5 ! 2 finished local2 now sbox 6
725 ld [global4+local4],local4
727 xor out5, local3, out5 ! 3 finished local3 now sbox 5
729 ld [out3+local0],local0
730 and local2, 252, local2
731 add global1, 1536, local5 ! address sbox 7
733 ld [local6+local2], local2
735 xor out5, local4, out5 ! 4 finished
737 ld [local5+local1],local1
738 and local3, 252, local3
739 xor out5, local0, out5
741 ld [global5+local3],local3
742 xor out5, local2, out5 ! 6 finished
745 ld [out2+280], out4 ! loop counter
746 xor out5, local7, local2 ! sbox 5 next round
747 xor out5, local1, out5 ! 7 finished
749 ld [in4+-1*8+4], out0
750 srl local2, 16, local2 ! sbox 5 next round
751 xor out5, local3, out5 ! 5 finished
753 and local2, 252, local2
754 ! next round (two rounds more)
755 xor out5, local7, local7 ! 7531
757 ld [global5+local2], local2
758 srl local7, 24, local3
759 xor out5, out0, out0 ! 8642
761 ldub [out2+local3], local3
762 srl out0, 4, local0 ! rotate
763 and local7, 252, local1
765 sll out0, 28, out0 ! rotate
766 xor in5, local2, in5 ! 5 finished local2 used
768 srl local0, 8, local4
769 and local0, 252, local2
770 ld [local5+local3], local3
772 srl local0, 16, local5
773 or out0, local0, out0 ! rotate
774 ld [global2+local2], local2
777 ld [in3], out0 ! key next encryption/decryption
778 and local4, 252, local4
780 and local5, 252, local5
781 ld [global4+local4], local4
782 xor in5, local3, in5 ! 7 finished local3 used
784 and local0, 252, local0
785 ld [local6+local5], local5
786 xor in5, local2, in5 ! 2 finished local2 now sbox 3
788 srl local7, 8, local2 ! 3 start
789 ld [out3+local0], local0
792 and local2, 252, local2
793 ld [global1+local1], local1
794 xor in5, local5, in5 ! 6 finished local5 used
796 ld [global3+local2], local2
800 ld [in3+4], out1 ! key next encryption/decryption
810 ! void DES_encrypt1(data, ks, enc)
811 ! *******************************
815 .type DES_encrypt1,#function
821 sethi %hi(_PIC_DES_SPtrans-1f),global1
822 or global1,%lo(_PIC_DES_SPtrans-1f),global1
824 add %o7,global1,global1
825 sub global1,_PIC_DES_SPtrans-.des_and,out2
831 be,pn %icc, .encrypt.dec ! enc/dec
835 ld [in0+4], out5 ! right
837 ! parameter 6 1/2 for include encryption/decryption
838 ! parameter 7 1 for move in1 to in3
839 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
844 ! in5 out5 out5 in5 in3 0 1 1
846 ld [out2+256], local1
849 xor local4, in5, local4
852 ld [out2+260], local2
853 and local4, local1, local4
857 ld [out2+280], out4 ! loop counter
858 sll local4, 4, local1
861 ld [out2+264], local3
863 xor out5, local1, out5
866 xor local4, out5, local4
867 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
870 and local4, local2, local4
871 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
873 sll local4, 16, local1
874 xor out5, local4, out5
879 sethi %hi(16711680), local5
880 xor local4, in5, local4
882 and local4, local3, local4
883 or local5, 255, local5
885 sll local4, 2, local2
889 xor out5, local2, out5
891 xor local4, out5, local4
892 add global1, 768, global4
894 and local4, local5, local4
895 add global1, 1024, global5
897 ld [out2+272], local7
898 sll local4, 8, local1
899 xor out5, local4, out5
904 ld [in3], out0 ! key 7531
905 xor local4, in5, local4
906 add global1, 256, global2
908 ld [in3+4], out1 ! key 8642
909 and local4, local7, local4
910 add global1, 512, global3
912 sll local4, 1, local1
916 xor out5, local1, out5
919 add global1, 1280, local6 ! address sbox 8
922 add global1, 1792, out3 ! address sbox 8
925 or local4, local3, out5
927 or local2, local1, in5
937 ! in5 out5 1 .des_encrypt1.1 in3 in4
939 xor out5, out0, local1
941 ld [out2+284], local5 ! 0x0000FC00
943 and local1, 252, local1
948 ! local6 is address sbox 6
949 ! out3 is address sbox 8
950 ! out4 is loop counter
952 ld [global1+local1], local1
953 xor out5, out1, out1 ! 8642
954 xor out5, out0, out0 ! 7531
955 ! fmovs %f0, %f0 ! fxor used for alignment
957 srl out1, 4, local0 ! rotate 4 right
958 and out0, local5, local3 ! 3
961 ld [in3+1*8], local7 ! key 7531 next round
962 srl local3, 8, local3 ! 3
963 and local0, 252, local2 ! 2
966 ld [global3+local3],local3 ! 3
967 sll out1, 28, out1 ! rotate
968 xor in5, local1, in5 ! 1 finished, local1 now sbox 7
970 ld [global2+local2], local2 ! 2
971 srl out0, 24, local1 ! 7
972 or out1, local0, out1 ! rotate
974 ldub [out2+local1], local1 ! 7 (and 0xFC)
975 srl out1, 24, local0 ! 8
976 and out1, local5, local4 ! 4
978 ldub [out2+local0], local0 ! 8 (and 0xFC)
979 srl local4, 8, local4 ! 4
980 xor in5, local2, in5 ! 2 finished local2 now sbox 6
982 ld [global4+local4],local4 ! 4
983 srl out1, 16, local2 ! 6
984 xor in5, local3, in5 ! 3 finished local3 now sbox 5
986 ld [out3+local0],local0 ! 8
987 and local2, 252, local2 ! 6
988 add global1, 1536, local5 ! address sbox 7
990 ld [local6+local2], local2 ! 6
991 srl out0, 16, local3 ! 5
992 xor in5, local4, in5 ! 4 finished
994 ld [local5+local1],local1 ! 7
995 and local3, 252, local3 ! 5
996 xor in5, local0, in5 ! 8 finished
998 ld [global5+local3],local3 ! 5
999 xor in5, local2, in5 ! 6 finished
1002 ld [in3+1*8+4], out0 ! key 8642 next round
1003 xor in5, local7, local2 ! sbox 5 next round
1004 xor in5, local1, in5 ! 7 finished
1006 srl local2, 16, local2 ! sbox 5 next round
1007 xor in5, local3, in5 ! 5 finished
1009 ld [in3+1*16+4], out1 ! key 8642 next round again
1010 and local2, 252, local2 ! sbox5 next round
1012 xor in5, local7, local7 ! 7531
1014 ld [global5+local2], local2 ! 5
1015 srl local7, 24, local3 ! 7
1016 xor in5, out0, out0 ! 8642
1018 ldub [out2+local3], local3 ! 7 (and 0xFC)
1019 srl out0, 4, local0 ! rotate 4 right
1020 and local7, 252, local1 ! 1
1022 sll out0, 28, out0 ! rotate
1023 xor out5, local2, out5 ! 5 finished local2 used
1025 srl local0, 8, local4 ! 4
1026 and local0, 252, local2 ! 2
1027 ld [local5+local3], local3 ! 7
1029 srl local0, 16, local5 ! 6
1030 or out0, local0, out0 ! rotate
1031 ld [global2+local2], local2 ! 2
1033 srl out0, 24, local0
1034 ld [in3+1*16], out0 ! key 7531 next round
1035 and local4, 252, local4 ! 4
1037 and local5, 252, local5 ! 6
1038 ld [global4+local4], local4 ! 4
1039 xor out5, local3, out5 ! 7 finished local3 used
1041 and local0, 252, local0 ! 8
1042 ld [local6+local5], local5 ! 6
1043 xor out5, local2, out5 ! 2 finished local2 now sbox 3
1045 srl local7, 8, local2 ! 3 start
1046 ld [out3+local0], local0 ! 8
1047 xor out5, local4, out5 ! 4 finished
1049 and local2, 252, local2 ! 3
1050 ld [global1+local1], local1 ! 1
1051 xor out5, local5, out5 ! 6 finished local5 used
1053 ld [global3+local2], local2 ! 3
1054 xor out5, local0, out5 ! 8 finished
1055 add in3, 1*16, in3 ! enc add 8, dec add -8 to key pointer
1057 ld [out2+284], local5 ! 0x0000FC00
1058 xor out5, out0, local4 ! sbox 1 next round
1059 xor out5, local1, out5 ! 1 finished
1061 xor out5, local2, out5 ! 3 finished
1063 bne,pt %icc, .des_encrypt1.1
1067 and local4, 252, local1 ! sbox 1 next round
1071 ld [global1+local1], local1
1072 xor out5, out1, out1
1073 xor out5, out0, out0
1075 srl out1, 4, local0 ! rotate
1076 and out0, local5, local3
1078 ld [in3+1*8], local7 ! key 7531
1079 srl local3, 8, local3
1080 and local0, 252, local2
1082 ld [global3+local3],local3
1083 sll out1, 28, out1 ! rotate
1084 xor in5, local1, in5 ! 1 finished, local1 now sbox 7
1086 ld [global2+local2], local2
1087 srl out0, 24, local1
1088 or out1, local0, out1 ! rotate
1090 ldub [out2+local1], local1
1091 srl out1, 24, local0
1092 and out1, local5, local4
1094 ldub [out2+local0], local0
1095 srl local4, 8, local4
1096 xor in5, local2, in5 ! 2 finished local2 now sbox 6
1098 ld [global4+local4],local4
1099 srl out1, 16, local2
1100 xor in5, local3, in5 ! 3 finished local3 now sbox 5
1102 ld [out3+local0],local0
1103 and local2, 252, local2
1104 add global1, 1536, local5 ! address sbox 7
1106 ld [local6+local2], local2
1107 srl out0, 16, local3
1108 xor in5, local4, in5 ! 4 finished
1110 ld [local5+local1],local1
1111 and local3, 252, local3
1112 xor in5, local0, in5
1114 ld [global5+local3],local3
1115 xor in5, local2, in5 ! 6 finished
1118 ld [out2+280], out4 ! loop counter
1119 xor in5, local7, local2 ! sbox 5 next round
1120 xor in5, local1, in5 ! 7 finished
1122 ld [in3+1*8+4], out0
1123 srl local2, 16, local2 ! sbox 5 next round
1124 xor in5, local3, in5 ! 5 finished
1126 and local2, 252, local2
1127 ! next round (two rounds more)
1128 xor in5, local7, local7 ! 7531
1130 ld [global5+local2], local2
1131 srl local7, 24, local3
1132 xor in5, out0, out0 ! 8642
1134 ldub [out2+local3], local3
1135 srl out0, 4, local0 ! rotate
1136 and local7, 252, local1
1138 sll out0, 28, out0 ! rotate
1139 xor out5, local2, out5 ! 5 finished local2 used
1141 srl local0, 8, local4
1142 and local0, 252, local2
1143 ld [local5+local3], local3
1145 srl local0, 16, local5
1146 or out0, local0, out0 ! rotate
1147 ld [global2+local2], local2
1149 srl out0, 24, local0
1150 ld [in4], out0 ! key next encryption/decryption
1151 and local4, 252, local4
1153 and local5, 252, local5
1154 ld [global4+local4], local4
1155 xor out5, local3, out5 ! 7 finished local3 used
1157 and local0, 252, local0
1158 ld [local6+local5], local5
1159 xor out5, local2, out5 ! 2 finished local2 now sbox 3
1161 srl local7, 8, local2 ! 3 start
1162 ld [out3+local0], local0
1163 xor out5, local4, out5
1165 and local2, 252, local2
1166 ld [global1+local1], local1
1167 xor out5, local5, out5 ! 6 finished local5 used
1169 ld [global3+local2], local2
1171 xor out5, local0, out5
1173 ld [in4+4], out1 ! key next encryption/decryption
1175 xor out5, local1, out5
1178 xor out5, local2, out5
1186 ! initially undo the rotate 3 left done after initial permutation
1187 ! original left is received shifted 3 right and 29 left in local3/4
1189 sll out5, 29, local1
1190 or local3, local4, in5
1193 sethi %hi(0x55555555), local2
1195 or out5, local1, out5
1196 or local2, %lo(0x55555555), local2
1199 sethi %hi(0x00ff00ff), local1
1200 xor local3, in5, local3
1201 or local1, %lo(0x00ff00ff), local1
1202 and local3, local2, local3
1203 sethi %hi(0x33333333), local4
1204 sll local3, 1, local2
1206 xor in5, local3, in5
1209 xor out5, local2, out5
1210 xor local3, out5, local3
1211 or local4, %lo(0x33333333), local4
1212 and local3, local1, local3
1213 sethi %hi(0x0000ffff), local1
1214 sll local3, 8, local2
1216 xor out5, local3, out5
1219 xor in5, local2, in5
1220 xor local3, in5, local3
1221 or local1, %lo(0x0000ffff), local1
1222 and local3, local4, local3
1223 sethi %hi(0x0f0f0f0f), local4
1224 sll local3, 2, local2
1227 xor in5, local3, in5
1231 xor out5, local2, out5
1232 xor local3, out5, local3
1233 or local4, %lo(0x0f0f0f0f), local4
1234 and local3, local1, local3
1235 sll local3, 16, local2
1237 xor out5, local3, local1
1239 srl local1, 4, local3
1240 xor in5, local2, in5
1241 xor local3, in5, local3
1242 and local3, local4, local3
1243 sll local3, 4, local2
1245 xor in5, local3, in5
1251 xor local1, local2, out5
1255 ! 1 for store to [in0]
1262 add in1, 120, in3 ! use last subkey for first round
1264 ! parameter 6 1/2 for include encryption/decryption
1265 ! parameter 7 1 for move in1 to in3
1266 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1271 ! in5 out5 in5 out5 in4 2 0 1
1273 ld [out2+256], local1
1276 xor local4, in5, local4
1279 ld [out2+260], local2
1280 and local4, local1, local4
1284 ld [out2+280], out4 ! loop counter
1285 sll local4, 4, local1
1286 xor in5, local4, in5
1288 ld [out2+264], local3
1290 xor out5, local1, out5
1293 xor local4, out5, local4
1294 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
1297 and local4, local2, local4
1298 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
1300 sll local4, 16, local1
1301 xor out5, local4, out5
1304 xor in5, local1, in5
1306 sethi %hi(16711680), local5
1307 xor local4, in5, local4
1309 and local4, local3, local4
1310 or local5, 255, local5
1312 sll local4, 2, local2
1313 xor in5, local4, in5
1316 xor out5, local2, out5
1318 xor local4, out5, local4
1319 add global1, 768, global4
1321 and local4, local5, local4
1322 add global1, 1024, global5
1324 ld [out2+272], local7
1325 sll local4, 8, local1
1326 xor out5, local4, out5
1329 xor in5, local1, in5
1331 ld [in4], out0 ! key 7531
1332 xor local4, in5, local4
1333 add global1, 256, global2
1335 ld [in4+4], out1 ! key 8642
1336 and local4, local7, local4
1337 add global1, 512, global3
1339 sll local4, 1, local1
1340 xor in5, local4, in5
1343 xor out5, local1, out5
1346 add global1, 1280, local6 ! address sbox 8
1349 add global1, 1792, out3 ! address sbox 8
1351 srl out5, 29, local1
1352 or local4, local3, in5
1354 or local2, local1, out5
1360 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
1361 or local2, local1, out5
1362 xor in5, out0, local1
1365 and local1, 252, local1
1368 ! include dec, ks in4
1375 ! initially undo the rotate 3 left done after initial permutation
1376 ! original left is received shifted 3 right and 29 left in local3/4
1379 or local3, local4, out5
1382 sethi %hi(0x55555555), local2
1385 or local2, %lo(0x55555555), local2
1388 sethi %hi(0x00ff00ff), local1
1389 xor local3, out5, local3
1390 or local1, %lo(0x00ff00ff), local1
1391 and local3, local2, local3
1392 sethi %hi(0x33333333), local4
1393 sll local3, 1, local2
1395 xor out5, local3, out5
1398 xor in5, local2, in5
1399 xor local3, in5, local3
1400 or local4, %lo(0x33333333), local4
1401 and local3, local1, local3
1402 sethi %hi(0x0000ffff), local1
1403 sll local3, 8, local2
1405 xor in5, local3, in5
1408 xor out5, local2, out5
1409 xor local3, out5, local3
1410 or local1, %lo(0x0000ffff), local1
1411 and local3, local4, local3
1412 sethi %hi(0x0f0f0f0f), local4
1413 sll local3, 2, local2
1416 xor out5, local3, out5
1419 srl out5, 16, local3
1420 xor in5, local2, in5
1421 xor local3, in5, local3
1422 or local4, %lo(0x0f0f0f0f), local4
1423 and local3, local1, local3
1424 sll local3, 16, local2
1426 xor in5, local3, local1
1428 srl local1, 4, local3
1429 xor out5, local2, out5
1430 xor local3, out5, local3
1431 and local3, local4, local3
1432 sll local3, 4, local2
1434 xor out5, local3, out5
1440 xor local1, local2, in5
1444 ! 1 for store to [in0]
1450 .size DES_encrypt1,.DES_encrypt1.end-DES_encrypt1
1453 ! void DES_encrypt2(data, ks, enc)
1454 !*********************************
1456 ! encrypts/decrypts without initial/final permutation
1459 .global DES_encrypt2
1460 .type DES_encrypt2,#function
1464 save %sp, FRAME, %sp
1466 sethi %hi(_PIC_DES_SPtrans-1f),global1
1467 or global1,%lo(_PIC_DES_SPtrans-1f),global1
1469 add %o7,global1,global1
1470 sub global1,_PIC_DES_SPtrans-.des_and,out2
1472 ! Set sbox address 1 to 6 and rotate halfs 3 left
1473 ! Errors caught by destest? Yes. Still? *NO*
1475 !sethi %hi(DES_SPtrans), global1 ! address sbox 1
1477 !or global1, %lo(DES_SPtrans), global1 ! sbox 1
1479 add global1, 256, global2 ! sbox 2
1480 add global1, 512, global3 ! sbox 3
1482 ld [in0], out5 ! right
1483 add global1, 768, global4 ! sbox 4
1484 add global1, 1024, global5 ! sbox 5
1486 ld [in0+4], in5 ! left
1487 add global1, 1280, local6 ! sbox 6
1488 add global1, 1792, out3 ! sbox 8
1493 mov in1, in3 ! key address to in3
1499 add in5, local5, in5
1501 add out5, local7, out5
1504 ! we use our own stackframe
1507 be,pn %icc, .encrypt2.dec ! decryption
1511 STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
1513 ld [in3], out0 ! key 7531 first round
1514 mov LOOPS, out4 ! loop counter
1516 ld [in3+4], out1 ! key 8642 first round
1517 sethi %hi(0x0000FC00), local5
1528 LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
1541 ld [in4], out0 ! key 7531 first round
1542 mov LOOPS, out4 ! loop counter
1544 ld [in4+4], out1 ! key 8642 first round
1545 sethi %hi(0x0000FC00), local5
1547 mov in5, local1 ! left expected in out5
1561 LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
1570 .size DES_encrypt2, .DES_encrypt2.end-DES_encrypt2
1573 ! void DES_encrypt3(data, ks1, ks2, ks3)
1574 ! **************************************
1577 .global DES_encrypt3
1578 .type DES_encrypt3,#function
1582 save %sp, FRAME, %sp
1584 sethi %hi(_PIC_DES_SPtrans-1f),global1
1585 or global1,%lo(_PIC_DES_SPtrans-1f),global1
1587 add %o7,global1,global1
1588 sub global1,_PIC_DES_SPtrans-.des_and,out2
1590 ld [in0], in5 ! left
1591 add in2, 120, in4 ! ks2
1593 ld [in0+4], out5 ! right
1594 mov in3, in2 ! save ks3
1596 ! parameter 6 1/2 for include encryption/decryption
1597 ! parameter 7 1 for mov in1 to in3
1598 ! parameter 8 1 for mov in3 to in4
1599 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1604 ! in5 out5 out5 in5 in3 1 1 0 0
1606 ld [out2+256], local1
1609 xor local4, in5, local4
1612 ld [out2+260], local2
1613 and local4, local1, local4
1617 ld [out2+280], out4 ! loop counter
1618 sll local4, 4, local1
1619 xor in5, local4, in5
1621 ld [out2+264], local3
1623 xor out5, local1, out5
1626 xor local4, out5, local4
1627 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
1630 and local4, local2, local4
1631 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
1633 sll local4, 16, local1
1634 xor out5, local4, out5
1637 xor in5, local1, in5
1639 sethi %hi(16711680), local5
1640 xor local4, in5, local4
1642 and local4, local3, local4
1643 or local5, 255, local5
1645 sll local4, 2, local2
1646 xor in5, local4, in5
1649 xor out5, local2, out5
1651 xor local4, out5, local4
1652 add global1, 768, global4
1654 and local4, local5, local4
1655 add global1, 1024, global5
1657 ld [out2+272], local7
1658 sll local4, 8, local1
1659 xor out5, local4, out5
1662 xor in5, local1, in5
1664 ld [in3], out0 ! key 7531
1665 xor local4, in5, local4
1666 add global1, 256, global2
1668 ld [in3+4], out1 ! key 8642
1669 and local4, local7, local4
1670 add global1, 512, global3
1672 sll local4, 1, local1
1673 xor in5, local4, in5
1676 xor out5, local1, out5
1679 add global1, 1280, local6 ! address sbox 8
1682 add global1, 1792, out3 ! address sbox 8
1684 srl out5, 29, local1
1685 or local4, local3, out5
1687 or local2, local1, in5
1691 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
1692 or local2, local1, in5
1693 xor out5, out0, local1
1696 and local1, 252, local1
1704 mov in2, in3 ! preload ks3
1714 ! initially undo the rotate 3 left done after initial permutation
1715 ! original left is received shifted 3 right and 29 left in local3/4
1717 sll out5, 29, local1
1718 or local3, local4, in5
1721 sethi %hi(0x55555555), local2
1723 or out5, local1, out5
1724 or local2, %lo(0x55555555), local2
1727 sethi %hi(0x00ff00ff), local1
1728 xor local3, in5, local3
1729 or local1, %lo(0x00ff00ff), local1
1730 and local3, local2, local3
1731 sethi %hi(0x33333333), local4
1732 sll local3, 1, local2
1734 xor in5, local3, in5
1737 xor out5, local2, out5
1738 xor local3, out5, local3
1739 or local4, %lo(0x33333333), local4
1740 and local3, local1, local3
1741 sethi %hi(0x0000ffff), local1
1742 sll local3, 8, local2
1744 xor out5, local3, out5
1747 xor in5, local2, in5
1748 xor local3, in5, local3
1749 or local1, %lo(0x0000ffff), local1
1750 and local3, local4, local3
1751 sethi %hi(0x0f0f0f0f), local4
1752 sll local3, 2, local2
1755 xor in5, local3, in5
1759 xor out5, local2, out5
1760 xor local3, out5, local3
1761 or local4, %lo(0x0f0f0f0f), local4
1762 and local3, local1, local3
1763 sll local3, 16, local2
1765 xor out5, local3, local1
1767 srl local1, 4, local3
1768 xor in5, local2, in5
1769 xor local3, in5, local3
1770 and local3, local4, local3
1771 sll local3, 4, local2
1773 xor in5, local3, in5
1779 xor local1, local2, out5
1789 .size DES_encrypt3,.DES_encrypt3.end-DES_encrypt3
1792 ! void DES_decrypt3(data, ks1, ks2, ks3)
1793 ! **************************************
1796 .global DES_decrypt3
1797 .type DES_decrypt3,#function
1801 save %sp, FRAME, %sp
1803 sethi %hi(_PIC_DES_SPtrans-1f),global1
1804 or global1,%lo(_PIC_DES_SPtrans-1f),global1
1806 add %o7,global1,global1
1807 sub global1,_PIC_DES_SPtrans-.des_and,out2
1809 ld [in0], in5 ! left
1810 add in3, 120, in4 ! ks3
1812 ld [in0+4], out5 ! right
1815 ! parameter 6 1/2 for include encryption/decryption
1816 ! parameter 7 1 for mov in1 to in3
1817 ! parameter 8 1 for mov in3 to in4
1818 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1823 ! in5 out5 in5 out5 in4 2 0 0 0
1825 ld [out2+256], local1
1828 xor local4, in5, local4
1831 ld [out2+260], local2
1832 and local4, local1, local4
1836 ld [out2+280], out4 ! loop counter
1837 sll local4, 4, local1
1838 xor in5, local4, in5
1840 ld [out2+264], local3
1842 xor out5, local1, out5
1845 xor local4, out5, local4
1846 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
1849 and local4, local2, local4
1850 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
1852 sll local4, 16, local1
1853 xor out5, local4, out5
1856 xor in5, local1, in5
1858 sethi %hi(16711680), local5
1859 xor local4, in5, local4
1861 and local4, local3, local4
1862 or local5, 255, local5
1864 sll local4, 2, local2
1865 xor in5, local4, in5
1868 xor out5, local2, out5
1870 xor local4, out5, local4
1871 add global1, 768, global4
1873 and local4, local5, local4
1874 add global1, 1024, global5
1876 ld [out2+272], local7
1877 sll local4, 8, local1
1878 xor out5, local4, out5
1881 xor in5, local1, in5
1883 ld [in4], out0 ! key 7531
1884 xor local4, in5, local4
1885 add global1, 256, global2
1887 ld [in4+4], out1 ! key 8642
1888 and local4, local7, local4
1889 add global1, 512, global3
1891 sll local4, 1, local1
1892 xor in5, local4, in5
1895 xor out5, local1, out5
1898 add global1, 1280, local6 ! address sbox 8
1901 add global1, 1792, out3 ! address sbox 8
1903 srl out5, 29, local1
1904 or local4, local3, in5
1906 or local2, local1, out5
1912 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
1913 or local2, local1, out5
1914 xor in5, out0, local1
1917 and local1, 252, local1
1923 add in1, 120, in4 ! preload ks1
1933 ! initially undo the rotate 3 left done after initial permutation
1934 ! original left is received shifted 3 right and 29 left in local3/4
1937 or local3, local4, out5
1940 sethi %hi(0x55555555), local2
1943 or local2, %lo(0x55555555), local2
1946 sethi %hi(0x00ff00ff), local1
1947 xor local3, out5, local3
1948 or local1, %lo(0x00ff00ff), local1
1949 and local3, local2, local3
1950 sethi %hi(0x33333333), local4
1951 sll local3, 1, local2
1953 xor out5, local3, out5
1956 xor in5, local2, in5
1957 xor local3, in5, local3
1958 or local4, %lo(0x33333333), local4
1959 and local3, local1, local3
1960 sethi %hi(0x0000ffff), local1
1961 sll local3, 8, local2
1963 xor in5, local3, in5
1966 xor out5, local2, out5
1967 xor local3, out5, local3
1968 or local1, %lo(0x0000ffff), local1
1969 and local3, local4, local3
1970 sethi %hi(0x0f0f0f0f), local4
1971 sll local3, 2, local2
1974 xor out5, local3, out5
1977 srl out5, 16, local3
1978 xor in5, local2, in5
1979 xor local3, in5, local3
1980 or local4, %lo(0x0f0f0f0f), local4
1981 and local3, local1, local3
1982 sll local3, 16, local2
1984 xor in5, local3, local1
1986 srl local1, 4, local3
1987 xor out5, local2, out5
1988 xor local3, out5, local3
1989 and local3, local4, local3
1990 sll local3, 4, local2
1992 xor out5, local3, out5
1998 xor local1, local2, in5
2008 .size DES_decrypt3,.DES_decrypt3.end-DES_decrypt3
2010 ! void DES_ncbc_encrypt(input, output, length, schedule, ivec, enc)
2011 ! *****************************************************************
2015 .global DES_ncbc_encrypt
2016 .type DES_ncbc_encrypt,#function
2020 save %sp, FRAME, %sp
2026 sethi %hi(_PIC_DES_SPtrans-1f),global1
2027 or global1,%lo(_PIC_DES_SPtrans-1f),global1
2029 add %o7,global1,global1
2030 sub global1,_PIC_DES_SPtrans-.des_and,out2
2035 be,pn %icc, .ncbc.dec
2039 STPTR in4, [%sp+BIAS+ARG0+4*ARGSZ]
2041 ! addr left right temp label
2044 ! load_little_endian
2045 ! in4 in5 out5 local3 .LLE1
2047 ! first in memory to rightmost in register
2050 andcc in4, 3, global0
2058 lda [local3] 0x88, out5
2064 ldub [in4+2], local3
2068 ldub [in4+1], local3
2072 ldub [in4+0], local3
2077 ldub [in4+3+4], out5
2079 ldub [in4+2+4], local3
2081 or out5, local3, out5
2083 ldub [in4+1+4], local3
2085 or out5, local3, out5
2087 ldub [in4+0+4], local3
2089 or out5, local3, out5
2094 addcc in2, -8, in2 ! bytes missing when first block done
2097 bl,pn %icc, .ncbc.enc.seven.or.less
2099 bl .ncbc.enc.seven.or.less
2101 mov in3, in4 ! schedule
2103 .ncbc.enc.next.block:
2107 ! load_little_endian
2108 ! in0 out4 global4 local3 .LLE2
2110 ! first in memory to rightmost in register
2113 andcc in0, 3, global0
2117 lda [in0] 0x88, out4
2121 lda [local3] 0x88, global4
2127 ldub [in0+2], local3
2129 or out4, local3, out4
2131 ldub [in0+1], local3
2133 or out4, local3, out4
2135 ldub [in0+0], local3
2137 or out4, local3, out4
2140 ldub [in0+3+4], global4
2142 ldub [in0+2+4], local3
2143 sll global4, 8, global4
2144 or global4, local3, global4
2146 ldub [in0+1+4], local3
2147 sll global4, 8, global4
2148 or global4, local3, global4
2150 ldub [in0+0+4], local3
2151 sll global4, 8, global4
2152 or global4, local3, global4
2157 .ncbc.enc.next.block_1:
2159 xor in5, out4, in5 ! iv xor
2160 xor out5, global4, out5 ! iv xor
2162 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
2166 ! in5 out5 out5 in5 in3 0 0 2
2168 ld [out2+256], local1
2171 xor local4, in5, local4
2174 ld [out2+260], local2
2175 and local4, local1, local4
2179 ld [out2+280], out4 ! loop counter
2180 sll local4, 4, local1
2181 xor in5, local4, in5
2183 ld [out2+264], local3
2185 xor out5, local1, out5
2188 xor local4, out5, local4
2189 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
2192 and local4, local2, local4
2193 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
2195 sll local4, 16, local1
2196 xor out5, local4, out5
2199 xor in5, local1, in5
2201 sethi %hi(16711680), local5
2202 xor local4, in5, local4
2204 and local4, local3, local4
2205 or local5, 255, local5
2207 sll local4, 2, local2
2208 xor in5, local4, in5
2211 xor out5, local2, out5
2213 xor local4, out5, local4
2214 add global1, 768, global4
2216 and local4, local5, local4
2217 add global1, 1024, global5
2219 ld [out2+272], local7
2220 sll local4, 8, local1
2221 xor out5, local4, out5
2224 xor in5, local1, in5
2226 ld [in3], out0 ! key 7531
2227 xor local4, in5, local4
2228 add global1, 256, global2
2230 ld [in3+4], out1 ! key 8642
2231 and local4, local7, local4
2232 add global1, 512, global3
2234 sll local4, 1, local1
2235 xor in5, local4, in5
2238 xor out5, local1, out5
2241 add global1, 1280, local6 ! address sbox 8
2244 add global1, 1792, out3 ! address sbox 8
2246 srl out5, 29, local1
2247 or local4, local3, out5
2249 or local2, local1, in5
2256 .ncbc.enc.next.block_2:
2258 !// call .des_enc ! compares in2 to 8
2259 ! rounds inlined for alignment purposes
2261 add global1, 768, global4 ! address sbox 4 since register used below
2266 ! in5 out5 1 .ncbc.enc.1 in3 in4
2268 xor out5, out0, local1
2270 ld [out2+284], local5 ! 0x0000FC00
2272 and local1, 252, local1
2277 ! local6 is address sbox 6
2278 ! out3 is address sbox 8
2279 ! out4 is loop counter
2281 ld [global1+local1], local1
2282 xor out5, out1, out1 ! 8642
2283 xor out5, out0, out0 ! 7531
2284 ! fmovs %f0, %f0 ! fxor used for alignment
2286 srl out1, 4, local0 ! rotate 4 right
2287 and out0, local5, local3 ! 3
2290 ld [in3+1*8], local7 ! key 7531 next round
2291 srl local3, 8, local3 ! 3
2292 and local0, 252, local2 ! 2
2295 ld [global3+local3],local3 ! 3
2296 sll out1, 28, out1 ! rotate
2297 xor in5, local1, in5 ! 1 finished, local1 now sbox 7
2299 ld [global2+local2], local2 ! 2
2300 srl out0, 24, local1 ! 7
2301 or out1, local0, out1 ! rotate
2303 ldub [out2+local1], local1 ! 7 (and 0xFC)
2304 srl out1, 24, local0 ! 8
2305 and out1, local5, local4 ! 4
2307 ldub [out2+local0], local0 ! 8 (and 0xFC)
2308 srl local4, 8, local4 ! 4
2309 xor in5, local2, in5 ! 2 finished local2 now sbox 6
2311 ld [global4+local4],local4 ! 4
2312 srl out1, 16, local2 ! 6
2313 xor in5, local3, in5 ! 3 finished local3 now sbox 5
2315 ld [out3+local0],local0 ! 8
2316 and local2, 252, local2 ! 6
2317 add global1, 1536, local5 ! address sbox 7
2319 ld [local6+local2], local2 ! 6
2320 srl out0, 16, local3 ! 5
2321 xor in5, local4, in5 ! 4 finished
2323 ld [local5+local1],local1 ! 7
2324 and local3, 252, local3 ! 5
2325 xor in5, local0, in5 ! 8 finished
2327 ld [global5+local3],local3 ! 5
2328 xor in5, local2, in5 ! 6 finished
2331 ld [in3+1*8+4], out0 ! key 8642 next round
2332 xor in5, local7, local2 ! sbox 5 next round
2333 xor in5, local1, in5 ! 7 finished
2335 srl local2, 16, local2 ! sbox 5 next round
2336 xor in5, local3, in5 ! 5 finished
2338 ld [in3+1*16+4], out1 ! key 8642 next round again
2339 and local2, 252, local2 ! sbox5 next round
2341 xor in5, local7, local7 ! 7531
2343 ld [global5+local2], local2 ! 5
2344 srl local7, 24, local3 ! 7
2345 xor in5, out0, out0 ! 8642
2347 ldub [out2+local3], local3 ! 7 (and 0xFC)
2348 srl out0, 4, local0 ! rotate 4 right
2349 and local7, 252, local1 ! 1
2351 sll out0, 28, out0 ! rotate
2352 xor out5, local2, out5 ! 5 finished local2 used
2354 srl local0, 8, local4 ! 4
2355 and local0, 252, local2 ! 2
2356 ld [local5+local3], local3 ! 7
2358 srl local0, 16, local5 ! 6
2359 or out0, local0, out0 ! rotate
2360 ld [global2+local2], local2 ! 2
2362 srl out0, 24, local0
2363 ld [in3+1*16], out0 ! key 7531 next round
2364 and local4, 252, local4 ! 4
2366 and local5, 252, local5 ! 6
2367 ld [global4+local4], local4 ! 4
2368 xor out5, local3, out5 ! 7 finished local3 used
2370 and local0, 252, local0 ! 8
2371 ld [local6+local5], local5 ! 6
2372 xor out5, local2, out5 ! 2 finished local2 now sbox 3
2374 srl local7, 8, local2 ! 3 start
2375 ld [out3+local0], local0 ! 8
2376 xor out5, local4, out5 ! 4 finished
2378 and local2, 252, local2 ! 3
2379 ld [global1+local1], local1 ! 1
2380 xor out5, local5, out5 ! 6 finished local5 used
2382 ld [global3+local2], local2 ! 3
2383 xor out5, local0, out5 ! 8 finished
2384 add in3, 1*16, in3 ! enc add 8, dec add -8 to key pointer
2386 ld [out2+284], local5 ! 0x0000FC00
2387 xor out5, out0, local4 ! sbox 1 next round
2388 xor out5, local1, out5 ! 1 finished
2390 xor out5, local2, out5 ! 3 finished
2392 bne,pt %icc, .ncbc.enc.1
2396 and local4, 252, local1 ! sbox 1 next round
2400 ld [global1+local1], local1
2401 xor out5, out1, out1
2402 xor out5, out0, out0
2404 srl out1, 4, local0 ! rotate
2405 and out0, local5, local3
2407 ld [in3+1*8], local7 ! key 7531
2408 srl local3, 8, local3
2409 and local0, 252, local2
2411 ld [global3+local3],local3
2412 sll out1, 28, out1 ! rotate
2413 xor in5, local1, in5 ! 1 finished, local1 now sbox 7
2415 ld [global2+local2], local2
2416 srl out0, 24, local1
2417 or out1, local0, out1 ! rotate
2419 ldub [out2+local1], local1
2420 srl out1, 24, local0
2421 and out1, local5, local4
2423 ldub [out2+local0], local0
2424 srl local4, 8, local4
2425 xor in5, local2, in5 ! 2 finished local2 now sbox 6
2427 ld [global4+local4],local4
2428 srl out1, 16, local2
2429 xor in5, local3, in5 ! 3 finished local3 now sbox 5
2431 ld [out3+local0],local0
2432 and local2, 252, local2
2433 add global1, 1536, local5 ! address sbox 7
2435 ld [local6+local2], local2
2436 srl out0, 16, local3
2437 xor in5, local4, in5 ! 4 finished
2439 ld [local5+local1],local1
2440 and local3, 252, local3
2441 xor in5, local0, in5
2443 ld [global5+local3],local3
2444 xor in5, local2, in5 ! 6 finished
2447 ld [out2+280], out4 ! loop counter
2448 xor in5, local7, local2 ! sbox 5 next round
2449 xor in5, local1, in5 ! 7 finished
2451 ld [in3+1*8+4], out0
2452 srl local2, 16, local2 ! sbox 5 next round
2453 xor in5, local3, in5 ! 5 finished
2455 and local2, 252, local2
2456 ! next round (two rounds more)
2457 xor in5, local7, local7 ! 7531
2459 ld [global5+local2], local2
2460 srl local7, 24, local3
2461 xor in5, out0, out0 ! 8642
2463 ldub [out2+local3], local3
2464 srl out0, 4, local0 ! rotate
2465 and local7, 252, local1
2467 sll out0, 28, out0 ! rotate
2468 xor out5, local2, out5 ! 5 finished local2 used
2470 srl local0, 8, local4
2471 and local0, 252, local2
2472 ld [local5+local3], local3
2474 srl local0, 16, local5
2475 or out0, local0, out0 ! rotate
2476 ld [global2+local2], local2
2478 srl out0, 24, local0
2479 ld [in4], out0 ! key next encryption/decryption
2480 and local4, 252, local4
2482 and local5, 252, local5
2483 ld [global4+local4], local4
2484 xor out5, local3, out5 ! 7 finished local3 used
2486 and local0, 252, local0
2487 ld [local6+local5], local5
2488 xor out5, local2, out5 ! 2 finished local2 now sbox 3
2490 srl local7, 8, local2 ! 3 start
2491 ld [out3+local0], local0
2492 xor out5, local4, out5
2494 and local2, 252, local2
2495 ld [global1+local1], local1
2496 xor out5, local5, out5 ! 6 finished local5 used
2498 ld [global3+local2], local2
2500 xor out5, local0, out5
2502 ld [in4+4], out1 ! key next encryption/decryption
2504 xor out5, local1, out5
2507 xor out5, local2, out5
2508 ! include encryption ks in3
2511 bl,pn %icc, .ncbc.enc.next.block_fp
2513 bl .ncbc.enc.next.block_fp
2515 add in0, 8, in0 ! input address
2517 ! If 8 or more bytes are to be encrypted after this block,
2518 ! we combine final permutation for this block with initial
2519 ! permutation for next block. Load next block:
2523 ! load_little_endian
2524 ! in0 global3 global4 local5 .LLE12
2526 ! first in memory to rightmost in register
2529 andcc in0, 3, global0
2533 lda [in0] 0x88, global3
2537 lda [local5] 0x88, global4
2541 ldub [in0+3], global3
2543 ldub [in0+2], local5
2544 sll global3, 8, global3
2545 or global3, local5, global3
2547 ldub [in0+1], local5
2548 sll global3, 8, global3
2549 or global3, local5, global3
2551 ldub [in0+0], local5
2552 sll global3, 8, global3
2553 or global3, local5, global3
2556 ldub [in0+3+4], global4
2558 ldub [in0+2+4], local5
2559 sll global4, 8, global4
2560 or global4, local5, global4
2562 ldub [in0+1+4], local5
2563 sll global4, 8, global4
2564 or global4, local5, global4
2566 ldub [in0+0+4], local5
2567 sll global4, 8, global4
2568 or global4, local5, global4
2573 ! parameter 1 original left
2574 ! parameter 2 original right
2575 ! parameter 3 left ip
2576 ! parameter 4 right ip
2577 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
2580 ! also adds -8 to length in2 and loads loop counter to out4
2585 ! out0 out1 global3 global4 2
2595 ! out0 in local3, local4
2597 ld [out2+256], local1
2599 or local3, local4, out0
2604 ld [out2+272], local5
2605 srl global4, 4, local0
2609 xor out4, out0, out4
2611 and out4, local5, out4
2612 xor local0, global3, local0
2615 xor out0, out4, out0
2617 and local0, local1, local0
2620 sll local0, 4, local7
2621 xor global3, local0, global3
2623 ld [out2+268], local4
2625 xor out1, local3, out1
2626 ld [out2+260], local2
2627 srl global3, 16, local0
2628 xor global4, local7, global4
2629 xor out4, out1, out4
2630 xor local0, global4, local0
2631 and out4, local4, out4
2632 and local0, local2, local0
2634 xor out1, out4, out1
2635 sll local0, 16, local7
2636 xor global4, local0, global4
2639 xor out0, local3, out0
2641 ld [out2+264], local3 ! ip3
2642 srl global4, 2, local0
2643 xor global3, local7, global3
2644 xor out4, out0, out4
2645 xor local0, global3, local0
2646 and out4, local3, out4
2647 and local0, local3, local0
2649 xor out0, out4, out0
2650 sll local0, 2, local7
2651 xor global3, local0, global3
2654 xor out1, local3, out1
2655 srl global3, 8, local0
2656 xor global4, local7, global4
2657 xor out4, out1, out4
2658 xor local0, global4, local0
2659 and out4, local2, out4
2660 and local0, local4, local0
2661 sll out4, 16, local3
2662 xor out1, out4, local4
2663 sll local0, 8, local7
2664 xor global4, local0, global4
2666 srl global4, 1, local0
2667 xor global3, local7, global3
2670 xor local0, global3, local0
2672 xor out0, local3, out0
2673 and local0, local5, local0
2675 sll local0, 1, local7
2676 xor out4, out0, out4
2678 xor global3, local0, global3
2679 xor global4, local7, global4
2681 sll global3, 3, local5
2682 and out4, local1, out4
2685 xor out0, out4, out0
2688 sll global4, 3, local2
2689 xor local4, local3, out1
2691 ! reload since used as temporar:
2693 ld [out2+280], out4 ! loop counter
2695 srl global3, 29, local0
2699 srl global4, 29, local7
2701 or local0, local5, global4
2702 or local2, local7, global3
2708 ! store_little_endian
2709 ! in1 out0 out1 local3 .SLE10
2711 ! rightmost in register to first in memory
2714 andcc in1, 3, global0
2718 sta out0, [in1] 0x88
2722 sta out1, [local3] 0x88
2726 and out0, 255, local3
2727 stub local3, [in1+0]
2730 and local3, 255, local3
2731 stub local3, [in1+1]
2733 srl out0, 16, local3
2734 and local3, 255, local3
2735 stub local3, [in1+2]
2737 srl out0, 24, local3
2738 stub local3, [in1+3]
2741 and out1, 255, local3
2742 stub local3, [in1+0+4]
2745 and local3, 255, local3
2746 stub local3, [in1+1+4]
2748 srl out1, 16, local3
2749 and local3, 255, local3
2750 stub local3, [in1+2+4]
2752 srl out1, 24, local3
2753 stub local3, [in1+3+4]
2759 ld [in3], out0 ! key 7531 first round next block
2761 xor global3, out5, in5 ! iv xor next block
2763 ld [in3+4], out1 ! key 8642
2764 add global1, 512, global3 ! address sbox 3 since register used
2765 xor global4, local1, out5 ! iv xor next block
2767 ba .ncbc.enc.next.block_2
2768 add in1, 8, in1 ! output adress
2770 .ncbc.enc.next.block_fp:
2777 ! initially undo the rotate 3 left done after initial permutation
2778 ! original left is received shifted 3 right and 29 left in local3/4
2780 sll out5, 29, local1
2781 or local3, local4, in5
2784 sethi %hi(0x55555555), local2
2786 or out5, local1, out5
2787 or local2, %lo(0x55555555), local2
2790 sethi %hi(0x00ff00ff), local1
2791 xor local3, in5, local3
2792 or local1, %lo(0x00ff00ff), local1
2793 and local3, local2, local3
2794 sethi %hi(0x33333333), local4
2795 sll local3, 1, local2
2797 xor in5, local3, in5
2800 xor out5, local2, out5
2801 xor local3, out5, local3
2802 or local4, %lo(0x33333333), local4
2803 and local3, local1, local3
2804 sethi %hi(0x0000ffff), local1
2805 sll local3, 8, local2
2807 xor out5, local3, out5
2810 xor in5, local2, in5
2811 xor local3, in5, local3
2812 or local1, %lo(0x0000ffff), local1
2813 and local3, local4, local3
2814 sethi %hi(0x0f0f0f0f), local4
2815 sll local3, 2, local2
2818 xor in5, local3, in5
2822 xor out5, local2, out5
2823 xor local3, out5, local3
2824 or local4, %lo(0x0f0f0f0f), local4
2825 and local3, local1, local3
2826 sll local3, 16, local2
2828 xor out5, local3, local1
2830 srl local1, 4, local3
2831 xor in5, local2, in5
2832 xor local3, in5, local3
2833 and local3, local4, local3
2834 sll local3, 4, local2
2836 xor in5, local3, in5
2842 xor local1, local2, out5
2850 ! store_little_endian
2851 ! in1 in5 out5 local3 .SLE1
2853 ! rightmost in register to first in memory
2856 andcc in1, 3, global0
2864 sta out5, [local3] 0x88
2868 and in5, 255, local3
2869 stub local3, [in1+0]
2872 and local3, 255, local3
2873 stub local3, [in1+1]
2876 and local3, 255, local3
2877 stub local3, [in1+2]
2880 stub local3, [in1+3]
2883 and out5, 255, local3
2884 stub local3, [in1+0+4]
2887 and local3, 255, local3
2888 stub local3, [in1+1+4]
2890 srl out5, 16, local3
2891 and local3, 255, local3
2892 stub local3, [in1+2+4]
2894 srl out5, 24, local3
2895 stub local3, [in1+3+4]
2901 addcc in2, -8, in2 ! bytes missing when next block done
2904 bpos,pt %icc, .ncbc.enc.next.block ! also jumps if 0
2906 bpos .ncbc.enc.next.block
2910 .ncbc.enc.seven.or.less:
2915 ble,pt %icc, .ncbc.enc.finish
2917 ble .ncbc.enc.finish
2921 add in2, 8, local1 ! bytes to load
2923 ! addr, length, dest left, dest right, temp, local3, label, ret label
2927 ! in0 local1 local2 local3 .LNB1 .ncbc.enc.next.block_1 .LNB1 .ncbc.enc.next.block_1
2930 sll local1, 2, local3
2932 add %o7,.LNB1.jmp.table-.LNB1.0,local2
2934 add local2, local3, local2
2943 ldub [in0+6], local2
2944 sll local2, 16, local2
2945 or global4, local2, global4
2947 ldub [in0+5], local2
2948 sll local2, 8, local2
2949 or global4, local2, global4
2951 ldub [in0+4], local2
2952 or global4, local2, global4
2954 ldub [in0+3], local2
2955 sll local2, 24, local2
2956 or out4, local2, out4
2958 ldub [in0+2], local2
2959 sll local2, 16, local2
2960 or out4, local2, out4
2962 ldub [in0+1], local2
2963 sll local2, 8, local2
2964 or out4, local2, out4
2966 ldub [in0+0], local2
2967 ba .ncbc.enc.next.block_1
2968 or out4, local2, out4
2974 .word .LNB1.1-.LNB1.0
2975 .word .LNB1.2-.LNB1.0
2976 .word .LNB1.3-.LNB1.0
2977 .word .LNB1.4-.LNB1.0
2978 .word .LNB1.5-.LNB1.0
2979 .word .LNB1.6-.LNB1.0
2980 .word .LNB1.7-.LNB1.0
2983 ! Loads 1 to 7 bytes little endian to global4, out4
2988 LDPTR [%sp+BIAS+ARG0+4*ARGSZ] , local4
2991 ! store_little_endian
2992 ! local4 in5 out5 local5 .SLE2
2994 ! rightmost in register to first in memory
2997 andcc local4, 3, global0
3001 sta in5, [local4] 0x88
3002 add local4, 4, local5
3005 sta out5, [local5] 0x88
3009 and in5, 255, local5
3010 stub local5, [local4+0]
3013 and local5, 255, local5
3014 stub local5, [local4+1]
3017 and local5, 255, local5
3018 stub local5, [local4+2]
3021 stub local5, [local4+3]
3024 and out5, 255, local5
3025 stub local5, [local4+0+4]
3028 and local5, 255, local5
3029 stub local5, [local4+1+4]
3031 srl out5, 16, local5
3032 and local5, 255, local5
3033 stub local5, [local4+2+4]
3035 srl out5, 24, local5
3036 stub local5, [local4+3+4]
3048 STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
3052 LDPTR [%sp+BIAS+ARG0+4*ARGSZ] , local7 ! ivec
3054 ble,pn %icc, .ncbc.dec.finish
3056 ble .ncbc.dec.finish
3058 mov in3, in4 ! schedule
3060 STPTR in1, [%sp+BIAS+ARG0+1*ARGSZ]
3061 mov in0, local5 ! input
3065 ! load_little_endian
3066 ! local7 in0 in1 local3 .LLE3
3068 ! first in memory to rightmost in register
3071 andcc local7, 3, global0
3075 lda [local7] 0x88, in0
3076 add local7, 4, local3
3079 lda [local3] 0x88, in1
3083 ldub [local7+3], in0
3085 ldub [local7+2], local3
3089 ldub [local7+1], local3
3093 ldub [local7+0], local3
3098 ldub [local7+3+4], in1
3100 ldub [local7+2+4], local3
3104 ldub [local7+1+4], local3
3108 ldub [local7+0+4], local3
3115 .ncbc.dec.next.block:
3119 ! load_little_endian
3120 ! local5 in5 out5 local3 .LLE4
3122 ! first in memory to rightmost in register
3125 andcc local5, 3, global0
3129 lda [local5] 0x88, in5
3130 add local5, 4, local3
3133 lda [local3] 0x88, out5
3137 ldub [local5+3], in5
3139 ldub [local5+2], local3
3143 ldub [local5+1], local3
3147 ldub [local5+0], local3
3152 ldub [local5+3+4], out5
3154 ldub [local5+2+4], local3
3156 or out5, local3, out5
3158 ldub [local5+1+4], local3
3160 or out5, local3, out5
3162 ldub [local5+0+4], local3
3164 or out5, local3, out5
3169 ! parameter 6 1/2 for include encryption/decryption
3170 ! parameter 7 1 for mov in1 to in3
3171 ! parameter 8 1 for mov in3 to in4
3176 ! in5 out5 in5 out5 in4 2 0 1
3178 ld [out2+256], local1
3181 xor local4, in5, local4
3184 ld [out2+260], local2
3185 and local4, local1, local4
3189 ld [out2+280], out4 ! loop counter
3190 sll local4, 4, local1
3191 xor in5, local4, in5
3193 ld [out2+264], local3
3195 xor out5, local1, out5
3198 xor local4, out5, local4
3199 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
3202 and local4, local2, local4
3203 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
3205 sll local4, 16, local1
3206 xor out5, local4, out5
3209 xor in5, local1, in5
3211 sethi %hi(16711680), local5
3212 xor local4, in5, local4
3214 and local4, local3, local4
3215 or local5, 255, local5
3217 sll local4, 2, local2
3218 xor in5, local4, in5
3221 xor out5, local2, out5
3223 xor local4, out5, local4
3224 add global1, 768, global4
3226 and local4, local5, local4
3227 add global1, 1024, global5
3229 ld [out2+272], local7
3230 sll local4, 8, local1
3231 xor out5, local4, out5
3234 xor in5, local1, in5
3236 ld [in4], out0 ! key 7531
3237 xor local4, in5, local4
3238 add global1, 256, global2
3240 ld [in4+4], out1 ! key 8642
3241 and local4, local7, local4
3242 add global1, 512, global3
3244 sll local4, 1, local1
3245 xor in5, local4, in5
3248 xor out5, local1, out5
3251 add global1, 1280, local6 ! address sbox 8
3254 add global1, 1792, out3 ! address sbox 8
3256 srl out5, 29, local1
3257 or local4, local3, in5
3259 or local2, local1, out5
3265 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
3266 or local2, local1, out5
3267 xor in5, out0, local1
3270 and local1, 252, local1
3273 ! include decryprion ks in4
3280 ! initially undo the rotate 3 left done after initial permutation
3281 ! original left is received shifted 3 right and 29 left in local3/4
3284 or local3, local4, out5
3287 sethi %hi(0x55555555), local2
3290 or local2, %lo(0x55555555), local2
3293 sethi %hi(0x00ff00ff), local1
3294 xor local3, out5, local3
3295 or local1, %lo(0x00ff00ff), local1
3296 and local3, local2, local3
3297 sethi %hi(0x33333333), local4
3298 sll local3, 1, local2
3300 xor out5, local3, out5
3303 xor in5, local2, in5
3304 xor local3, in5, local3
3305 or local4, %lo(0x33333333), local4
3306 and local3, local1, local3
3307 sethi %hi(0x0000ffff), local1
3308 sll local3, 8, local2
3310 xor in5, local3, in5
3313 xor out5, local2, out5
3314 xor local3, out5, local3
3315 or local1, %lo(0x0000ffff), local1
3316 and local3, local4, local3
3317 sethi %hi(0x0f0f0f0f), local4
3318 sll local3, 2, local2
3320 LDPTR [%sp+BIAS+ARG0+0*ARGSZ] , local5
3321 xor out5, local3, out5
3323 LDPTR [%sp+BIAS+ARG0+1*ARGSZ] , local7
3324 srl out5, 16, local3
3325 xor in5, local2, in5
3326 xor local3, in5, local3
3327 or local4, %lo(0x0f0f0f0f), local4
3328 and local3, local1, local3
3329 sll local3, 16, local2
3331 xor in5, local3, local1
3333 srl local1, 4, local3
3334 xor out5, local2, out5
3335 xor local3, out5, local3
3336 and local3, local4, local3
3337 sll local3, 4, local2
3339 xor out5, local3, out5
3345 xor local1, local2, in5
3349 ! 1 for input and output address to local5/7
3351 ! in2 is bytes left to be stored
3352 ! in2 is compared to 8 in the rounds
3354 xor out5, in0, out4 ! iv xor
3356 bl,pn %icc, .ncbc.dec.seven.or.less
3358 bl .ncbc.dec.seven.or.less
3360 xor in5, in1, global4 ! iv xor
3362 ! Load ivec next block now, since input and output address might be the same.
3366 ! load_little_endian_inc
3367 ! local5 in0 in1 local3 .LLE5
3369 ! first in memory to rightmost in register
3372 andcc local5, 3, global0
3376 lda [local5] 0x88, in0
3377 add local5, 4, local5
3379 lda [local5] 0x88, in1
3381 add local5, 4, local5
3385 ldub [local5+3], in0
3387 ldub [local5+2], local3
3391 ldub [local5+1], local3
3395 ldub [local5+0], local3
3399 ldub [local5+3+4], in1
3400 add local5, 8, local5
3402 ldub [local5+2+4-8], local3
3406 ldub [local5+1+4-8], local3
3410 ldub [local5+0+4-8], local3
3419 ! store_little_endian
3420 ! local7 out4 global4 local3 .SLE3
3422 ! rightmost in register to first in memory
3425 andcc local7, 3, global0
3429 sta out4, [local7] 0x88
3430 add local7, 4, local3
3433 sta global4, [local3] 0x88
3437 and out4, 255, local3
3438 stub local3, [local7+0]
3441 and local3, 255, local3
3442 stub local3, [local7+1]
3444 srl out4, 16, local3
3445 and local3, 255, local3
3446 stub local3, [local7+2]
3448 srl out4, 24, local3
3449 stub local3, [local7+3]
3452 and global4, 255, local3
3453 stub local3, [local7+0+4]
3455 srl global4, 8, local3
3456 and local3, 255, local3
3457 stub local3, [local7+1+4]
3459 srl global4, 16, local3
3460 and local3, 255, local3
3461 stub local3, [local7+2+4]
3463 srl global4, 24, local3
3464 stub local3, [local7+3+4]
3470 STPTR local5, [%sp+BIAS+ARG0+0*ARGSZ]
3471 add local7, 8, local7
3475 bg,pt %icc, .ncbc.dec.next.block
3477 bg .ncbc.dec.next.block
3479 STPTR local7, [%sp+BIAS+ARG0+1*ARGSZ]
3484 LDPTR [%sp+BIAS+ARG0+4*ARGSZ] , local4 ! ivec
3487 ! store_little_endian
3488 ! local4 in0 in1 local5 .SLE4
3490 ! rightmost in register to first in memory
3493 andcc local4, 3, global0
3497 sta in0, [local4] 0x88
3498 add local4, 4, local5
3501 sta in1, [local5] 0x88
3505 and in0, 255, local5
3506 stub local5, [local4+0]
3509 and local5, 255, local5
3510 stub local5, [local4+1]
3513 and local5, 255, local5
3514 stub local5, [local4+2]
3517 stub local5, [local4+3]
3520 and in1, 255, local5
3521 stub local5, [local4+0+4]
3524 and local5, 255, local5
3525 stub local5, [local4+1+4]
3528 and local5, 255, local5
3529 stub local5, [local4+2+4]
3532 stub local5, [local4+3+4]
3543 .ncbc.dec.seven.or.less:
3547 ! load_little_endian_inc
3548 ! local5 in0 in1 local3 .LLE13
3550 ! first in memory to rightmost in register
3553 andcc local5, 3, global0
3557 lda [local5] 0x88, in0
3558 add local5, 4, local5
3560 lda [local5] 0x88, in1
3562 add local5, 4, local5
3566 ldub [local5+3], in0
3568 ldub [local5+2], local3
3572 ldub [local5+1], local3
3576 ldub [local5+0], local3
3580 ldub [local5+3+4], in1
3581 add local5, 8, local5
3583 ldub [local5+2+4-8], local3
3587 ldub [local5+1+4-8], local3
3591 ldub [local5+0+4-8], local3
3601 ! local7 in2 local3 local4 .SNB1 .ncbc.dec.store.iv .SNB1 .ncbc.dec.store.iv
3606 add %o7,.SNB1.jmp.table-.SNB1.0,local3
3608 add local3, local4, local3
3616 srl global4, 16, local3
3617 and local3, 0xff, local3
3618 stub local3, [local7+6]
3620 srl global4, 8, local3
3621 and local3, 0xff, local3
3622 stub local3, [local7+5]
3624 and global4, 0xff, local3
3625 stub local3, [local7+4]
3627 srl out4, 24, local3
3628 stub local3, [local7+3]
3630 srl out4, 16, local3
3631 and local3, 0xff, local3
3632 stub local3, [local7+2]
3635 and local3, 0xff, local3
3636 stub local3, [local7+1]
3638 and out4, 0xff, local3
3641 ba .ncbc.dec.store.iv
3642 stub local3, [local7]
3649 .word .SNB1.1-.SNB1.0
3650 .word .SNB1.2-.SNB1.0
3651 .word .SNB1.3-.SNB1.0
3652 .word .SNB1.4-.SNB1.0
3653 .word .SNB1.5-.SNB1.0
3654 .word .SNB1.6-.SNB1.0
3655 .word .SNB1.7-.SNB1.0
3659 .DES_ncbc_encrypt.end:
3660 .size DES_ncbc_encrypt, .DES_ncbc_encrypt.end-DES_ncbc_encrypt
3663 ! void DES_ede3_cbc_encrypt(input, output, lenght, ks1, ks2, ks3, ivec, enc)
3664 ! **************************************************************************
3668 .global DES_ede3_cbc_encrypt
3669 .type DES_ede3_cbc_encrypt,#function
3671 DES_ede3_cbc_encrypt:
3673 save %sp, FRAME, %sp
3679 sethi %hi(_PIC_DES_SPtrans-1f),global1
3680 or global1,%lo(_PIC_DES_SPtrans-1f),global1
3682 add %o7,global1,global1
3683 sub global1,_PIC_DES_SPtrans-.des_and,out2
3685 LDPTR [%fp+BIAS+ARG0+7*ARGSZ], local3 ! enc
3686 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
3690 be,pn %icc, .ede3.dec
3694 STPTR in4, [%sp+BIAS+ARG0+4*ARGSZ]
3696 STPTR in5, [%sp+BIAS+ARG0+5*ARGSZ]
3700 ! load_little_endian
3701 ! local4 in5 out5 local3 .LLE6
3703 ! first in memory to rightmost in register
3706 andcc local4, 3, global0
3710 lda [local4] 0x88, in5
3711 add local4, 4, local3
3714 lda [local3] 0x88, out5
3718 ldub [local4+3], in5
3720 ldub [local4+2], local3
3724 ldub [local4+1], local3
3728 ldub [local4+0], local3
3733 ldub [local4+3+4], out5
3735 ldub [local4+2+4], local3
3737 or out5, local3, out5
3739 ldub [local4+1+4], local3
3741 or out5, local3, out5
3743 ldub [local4+0+4], local3
3745 or out5, local3, out5
3750 addcc in2, -8, in2 ! bytes missing after next block
3753 bl,pn %icc, .ede3.enc.seven.or.less
3755 bl .ede3.enc.seven.or.less
3757 STPTR in3, [%sp+BIAS+ARG0+3*ARGSZ]
3759 .ede3.enc.next.block:
3763 ! load_little_endian
3764 ! in0 out4 global4 local3 .LLE7
3766 ! first in memory to rightmost in register
3769 andcc in0, 3, global0
3773 lda [in0] 0x88, out4
3777 lda [local3] 0x88, global4
3783 ldub [in0+2], local3
3785 or out4, local3, out4
3787 ldub [in0+1], local3
3789 or out4, local3, out4
3791 ldub [in0+0], local3
3793 or out4, local3, out4
3796 ldub [in0+3+4], global4
3798 ldub [in0+2+4], local3
3799 sll global4, 8, global4
3800 or global4, local3, global4
3802 ldub [in0+1+4], local3
3803 sll global4, 8, global4
3804 or global4, local3, global4
3806 ldub [in0+0+4], local3
3807 sll global4, 8, global4
3808 or global4, local3, global4
3813 .ede3.enc.next.block_1:
3815 LDPTR [%sp+BIAS+ARG0+4*ARGSZ] , in4
3816 xor in5, out4, in5 ! iv xor
3817 xor out5, global4, out5 ! iv xor
3819 LDPTR [%sp+BIAS+ARG0+3*ARGSZ] , in3
3820 add in4, 120, in4 ! for decryption we use last subkey first
3826 ! in5 out5 out5 in5 in3
3828 ld [out2+256], local1
3831 xor local4, in5, local4
3834 ld [out2+260], local2
3835 and local4, local1, local4
3839 ld [out2+280], out4 ! loop counter
3840 sll local4, 4, local1
3841 xor in5, local4, in5
3843 ld [out2+264], local3
3845 xor out5, local1, out5
3848 xor local4, out5, local4
3849 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
3852 and local4, local2, local4
3853 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
3855 sll local4, 16, local1
3856 xor out5, local4, out5
3859 xor in5, local1, in5
3861 sethi %hi(16711680), local5
3862 xor local4, in5, local4
3864 and local4, local3, local4
3865 or local5, 255, local5
3867 sll local4, 2, local2
3868 xor in5, local4, in5
3871 xor out5, local2, out5
3873 xor local4, out5, local4
3874 add global1, 768, global4
3876 and local4, local5, local4
3877 add global1, 1024, global5
3879 ld [out2+272], local7
3880 sll local4, 8, local1
3881 xor out5, local4, out5
3884 xor in5, local1, in5
3886 ld [in3], out0 ! key 7531
3887 xor local4, in5, local4
3888 add global1, 256, global2
3890 ld [in3+4], out1 ! key 8642
3891 and local4, local7, local4
3892 add global1, 512, global3
3894 sll local4, 1, local1
3895 xor in5, local4, in5
3898 xor out5, local1, out5
3901 add global1, 1280, local6 ! address sbox 8
3904 add global1, 1792, out3 ! address sbox 8
3906 srl out5, 29, local1
3907 or local4, local3, out5
3909 or local2, local1, in5
3916 .ede3.enc.next.block_2:
3918 call .des_enc ! ks1 in3
3921 call .des_dec ! ks2 in4
3922 LDPTR [%sp+BIAS+ARG0+5*ARGSZ] , in3
3924 call .des_enc ! ks3 in3 compares in2 to 8
3928 bl,pn %icc, .ede3.enc.next.block_fp
3930 bl .ede3.enc.next.block_fp
3934 ! If 8 or more bytes are to be encrypted after this block,
3935 ! we combine final permutation for this block with initial
3936 ! permutation for next block. Load next block:
3940 ! load_little_endian
3941 ! in0 global3 global4 local5 .LLE11
3943 ! first in memory to rightmost in register
3946 andcc in0, 3, global0
3950 lda [in0] 0x88, global3
3954 lda [local5] 0x88, global4
3958 ldub [in0+3], global3
3960 ldub [in0+2], local5
3961 sll global3, 8, global3
3962 or global3, local5, global3
3964 ldub [in0+1], local5
3965 sll global3, 8, global3
3966 or global3, local5, global3
3968 ldub [in0+0], local5
3969 sll global3, 8, global3
3970 or global3, local5, global3
3973 ldub [in0+3+4], global4
3975 ldub [in0+2+4], local5
3976 sll global4, 8, global4
3977 or global4, local5, global4
3979 ldub [in0+1+4], local5
3980 sll global4, 8, global4
3981 or global4, local5, global4
3983 ldub [in0+0+4], local5
3984 sll global4, 8, global4
3985 or global4, local5, global4
3990 ! parameter 1 original left
3991 ! parameter 2 original right
3992 ! parameter 3 left ip
3993 ! parameter 4 right ip
3994 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
3997 ! also adds -8 to length in2 and loads loop counter to out4
4002 ! out0 out1 global3 global4 1
4012 ! out0 in local3, local4
4014 ld [out2+256], local1
4016 or local3, local4, out0
4021 ld [out2+272], local5
4022 srl global4, 4, local0
4026 xor out4, out0, out4
4028 and out4, local5, out4
4029 xor local0, global3, local0
4032 xor out0, out4, out0
4034 and local0, local1, local0
4037 sll local0, 4, local7
4038 xor global3, local0, global3
4040 ld [out2+268], local4
4042 xor out1, local3, out1
4043 ld [out2+260], local2
4044 srl global3, 16, local0
4045 xor global4, local7, global4
4046 xor out4, out1, out4
4047 xor local0, global4, local0
4048 and out4, local4, out4
4049 and local0, local2, local0
4051 xor out1, out4, out1
4052 sll local0, 16, local7
4053 xor global4, local0, global4
4056 xor out0, local3, out0
4058 ld [out2+264], local3 ! ip3
4059 srl global4, 2, local0
4060 xor global3, local7, global3
4061 xor out4, out0, out4
4062 xor local0, global3, local0
4063 and out4, local3, out4
4064 and local0, local3, local0
4066 xor out0, out4, out0
4067 sll local0, 2, local7
4068 xor global3, local0, global3
4071 xor out1, local3, out1
4072 srl global3, 8, local0
4073 xor global4, local7, global4
4074 xor out4, out1, out4
4075 xor local0, global4, local0
4076 and out4, local2, out4
4077 and local0, local4, local0
4078 sll out4, 16, local3
4079 xor out1, out4, local4
4080 sll local0, 8, local7
4081 xor global4, local0, global4
4083 srl global4, 1, local0
4084 xor global3, local7, global3
4087 xor local0, global3, local0
4089 xor out0, local3, out0
4090 and local0, local5, local0
4092 sll local0, 1, local7
4093 xor out4, out0, out4
4095 xor global3, local0, global3
4096 xor global4, local7, global4
4098 sll global3, 3, local5
4099 and out4, local1, out4
4102 xor out0, out4, out0
4104 LDPTR [%sp+BIAS+ARG0+4*ARGSZ] , in4
4105 sll global4, 3, local2
4106 xor local4, local3, out1
4108 ! reload since used as temporar:
4110 ld [out2+280], out4 ! loop counter
4112 srl global3, 29, local0
4115 LDPTR [%sp+BIAS+ARG0+3*ARGSZ] , in3
4116 srl global4, 29, local7
4118 or local0, local5, global4
4119 or local2, local7, global3
4125 ! store_little_endian
4126 ! in1 out0 out1 local3 .SLE9
4128 ! rightmost in register to first in memory
4131 andcc in1, 3, global0
4135 sta out0, [in1] 0x88
4139 sta out1, [local3] 0x88
4143 and out0, 255, local3
4144 stub local3, [in1+0]
4147 and local3, 255, local3
4148 stub local3, [in1+1]
4150 srl out0, 16, local3
4151 and local3, 255, local3
4152 stub local3, [in1+2]
4154 srl out0, 24, local3
4155 stub local3, [in1+3]
4158 and out1, 255, local3
4159 stub local3, [in1+0+4]
4162 and local3, 255, local3
4163 stub local3, [in1+1+4]
4165 srl out1, 16, local3
4166 and local3, 255, local3
4167 stub local3, [in1+2+4]
4169 srl out1, 24, local3
4170 stub local3, [in1+3+4]
4177 xor global3, out5, in5 ! iv xor next block
4179 ld [in3], out0 ! key 7531
4180 add global1, 512, global3 ! address sbox 3
4181 xor global4, local1, out5 ! iv xor next block
4183 ld [in3+4], out1 ! key 8642
4184 add global1, 768, global4 ! address sbox 4
4185 ba .ede3.enc.next.block_2
4188 .ede3.enc.next.block_fp:
4195 ! initially undo the rotate 3 left done after initial permutation
4196 ! original left is received shifted 3 right and 29 left in local3/4
4198 sll out5, 29, local1
4199 or local3, local4, in5
4202 sethi %hi(0x55555555), local2
4204 or out5, local1, out5
4205 or local2, %lo(0x55555555), local2
4208 sethi %hi(0x00ff00ff), local1
4209 xor local3, in5, local3
4210 or local1, %lo(0x00ff00ff), local1
4211 and local3, local2, local3
4212 sethi %hi(0x33333333), local4
4213 sll local3, 1, local2
4215 xor in5, local3, in5
4218 xor out5, local2, out5
4219 xor local3, out5, local3
4220 or local4, %lo(0x33333333), local4
4221 and local3, local1, local3
4222 sethi %hi(0x0000ffff), local1
4223 sll local3, 8, local2
4225 xor out5, local3, out5
4228 xor in5, local2, in5
4229 xor local3, in5, local3
4230 or local1, %lo(0x0000ffff), local1
4231 and local3, local4, local3
4232 sethi %hi(0x0f0f0f0f), local4
4233 sll local3, 2, local2
4236 xor in5, local3, in5
4240 xor out5, local2, out5
4241 xor local3, out5, local3
4242 or local4, %lo(0x0f0f0f0f), local4
4243 and local3, local1, local3
4244 sll local3, 16, local2
4246 xor out5, local3, local1
4248 srl local1, 4, local3
4249 xor in5, local2, in5
4250 xor local3, in5, local3
4251 and local3, local4, local3
4252 sll local3, 4, local2
4254 xor in5, local3, in5
4260 xor local1, local2, out5
4268 ! store_little_endian
4269 ! in1 in5 out5 local3 .SLE5
4271 ! rightmost in register to first in memory
4274 andcc in1, 3, global0
4282 sta out5, [local3] 0x88
4286 and in5, 255, local3
4287 stub local3, [in1+0]
4290 and local3, 255, local3
4291 stub local3, [in1+1]
4294 and local3, 255, local3
4295 stub local3, [in1+2]
4298 stub local3, [in1+3]
4301 and out5, 255, local3
4302 stub local3, [in1+0+4]
4305 and local3, 255, local3
4306 stub local3, [in1+1+4]
4308 srl out5, 16, local3
4309 and local3, 255, local3
4310 stub local3, [in1+2+4]
4312 srl out5, 24, local3
4313 stub local3, [in1+3+4]
4319 addcc in2, -8, in2 ! bytes missing when next block done
4322 bpos,pt %icc, .ede3.enc.next.block
4324 bpos .ede3.enc.next.block
4328 .ede3.enc.seven.or.less:
4333 ble,pt %icc, .ede3.enc.finish
4335 ble .ede3.enc.finish
4339 add in2, 8, local1 ! bytes to load
4341 ! addr, length, dest left, dest right, temp, local3, label, ret label
4345 ! in0 local1 local2 local3 .LNB2 .ede3.enc.next.block_1 .LNB2 .ede3.enc.next.block_1
4348 sll local1, 2, local3
4350 add %o7,.LNB2.jmp.table-.LNB2.0,local2
4352 add local2, local3, local2
4361 ldub [in0+6], local2
4362 sll local2, 16, local2
4363 or global4, local2, global4
4365 ldub [in0+5], local2
4366 sll local2, 8, local2
4367 or global4, local2, global4
4369 ldub [in0+4], local2
4370 or global4, local2, global4
4372 ldub [in0+3], local2
4373 sll local2, 24, local2
4374 or out4, local2, out4
4376 ldub [in0+2], local2
4377 sll local2, 16, local2
4378 or out4, local2, out4
4380 ldub [in0+1], local2
4381 sll local2, 8, local2
4382 or out4, local2, out4
4384 ldub [in0+0], local2
4385 ba .ede3.enc.next.block_1
4386 or out4, local2, out4
4392 .word .LNB2.1-.LNB2.0
4393 .word .LNB2.2-.LNB2.0
4394 .word .LNB2.3-.LNB2.0
4395 .word .LNB2.4-.LNB2.0
4396 .word .LNB2.5-.LNB2.0
4397 .word .LNB2.6-.LNB2.0
4398 .word .LNB2.7-.LNB2.0
4403 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
4406 ! store_little_endian
4407 ! local4 in5 out5 local5 .SLE6
4409 ! rightmost in register to first in memory
4412 andcc local4, 3, global0
4416 sta in5, [local4] 0x88
4417 add local4, 4, local5
4420 sta out5, [local5] 0x88
4424 and in5, 255, local5
4425 stub local5, [local4+0]
4428 and local5, 255, local5
4429 stub local5, [local4+1]
4432 and local5, 255, local5
4433 stub local5, [local4+2]
4436 stub local5, [local4+3]
4439 and out5, 255, local5
4440 stub local5, [local4+0+4]
4443 and local5, 255, local5
4444 stub local5, [local4+1+4]
4446 srl out5, 16, local5
4447 and local5, 255, local5
4448 stub local5, [local4+2+4]
4450 srl out5, 24, local5
4451 stub local5, [local4+3+4]
4462 STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
4465 STPTR in1, [%sp+BIAS+ARG0+1*ARGSZ]
4469 STPTR in3, [%sp+BIAS+ARG0+3*ARGSZ]
4473 ble %icc, .ede3.dec.finish
4475 ble .ede3.dec.finish
4477 STPTR in5, [%sp+BIAS+ARG0+5*ARGSZ]
4479 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local7 ! iv
4482 ! load_little_endian
4483 ! local7 in0 in1 local3 .LLE8
4485 ! first in memory to rightmost in register
4488 andcc local7, 3, global0
4492 lda [local7] 0x88, in0
4493 add local7, 4, local3
4496 lda [local3] 0x88, in1
4500 ldub [local7+3], in0
4502 ldub [local7+2], local3
4506 ldub [local7+1], local3
4510 ldub [local7+0], local3
4515 ldub [local7+3+4], in1
4517 ldub [local7+2+4], local3
4521 ldub [local7+1+4], local3
4525 ldub [local7+0+4], local3
4532 .ede3.dec.next.block:
4536 ! load_little_endian
4537 ! local5 in5 out5 local3 .LLE9
4539 ! first in memory to rightmost in register
4542 andcc local5, 3, global0
4546 lda [local5] 0x88, in5
4547 add local5, 4, local3
4550 lda [local3] 0x88, out5
4554 ldub [local5+3], in5
4556 ldub [local5+2], local3
4560 ldub [local5+1], local3
4564 ldub [local5+0], local3
4569 ldub [local5+3+4], out5
4571 ldub [local5+2+4], local3
4573 or out5, local3, out5
4575 ldub [local5+1+4], local3
4577 or out5, local3, out5
4579 ldub [local5+0+4], local3
4581 or out5, local3, out5
4586 ! parameter 6 1/2 for include encryption/decryption
4587 ! parameter 7 1 for mov in1 to in3
4588 ! parameter 8 1 for mov in3 to in4
4589 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
4594 ! in5 out5 in5 out5 in4 2 0 0 1
4596 ld [out2+256], local1
4599 xor local4, in5, local4
4602 ld [out2+260], local2
4603 and local4, local1, local4
4607 ld [out2+280], out4 ! loop counter
4608 sll local4, 4, local1
4609 xor in5, local4, in5
4611 ld [out2+264], local3
4613 xor out5, local1, out5
4615 LDPTR [%sp+BIAS+ARG0+5*ARGSZ] , in4
4616 xor local4, out5, local4
4617 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
4619 LDPTR [%sp+BIAS+ARG0+4*ARGSZ] , in3
4620 and local4, local2, local4
4621 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
4623 sll local4, 16, local1
4624 xor out5, local4, out5
4627 xor in5, local1, in5
4629 sethi %hi(16711680), local5
4630 xor local4, in5, local4
4632 and local4, local3, local4
4633 or local5, 255, local5
4635 sll local4, 2, local2
4636 xor in5, local4, in5
4639 xor out5, local2, out5
4641 xor local4, out5, local4
4642 add global1, 768, global4
4644 and local4, local5, local4
4645 add global1, 1024, global5
4647 ld [out2+272], local7
4648 sll local4, 8, local1
4649 xor out5, local4, out5
4652 xor in5, local1, in5
4654 ld [in4], out0 ! key 7531
4655 xor local4, in5, local4
4656 add global1, 256, global2
4658 ld [in4+4], out1 ! key 8642
4659 and local4, local7, local4
4660 add global1, 512, global3
4662 sll local4, 1, local1
4663 xor in5, local4, in5
4666 xor out5, local1, out5
4669 add global1, 1280, local6 ! address sbox 8
4672 add global1, 1792, out3 ! address sbox 8
4674 srl out5, 29, local1
4675 or local4, local3, in5
4677 or local2, local1, out5
4683 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
4684 or local2, local1, out5
4685 xor in5, out0, local1
4688 and local1, 252, local1
4691 ! inc .des_dec ks3 in4
4693 call .des_enc ! ks2 in3
4694 LDPTR [%sp+BIAS+ARG0+3*ARGSZ] , in4
4696 call .des_dec ! ks1 in4
4704 ! initially undo the rotate 3 left done after initial permutation
4705 ! original left is received shifted 3 right and 29 left in local3/4
4708 or local3, local4, out5
4711 sethi %hi(0x55555555), local2
4714 or local2, %lo(0x55555555), local2
4717 sethi %hi(0x00ff00ff), local1
4718 xor local3, out5, local3
4719 or local1, %lo(0x00ff00ff), local1
4720 and local3, local2, local3
4721 sethi %hi(0x33333333), local4
4722 sll local3, 1, local2
4724 xor out5, local3, out5
4727 xor in5, local2, in5
4728 xor local3, in5, local3
4729 or local4, %lo(0x33333333), local4
4730 and local3, local1, local3
4731 sethi %hi(0x0000ffff), local1
4732 sll local3, 8, local2
4734 xor in5, local3, in5
4737 xor out5, local2, out5
4738 xor local3, out5, local3
4739 or local1, %lo(0x0000ffff), local1
4740 and local3, local4, local3
4741 sethi %hi(0x0f0f0f0f), local4
4742 sll local3, 2, local2
4744 LDPTR [%sp+BIAS+ARG0+0*ARGSZ] , local5
4745 xor out5, local3, out5
4747 LDPTR [%sp+BIAS+ARG0+1*ARGSZ] , local7
4748 srl out5, 16, local3
4749 xor in5, local2, in5
4750 xor local3, in5, local3
4751 or local4, %lo(0x0f0f0f0f), local4
4752 and local3, local1, local3
4753 sll local3, 16, local2
4755 xor in5, local3, local1
4757 srl local1, 4, local3
4758 xor out5, local2, out5
4759 xor local3, out5, local3
4760 and local3, local4, local3
4761 sll local3, 4, local2
4763 xor out5, local3, out5
4769 xor local1, local2, in5
4773 ! 1 for input and output address local5/7
4775 ! in2 is bytes left to be stored
4776 ! in2 is compared to 8 in the rounds
4780 bl,pn %icc, .ede3.dec.seven.or.less
4782 bl .ede3.dec.seven.or.less
4784 xor in5, in1, global4
4788 ! load_little_endian_inc
4789 ! local5 in0 in1 local3 .LLE10
4791 ! first in memory to rightmost in register
4794 andcc local5, 3, global0
4798 lda [local5] 0x88, in0
4799 add local5, 4, local5
4801 lda [local5] 0x88, in1
4803 add local5, 4, local5
4807 ldub [local5+3], in0
4809 ldub [local5+2], local3
4813 ldub [local5+1], local3
4817 ldub [local5+0], local3
4821 ldub [local5+3+4], in1
4822 add local5, 8, local5
4824 ldub [local5+2+4-8], local3
4828 ldub [local5+1+4-8], local3
4832 ldub [local5+0+4-8], local3
4841 ! store_little_endian
4842 ! local7 out4 global4 local3 .SLE7
4844 ! rightmost in register to first in memory
4847 andcc local7, 3, global0
4851 sta out4, [local7] 0x88
4852 add local7, 4, local3
4855 sta global4, [local3] 0x88
4859 and out4, 255, local3
4860 stub local3, [local7+0]
4863 and local3, 255, local3
4864 stub local3, [local7+1]
4866 srl out4, 16, local3
4867 and local3, 255, local3
4868 stub local3, [local7+2]
4870 srl out4, 24, local3
4871 stub local3, [local7+3]
4874 and global4, 255, local3
4875 stub local3, [local7+0+4]
4877 srl global4, 8, local3
4878 and local3, 255, local3
4879 stub local3, [local7+1+4]
4881 srl global4, 16, local3
4882 and local3, 255, local3
4883 stub local3, [local7+2+4]
4885 srl global4, 24, local3
4886 stub local3, [local7+3+4]
4892 STPTR local5, [%sp+BIAS+ARG0+0*ARGSZ]
4894 add local7, 8, local7
4897 bg,pt %icc, .ede3.dec.next.block
4899 bg .ede3.dec.next.block
4901 STPTR local7, [%sp+BIAS+ARG0+1*ARGSZ]
4905 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
4908 ! store_little_endian
4909 ! local4 in0 in1 local5 .SLE8
4911 ! rightmost in register to first in memory
4914 andcc local4, 3, global0
4918 sta in0, [local4] 0x88
4919 add local4, 4, local5
4922 sta in1, [local5] 0x88
4926 and in0, 255, local5
4927 stub local5, [local4+0]
4930 and local5, 255, local5
4931 stub local5, [local4+1]
4934 and local5, 255, local5
4935 stub local5, [local4+2]
4938 stub local5, [local4+3]
4941 and in1, 255, local5
4942 stub local5, [local4+0+4]
4945 and local5, 255, local5
4946 stub local5, [local4+1+4]
4949 and local5, 255, local5
4950 stub local5, [local4+2+4]
4953 stub local5, [local4+3+4]
4964 .ede3.dec.seven.or.less:
4968 ! load_little_endian_inc
4969 ! local5 in0 in1 local3 .LLE14
4971 ! first in memory to rightmost in register
4974 andcc local5, 3, global0
4978 lda [local5] 0x88, in0
4979 add local5, 4, local5
4981 lda [local5] 0x88, in1
4983 add local5, 4, local5
4987 ldub [local5+3], in0
4989 ldub [local5+2], local3
4993 ldub [local5+1], local3
4997 ldub [local5+0], local3
5001 ldub [local5+3+4], in1
5002 add local5, 8, local5
5004 ldub [local5+2+4-8], local3
5008 ldub [local5+1+4-8], local3
5012 ldub [local5+0+4-8], local3
5022 ! local7 in2 local3 local4 .SNB2 .ede3.dec.store.iv .SNB2 .ede3.dec.store.iv
5027 add %o7,.SNB2.jmp.table-.SNB2.0,local3
5029 add local3, local4, local3
5037 srl global4, 16, local3
5038 and local3, 0xff, local3
5039 stub local3, [local7+6]
5041 srl global4, 8, local3
5042 and local3, 0xff, local3
5043 stub local3, [local7+5]
5045 and global4, 0xff, local3
5046 stub local3, [local7+4]
5048 srl out4, 24, local3
5049 stub local3, [local7+3]
5051 srl out4, 16, local3
5052 and local3, 0xff, local3
5053 stub local3, [local7+2]
5056 and local3, 0xff, local3
5057 stub local3, [local7+1]
5059 and out4, 0xff, local3
5062 ba .ede3.dec.store.iv
5063 stub local3, [local7]
5070 .word .SNB2.1-.SNB2.0
5071 .word .SNB2.2-.SNB2.0
5072 .word .SNB2.3-.SNB2.0
5073 .word .SNB2.4-.SNB2.0
5074 .word .SNB2.5-.SNB2.0
5075 .word .SNB2.6-.SNB2.0
5076 .word .SNB2.7-.SNB2.0
5080 .DES_ede3_cbc_encrypt.end:
5081 .size DES_ede3_cbc_encrypt,.DES_ede3_cbc_encrypt.end-DES_ede3_cbc_encrypt
5084 .type .des_and,#object
5089 ! This table is used for AND 0xFC when it is known that register
5090 ! bits 8-31 are zero. Makes it possible to do three arithmetic
5091 ! operations in one cycle.
5093 .byte 0, 0, 0, 0, 4, 4, 4, 4
5094 .byte 8, 8, 8, 8, 12, 12, 12, 12
5095 .byte 16, 16, 16, 16, 20, 20, 20, 20
5096 .byte 24, 24, 24, 24, 28, 28, 28, 28
5097 .byte 32, 32, 32, 32, 36, 36, 36, 36
5098 .byte 40, 40, 40, 40, 44, 44, 44, 44
5099 .byte 48, 48, 48, 48, 52, 52, 52, 52
5100 .byte 56, 56, 56, 56, 60, 60, 60, 60
5101 .byte 64, 64, 64, 64, 68, 68, 68, 68
5102 .byte 72, 72, 72, 72, 76, 76, 76, 76
5103 .byte 80, 80, 80, 80, 84, 84, 84, 84
5104 .byte 88, 88, 88, 88, 92, 92, 92, 92
5105 .byte 96, 96, 96, 96, 100, 100, 100, 100
5106 .byte 104, 104, 104, 104, 108, 108, 108, 108
5107 .byte 112, 112, 112, 112, 116, 116, 116, 116
5108 .byte 120, 120, 120, 120, 124, 124, 124, 124
5109 .byte 128, 128, 128, 128, 132, 132, 132, 132
5110 .byte 136, 136, 136, 136, 140, 140, 140, 140
5111 .byte 144, 144, 144, 144, 148, 148, 148, 148
5112 .byte 152, 152, 152, 152, 156, 156, 156, 156
5113 .byte 160, 160, 160, 160, 164, 164, 164, 164
5114 .byte 168, 168, 168, 168, 172, 172, 172, 172
5115 .byte 176, 176, 176, 176, 180, 180, 180, 180
5116 .byte 184, 184, 184, 184, 188, 188, 188, 188
5117 .byte 192, 192, 192, 192, 196, 196, 196, 196
5118 .byte 200, 200, 200, 200, 204, 204, 204, 204
5119 .byte 208, 208, 208, 208, 212, 212, 212, 212
5120 .byte 216, 216, 216, 216, 220, 220, 220, 220
5121 .byte 224, 224, 224, 224, 228, 228, 228, 228
5122 .byte 232, 232, 232, 232, 236, 236, 236, 236
5123 .byte 240, 240, 240, 240, 244, 244, 244, 244
5124 .byte 248, 248, 248, 248, 252, 252, 252, 252
5126 ! 5 numbers for initil/final permutation
5128 .word 0x0f0f0f0f ! offset 256
5129 .word 0x0000ffff ! 260
5130 .word 0x33333333 ! 264
5131 .word 0x00ff00ff ! 268
5132 .word 0x55555555 ! 272
5136 .word 0x0000FC00 ! 284
5139 .type DES_SPtrans,#object
5140 .size DES_SPtrans,2048
5145 .word 0x02080800, 0x00080000, 0x02000002, 0x02080802
5146 .word 0x02000000, 0x00080802, 0x00080002, 0x02000002
5147 .word 0x00080802, 0x02080800, 0x02080000, 0x00000802
5148 .word 0x02000802, 0x02000000, 0x00000000, 0x00080002
5149 .word 0x00080000, 0x00000002, 0x02000800, 0x00080800
5150 .word 0x02080802, 0x02080000, 0x00000802, 0x02000800
5151 .word 0x00000002, 0x00000800, 0x00080800, 0x02080002
5152 .word 0x00000800, 0x02000802, 0x02080002, 0x00000000
5153 .word 0x00000000, 0x02080802, 0x02000800, 0x00080002
5154 .word 0x02080800, 0x00080000, 0x00000802, 0x02000800
5155 .word 0x02080002, 0x00000800, 0x00080800, 0x02000002
5156 .word 0x00080802, 0x00000002, 0x02000002, 0x02080000
5157 .word 0x02080802, 0x00080800, 0x02080000, 0x02000802
5158 .word 0x02000000, 0x00000802, 0x00080002, 0x00000000
5159 .word 0x00080000, 0x02000000, 0x02000802, 0x02080800
5160 .word 0x00000002, 0x02080002, 0x00000800, 0x00080802
5162 .word 0x40108010, 0x00000000, 0x00108000, 0x40100000
5163 .word 0x40000010, 0x00008010, 0x40008000, 0x00108000
5164 .word 0x00008000, 0x40100010, 0x00000010, 0x40008000
5165 .word 0x00100010, 0x40108000, 0x40100000, 0x00000010
5166 .word 0x00100000, 0x40008010, 0x40100010, 0x00008000
5167 .word 0x00108010, 0x40000000, 0x00000000, 0x00100010
5168 .word 0x40008010, 0x00108010, 0x40108000, 0x40000010
5169 .word 0x40000000, 0x00100000, 0x00008010, 0x40108010
5170 .word 0x00100010, 0x40108000, 0x40008000, 0x00108010
5171 .word 0x40108010, 0x00100010, 0x40000010, 0x00000000
5172 .word 0x40000000, 0x00008010, 0x00100000, 0x40100010
5173 .word 0x00008000, 0x40000000, 0x00108010, 0x40008010
5174 .word 0x40108000, 0x00008000, 0x00000000, 0x40000010
5175 .word 0x00000010, 0x40108010, 0x00108000, 0x40100000
5176 .word 0x40100010, 0x00100000, 0x00008010, 0x40008000
5177 .word 0x40008010, 0x00000010, 0x40100000, 0x00108000
5179 .word 0x04000001, 0x04040100, 0x00000100, 0x04000101
5180 .word 0x00040001, 0x04000000, 0x04000101, 0x00040100
5181 .word 0x04000100, 0x00040000, 0x04040000, 0x00000001
5182 .word 0x04040101, 0x00000101, 0x00000001, 0x04040001
5183 .word 0x00000000, 0x00040001, 0x04040100, 0x00000100
5184 .word 0x00000101, 0x04040101, 0x00040000, 0x04000001
5185 .word 0x04040001, 0x04000100, 0x00040101, 0x04040000
5186 .word 0x00040100, 0x00000000, 0x04000000, 0x00040101
5187 .word 0x04040100, 0x00000100, 0x00000001, 0x00040000
5188 .word 0x00000101, 0x00040001, 0x04040000, 0x04000101
5189 .word 0x00000000, 0x04040100, 0x00040100, 0x04040001
5190 .word 0x00040001, 0x04000000, 0x04040101, 0x00000001
5191 .word 0x00040101, 0x04000001, 0x04000000, 0x04040101
5192 .word 0x00040000, 0x04000100, 0x04000101, 0x00040100
5193 .word 0x04000100, 0x00000000, 0x04040001, 0x00000101
5194 .word 0x04000001, 0x00040101, 0x00000100, 0x04040000
5196 .word 0x00401008, 0x10001000, 0x00000008, 0x10401008
5197 .word 0x00000000, 0x10400000, 0x10001008, 0x00400008
5198 .word 0x10401000, 0x10000008, 0x10000000, 0x00001008
5199 .word 0x10000008, 0x00401008, 0x00400000, 0x10000000
5200 .word 0x10400008, 0x00401000, 0x00001000, 0x00000008
5201 .word 0x00401000, 0x10001008, 0x10400000, 0x00001000
5202 .word 0x00001008, 0x00000000, 0x00400008, 0x10401000
5203 .word 0x10001000, 0x10400008, 0x10401008, 0x00400000
5204 .word 0x10400008, 0x00001008, 0x00400000, 0x10000008
5205 .word 0x00401000, 0x10001000, 0x00000008, 0x10400000
5206 .word 0x10001008, 0x00000000, 0x00001000, 0x00400008
5207 .word 0x00000000, 0x10400008, 0x10401000, 0x00001000
5208 .word 0x10000000, 0x10401008, 0x00401008, 0x00400000
5209 .word 0x10401008, 0x00000008, 0x10001000, 0x00401008
5210 .word 0x00400008, 0x00401000, 0x10400000, 0x10001008
5211 .word 0x00001008, 0x10000000, 0x10000008, 0x10401000
5213 .word 0x08000000, 0x00010000, 0x00000400, 0x08010420
5214 .word 0x08010020, 0x08000400, 0x00010420, 0x08010000
5215 .word 0x00010000, 0x00000020, 0x08000020, 0x00010400
5216 .word 0x08000420, 0x08010020, 0x08010400, 0x00000000
5217 .word 0x00010400, 0x08000000, 0x00010020, 0x00000420
5218 .word 0x08000400, 0x00010420, 0x00000000, 0x08000020
5219 .word 0x00000020, 0x08000420, 0x08010420, 0x00010020
5220 .word 0x08010000, 0x00000400, 0x00000420, 0x08010400
5221 .word 0x08010400, 0x08000420, 0x00010020, 0x08010000
5222 .word 0x00010000, 0x00000020, 0x08000020, 0x08000400
5223 .word 0x08000000, 0x00010400, 0x08010420, 0x00000000
5224 .word 0x00010420, 0x08000000, 0x00000400, 0x00010020
5225 .word 0x08000420, 0x00000400, 0x00000000, 0x08010420
5226 .word 0x08010020, 0x08010400, 0x00000420, 0x00010000
5227 .word 0x00010400, 0x08010020, 0x08000400, 0x00000420
5228 .word 0x00000020, 0x00010420, 0x08010000, 0x08000020
5230 .word 0x80000040, 0x00200040, 0x00000000, 0x80202000
5231 .word 0x00200040, 0x00002000, 0x80002040, 0x00200000
5232 .word 0x00002040, 0x80202040, 0x00202000, 0x80000000
5233 .word 0x80002000, 0x80000040, 0x80200000, 0x00202040
5234 .word 0x00200000, 0x80002040, 0x80200040, 0x00000000
5235 .word 0x00002000, 0x00000040, 0x80202000, 0x80200040
5236 .word 0x80202040, 0x80200000, 0x80000000, 0x00002040
5237 .word 0x00000040, 0x00202000, 0x00202040, 0x80002000
5238 .word 0x00002040, 0x80000000, 0x80002000, 0x00202040
5239 .word 0x80202000, 0x00200040, 0x00000000, 0x80002000
5240 .word 0x80000000, 0x00002000, 0x80200040, 0x00200000
5241 .word 0x00200040, 0x80202040, 0x00202000, 0x00000040
5242 .word 0x80202040, 0x00202000, 0x00200000, 0x80002040
5243 .word 0x80000040, 0x80200000, 0x00202040, 0x00000000
5244 .word 0x00002000, 0x80000040, 0x80002040, 0x80202000
5245 .word 0x80200000, 0x00002040, 0x00000040, 0x80200040
5247 .word 0x00004000, 0x00000200, 0x01000200, 0x01000004
5248 .word 0x01004204, 0x00004004, 0x00004200, 0x00000000
5249 .word 0x01000000, 0x01000204, 0x00000204, 0x01004000
5250 .word 0x00000004, 0x01004200, 0x01004000, 0x00000204
5251 .word 0x01000204, 0x00004000, 0x00004004, 0x01004204
5252 .word 0x00000000, 0x01000200, 0x01000004, 0x00004200
5253 .word 0x01004004, 0x00004204, 0x01004200, 0x00000004
5254 .word 0x00004204, 0x01004004, 0x00000200, 0x01000000
5255 .word 0x00004204, 0x01004000, 0x01004004, 0x00000204
5256 .word 0x00004000, 0x00000200, 0x01000000, 0x01004004
5257 .word 0x01000204, 0x00004204, 0x00004200, 0x00000000
5258 .word 0x00000200, 0x01000004, 0x00000004, 0x01000200
5259 .word 0x00000000, 0x01000204, 0x01000200, 0x00004200
5260 .word 0x00000204, 0x00004000, 0x01004204, 0x01000000
5261 .word 0x01004200, 0x00000004, 0x00004004, 0x01004204
5262 .word 0x01000004, 0x01004200, 0x01004000, 0x00004004
5264 .word 0x20800080, 0x20820000, 0x00020080, 0x00000000
5265 .word 0x20020000, 0x00800080, 0x20800000, 0x20820080
5266 .word 0x00000080, 0x20000000, 0x00820000, 0x00020080
5267 .word 0x00820080, 0x20020080, 0x20000080, 0x20800000
5268 .word 0x00020000, 0x00820080, 0x00800080, 0x20020000
5269 .word 0x20820080, 0x20000080, 0x00000000, 0x00820000
5270 .word 0x20000000, 0x00800000, 0x20020080, 0x20800080
5271 .word 0x00800000, 0x00020000, 0x20820000, 0x00000080
5272 .word 0x00800000, 0x00020000, 0x20000080, 0x20820080
5273 .word 0x00020080, 0x20000000, 0x00000000, 0x00820000
5274 .word 0x20800080, 0x20020080, 0x20020000, 0x00800080
5275 .word 0x20820000, 0x00000080, 0x00800080, 0x20020000
5276 .word 0x20820080, 0x00800000, 0x20800000, 0x20000080
5277 .word 0x00820000, 0x00020080, 0x20020080, 0x20800000
5278 .word 0x00000080, 0x20820000, 0x00820080, 0x00000000
5279 .word 0x20000000, 0x20800080, 0x00020000, 0x00820080