private void ReverseFinalRound() { byte[][] roundKey = _key.PreviousSubKey(); _stateMatrix = AESFunction.AddRoundKey(_stateMatrix, roundKey); _stateMatrix = AESFunction.ReverseShiftRows(_stateMatrix); _stateMatrix = AESFunction.ReverseSubBytes(_stateMatrix); }
public void ReverseShiftRows_ShiftsRows_Shifted() { byte[][] array = { new byte[] { 0xd4, 0xe0, 0xb8, 0x1e }, new byte[] { 0xbf, 0xb4, 0x41, 0x27 }, new byte[] { 0x5d, 0x52, 0x11, 0x98 }, new byte[] { 0x30, 0xae, 0xf1, 0xe5 } }; byte[][] expected = { new byte[] { 0xd4, 0xe0, 0xb8, 0x1e }, new byte[] { 0x27, 0xbf, 0xb4, 0x41 }, new byte[] { 0x11, 0x98, 0x5d, 0x52 }, new byte[] { 0xae, 0xf1, 0xe5, 0x30 } }; byte[][] result = AESFunction.ReverseShiftRows(array); for (int i = 0; i < result.Length; i++) { for (int j = 0; j < result[i].Length; j++) { Assert.AreEqual(expected[j][i], result[j][i]); } } }