Build finite-field arithmetic tables and connect polynomial reduction and inversion to the AES S-box and state transformations.
The focus of this experiment is to represent AES state and compute binary-field products. Students then trace substitution, row movement, column mixing and key addition, and verify inverse recovery and distinguish each stage from full AES. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.
Learning objectives
Represent AES state and compute binary-field products.
Trace substitution, row movement, column mixing and key addition.
Verify inverse recovery and distinguish each stage from full AES.
Record the relevant inputs, intermediate states and final verification result before changing the reference configuration.
Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.
Expected learning outcomes
On completion, students can represent AES state and compute binary-field products, trace substitution, row movement, column mixing and key addition, and verify inverse recovery and distinguish each stage from full AES.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify inverse recovery and distinguish each stage from full AES. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the foundational terminology in Concepts and confirm readiness using the existing setup instructions. After completion, continue to RSA — Keys, modular exponentiation and encryption.
Environment and experimental methodology
The included teaching workstation and the listed Python/Colab or WSL implementation. Historical and small-number constructions are instructional, not deployment recommendations.
Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.
How to investigate AES mathematics — Galois fields and block transformations
Build finite-field arithmetic tables and connect polynomial reduction and inversion to the AES S-box and state transformations.
Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.
Experiment-specific guided practice
Objective: Build finite-field arithmetic tables and connect polynomial reduction and inversion to the AES S-box and state transformations.
Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
Prime and extension fields — complete its numbered steps and record the requested evidence.
AES polynomial reduction and S-box — complete its numbered steps and record the requested evidence.
AES state, ShiftRows and MixColumns — complete its numbered steps and record the requested evidence.
Reference check: DA×C5=DB in GF(256); AES S-box(05)=6B; AES known-answer ciphertext is 69c4e0d86a7b0430d8cdb78070b4c55a.
Model boundary: Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser.
Independent task and submission evidence
2. Prime and extension fields — complete its numbered steps and record the requested evidence. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.
Trial
Changed setting
Fixed settings
Predicted result
Actual observation / units
Evidence / uncertainty
A: baseline
Reference
Record
Predict
Record
Record
B: one change
Record
Same as A
Predict
Record
Record
A: repeat
Restore
Same as A
Predict
Record
Record
Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.
Scientific concept map: 16 plaintext bytes — State columns; AddRoundKey — XOR subkey; SubBytes + ShiftRows — Substitution / permutation; MixColumns — \(\mathrm{GF}(2^{8})\) multiplication; Final round — No MixColumns.
Prime and extension fields
GF(p) has p residues for prime p. GF(p^m) can be represented as polynomials of degree below m with coefficients in GF(p), reduced modulo a chosen irreducible degree-m polynomial. In GF(2^m), addition is XOR. Changing the irreducible polynomial changes the representation of multiplication and inverses.
AES byte arithmetic
AES uses GF(256) with modulus \(x^{8}\)+\(x^{4}\)+\(x^{3}\)+x+1 (0x11B). Multiplication by x is a left shift with conditional reduction by 0x1B. For nonzero bytes, calculate the multiplicative inverse; the AES S-box applies an affine transformation to that inverse, with zero mapped through the affine transform from zero.
State and rounds
The 16-byte AES state is arranged column-major. AES-128 starts with AddRoundKey, then executes ten rounds. SubBytes introduces nonlinearity; ShiftRows moves bytes across columns; MixColumns combines each column using a fixed matrix in GF(256); AddRoundKey XORs a 128-bit round key. Round ten omits MixColumns. The inverse transformations recover the plaintext.
Prerequisites: EC07 and earlier foundations as applicable.
Algorithm structure and data flow. Use the simulation to inspect the corresponding numerical transformations.
The order of the four AES round transformations.
AES S-box (hexadecimal)
Row / column
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0
63
7C
77
7B
F2
6B
6F
C5
30
01
67
2B
FE
D7
AB
76
1
CA
82
C9
7D
FA
59
47
F0
AD
D4
A2
AF
9C
A4
72
C0
2
B7
FD
93
26
36
3F
F7
CC
34
A5
E5
F1
71
D8
31
15
3
04
C7
23
C3
18
96
05
9A
07
12
80
E2
EB
27
B2
75
4
09
83
2C
1A
1B
6E
5A
A0
52
3B
D6
B3
29
E3
2F
84
5
53
D1
00
ED
20
FC
B1
5B
6A
CB
BE
39
4A
4C
58
CF
6
D0
EF
AA
FB
43
4D
33
85
45
F9
02
7F
50
3C
9F
A8
7
51
A3
40
8F
92
9D
38
F5
BC
B6
DA
21
10
FF
F3
D2
8
CD
0C
13
EC
5F
97
44
17
C4
A7
7E
3D
64
5D
19
73
9
60
81
4F
DC
22
2A
90
88
46
EE
B8
14
DE
5E
0B
DB
A
E0
32
3A
0A
49
06
24
5C
C2
D3
AC
62
91
95
E4
79
B
E7
C8
37
6D
8D
D5
4E
A9
6C
56
F4
EA
65
7A
AE
08
C
BA
78
25
2E
1C
A6
B4
C6
E8
DD
74
1F
4B
BD
8B
8A
D
70
3E
B5
66
48
03
F6
0E
61
35
57
B9
86
C1
1D
9E
E
E1
F8
98
11
69
D9
8E
94
9B
1E
87
E9
CE
55
28
DF
F
8C
A1
89
0D
BF
E6
42
68
41
99
2D
0F
B0
54
BB
16
AES inverse S-box (hexadecimal)
Row / column
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0
52
09
6A
D5
30
36
A5
38
BF
40
A3
9E
81
F3
D7
FB
1
7C
E3
39
82
9B
2F
FF
87
34
8E
43
44
C4
DE
E9
CB
2
54
7B
94
32
A6
C2
23
3D
EE
4C
95
0B
42
FA
C3
4E
3
08
2E
A1
66
28
D9
24
B2
76
5B
A2
49
6D
8B
D1
25
4
72
F8
F6
64
86
68
98
16
D4
A4
5C
CC
5D
65
B6
92
5
6C
70
48
50
FD
ED
B9
DA
5E
15
46
57
A7
8D
9D
84
6
90
D8
AB
00
8C
BC
D3
0A
F7
E4
58
05
B8
B3
45
06
7
D0
2C
1E
8F
CA
3F
0F
02
C1
AF
BD
03
01
13
8A
6B
8
3A
91
11
41
4F
67
DC
EA
97
F2
CF
CE
F0
B4
E6
73
9
96
AC
74
22
E7
AD
35
85
E2
F9
37
E8
1C
75
DF
6E
A
47
F1
1A
71
1D
29
C5
89
6F
B7
62
0E
AA
18
BE
1B
B
FC
56
3E
4B
C6
D2
79
20
9A
DB
C0
FE
78
CD
5A
F4
C
1F
DD
A8
33
88
07
C7
31
B1
12
10
59
27
80
EC
5F
D
60
51
7F
A9
19
B5
4A
0D
2D
E5
7A
9F
93
C9
9C
EF
E
A0
E0
3B
4D
AE
2A
F5
B0
C8
EB
BB
3C
83
53
99
61
F
17
2B
04
7E
BA
77
D6
26
E1
69
14
63
55
21
0C
7D
MixColumns matrix
Column 0
Column 1
Column 2
Column 3
Row 0
02
03
01
01
Row 1
01
02
03
01
Row 2
01
01
02
03
Row 3
03
01
01
02
Engineering diagrams
AES round stages and state layout.
Scientific foundations and worked examples
Prime-field and extension-field construction
GF(7) contains 0 through 6; operations reduce modulo 7, and all nonzero elements have inverses. GF(5) provides a smaller worked example: 2×3≡1, so 2 and 3 are inverses. GF(9) consists of a₁x+\(a_{0}\) with coefficients in GF(3); GF(16) consists of four binary coefficients. These extension fields are not integer arithmetic modulo 9 or 16. GF(4) with \(x^{2}\)+x+1 gives (x+1)²=x. GF(8) may use \(x^{3}\)+x+1 or \(x^{3}\)+\(x^{2}\)+1; addition is the same XOR table but multiplication depends on the modulus.
AES polynomial reduction and inversion
The byte DA represents \(x^{7}\)+\(x^{6}\)+\(x^{4}\)+\(x^{3}\)+x. AES reduces products by \(m(x)=x^8+x^4+x^3+x+1\) (0x11B). Thus \(x^{8}\)≡\(x^{4}\)+\(x^{3}\)+x+1 (0x1B) and \(x^{9}\)≡\(x^{5}\)+\(x^{4}\)+\(x^{2}\)+x (0x36). Multiply a byte by x using a left shift, then XOR 0x1B if the original top bit was set. Repeat for higher powers; XOR partial products for DA×C5. The extended polynomial Euclidean algorithm finds inverses: 05 has inverse 52 because 05·52=01 in GF(256). The AES S-box applies a bitwise affine transform to that inverse, yielding 6B for input 05.
State layout and round transformations
AES-128 maps 16 input bytes into a 4×4 column-major state. SubBytes applies the S-box independently; ShiftRows rotates row r left by r positions; MixColumns multiplies each column by the fixed matrix with first row [02,03,01,01] and cyclic shifts. AddRoundKey XORs the state with a round key. The initial AddRoundKey precedes ten rounds, and the tenth omits MixColumns. For the assigned state DA C5 followed by fourteen zero bytes, identify the nonzero positions before and after ShiftRows and calculate the four field products per affected column.
Engineering principles · additional worked teaching example
AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition.
From theory to experiment
Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.
Worked engineering reasoning and boundary conditions
AES bytes are \(\mathrm{GF}(2^{8})\) elements, with polynomial reduction by 0x11B. For xtime(0x83), shift to 0x106 then XOR 0x11B =0x1D. The state is column-major.
Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.
Mathematical representation and interpretation
Binary polynomial arithmetic
a_i and b_i are binary coefficients. Multiplication is polynomial multiplication; reduction by the selected irreducible degree-n polynomial m gives a degree below n. It is not ordinary integer remainder arithmetic.
For example, over GF(2), (x+1)+(x+1)=0 because each repeated coefficient cancels.
Concept animation · operation pathway
Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.
Step 1 of 4 · Byte
Byte
Byte
83 hex
Shift
Byte
83 hex
Shift
106 hex
Reduce
Byte
83 hex
Shift
106 hex
Reduce
106 XOR 11B = 1D
Field result
Byte
83 hex
Shift
106 hex
Reduce
106 XOR 11B = 1D
Field result
xtime(83)=1D
Teaching example only; inspect live calculations or real practical evidence separately.
Interactive flashcards
Self-rated study progress is stored locally, not used for official grades.
Browse all explanationsWhat is AES block size?
128 bits.
Which operation mixes column bytes?
MixColumns over GF(256).
Which transformation is omitted in final round?
MixColumns.
What does AddRoundKey do?
XORs state with round key.
Why are AES bytes elements of GF(256)?
Each byte represents a degree-below-8 binary polynomial.
What polynomial defines the AES field?
x^8+x^4+x^3+x+1, represented by 0x11b.
What is AES field addition?
Bitwise XOR.
How is the AES S-box constructed?
Multiplicative inverse in GF(256), followed by an affine transform; zero maps through the affine transform.
What is S-box(0x53)?
0xed.
What is S-box(0x00)?
0x63.
What does ShiftRows do?
Cyclically shifts rows by their row index.
What does MixColumns do?
Multiplies each state column by a fixed matrix over GF(256).
How many rounds does AES-128 have?
10.
What operation is omitted in the final encryption round?
MixColumns.
Why use the Rijndael Inspector?
To inspect individual transformations and compare them with manual calculations.
Why is the AES field reduction polynomial 0x11B relevant when a byte is multiplied by 02?
The left shift may exceed eight bits. Reduction by \(x^{8}\)+\(x^{4}\)+\(x^{3}\)+x+1 keeps the result in \(\mathrm{GF}(2^{8})\).
Which transformation is absent in the last AES encryption round?
MixColumns. The final round contains SubBytes, ShiftRows and AddRoundKey.
A student applies AES S-box to input 05. What is the correct result?
6B hexadecimal. Invert the nonzero element in GF(256), apply the affine map, then verify the table entry.
How many round keys does AES-128 expand?
11 keys: the initial AddRoundKey and one for each of ten rounds.
Choose a workstation, edit the inputs, and observe recalculated results. Play or step through the actual calculation trace. Hash-search stations calculate successive candidates during playback. All inputs are fictional training data.
Where the browser requires Web Crypto, launch the local portal on localhost or use the HTTPS deployment. The classroom algorithms and keys are not intended for production use.
Rijndael Inspector
Independent theoretical exercises
Complete every question independently on paper or in the fields below before using the simulation or programming activities. Show formulas, intermediate steps, tables, proofs and units. Afterward verify your work using the simulator and Python, and explain discrepancies. Worked examples in Concepts do not replace your own derivation.
01 · GF(7)
List elements; construct complete 7×7 addition and multiplication tables. Identify all nonzero multiplicative inverses.
Engineering method — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · GF(8) with P1
Prove \(X^{3}\)+X+1 irreducible over GF(2). Enumerate the field elements; construct both 8×8 tables and find every nonzero inverse.
Engineering method — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · GF(8) with P2
Prove \(X^{3}\)+\(X^{2}\)+1 irreducible. Compare addition and multiplication tables with P1 and construct the differing table(s).
Engineering method — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
04 · AES polynomial reduction
For P=\(X^{8}\)+\(X^{4}\)+\(X^{3}\)+X+1 derive \(X^{8}\) through \(X^{15}\) mod P by polynomial division. State the reduction rule. Calculate DA·C5 in GF(256).
Engineering method — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
05 · AES substitution
Use polynomial extended Euclid to invert 05, then apply the AES affine S-box transformation and compare the lookup. Optional: repeat inverse calculation for DA and verify its substitution.
Engineering method — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
06 · State transformations
Place DAC5 followed by zeros into the AES state using column-major order. Count zero bytes, then calculate ShiftRows and MixColumns byte by byte.
Engineering method — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
07 · Calculation
Calculation · Independent work
Calculate multiplication of byte 0x95 by 02 and 03 in AES field. Explain why ordinary integer multiplication gives a different result.
Calculation — AES treats bytes as polynomials in \(\mathrm{GF}(2^{8})\) modulo 0x11B. xtime(0xC0) shifts left then reduces with 0x1B: 0x80 XOR 0x1B=0x9B. Multiplication by 3 equals xtime XOR original, giving 0x5B. XOR is addition, not decimal addition. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Responses are saved locally when browser storage is available. Export your work for submission. No automatic grading or remote upload occurs.
Expanded independent theoretical exercise bank
Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.
Foundational · Apply the principle
Independent theoretical exercise · EC08-01
Compute xtime(0xC7).
Intermediate · Calculate or trace
Independent theoretical exercise · EC08-02
Compute 03·0x57 in \(\mathrm{GF}(2^{8})\).
Intermediate · Interpret the result
Independent theoretical exercise · EC08-03
For input bytes 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F, list row 1 of the AES state.
Advanced · Analyze a condition
Independent theoretical exercise · EC08-04
Apply ShiftRows to row 2 [02,06,0A,0E].
Advanced · Diagnose or compare
Independent theoretical exercise · EC08-05
XOR byte 0xD4 with key byte 0xA9 and recover the input.
Challenging · Engineering verification
Independent theoretical exercise · EC08-06
Why is MixColumns absent in the final AES encryption round?
Activity sequence
Follow the setup commands, then each named activity. The detailed instructions, given values and recording fields appear below.
Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
Compare observations with the reference checks and submit the required evidence.
Analytical preparation — before Python
Complete this written or hand-calculation activity first, then compare it with the simulator and executable implementation.
Construct GF(7) and both GF(8) tables by hand or spreadsheet. Derive \(x^{8}\) through \(x^{15}\) reductions, the inverse of 05 and the S-box output; trace the assigned DAC5 state through the two transformations.
Evidence: show the derivation, intermediate values and independent checks; explain any mismatch with the practical result.
Practical laboratory manual
Scientific experimental protocol
Research question: How do finite-field operations produce reversible AES transformations?
Independent variables
Field polynomial, operands, state, key
Dependent observations
Field product/inverse, state matrices, ciphertext
Controls
Hold field polynomial fixed within a trial; compare field definitions and use column-major layout.
Validation and evidence
Before running a trial, predict its output. Use the baseline conditions below to check your method, then vary one independent variable. Save calculated outputs or the actual Python trace. Keep browser results and local Python execution distinct.
3. Run the check before changing inputs. Record the exact Python version and any dependency error. Use Python visualizer to inspect the recorded traces; for edited code, generate and import a new trace using the instructions in that tab.
Complete the activities in order. Hold the controlled conditions fixed, record the input and actual output, and compare your observations with an independent calculation or test vector.
01
Prime and extension fields
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Construct GF(7) elements, addition/multiplication tables and inverses of all nonzero elements. Use a GF(5) calculation as a warm-up.
List GF(8) binary polynomials. Verify irreducibility of P1=\(X^{3}\)+X+1 and P2=\(X^{3}\)+\(X^{2}\)+1 by testing roots.
Generate addition and multiplication tables for both reductions and all inverses; compare unchanged addition with changed multiplication. Work through GF(4), GF(9) and GF(16) representations.
Experimental inputs and checks
Extension-field reduction polynomials
GF(4): x²+x+1; GF(8): x³+x+1 or x³+x²+1; GF(9): x²+1 over GF(3); GF(16): x⁴+x+1
Evidence to record
Tables, inverse checks and polynomial representation conventions.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
02
AES polynomial reduction and S-box
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Use modulus 0x11B=\(X^{8}\)+\(X^{4}\)+\(X^{3}\)+X+1; derive \(X^{8}\) through \(X^{15}\) residues by repeated multiplication by X.
Calculate DA×C5 by carryless multiplication and reduction; verify using GF(256) workstation.
Run polynomial extended Euclid for 05=\(X^{2}\)+1 and modulus, verify inverse by multiplication; apply the affine S-box transform and compare S(05) with table.
Repeat optional DA inverse, and the checks S(06), S(3D), inverse S-box outputs 6F and 27. Separate GF(16) reduction examples from AES GF(256).
Experimental inputs and checks
AES field modulus
0x11B
Multiplication check
DA × C5 = DB
Substitution check
S(05) = 6B
Evidence to record
Reduction table, products, Euclid rows, inverse and S-box values.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
03
AES state, ShiftRows and MixColumns
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Map bytes column-major into a 4×4 state. Use the phrase AES USES A MATRIX (remove spaces as instructed; explicitly declare any padding required to fill 16 bytes).
Enter DAC5 followed by enough zero bytes for a 16-byte state. Inspect before/after ShiftRows and compute each MixColumns result using GF(256) multiplication.
Use Rijndael Inspector and native AES transformations to inspect AddRoundKey, SubBytes, ShiftRows and MixColumns, including the final-round omission of MixColumns. Verify the standard AES-128 known-answer pair.
State matrices after each transformation and ciphertext verification.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
Verification criteria
DA×C5=DB in GF(256); AES S-box(05)=6B; AES known-answer ciphertext is 69c4e0d86a7b0430d8cdb78070b4c55a.
Deliverables
Submit GF tables, inverses, reduction steps, AES S-box computation, state matrices and known-answer validation.
Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.
Execution scope: Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# EC08 · AES mathematics — Galois fields and block transformations
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## 1. Scientific objective
Follow the setup commands, then each named activity. The detailed instructions, given values and recording fields appear below.
Complete the analytical worksheet in the portal first. Record your predictions before running this notebook. This notebook is a bounded local computational investigation; use the portal’s separate WSL, hardware or Remix procedure for real interfaces.
02Instructions · Markdown
## Experiment-specific preparation
Build finite-field arithmetic tables and connect polynomial reduction and inversion to the AES S-box and state transformations.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
2. Prime and extension fields — complete its numbered steps and record the requested evidence.
3. AES polynomial reduction and S-box — complete its numbered steps and record the requested evidence.
4. AES state, ShiftRows and MixColumns — complete its numbered steps and record the requested evidence.
5. Compare observations with the reference checks and submit the required evidence.
**Evidence:** DA×C5=DB in GF(256); AES S-box(05)=6B; AES known-answer ciphertext is 69c4e0d86a7b0430d8cdb78070b4c55a.
**Boundary:** Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser.
03Instructions · Markdown
## 2. Reference configuration and investigation
1. Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
2. Prime and extension fields — complete its numbered steps and record the requested evidence.
3. AES polynomial reduction and S-box — complete its numbered steps and record the requested evidence.
4. AES state, ShiftRows and MixColumns — complete its numbered steps and record the requested evidence.
5. Compare observations with the reference checks and submit the required evidence.
Run cells in order; do not substitute model results for physical measurements.
04Instructions · Markdown
### Environment
Colab usually provides cryptography. If imports fail, install dependencies in a separate Colab cell using `%pip install pycryptodome cryptography`, then restart the runtime. Local validation uses the installed backend. No actual secrets are used.
05Instructions · Markdown
### Dependency — lab05
The following cells define the actual toolkit dependency.
06Instructions · Markdown
Dependency definitions 1
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC08 | Code cell 01 | AES mathematics — Galois fields and block transformations
# Purpose: Dependency definitions 1
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
"""Essential 05 — GF(2) polynomial arithmetic and LFSR state traces."""
# Define the reusable operation gf2 multiply; keep its logic separate from the trial.
def gf2_multiply(a,b):
out=0
while b:
if b&1: out^=a
a<<=1; b>>=1
return out
# Define the reusable operation gf2 divide; keep its logic separate from the trial.
def gf2_divide(a,b):
if a<0 or b<=0: raise ValueError('Nonnegative binary polynomials, nonzero divisor required')
q=0
while a and a.bit_length()>=b.bit_length():
k=a.bit_length()-b.bit_length(); q^=1<<k; a^=b<<k
return q,a
# =====================================================================
# EC08 | Code cell 02 | AES mathematics — Galois fields and block transformations
# Purpose: Dependency definitions 2
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Define the reusable operation lfsr trace; keep its logic separate from the trial.
def lfsr_trace(state,taps):
if not 2<=len(state)<=10 or set(state)-{'0','1'} or not taps or len(set(taps))!=len(taps) or any(i<0 or i>=len(state) for i in taps):
raise ValueError('Invalid register or tap indices')
seen={}; trace=[]
while state not in seen:
seen[state]=len(trace); feedback=0
for i in taps: feedback^=int(state[i])
nxt=str(feedback)+state[:-1]; trace.append((state,feedback,state[-1],nxt)); state=nxt
return trace,len(trace)-seen[state],seen[state]
# =====================================================================
# EC08 | Code cell 03 | AES mathematics — Galois fields and block transformations
# Purpose: Dependency definitions 2
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import types, sys
# Set _dependency for the next computation or reference condition.
_dependency = types.ModuleType('lab05')
_dependency.__dict__.update({k:v for k,v in globals().copy().items() if not k.startswith("__")})
# Set sys.modules['lab05'] for the next computation or reference condition.
sys.modules['lab05'] = _dependency
### Dependency — crypto_backend
The following cells define the actual toolkit dependency.
12Instructions · Markdown
Dependency definitions 1
13Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC08 | Code cell 04 | AES mathematics — Galois fields and block transformations
# Purpose: Dependency definitions 1
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
"""Reference library adapter for classroom AES. No production key storage."""
try:
from Crypto.Cipher import AES as _AES
BACKEND='PyCryptodome'
except ImportError:
from cryptography.hazmat.primitives.ciphers import Cipher,algorithms,modes
_AES=None; BACKEND='cryptography'
# Define the reusable operation aes crypt; keep its logic separate from the trial.
def aes_crypt(key,data,mode,iv=b'',decrypt=False):
if len(key) not in (16,24,32): raise ValueError('Invalid AES key length')
if mode in ('ECB','CBC') and len(data)%16: raise ValueError('Unaligned block-mode data')
if mode=='CBC' and len(iv)!=16: raise ValueError('CBC requires 16-byte IV')
if mode=='CTR' and len(iv)!=8: raise ValueError('This CTR fixture uses an 8-byte nonce')
if mode not in ('ECB','CBC','CTR'): raise ValueError('Unknown mode')
if _AES is not None:
if mode=='ECB': c=_AES.new(key,_AES.MODE_ECB)
elif mode=='CBC': c=_AES.new(key,_AES.MODE_CBC,iv=iv)
else: c=_AES.new(key,_AES.MODE_CTR,nonce=iv,initial_value=0)
return c.decrypt(data) if decrypt else c.encrypt(data)
m={'ECB':lambda:modes.ECB(),'CBC':lambda:modes.CBC(iv),'CTR':lambda:modes.CTR(iv+b'\0'*8)}[mode]()
c=Cipher(algorithms.AES(key),m); op=c.decryptor() if decrypt else c.encryptor()
return op.update(data)+op.finalize()
# =====================================================================
# EC08 | Code cell 05 | AES mathematics — Galois fields and block transformations
# Purpose: Dependency definitions 2
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Define the reusable operation pad; keep its logic separate from the trial.
def pad(data):
n=16-len(data)%16; return data+bytes([n])*n
# Define the reusable operation unpad; keep its logic separate from the trial.
def unpad(data):
if not data or len(data)%16: raise ValueError('Invalid padded data length')
n=data[-1]
if not 1<=n<=16 or data[-n:]!=bytes([n])*n: raise ValueError('Invalid PKCS#7 padding')
return data[:-n]
# =====================================================================
# EC08 | Code cell 06 | AES mathematics — Galois fields and block transformations
# Purpose: Dependency definitions 2
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import types, sys
# Set _dependency for the next computation or reference condition.
_dependency = types.ModuleType('crypto_backend')
_dependency.__dict__.update({k:v for k,v in globals().copy().items() if not k.startswith("__")})
# Set sys.modules['crypto_backend'] for the next computation or reference condition.
sys.modules['crypto_backend'] = _dependency
## 3. Algorithm implementation
Read each definition and relate it to the equations and scientific SVGs in Concepts.
18Instructions · Markdown
### Implementation cell 1
Inspect the definitions, then execute to make them available for the investigation.
19Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC08 | Code cell 07 | AES mathematics — Galois fields and block transformations
# Purpose: Implementation cell 1 Inspect the definitions, then execute to make them available for the investigation.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
"""Essential 08 — finite-field arithmetic and an AES known-answer test."""
from lab05 import gf2_divide,gf2_multiply
# Define the reusable operation multiply; keep its logic separate from the trial.
def multiply(a,b,polynomial=0x11b): return gf2_divide(gf2_multiply(a,b),polynomial)[1]
### Implementation cell 2
Inspect the definitions, then execute to make them available for the investigation.
21Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC08 | Code cell 08 | AES mathematics — Galois fields and block transformations
# Purpose: Implementation cell 2 Inspect the definitions, then execute to make them available for the investigation.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Define the reusable operation inverse; keep its logic separate from the trial.
def inverse(a,polynomial=0x11b):
if not a: raise ValueError('Zero has no inverse')
return next(x for x in range(1,1<<(polynomial.bit_length()-1)) if multiply(a,x,polynomial)==1)
# Define the reusable operation sbox; keep its logic separate from the trial.
def sbox(a):
x=inverse(a) if a else 0
def rol(n): return ((x<<n)|(x>>(8-n)))&255
return x^rol(1)^rol(2)^rol(3)^rol(4)^0x63
# Define the reusable operation field table; keep its logic separate from the trial.
def field_table(order,polynomial=None,add=False):
def operation(a,b):
if polynomial is None: return (a+b if add else a*b)%order
return a^b if add else multiply(a,b,polynomial)
return [[operation(a,b) for b in range(order)] for a in range(order)]
## 4. Execute reference controls
The program checks selected algorithm outcomes. Record the observed output. These checks do not replace the independent calculation assignment.
23Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC08 | Code cell 09 | AES mathematics — Galois fields and block transformations
# Purpose: 4. Execute reference controls The program checks selected algorithm outcomes. Record the observed output. These checks do not replace the independent calculation assignment.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert multiply(218, 197) == 219 and sbox(5) == 107
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert multiply(5, inverse(5)) == 1
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert field_table(8, 11, True) == field_table(8, 13, True)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert field_table(8, 11) != field_table(8, 13)
from crypto_backend import aes_crypt
# Prepare key; retain only the scope required for this trial.
key = bytes.fromhex('000102030405060708090a0b0c0d0e0f')
# Set block for the next computation or reference condition.
block = bytes.fromhex('00112233445566778899aabbccddeeff')
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert aes_crypt(key, block, 'ECB').hex() == '69c4e0d86a7b0430d8cdb78070b4c55a'
print('GF tables, inversion, S-box and AES known-answer checks passed')
## 5. Controlled variation
Predict the effect of the parameter changes below. Compare each actual result to your prediction.
25Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC08 | Code cell 10 | AES mathematics — Galois fields and block transformations
# Purpose: 5. Controlled variation Predict the effect of the parameter changes below. Compare each actual result to your prediction.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Repeat the same operation for each configured input so observations are comparable.
for a in (1,2,3,0x57):
print(hex(a), "field element; compare against your table")
## Experimental analysis and submission
1. Record the reference input, predicted output and actual result.
2. Modify one independent variable and run the relevant cells again.
3. Explain the result using the theory and identify model limitations.
4. Save the notebook with outputs and retain the separate theoretical worksheet.
**Your derivation and conclusion:**
(Complete independently.)
27Instructions · Markdown
## Guided reasoning and evidence
A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above.
**Independent task:** 2. Prime and extension fields — complete its numbered steps and record the requested evidence. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
| Trial | Input/configuration | Prediction | Observation | Evidence / limitation |
|---|---|---|---|---|
| A | Reference | | | |
| B | Changed input | | | |
| A repeat | Reference | | | |
A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Python implementation
Download the complete practical toolkit and extract it to a new directory. Keep the code and challenges folders together.
For the practical tasks, install PyCryptodome in your virtual environment. The included Python programs also support the cryptography library; the optional capstone uses cryptography.
Explore actual CPython execution traces from the included laboratory programs. Play, pause, step, inspect the current line, local variable values, function call stack, return values and output. Green variable cells changed relative to the preceding event. Line events show state before the highlighted line executes.
Run and visualize your own modified Python program
Download the Essential Cryptography Toolkit, extract it, and open a terminal in its code directory. Run the worked example or edit a copy. The trace generator executes your actual local Python file and creates an importable JSON record. Only run trusted code and use fictional keys and data.
Choose Import your trace in the visualizer and select my-trace.json. This works offline; the portal does not execute arbitrary Python on its server. The optional external Python Tutor link is suitable for standalone standard-library code, but external dependencies or local imports may not work.
For AES/DES exercises, install either supported cryptographic backend in an isolated Python environment as described in the Python code tab. Native library internals are not traced; the algorithm-specific browser workstations display the intermediate mathematics.
Why is addition the same for both GF(8) representations?
Why is multiplication reduced by 0x11B?
Why is there no MixColumns in the final AES round?
Submission: Submit GF tables, inverses, reduction steps, AES S-box computation, state matrices and known-answer validation.
Export actual calculated observations from each workstation. Record your own predictions and conclusions, and distinguish browser calculations from local or physical measurements.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research