예제 #1
0
        private byte[] GetSecondRoundResult(byte[] firstRoundResult, byte[] subKey)
        {
            var nibbled = Aes16Helper.NibbleSubstitution(firstRoundResult);
            var secondFourBitsOfFirstByte  = (byte)(nibbled[0] & 0b00001111);
            var secondFourBitsOfSecondByte = (byte)(nibbled[1] & 0b00001111);
            var newFirstByte  = (byte)((nibbled[0] & 0b11110000) | secondFourBitsOfSecondByte);
            var newSecondByte = (byte)((nibbled[1] & 0b11110000) | secondFourBitsOfFirstByte);
            var shiftedBytes  = new[] { newFirstByte, newSecondByte };

            return(Aes16Helper.AddRoundKey(shiftedBytes, subKey));
        }
예제 #2
0
        private byte[] GetFirstRoundResult(byte[] zeroRoundResult, byte[] roundKey)
        {
            // Nibble substitution
            var nibbled = Aes16Helper.NibbleSubstitution(zeroRoundResult);

            // Shift row
            var shiftedRowBytes = Aes16Helper.ShiftRow(nibbled);
            var mixedBytes      = Aes16Helper.MixColumns(shiftedRowBytes);

            return(Aes16Helper.AddRoundKey(new[] { mixedBytes[0], mixedBytes[1] }, roundKey));
        }