# How are calculated numbers in AES S-box?

I have a problem calculating the 0x02 value of the AES S-Box.

I followed the steps descibed in “How are the AES S-Boxes calculated?”, but my answer is not correct.

0x02 is 00000010

Input = 0  0  0  0  0  0  1  0 (LSB First)
Row 0 = 1  0  0  0  1  1  1  1
Bit 0 = 0  0  0  0  0  0  1  0 = 1

Row 1 = 1  1  0  0  0  1  1  1
Bit 1 = 0  0  0  0  0  0  1  0 = 1

Row 2 = 1  1  1  0  0  0  1  1
Bit 2 = 0  0  0  0  0  0  1  0 = 1

Row 3 = 1  1  1  1  0  0  0  1
Bit 3 = 0  0  0  0  0  0  0  0 = 0

Row 4 = 1  1  1  1  1  0  0  0
Bit 4 = 0  0  0  0  0  0  0  0 = 0

Row 5 = 0  1  1  1  1  1  0  0
Bit 5 = 0  0  0  0  0  0  0  0 = 0

Row 6 = 0  0  1  1  1  1  1  0
Bit 6 = 0  0  0  0  0  0  1  0 = 1

Row 7 = 0  0  0  1  1  1  1  1
Bit 7 = 0  0  0  0  0  0  1  0 = 1


LSB is 11100011, MSB = 11000111, than (XOR) to the final vector 0x63, the result is 0xa4, but it should be 0x77

What am I missing or what might I be doing wrong?

You forgot to compute the inverse of 02 first. The inverse of 02 is 8d (as $02 \cdot 8d = 01$ in the AES $GF(2^8)$ representation). You then apply the affine transform to the value 8d.