multiplication in GF(256) (AES algorithm)

12.7k Views Asked by At

I'm trying to understand the AES algorithm in order to implement this (on my own) in Java code.

In the algorithm all byte values will be presented as the concatenation of its individual bit values (0 or 1) between braces with the most significant bit first.

So bytes are interpreted as finite field elements using a polynomial representation: $$b_7x^7+b_6x^6+b_5x^5+b_4x^4+b_3x^3+b_2x^2+b_1x+b_0$$

Example: ${01100011} \equiv x^6 + x^5 + x +1$

These finite field elements can easily be added with the XOR operator.

But multiplication is a little bit more complex, and I don't understand it. In the polynomial representation, multiplication in GF(256) corresponds with the multiplication of polynomials modulo an irreducible polynomial of degree 8

This irreducible polynomial is: $m(x)=x^8 +x^4 +x^3 +x+1$

Here is my example:

$$01010111 * 00010011$$

$$01010111\equiv (x^6+x^4+x^2+x+1)$$

$$00010011\equiv(x^4+x+1)$$

$$(x^6+x^4+x^2+x+1) * (x^4+x+1) = x^{10}+x^8+x^7+x^3$$

$$(x^{10}+x^8+x^7+x^3) \mod m(x)$$

$$(x^{10}+x^8+x^7+x^3) \mod (x^8 +x^4 +x^3 +x+1) = x^2 + 1$$

$$x^{10} x^3$$

$$x^8+x^7+x^6+x^5+x^2$$

$$x^8$$

$$x^7+x^6+x^5+x^4+x^3+x^2+x+1$$

So here $x^7+x^6+x^5+x^4+x^3+x^2+x+1$ is my solution, that leads to a binary representation: $11111111$ But in the literature the correct solution is: $11111110$

I would be happy if you could tell me where my mistake is.

1

There are 1 best solutions below

1
On BEST ANSWER

$$(x^6+x^4+x^2+x+1) * (x^4+x+1) = x^{10}+x^8+x^7+x^3$$

should make you suspicious. What happened to the cross-term $1*1$?

I make that product to evaluate to $x^{10}+x^8+x^7+x^3+1$, and the difference of $+1$ should carry through the remaining computation to give the difference you sought.

The modulo operation is equivalent to assuming $x^8 = x^4+x^3+x+1$, which gives $x^{10} = x^6+x^5+x^3+x^2$ so $$\begin{eqnarray*}x^{10}+x^8+x^7+x^3+1 & = & (x^6+x^5+x^3+x^2) + (x^4+x^3+x+1) + x^7+x^3+1\\ & = & x^7+x^6+x^5+x^4+x^3+x^2+x\end{eqnarray*}$$