コード例 #1
0
 private void FinalRound()
 {
     _stateMatrix = AESFunction.SubBytes(_stateMatrix);
     _stateMatrix = AESFunction.ShiftRows(_stateMatrix);
     byte[][] roundKey = _key.NextSubKey();
     _stateMatrix = AESFunction.AddRoundKey(_stateMatrix, roundKey);
 }
コード例 #2
0
 private void ReverseFinalRound()
 {
     byte[][] roundKey = _key.PreviousSubKey();
     _stateMatrix = AESFunction.AddRoundKey(_stateMatrix, roundKey);
     _stateMatrix = AESFunction.ReverseShiftRows(_stateMatrix);
     _stateMatrix = AESFunction.ReverseSubBytes(_stateMatrix);
 }
コード例 #3
0
ファイル: AESFunctionTests.cs プロジェクト: przpl/CryptZip
        public void AddRoundKey_GoesOverAddRoundKeyStep_Executed()
        {
            byte[][] array =
            {
                new byte[] { 0x04, 0xe0, 0x48, 0x28 },
                new byte[] { 0x66, 0xcb, 0xf8, 0x06 },
                new byte[] { 0x81, 0x19, 0xd3, 0x26 },
                new byte[] { 0xe5, 0x9a, 0x7a, 0x4c }
            };

            byte[][] roundKey =
            {
                new byte[] { 0xa0, 0x88, 0x23, 0x2a },
                new byte[] { 0xfa, 0x54, 0xa3, 0x6c },
                new byte[] { 0xfe, 0x2c, 0x39, 0x76 },
                new byte[] { 0x17, 0xb1, 0x39, 0x05 }
            };

            byte[][] expected =
            {
                new byte[] { 0xa4, 0x68, 0x6b, 0x02 },
                new byte[] { 0x9c, 0x9f, 0x5b, 0x6a },
                new byte[] { 0x7f, 0x35, 0xea, 0x50 },
                new byte[] { 0xf2, 0x2b, 0x43, 0x49 }
            };

            byte[][] result = AESFunction.AddRoundKey(array, roundKey);

            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]);
                }
            }
        }
コード例 #4
0
 private void RoundZero()
 {
     byte[][] roundKey = _key.NextSubKey();
     _stateMatrix = AESFunction.AddRoundKey(_stateMatrix, roundKey);
 }
コード例 #5
0
 private void ReverseRoundZero()
 {
     byte[][] roundKey = _key.PreviousSubKey();
     _stateMatrix = AESFunction.AddRoundKey(_stateMatrix, roundKey);
 }