Calculation of 0xf8
m(x) = 0x11b = 100011011 = x^8 + x^4 + x^3 + x + 1
a(x) = 0xf8 = 11111000 = x^7 + x^6 + x^5 + x^4 + x^3
m(x) = (x + 1) * a(x) + (x^4 + x + 1)
Calculation of 0xf8-1 in the finite field GF(28)00010011 = 00000001 * 100011011 + 00000011 * 11111000
00001010 = 00001110 * 100011011 + 00010011 * 11111000
00000111 = 00011101 * 100011011 + 00100101 * 11111000
00000011 = 00101001 * 100011011 + 01111100 * 11111000
00000001 = 01001111 * 100011011 +
11011101 * 11111000
00000000 = 11111000 * 100011011 + 100011011 * 11111000
a
-1(x) = x^7 + x^6 + x^4 + x^3 + x^2 + 1 = 11011101 = 0xdd
The calculation of 0xf8
-1 is made with the
Extended Euclidean algorithm. Instead of normal division and multiplication you need to use Polynomialdivision and Polynomialmultiplication.
Affine transformation over GF(2) 1 0 0 0 1 1 1 1 1 1 1
1 1 0 0 0 1 1 1 0 1 0
1 1 1 0 0 0 1 1 1 0 0
1 1 1 1 0 0 0 1 1 0 0
SBOX(f8) = 1 1 1 1 1 0 0 0 * 1 + 0 = 0
0 1 1 1 1 1 0 0 0 1 0
0 0 1 1 1 1 1 0 1 1 1
0 0 0 1 1 1 1 1 1 0 0
SBOX(f8) = 01000001 = 41
For more information see
FIPS 197.
Implemented by bachph [at] philba [dot] com