Skip to content
GF(2^8) Arithmetic
step 1/5

Reading — step 1 of 5

Read

~1 min readThe State & Galois Field

GF(2^8) Arithmetic

AES does math in the Galois field GF(2^8) — finite field with 256 elements. Each byte is an element.

Addition is just XOR:

0x53 + 0xCA = 0x53 ^ 0xCA = 0x99

(Adding two polynomials over GF(2) is XOR. No carry.)

Multiplication is harder. View bytes as polynomials in x:

0x53 = 01010011 = x^6 + x^4 + x + 1

Multiply two polynomials, then reduce modulo the AES "irreducible polynomial":

m(x) = x^8 + x^4 + x^3 + x + 1   (= 0x11B)

Implementing GF(2^8) multiplication:

python

This "shift and reduce" is the standard schoolbook approach. Faster implementations use lookup tables.

You only need GF multiply by small constants in MixColumns: 0x01, 0x02, 0x03, 0x09, 0x0b, 0x0d, 0x0e. So precomputed tables work great.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…