AES MixColumns
The MixColumns step worked by hand. GF(2^8) multiplication by 02 and 03, the matrix equations, a full worked column and the inverse matrix.
Mix Column Transformation in AES | Solved ExampleSK Page · MixColumns on one column, solved by hand, 10 min
AES MIX COLUMN MATRIX MULTIPLICATION COMPLETE SOLUTIONONLINE LEARNING HUB · MixColumns matrix multiplication, every step shown, 19 min
AES Mix Column Example with GF(2^8) Polynomial MethodPritesh Prajapati · MixColumns with the GF(2^8) polynomial method, 2 minMixColumns overviewSearch on YouTube
PurposeSearch on YouTube
SubBytes changes each byte on its own. MixColumns makes each output byte of a column depend on all four input bytes of that column. This gives diffusion.
MixColumns works on one column of the 4 x 4 state at a time. Each full round applies it to all four columns.
ShiftRows moves bytes into other columns. MixColumns then mixes the bytes in each column. After two rounds, a change in one byte affects all 16 bytes of the state.
The matrixSearch on YouTube
Each column is multiplied by a fixed matrix over :
Each row gives one equation:
The "" is XOR. A multiplication by 01 does not change the byte.
Matrix rows: 02 03 01 01, then move each row one place to the right. The value 02 is always on the diagonal, and 03 is always to its right.
GF(2^8) arithmeticSearch on YouTube
The fieldSearch on YouTube
All MixColumns arithmetic is in with the AES irreducible polynomial:
- Each byte is a polynomial of degree 7 or less. Each bit is one coefficient.
- Addition is XOR.
- Multiplication is done modulo .
Multiply by 02Search on YouTube
The byte 02 is . To multiply by 02:
- Shift the byte left by one bit.
- If the bit that shifts out is 0, the result is complete.
- If the bit that shifts out is 1, XOR the result with .
This rule is called xtime.
Handwritten notes: .
- .
- .
- The term is present, so reduce modulo :
Multiply by 03Search on YouTube
The byte 03 is . Thus .
Handwritten notes: .
- .
- .
- Equal terms cancel in pairs: .
Byte method: (no overflow). Then .
is the low 8 bits of .
Worked columnSearch on YouTube
Input stateSearch on YouTube
The handwritten notes use the state after ShiftRows from the AES deck:
The first column is .
First byteSearch on YouTube
| Term | Binary |
|---|---|
| 0001 0101 | |
| 1011 0010 | |
| 0100 0110 | |
| 1010 0110 | |
| XOR of all four | 0100 0111 |
Other bytesSearch on YouTube
Use the same method for the other three rows:
| Byte | Terms | Result |
|---|---|---|
The intermediate products are:
- and .
- and .
- and .
The full column changes from to . This is the first column of the MixColumns output in the AES deck.
The handwritten notes write "GF(2^3)" next to the reduction. The correct field is . Also, has an overflow bit: , and the XOR with gives . Do not forget this reduction.
Other viewsSearch on YouTube
Polynomial viewSearch on YouTube
The AES deck gives an alternative view of MixColumns. Each column is a 4-term polynomial with coefficients in :
This polynomial is multiplied by a fixed polynomial modulo :
The result is the same as the matrix multiplication.
Inverse MixColumnsSearch on YouTube
Decryption uses the inverse matrix:
The coefficients are larger. Each multiplication needs more xtime and XOR steps. Thus decryption is a little harder.
Coefficient choiceSearch on YouTube
The AES deck says that the coefficients come from a linear code with maximal distance between codewords. The forward coefficients 01, 02 and 03 are small, so encryption is fast. A multiplication by 02 needs one xtime. A multiplication by 03 needs one xtime and one XOR.
Quick self-testSearch on YouTube
What does MixColumns do, and why does AES need it?
It multiplies each state column by a fixed matrix over . Each output byte then depends on all four input bytes of the column. This gives diffusion.
Write the first row of the MixColumns matrix and the equation.
The row is 02 03 01 01. Thus .
What is xtime?
It is multiplication by 02. Shift the byte left by one bit. If the bit that shifts out is 1, XOR the result with .
Calculate .
The shift gives . XOR with gives .
Calculate .
. Then .
Calculate for the column 87, 6E, 46, A6.
.
Give the full output column for the input 87, 6E, 46, A6.
.
Which polynomial and modulus give the polynomial view of MixColumns?
Multiply the column polynomial by , modulo .
Give the inverse matrix coefficients. Why is decryption harder?
The coefficients are , , and . They are larger, so each multiplication needs more xtime and XOR steps.
- MixColumns multiplies each column by the matrix with rows 02 03 01 01 (rotated). It gives diffusion.
- The arithmetic is in modulo . Addition is XOR.
- Multiply by 02: shift left, and XOR with if the top bit was 1. Multiply by 03: .
- Worked example: and .
- The column 87, 6E, 46, A6 becomes 47, 37, 94, ED.
- Polynomial view: multiply by modulo . Decryption uses the inverse matrix with 0E, 0B, 0D, 09.