Example #1
0
        public void AESDecryption(HexMat hexMat)
        {
            //Console.WriteLine("DECRYPTION");
            //Console.WriteLine();

            //Console.WriteLine("FIRST ROUND");
            //Console.WriteLine();

            hexMat.AddRoundKey(subKeys[9].hexMat);
            //hexMat.DebugDraw();
            //Console.WriteLine();

            hexMat.InvShiftRows();
            //hexMat.DebugDraw();
            //Console.WriteLine();

            hexMat.InvSubBytes();
            //hexMat.DebugDraw();
            //Console.WriteLine();

            for (int i = 8; i >= 0; i--)
            {
                //Console.WriteLine("ROUND " + (10 - i));
                //Console.WriteLine();

                hexMat.AddRoundKey(subKeys[i].hexMat);
                //hexMat.DebugDraw();
                //Console.WriteLine();

                hexMat.InvMixColumns();
                //hexMat.DebugDraw();
                //Console.WriteLine();

                hexMat.InvShiftRows();
                //hexMat.DebugDraw();
                //Console.WriteLine();

                hexMat.InvSubBytes();
                // hexMat.DebugDraw();
                //Console.WriteLine();
            }
        }
Example #2
0
        public void AESEncryption(HexMat hexMat)
        {
            //Console.WriteLine("ENCRYPTION");
            //Console.WriteLine();

            for (int i = 0; i < 9; i++)
            {
                //Console.WriteLine("ROUND " + (i + 1));
                //Console.WriteLine();

                hexMat.SubBytes();
                //hexMat.DebugDraw();
                //Console.WriteLine();

                hexMat.ShiftRows();
                //hexMat.DebugDraw();
                //Console.WriteLine();

                hexMat.MixColumns();
                //hexMat.DebugDraw();
                //Console.WriteLine();

                hexMat.AddRoundKey(subKeys[i].hexMat);
                //hexMat.DebugDraw();
                //Console.WriteLine();
            }

            //Console.WriteLine("FINAL ROUND");
            //Console.WriteLine();

            hexMat.SubBytes();
            //hexMat.DebugDraw();
            //Console.WriteLine();

            hexMat.ShiftRows();
            //hexMat.DebugDraw();
            //Console.WriteLine();

            hexMat.AddRoundKey(subKeys[9].hexMat);
            //hexMat.DebugDraw();
            //Console.WriteLine();
        }