ShiftRows and MixColumns
SubBytes changes each byte individually, but it does not mix the bytes. The mixing (diffusion) is performed in two steps:
- ShiftRows — the
r-th row of the state matrix is cyclically shifted to the left byrpositions (the 0-th row does not move). - MixColumns — each column is multiplied by a fixed 4x4 matrix in the GF(2^8) field. A change in one byte spreads to the entire column.
Both are linear and reversible operations: InvShiftRows shifts the rows to the right, and InvMixColumns multiplies by the inverse matrix (coefficients 14, 11, 13, 9).
The attached raund_funksiyalari.py file provides only the forward direction. ShiftRows was applied first, then MixColumns to a 16-byte secret block, and the result was as follows (hex):
756b63707e6c6d70a6c75a4aa5e16341
Recover the original 16 characters (they are readable ASCII text) and assemble the flag:
BAYROQ{A3S_<16 belgi>}
Pay attention to the order: during encryption it was ShiftRows -> MixColumns, so in the reverse direction it is InvMixColumns first, then InvShiftRows.