Lines Matching +full:2 +full:c
7 * Copyright (c) 2005 Dag Arne Osvik <da@osvik.no>
596 * PC2 lookup tables are organized as 2 consecutive sets of 4 interleaved
600 * After PC1 each of the variables a,b,c,d contains a 7 bit subset of C_i
604 #define T1(x) pt[2 * (x) + 0]
605 #define T2(x) pt[2 * (x) + 1]
606 #define T3(x) pt[2 * (x) + 2]
607 #define T4(x) pt[2 * (x) + 3]
609 #define DES_PC2(a, b, c, d) (T4(d) | T3(c) | T2(b) | T1(a)) argument
619 * alternating zero-one patterns in the C and D registers after Permuted
626 unsigned long a, b, c, d, w; in des_ekey() local
630 c = k[5]; c &= 0x0e; c <<= 4; c |= k[1] & 0x1e; c = pc1[c]; in des_ekey()
631 b = k[6]; b &= 0x0e; b <<= 4; b |= k[2] & 0x1e; b = pc1[b]; in des_ekey()
634 pe[15 * 2 + 0] = DES_PC2(a, b, c, d); d = rs[d]; in des_ekey()
635 pe[14 * 2 + 0] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in des_ekey()
636 pe[13 * 2 + 0] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in des_ekey()
637 pe[12 * 2 + 0] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in des_ekey()
638 pe[11 * 2 + 0] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in des_ekey()
639 pe[10 * 2 + 0] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in des_ekey()
640 pe[ 9 * 2 + 0] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in des_ekey()
641 pe[ 8 * 2 + 0] = DES_PC2(d, a, b, c); c = rs[c]; in des_ekey()
642 pe[ 7 * 2 + 0] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in des_ekey()
643 pe[ 6 * 2 + 0] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in des_ekey()
644 pe[ 5 * 2 + 0] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in des_ekey()
645 pe[ 4 * 2 + 0] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in des_ekey()
646 pe[ 3 * 2 + 0] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in des_ekey()
647 pe[ 2 * 2 + 0] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in des_ekey()
648 pe[ 1 * 2 + 0] = DES_PC2(c, d, a, b); b = rs[b]; in des_ekey()
649 pe[ 0 * 2 + 0] = DES_PC2(b, c, d, a); in des_ekey()
652 w = (a ^ c) | (b ^ d) | (rs[a] ^ c) | (b ^ rs[d]); in des_ekey()
658 c = k[1]; c &= 0xe0; c >>= 4; c |= k[5] & 0xf0; c = pc1[c + 1]; in des_ekey()
659 b = k[2]; b &= 0xe0; b >>= 4; b |= k[6] & 0xf0; b = pc1[b + 1]; in des_ekey()
663 w |= (a ^ c) | (b ^ d) | (rs[a] ^ c) | (b ^ rs[d]); in des_ekey()
665 pe[15 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; in des_ekey()
666 pe[14 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in des_ekey()
667 pe[13 * 2 + 1] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in des_ekey()
668 pe[12 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in des_ekey()
669 pe[11 * 2 + 1] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in des_ekey()
670 pe[10 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in des_ekey()
671 pe[ 9 * 2 + 1] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in des_ekey()
672 pe[ 8 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; in des_ekey()
673 pe[ 7 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in des_ekey()
674 pe[ 6 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in des_ekey()
675 pe[ 5 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in des_ekey()
676 pe[ 4 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in des_ekey()
677 pe[ 3 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in des_ekey()
678 pe[ 2 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in des_ekey()
679 pe[ 1 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; in des_ekey()
680 pe[ 0 * 2 + 1] = DES_PC2(b, c, d, a); in des_ekey()
684 a = pe[2 * d]; in des_ekey()
685 b = pe[2 * d + 1]; in des_ekey()
686 c = a ^ b; in des_ekey()
687 c &= 0xffff0000; in des_ekey()
688 a ^= c; in des_ekey()
689 b ^= c; in des_ekey()
691 pe[2 * d] = a; in des_ekey()
692 pe[2 * d + 1] = b; in des_ekey()
717 unsigned long a, b, c, d; in dkey() local
721 c = k[5]; c &= 0x0e; c <<= 4; c |= k[1] & 0x1e; c = pc1[c]; in dkey()
722 b = k[6]; b &= 0x0e; b <<= 4; b |= k[2] & 0x1e; b = pc1[b]; in dkey()
725 pe[ 0 * 2] = DES_PC2(a, b, c, d); d = rs[d]; in dkey()
726 pe[ 1 * 2] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in dkey()
727 pe[ 2 * 2] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in dkey()
728 pe[ 3 * 2] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in dkey()
729 pe[ 4 * 2] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in dkey()
730 pe[ 5 * 2] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in dkey()
731 pe[ 6 * 2] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in dkey()
732 pe[ 7 * 2] = DES_PC2(d, a, b, c); c = rs[c]; in dkey()
733 pe[ 8 * 2] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in dkey()
734 pe[ 9 * 2] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in dkey()
735 pe[10 * 2] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in dkey()
736 pe[11 * 2] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in dkey()
737 pe[12 * 2] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in dkey()
738 pe[13 * 2] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in dkey()
739 pe[14 * 2] = DES_PC2(c, d, a, b); b = rs[b]; in dkey()
740 pe[15 * 2] = DES_PC2(b, c, d, a); in dkey()
746 c = k[1]; c &= 0xe0; c >>= 4; c |= k[5] & 0xf0; c = pc1[c + 1]; in dkey()
747 b = k[2]; b &= 0xe0; b >>= 4; b |= k[6] & 0xf0; b = pc1[b + 1]; in dkey()
750 pe[ 0 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; in dkey()
751 pe[ 1 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in dkey()
752 pe[ 2 * 2 + 1] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in dkey()
753 pe[ 3 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in dkey()
754 pe[ 4 * 2 + 1] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in dkey()
755 pe[ 5 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; b = rs[b]; in dkey()
756 pe[ 6 * 2 + 1] = DES_PC2(b, c, d, a); a = rs[a]; d = rs[d]; in dkey()
757 pe[ 7 * 2 + 1] = DES_PC2(d, a, b, c); c = rs[c]; in dkey()
758 pe[ 8 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in dkey()
759 pe[ 9 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in dkey()
760 pe[10 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in dkey()
761 pe[11 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in dkey()
762 pe[12 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; a = rs[a]; in dkey()
763 pe[13 * 2 + 1] = DES_PC2(a, b, c, d); d = rs[d]; c = rs[c]; in dkey()
764 pe[14 * 2 + 1] = DES_PC2(c, d, a, b); b = rs[b]; in dkey()
765 pe[15 * 2 + 1] = DES_PC2(b, c, d, a); in dkey()
769 a = pe[2 * d]; in dkey()
770 b = pe[2 * d + 1]; in dkey()
771 c = a ^ b; in dkey()
772 c &= 0xffff0000; in dkey()
773 a ^= c; in dkey()
774 b ^= c; in dkey()
776 pe[2 * d] = a; in dkey()
777 pe[2 * d + 1] = b; in dkey()
792 ROUND(L, R, A, B, K, 2); in des_encrypt()
793 ROUND(R, L, A, B, K, 2); in des_encrypt()
804 const u32 *K = ctx->expkey + DES_EXPKEY_WORDS - 2; in des_decrypt()
813 ROUND(L, R, A, B, K, -2); in des_decrypt()
814 ROUND(R, L, A, B, K, -2); in des_decrypt()
855 ROUND(L, R, A, B, K, 2); in des3_ede_encrypt()
856 ROUND(R, L, A, B, K, 2); in des3_ede_encrypt()
859 ROUND(R, L, A, B, K, 2); in des3_ede_encrypt()
860 ROUND(L, R, A, B, K, 2); in des3_ede_encrypt()
863 ROUND(L, R, A, B, K, 2); in des3_ede_encrypt()
864 ROUND(R, L, A, B, K, 2); in des3_ede_encrypt()
875 const u32 *K = dctx->expkey + DES3_EDE_EXPKEY_WORDS - 2; in des3_ede_decrypt()
884 ROUND(L, R, A, B, K, -2); in des3_ede_decrypt()
885 ROUND(R, L, A, B, K, -2); in des3_ede_decrypt()
888 ROUND(R, L, A, B, K, -2); in des3_ede_decrypt()
889 ROUND(L, R, A, B, K, -2); in des3_ede_decrypt()
892 ROUND(L, R, A, B, K, -2); in des3_ede_decrypt()
893 ROUND(R, L, A, B, K, -2); in des3_ede_decrypt()