示例#1
0
        public void CheckCyclicShiftToLeft()
        {
            int[] inputs         = new int[] { 6, 15 };
            int[] expects        = new int[] { 12, 30 };
            int   numberOfShifts = 1;
            int   blockSize      = 5;

            for (int i = 0; i < inputs.Length; i++)
            {
                int result = CombinatoricsUtil.CyclicShiftToLeft(inputs[i], numberOfShifts, blockSize);
                Assert.AreEqual(expects[i], result);
            }
        }
示例#2
0
        private int[] KeySchedule(int key)
        {
            int permutatedKey = CombinatoricsUtil.Permutate(key, P10);

            int[] parts = CombinatoricsUtil.Halve(permutatedKey, HALF_OF_KEY);
            int   left  = parts[0];
            int   right = parts[1];

            subkeys = new int[2];

            for (int i = 0; i < 2; i++)
            {
                left       = CombinatoricsUtil.CyclicShiftToLeft(left, i + 1, HALF_OF_KEY);
                right      = CombinatoricsUtil.CyclicShiftToLeft(right, i + 1, HALF_OF_KEY);
                subkeys[i] = CombinatoricsUtil.Permutate((left << HALF_OF_KEY) | right, P8);
            }

            return(subkeys);
        }
示例#3
0
 private int SW(int x)
 {
     return(CombinatoricsUtil.CyclicShiftToLeft(x, 4, 8));
 }