Some AES calculations

Math 202 Cryptography, September 21, 2016
T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

Check result from inverse table

p=x^8+x^4+x^3+x+1

Recall the table gives that the inverse of 
	(Subscript[B5, hex]) = x^7+x^5+x^4+x^2+1
is 
	(Subscript[75, hex]) = x^6+x^5+x^4+x^2+1
Let’s check it.

PolynomialRemainder[(x^7+x^5+x^4+x^2+1)(x^6+x^5+x^4+x^2+1), p, x, Modulus->2]

The affine mapping

Define the matrix M and the vector v

M=(({{1, 0, 0, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 0, 1, 1, 1}, {1, 1, 1, 0, 0, 0, 1, 1}, {1, 1, 1, 1, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 0, 0, 0}, {0, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 0}, {0, 0, 0, 1, 1, 1, 1, 1}}))
v=(({{1}, {1}, {0}, {0}, {0}, {1}, {1}, {0}}))

Using (Subscript[A, 0])=(Subscript[B5, hex]) from above, (Subscript[B, 0])' = (Subscript[75, hex])= (Subscript[01110101, 2]). 
Mathematica won’t recognize the ‘ as part of a variable name, however. 
We need to remember that the least significant bit goes at the top of the vector.

B0prime = (({{1}, {0}, {1}, {0}, {1}, {1}, {1}, {0}}))

In Mathematica, it recognizes the period as matrix multiplication

B0 = Mod[M.B0prime+v,2]

B0//MatrixForm

Or in hex, B0 = (Subscript[11010101, 2])= (Subscript[D5, hex])