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); } }
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); }
private int SW(int x) { return(CombinatoricsUtil.CyclicShiftToLeft(x, 4, 8)); }