Trace DES bit permutations, subkey generation and round functions; quantify nonlinearity and the avalanche effect.
The focus of this experiment is to trace DES permutation, S-box lookup and Feistel rounds. Students then calculate subkey mixing and compare Hamming-distance trials, and verify known-answer behavior and explain legacy limitations. 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
Trace DES permutation, S-box lookup and Feistel rounds.
Calculate subkey mixing and compare Hamming-distance trials.
Verify known-answer behavior and explain legacy limitations.
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 trace DES permutation, S-box lookup and Feistel rounds, calculate subkey mixing and compare Hamming-distance trials, and verify known-answer behavior and explain legacy limitations.
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 known-answer behavior and explain legacy limitations. 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 AES mathematics — Galois fields and block transformations.
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 DES — S-boxes, Feistel rounds and avalanche
Trace DES bit permutations, subkey generation and round functions; quantify nonlinearity and the avalanche effect.
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: Trace DES bit permutations, subkey generation and round functions; quantify nonlinearity and the avalanche effect.
Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
S-box nonlinearity — complete its numbered steps and record the requested evidence.
DES initial permutation and key schedule — complete its numbered steps and record the requested evidence.
Plaintext avalanche assigned bit 57 — complete its numbered steps and record the requested evidence.
Reference check: The known-answer ciphertext is 85E813540F0AB405. The nonlinearity example differs. A parity-only key flip leaves the effective key and ciphertext unchanged.
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. S-box nonlinearity — 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 concepts and engineering principles
Scientific architecture · EC07 · DES — S-boxes, Feistel rounds and avalanche
Expansion, key mixing, eight S-boxes, permutation P and Feistel word exchange.
Block and effective key
DES encrypts a 64-bit block with a 56-bit effective key. The 64-bit key encoding includes eight parity bits, which PC-1 removes. The initial permutation rearranges plaintext bits before the 16-round Feistel network; the final permutation is its inverse after the final swap.
Nonlinear round function
The expansion E maps 32 right-half bits to 48. XOR with the 48-bit subkey, split into eight six-bit groups and apply S1 through S8. Concatenate the four-bit outputs, then apply permutation P. Update \(L_{i}\)=\(R_{i-1}\) and \(R_{i}\)=\(L_{i-1}\) XOR F(\(R_{i-1}\),\(K_{i}\)). The S-box row is the two outer bits and the column is the four inner bits.
Key schedule and avalanche
PC-1 forms two 28-bit halves. Scheduled circular left shifts and PC-2 generate each round subkey. Flip exactly one plaintext bit, one effective key bit, or one parity bit in separate trials; measure Hamming distance between corresponding states. DES is obsolete for real security. Its role here is to explain bit-level transformations.
Prerequisites: EC06 and earlier foundations as applicable.
Algorithm structure and data flow. Use the simulation to inspect the corresponding numerical transformations.
Six input bits determine the S-box lookup coordinates.
DES substitution tables — S1 through S8
Each DES S-box maps six input bits to four output bits. Select the row using the two outer bits and the column using the four inner bits.
S1 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
14
4
13
1
2
15
11
8
3
10
6
12
5
9
0
7
1
0
15
7
4
14
2
13
1
10
6
12
11
9
5
3
8
2
4
1
14
8
13
6
2
11
15
12
9
7
3
10
5
0
3
15
12
8
2
4
9
1
7
5
11
3
14
10
0
6
13
S2 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
15
1
8
14
6
11
3
4
9
7
2
13
12
0
5
10
1
3
13
4
7
15
2
8
14
12
0
1
10
6
9
11
5
2
0
14
7
11
10
4
13
1
5
8
12
6
9
3
2
15
3
13
8
10
1
3
15
4
2
11
6
7
12
0
5
14
9
S3 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
10
0
9
14
6
3
15
5
1
13
12
7
11
4
2
8
1
13
7
0
9
3
4
6
10
2
8
5
14
12
11
15
1
2
13
6
4
9
8
15
3
0
11
1
2
12
5
10
14
7
3
1
10
13
0
6
9
8
7
4
15
14
3
11
5
2
12
S4 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
7
13
14
3
0
6
9
10
1
2
8
5
11
12
4
15
1
13
8
11
5
6
15
0
3
4
7
2
12
1
10
14
9
2
10
6
9
0
12
11
7
13
15
1
3
14
5
2
8
4
3
3
15
0
6
10
1
13
8
9
4
5
11
12
7
2
14
S5 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
2
12
4
1
7
10
11
6
8
5
3
15
13
0
14
9
1
14
11
2
12
4
7
13
1
5
0
15
10
3
9
8
6
2
4
2
1
11
10
13
7
8
15
9
12
5
6
3
0
14
3
11
8
12
7
1
14
2
13
6
15
0
9
10
4
5
3
S6 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
12
1
10
15
9
2
6
8
0
13
3
4
14
7
5
11
1
10
15
4
2
7
12
9
5
6
1
13
14
0
11
3
8
2
9
14
15
5
2
8
12
3
7
0
4
10
1
13
11
6
3
4
3
2
12
9
5
15
10
11
14
1
7
6
0
8
13
S7 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
4
11
2
14
15
0
8
13
3
12
9
7
5
10
6
1
1
13
0
11
7
4
9
1
10
14
3
5
12
2
15
8
6
2
1
4
11
13
12
3
7
14
10
15
6
8
0
5
9
2
3
6
11
13
8
1
4
10
7
9
5
0
15
14
2
3
12
S8 — decimal values, row/column indices start at 0
r/c
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0
13
2
8
4
6
15
11
1
10
9
3
14
5
0
12
7
1
1
15
13
8
10
3
7
4
12
5
6
11
0
14
9
2
2
7
11
4
1
9
12
14
2
0
6
10
13
15
3
5
8
3
2
1
14
7
4
10
8
13
15
12
9
0
3
5
6
11
DES bit permutation tables
Read left to right, top to bottom. Entries are one-based input bit positions. These are the exact permutation tables used in the experiment engine.
IP — 64 output bits
58
50
42
34
26
18
10
2
60
52
44
36
28
20
12
4
62
54
46
38
30
22
14
6
64
56
48
40
32
24
16
8
57
49
41
33
25
17
9
1
59
51
43
35
27
19
11
3
61
53
45
37
29
21
13
5
63
55
47
39
31
23
15
7
PC1 — 56 output bits
57
49
41
33
25
17
9
1
58
50
42
34
26
18
10
2
59
51
43
35
27
19
11
3
60
52
44
36
63
55
47
39
31
23
15
7
62
54
46
38
30
22
14
6
61
53
45
37
29
21
13
5
28
20
12
4
PC2 — 48 output bits
14
17
11
24
1
5
3
28
15
6
21
10
23
19
12
4
26
8
16
7
27
20
13
2
41
52
31
37
47
55
30
40
51
45
33
48
44
49
39
56
34
53
46
42
50
36
29
32
E — 48 output bits
32
1
2
3
4
5
4
5
6
7
8
9
8
9
10
11
12
13
12
13
14
15
16
17
16
17
18
19
20
21
20
21
22
23
24
25
24
25
26
27
28
29
28
29
30
31
32
1
P — 32 output bits
16
7
20
21
29
12
28
17
1
15
23
26
5
18
31
10
2
8
24
14
32
27
3
9
19
13
30
6
22
11
4
25
Engineering diagrams
Feistel round and round-key generation.
Scientific foundations and worked examples
Complete DES processing chain
DES transforms a 64-bit input by IP, splits it into \(L_{0}\),\(R_{0}\), performs 16 rounds \(L_{i}\)=\(R_{i-1}\) and \(R_{i}\)=\(L_{i-1}\) XOR F(\(R_{i-1}\),\(K_{i}\)), swaps the halves and applies IP⁻¹. F expands R to 48 bits, XORs the subkey, splits into eight six-bit chunks, substitutes to 32 bits and applies P. Decryption uses the same Feistel structure with reversed subkey order. A Feistel round is invertible even if F is not.
S-box indexing and nonlinear worked example
The first and sixth bits form the two-bit row index, while the middle four select a column. For S1(000000)=14 and S1(000001)=0, the XOR of outputs is 14 while S1(000000 XOR 000001)=0. Thus the substitution is not linear. For S1(100101), row=3, column=2 and output=8. All eight tables below allow manual reproduction of each chunk. The DES S-box design criterion for one-bit input differences is at least two output bits per affected box; later permutations redistribute these changes.
Key schedule and avalanche methodology
PC-1 removes every eighth parity bit and permutes the remaining 56 bits into two 28-bit halves. Rotate each half by one position in rounds 1,2,9,16 and by two in other rounds, then PC-2 selects 48 bits. The sum of shifts is 28. All-zero and all-one key encodings fail odd parity, but are usable as mathematical effective-key fixtures in a permissive teaching implementation; real APIs may reject or correct parity. Track the changed bit through PC-1, rotations and PC-2. Compare plaintext-bit-57 and first-key-bit cases against an unchanged baseline using XOR and Hamming distance. DES is obsolete for new security systems.
Engineering principles · additional worked teaching example
DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits.
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
DES expands 32 bits to 48, combines a subkey using XOR, substitutes eight 6-bit groups into 4-bit groups, permutes, and applies a reversible Feistel exchange. For S1 input 000000 row 0 column 0 yields 14.
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.
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 · Expand R
Expand R
Expand R
32 → 48 bits
Key mixing
Expand R
32 → 48 bits
Key mixing
48-bit XOR
Eight S-boxes
Expand R
32 → 48 bits
Key mixing
48-bit XOR
Eight S-boxes
8 × 6 → 8 × 4 bits
Permutation + Feistel
Expand R
32 → 48 bits
Key mixing
48-bit XOR
Eight S-boxes
8 × 6 → 8 × 4 bits
Permutation + Feistel
32-bit output; XOR L
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 explanationsHow many DES rounds?
16 Feistel rounds.
What is the effective key size?
56 bits excluding parity.
What does an S-box do?
Nonlinear mapping of 6 bits to 4 bits.
Why not deploy DES?
Its key space is too small for contemporary security.
How is the DES S-box row selected?
Combine the first and last bits as a two-bit integer.
How is the column selected?
Use the middle four bits as a four-bit integer.
What is S1(100101)?
8 (1000): row 3, column 2.
What is S2(100101)?
10 (1010): row 3, column 2.
What is S1(000000)?
14 (1110).
What is S1(000001)?
0 (0000).
Why does the XOR experiment show nonlinearity?
S1(0) XOR S1(1)=14, while S1(0 XOR 1)=0.
How many bits does DES expansion produce?
48, from a 32-bit right half.
What is the purpose of PC-1?
Remove eight parity bits and permute the effective key into 56 bits.
What happens when only a DES parity bit is flipped?
The effective key and ciphertext do not change.
Where does the P permutation act?
On the concatenated 32-bit S-box output.
What does Hamming distance measure?
The number of differing bit positions.
DES S1 receives 100101. Which table entry is selected?
A DES parity bit is flipped, but the other 56 key bits remain fixed. What should happen?
PC-1 discards the parity bits. If the implementation accepts the changed encoding, the effective key and ciphertext remain unchanged.
A student wants to replace a DES S-box with a linear map. What property is lost?
The nonlinearity that frustrates linear and differential approximations. A reversible Feistel structure alone is not sufficient for security.
At the output of E, why are there 48 bits rather than 32?
E duplicates selected boundary bits and arranges eight overlapping six-bit groups for subkey XOR and substitution.
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.
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 · S-box nonlinearity
Let x1=000000, x2=000001, x3=x1 XOR x2. Use the native S1 table to calculate S1(x1), S1(x2), S1(x3) and S1(x1) XOR S1(x2). Compare and interpret.
Engineering method — DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · All-one input
Use 64 ones for plaintext and key. Assess block validity, parity and weak-key considerations separately. Show IP, PC-1, first subkey, E, XOR, each S-box output, P and the first-round state.
Engineering method — DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · All-zero input
Repeat with 64 zeros for plaintext and key. Record all the intermediate values and first-round output.
Engineering method — DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
04 · Plaintext bit 57
Using the all-zero baseline, flip plaintext bit 57 (MSB-first). After IP identify changed S-box inputs, derive the minimum changed output bits from the design criterion where applicable, calculate the first-round state and count actual changed bits.
Engineering method — DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
05 · First key bit
With all-zero plaintext, flip the first key bit. Assess parity, calculate K1 and affected S-boxes, derive the first-round output, then follow the bit through PC-1, rotations and PC-2 across 16 rounds. Count changed subkeys.
Engineering method — DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
06 · Calculation
Calculation · Independent work
For DES S1 input 011101, derive row and column and output using the standard S1 table.
Calculation — DES maps 64-bit blocks through 16 Feistel rounds; PC-1 discards eight parity bits of the supplied 64-bit key. For S-box input 101011, row is outer bits 11=3 and column 0101=5; use the specified S-box lookup, not integer conversion of all six bits. 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 · EC07-01
For S1 input 011011, determine row and column.
Intermediate · Calculate or trace
Independent theoretical exercise · EC07-02
How many bits are removed by PC-1 from a 64-bit DES key?
Intermediate · Interpret the result
Independent theoretical exercise · EC07-03
For toy Feistel L=0x12,R=0x34,F=0xA0, compute L',R'.
Advanced · Analyze a condition
Independent theoretical exercise · EC07-04
Recover the preceding halves from L'=34,R'=B2 and F= A0.
Advanced · Diagnose or compare
Independent theoretical exercise · EC07-05
Two DES ciphertexts differ in 29 bits. Calculate avalanche percentage.
Challenging · Engineering verification
Independent theoretical exercise · EC07-06
Why does DES EDE use decrypt in the middle, and why should it not be selected for a new IoT device?
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.
S-box nonlinearity — complete its numbered steps and record the requested evidence.
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.
Using the native tables, calculate S1 on 000000, 000001 and their XOR. Draw the expansion, subkey XOR, S-box and P stages for the first round, then track the two assigned avalanche cases.
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 does flipping one input or key bit affect DES round states?
Change one bit only; compare against the same baseline. Separate parity-bit changes from effective key changes.
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.
Trial
Controlled configuration
Reference check
Student observation (editable)
S-box
x1=0, x2=1
S1(0)=14; S1(1)=0; compare XOR relation
Enter observation
Known answer
0123456789ABCDEF / 133457799BBCDFF1
85E813540F0AB405
Enter observation
Parity control
Flip a parity bit only
Ciphertext unchanged after parity removal
Enter observation
Analysis: Plot Hamming distance across rounds; do not infer production security from a single avalanche experiment. DES is obsolete.
Trace DES bit permutations, subkey generation and round functions; quantify nonlinearity and the avalanche effect.
Equipment and execution
Browser-based simulator, Python 3, notebook or local evidence folder. Use WSL Setup only if you need a Linux runtime.
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
S-box nonlinearity
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.
Set x1=000000, x2=000001, x3=x1 XOR x2. In S-box workstation calculate row from outer bits and column from inner four bits.
Compute S1(x1), S1(x2), S1(x3) and compare S1(x1) XOR S1(x2) with S1(x3).
Experimental inputs and checks
Worked lookup input
100101
Control outputs
S1 = 1000; S2 = 1010
Evidence to record
Six-bit inputs, row/column, four-bit outputs and conclusion.
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.
For the input 100101, select S1 and S2 in turn. Record row 3, column 2, and the four-bit outputs. Use the same table to perform the nonlinearity exercise.
02
DES initial permutation and key schedule
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 the worked input beginning CB followed by seven zero bytes; inspect the first eight IP bits and first 16 PC-1 bits for the same key.
Set all-one plaintext and all-one key. Separate valid block width from DES odd-parity requirements and weak-key concerns.
Step IP, split L0/R0, expand R0, XOR K1, inspect S-box inputs/outputs, P permutation and round output.
Experimental inputs and checks
Input and key for permutation exercise
CB00000000000000
All-one block and key
FFFFFFFFFFFFFFFF
Evidence to record
IP/PC-1 values, K1 and L1/R1 (not final ciphertext).
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
Plaintext avalanche assigned bit 57
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 all-zero plaintext and key; record parity issue and baseline round 1.
Set only plaintext bit 57 (one-based MSB convention; hex 0000000000000080). Hold key constant.
Compare expansion and individual six-bit S-box inputs after IP, count affected boxes; derive minimum changed output bits from the relevant DES S-box design criterion, then count actual changes after round 1.
Play remaining rounds and plot state Hamming distance against round number.
Experimental inputs and checks
Baseline block/key
0000000000000000
Changed plaintext
0000000000000080
Evidence to record
Affected S-box indices, theoretical lower bound and actual round distances.
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.
04
Key avalanche assigned first bit
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.
Hold plaintext zero; change key from all zero to 8000000000000000. Record parity and effective key change.
Compare first subkey, affected S-box inputs and first-round output with baseline. Track the changed key bit through PC-1, rotations and PC-2 across all 16 rounds.
Count differing subkeys; compare with a parity-bit-only flip as a control. Verify the standard known-answer pair in the simulator.
Round-key table and avalanche observations; explain why DES is obsolete.
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
The known-answer ciphertext is 85E813540F0AB405. The nonlinearity example differs. A parity-only key flip leaves the effective key and ciphertext unchanged.
Deliverables
Submit S-box calculations, first-round bit trace, parity checks, round-by-round avalanche results and effective-key explanation.
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
# EC07 · DES — S-boxes, Feistel rounds and avalanche
**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
Trace DES bit permutations, subkey generation and round functions; quantify nonlinearity and the avalanche effect.
**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. S-box nonlinearity — complete its numbered steps and record the requested evidence.
3. DES initial permutation and key schedule — complete its numbered steps and record the requested evidence.
4. Plaintext avalanche assigned bit 57 — complete its numbered steps and record the requested evidence.
5. Key avalanche assigned first bit — complete its numbered steps and record the requested evidence.
**Evidence:** The known-answer ciphertext is 85E813540F0AB405. The nonlinearity example differs. A parity-only key flip leaves the effective key and ciphertext unchanged.
**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. S-box nonlinearity — complete its numbered steps and record the requested evidence.
3. DES initial permutation and key schedule — complete its numbered steps and record the requested evidence.
4. Plaintext avalanche assigned bit 57 — complete its numbered steps and record the requested evidence.
5. Key avalanche assigned first bit — complete its numbered steps and record the requested evidence.
6. 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
## 3. Algorithm implementation
Read each definition and relate it to the equations and scientific SVGs in Concepts.
06Instructions · Markdown
### Implementation cell 1
Inspect the definitions, then execute to make them available for the investigation.
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC07 | Code cell 01 | DES — S-boxes, Feistel rounds and avalanche
# 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 07 — DES reference check. DES is obsolete; never use it for real secrets."""
# Set S1 for the next computation or reference condition.
S1=[[14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7], [0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8], [4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0], [15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13]]
# Define the reusable operation sbox1; keep its logic separate from the trial.
def sbox1(x):
if not 0<=x<64: raise ValueError('6-bit input required')
return S1[((x&32)>>4)|(x&1)][(x>>1)&15]
### Implementation cell 2
Inspect the definitions, then execute to make them available for the investigation.
09Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC07 | Code cell 02 | DES — S-boxes, Feistel rounds and avalanche
# 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 odd parity; keep its logic separate from the trial.
def odd_parity(key): return all(x.bit_count()%2==1 for x in key)
# Define the reusable operation des encrypt; keep its logic separate from the trial.
def des_encrypt(block,key):
if len(block)!=8 or len(key)!=8: raise ValueError('8-byte block/key required')
try:
from Crypto.Cipher import DES
return DES.new(key,DES.MODE_ECB).encrypt(block)
except ImportError:
# Three equal component keys make EDE equivalent to single DES.
from cryptography.hazmat.decrepit.ciphers.algorithms import TripleDES
from cryptography.hazmat.primitives.ciphers import Cipher,modes
c=Cipher(TripleDES(key*3),modes.ECB()).encryptor(); return c.update(block)+c.finalize()
## 4. Execute reference controls
The program checks selected algorithm outcomes. Record the observed output. These checks do not replace the independent calculation assignment.
11Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC07 | Code cell 03 | DES — S-boxes, Feistel rounds and avalanche
# 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 sbox1(0) ^ sbox1(1) != sbox1(1)
# Set b for the next computation or reference condition.
b = bytes.fromhex('0123456789ABCDEF')
# Set k for the next computation or reference condition.
k = bytes.fromhex('133457799BBCDFF1')
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert odd_parity(k) and des_encrypt(b, k).hex() == '85e813540f0ab405'
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert des_encrypt(b, k) == des_encrypt(b, bytes([k[0] ^ 1]) + k[1:])
print('S-box, DES known answer and parity-bit control passed')
## 5. Controlled variation
Predict the effect of the parameter changes below. Compare each actual result to your prediction.
13Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC07 | Code cell 04 | DES — S-boxes, Feistel rounds and avalanche
# 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 x in (0,1,0b100101,63):
print(f"{x:06b}",f"{sbox1(x):04b}")
## 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.)
15Instructions · 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. S-box nonlinearity — 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.
Run from the extracted toolkit root. The Python program checks selected outcomes; the full exercise procedure remains in the Experiment tab.
lab07.py
PYTHON · Source code
"""Essential 07 — DES reference check. DES is obsolete; never use it for real secrets."""S1=[[14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7], [0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8], [4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0], [15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13]]
defsbox1(x):
ifnot0<=x<64: raiseValueError('6-bit input required')
returnS1[((x&32)>>4)|(x&1)][(x>>1)&15]
defodd_parity(key): returnall(x.bit_count()%2==1forxinkey)
defdes_encrypt(block,key):
iflen(block)!=8orlen(key)!=8: raiseValueError('8-byte block/key required')
try:
fromCrypto.CipherimportDESreturnDES.new(key,DES.MODE_ECB).encrypt(block)
exceptImportError:
# Three equal component keys make EDE equivalent to single DES.fromcryptography.hazmat.decrepit.ciphers.algorithmsimportTripleDESfromcryptography.hazmat.primitives.ciphersimportCipher,modesc=Cipher(TripleDES(key*3),modes.ECB()).encryptor(); returnc.update(block)+c.finalize()
if__name__=='__main__':
assertsbox1(0)^sbox1(1)!=sbox1(1)
b=bytes.fromhex('0123456789ABCDEF'); k=bytes.fromhex('133457799BBCDFF1')
assertodd_parity(k) anddes_encrypt(b,k).hex()=='85e813540f0ab405'assertdes_encrypt(b,k)==des_encrypt(b,bytes([k[0]^1])+k[1:])
print('S-box, DES known answer and parity-bit control passed')
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.
Which six bits determine the S-box row and column?
Why is 64 bits not the DES effective key length?
Why does a one-round result not establish full avalanche behavior?
Submission: Submit S-box calculations, first-round bit trace, parity checks, round-by-round avalanche results and effective-key explanation.
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