Exemplo n.º 1
0
 private void FinalRound()
 {
     _stateMatrix = AESFunction.SubBytes(_stateMatrix);
     _stateMatrix = AESFunction.ShiftRows(_stateMatrix);
     byte[][] roundKey = _key.NextSubKey();
     _stateMatrix = AESFunction.AddRoundKey(_stateMatrix, roundKey);
 }
Exemplo n.º 2
0
        public void ShiftRows_ShiftsRows_Shifted()
        {
            byte[][] array =
            {
                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[][] expected =
            {
                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[][] result = AESFunction.ShiftRows(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]);
                }
            }
        }