← Back to section · Foundations of Cryptography

Walking Through the AES Round Function: How Four Steps Stir One Byte Across the Whole Block

SubBytes creates nonlinearity, ShiftRows moves positions, MixColumns mixes, AddRoundKey injects the key — a step-by-step dissection of the four actions in every AES round, and how confusion and diffusion divide the labor on a 4×4 byte matrix.

Published 22 November 2026 · 5 min read · PQ Frontier

Walking Through the AES Round Function: How Four Steps Stir One Byte Across the Whole Block
AI-generated site artwork
Video explainer · Symmetric encryption: blocks and modes

AES does not process a string of bits but a 4×4 matrix of bytes called the state. A 128-bit plaintext fills this matrix column by column and then undergoes 10 rounds (for AES-128) of nearly identical processing. Each round has only four actions, named as plainly as a recipe: SubBytes, ShiftRows, MixColumns, AddRoundKey. This article walks through the four steps and shows how they divide the labor in Shannon’s framework — who makes confusion, who spreads diffusion, who injects the key.

Step one, SubBytes: the only nonlinearity on the field

SubBytes does the same thing to every byte of the state independently: take its multiplicative inverse in the finite field GF(2^8) (with 0 mapped to 0), then apply a fixed affine transformation. This inversion supplies all of AES’s nonlinearity. The algebraic properties of finite-field inversion were carefully chosen: it has no linear structure and no low-degree algebraic approximation, and its differential distribution and linear correlations are flat enough to deny differential and linear attacks any statistical handhold.

In practice nobody computes inverses on the fly: implementations look up the resulting 256-byte substitution table (the S-box) directly, or assemble it from composite-field arithmetic in hardware. A fact worth noting is that the AES S-box contains no mysterious trapdoor constants — its construction is fully public and reproducible, one source of the confidence that has survived more than two decades of global cryptanalysis.

Note that SubBytes acts on each byte in isolation: a byte’s output depends only on itself. The disturbance is still trapped in place; the next two steps carry it outward.

Step two, ShiftRows: moving bytes out of their column

ShiftRows cyclically shifts the four rows of the state left by 0, 1, 2, and 3 bytes respectively. It changes no byte’s value, only its position. Its purpose is to break the closedness of columns: without it, each column would evolve independently and AES would degenerate into four unrelated small ciphers that an attacker could defeat one by one. The row shifts deliver the four bytes of a column into four different columns, setting up a “cross-column rendezvous” for the mixing step that follows.

Step three, MixColumns: entangling the four bytes of a column

MixColumns treats each column as a polynomial over the finite field, multiplies it by a fixed polynomial, and reduces modulo another. The equivalent matrix view is more intuitive: each of the four output bytes of a column is a linear combination of all four input bytes, with coefficients arranged so that any single input byte influences all four outputs. Cryptographers quantify this mixing strength with the branch number: the minimum, over all nonzero inputs, of the number of active bytes in input plus output. The AES MixColumns matrix has branch number 5, the theoretical optimum for a 4-dimensional linear transform — even a single active input byte forces at least four active output bytes.

Now combine ShiftRows and MixColumns and do the arithmetic: one byte’s disturbance spreads through MixColumns to all four bytes of its column; in the next round ShiftRows sends those four bytes into four different columns; after one more MixColumns, the disturbance has reached all 16 bytes. Two rounds, full diffusion. This is why AES can afford as few as 10 rounds, and it is the core argument of the “wide trail strategy” in its design documentation: provable lower bounds on diffusion shut down the statistical paths of differential and linear attacks.

Step four, AddRoundKey: the key’s only entrance

AddRoundKey XORs the state with the round key byte by byte. It is the key’s only channel into the computation — almost plain in its simplicity, but its position is critical: sandwiched between nonlinear layers, it prevents an attacker from peeling the key’s influence away from the transformation and analyzing it separately. Round keys are derived from the master key by the key schedule, expanded step by step through word rotations, S-box substitutions, and round constants. The key schedule’s design goals matter as much as the round function’s: round keys must be sufficiently “unlike” one another, or related-key and slide attacks find an opening.

A word on the round-count margin is in order. Ten rounds is not a “just barely enough” number: public cryptanalysis against reduced-round AES has always stopped a few rounds short of the full cipher, and the best known attacks on full AES (such as biclique attacks) merely shave the cost of exhaustive search slightly — nowhere near practical. That is the point of a round margin: it prepays insurance against decades of future analytical progress, and it is the first question to ask of any SPN design — how many rounds separate the breakable count from the full count?

Two finishing details are worth knowing. First, before the regular rounds there is an initial AddRoundKey, so the plaintext is mixed with key material before entering the first S-box layer. Second, the final round has no MixColumns — not a weakening (omitting one linear mixing layer gives the attacker nothing), but an engineering arrangement that makes encryption and decryption strictly symmetric in structure, easing implementation and analysis.

The same drawing, three construction crews

The same round function wears completely different faces on different platforms, and grasping this completes the picture of AES’s engineering life. The most straightforward is the table-driven implementation: merge SubBytes and MixColumns into four large tables (T-tables) so a round becomes lookups plus XORs — early software implementations lived on this; the cost is that table indices depend on key-related data, so cache-hit patterns leak information, a timing side channel that plagued software AES for years. The second is hardware instructions: mainstream processors ship AES round instructions that complete an entire round of substitution and mixing in one instruction — fast and naturally constant-time — and much of AES’s dominance is locked in by this ecosystem. The third is bitslicing: interleave several blocks bit by bit and compute them in parallel with logic gates, common where no dedicated instructions exist but side channels must be resisted.

All three implementations run the same mathematics, yet their security boundaries differ — a reminder that the “round function” of an algorithm is only the drawing, and the security actually delivered is always the composite of drawing plus construction.

Seen as a whole, AES is a textbook construction of Shannon’s product cipher: inversion makes confusion, shifts and mixing spread diffusion, XOR injects the key, and ten rounds of iteration stack up the margin. Once this one round is understood, any SPN-type cipher — even the permutation of SHA-3 or the round functions of lightweight ciphers — reads as a variation on the same drawing.

Tags: AESRound FunctionS-boxMixColumns