562{
563
564 static unsigned char desKey[8], desKeys[128];
565 static Word *oldKey = (
Word *)(
void *) desKey, *keys = (
Word *) desKeys;
568 unsigned char b0[8] = "", b1[8];
570 *text,
571 *cb = (
Word *)(
void *) b0,
572 *cb1 = (
Word *)(
void *) b1;
573
574#if !defined(WORDS_BIGENDIAN)
575 unsigned int origSize = size;
578#endif
579
580
581
582
583
584 if (newKey[0] != oldKey[0] || newKey[1] != oldKey[1]) {
586
587 oldKey[0] = newKey[0];
588 oldKey[1] = newKey[1];
589 oldWhat = what;
591
593
596 int z;
600 { 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
601
602 for (z = 0; z < 16; z++, k += 2) {
603 for (r = 0; r < rol[z]; r++) {
606 }
608 }
609 } else {
610 int z;
614 { 0, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 };
615
616 for (z = 0; z < 16; z++, k += 2) {
617 r = 0;
618 while (ror[z] > r) {
619 r++;
622 }
624 }
625 }
626 } else if ((what != oldWhat)
628
629
630
631
632 Word *ik1, *ik2, ik3[2];
633
634 for (ik1 = keys, ik2 = &(keys[30]); ik1 < ik2;
635 ik1 += 2, ik2 -= 2) {
636 ik3[0] = ik1[0];
637 ik3[1] = ik1[1];
638 ik1[0] = ik2[0];
639 ik1[1] = ik2[1];
640 ik2[0] = ik3[0];
641 ik2[1] = ik3[1];
642 }
643
644 oldWhat = what;
645 }
646
647
649 if (initVec) {
650 {
651 cb[0] = ((
Word *)(
void *) initVec)[0];
652 cb[1] = ((
Word *)(
void *) initVec)[1];
653 }
654 } else {
655 cb[0] = 0;
656 cb[1] = 0;
657 }
658#if !defined(WORDS_BIGENDIAN)
660#endif
661 }
662
663
664
665
666
667
668
669
670
671 size >>= 3;
672
676 goto _ECB_;
678 goto _CBC_encrypt_;
680 goto _CFB_encrypt_;
682 goto _OFB_;
683 }
684 } else {
687 goto _ECB_;
689 goto _CBC_decrypt_;
691 goto _CFB_decrypt_;
693 goto _OFB_;
694 }
695 }
696
697 _ECB_:
698
699
700 for (text = (
Word *)(
void *) data; size; --size, text += 2) {
702 }
703
704 goto _exit_qfDES_;
705
706 _CBC_encrypt_:
707
708
709 for (text = (
Word *)(
void *) data; size; --size, text += 2) {
710
711
712 text[0] ^= cb[0];
713 text[1] ^= cb[1];
714
716
717
718 cb[0] = text[0];
719 cb[1] = text[1];
720 }
721
722 goto _initVec_;
723
724 _CBC_decrypt_:
725
726
727 for (text = (
Word *)(
void *) data; size; --size, text += 2) {
728
729
730
731
732
733
734 cb1[0] = text[0];
735 cb1[1] = text[1];
736
738
739
740 text[0] ^= cb[0];
741 text[1] ^= cb[1];
742
743
744
745
746
747 cb[0] = cb1[0];
748 cb[1] = cb1[1];
749 }
750
751 goto _initVec_;
752
753 _CFB_encrypt_:
754
755
756 for (text = (
Word *)(
void *) data; size; --size, text += 2) {
757
758
760
761 text[0] ^= cb[0];
762 text[1] ^= cb[1];
763
764
765 cb[0] = text[0];
766 cb[1] = text[1];
767 }
768
769 goto _initVec_;
770
771 _CFB_decrypt_:
772
773
774 for (text = (
Word *)(
void *) data; size; --size, text += 2) {
775
776
777
778
779
780
781 cb1[0] = text[0];
782 cb1[1] = text[1];
783
784
786
787 text[0] ^= cb[0];
788 text[1] ^= cb[1];
789
790
791 cb[0] = cb1[0];
792 cb[1] = cb1[1];
793 }
794
795 goto _initVec_;
796
797 _OFB_:
798
799
800 for (text = (
Word *)(
void *) data; size; --size, text += 2) {
801
802
804
805 text[0] ^= cb[0];
806 text[1] ^= cb[1];
807 }
808
809 _initVec_:
810
811
812
813
814
815
816 if (initVec) {
817 ((
Word *)(
void *) initVec)[0] = cb[0];
818 ((
Word *)(
void *) initVec)[1] = cb[1];
819
820#if !defined(WORDS_BIGENDIAN)
822#endif
823 }
824
825 _exit_qfDES_:
826
827#if !defined(WORDS_BIGENDIAN)
830#endif
831
832 return 0;
833}
#define PC2(regC, regD, k)
#define MAKE_LITTLE_ENDIAN(t, s)
static Word ROTATE_RIGHT(Word x)
#define PC1(k, regC, regD)
static Word ROTATE_LEFT(Word x)
struct __attribute__((packed))