Mix Column

The "Mix Column" operates on the rows of the 4x4 state matrix.

It is a non-linear operation that involves multiplying each column by a fixed matrix and reducing the result modulo a fixed polynomial.

The fixed matrice is the following :

+-------------+
| 02 03 01 01 |
| 01 02 03 01 |
| 01 01 02 03 |
| 03 01 01 02 |
+-------------+

Then the operation is the following :

Fixed matrice        User data          Result
+-------------+     +-------------+     +-------------+
| 02 03 01 01 |     | 00 01 02 03 |     | r1 r2 r3 r4 |
| 01 02 03 01 |     | 11 12 13 10 |     | ...         |
| 01 01 02 03 |  *  | 22 23 20 21 |  =  |      ?      |
| 03 01 01 02 |     | 33 30 31 32 |     |             |
+-------------+     +-------------+     +-------------+

Each row of the result are made by the result of the operation of the fixed matrice row times each column : 

r1 = ( 02 * 00 ) βŠ• ( 03 * 11 ) βŠ• ( 01 * 22 ) βŠ• ( 01 * 33 )
r2 = ( 02 * 01 ) βŠ• ( 03 * 12 ) βŠ• ( 01 * 23 ) βŠ• ( 01 * 30 ) 
r3 = ( 02 * 02 ) βŠ• ( 03 * 13 ) βŠ• ( 01 * 20 ) βŠ• ( 01 * 31 )
etc. 

Because of all operation are a Galois Field multiplication, it is not only a times 2 or 3

circle-exclamation

All operations are made with the binary forms of the number.

  • Multiply by 1 is just like standard decimal operation, a * 1 = a

  • Multiply by 2

Because we work into GF(2^8), the number can't have more than 8 bits, so if there is more after the bit shift, then the number must be xored with 0b0011011

circle-info

This value is calculated using the irreducible Polynomial theorem that it will not be explain here.

Here is an example with 0xd4 * 2

circle-exclamation
  • Multiply by 3

Here is an example with 0xd4 * 3

Python implementation

Optimized

Last updated