Skip to main content
IoT
PSUT Engineering StudioPrincess Sumaya University for Technology
Student Edition
Cyber Defense StudioIoT Security and PrivacyExperimentsWorkspaces
Home / IoT Security and Privacy / Cryptography Engineering
IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
CRYPTOGRAPHY ENGINEERING · CR03 · DES
IoT Security and Privacy

DES · permutations and complete round trace

DES consumes 64-bit blocks; PC-1 removes eight parity bits from the supplied 64-bit key.

CR03 · Laboratory mentorAsk about the current operation and its intermediate values.
CR03 · Academic orientation

Scope and objectives

Scope of the experiment

DES uses 64-bit blocks, a supplied 64-bit key with eight parity bits, and sixteen Feistel rounds. IP and IP⁻¹ are public fixed permutations. Expansion duplicates boundary bits, allowing a 48-bit subkey to interact with a 32-bit half.

The focus of this experiment is to trace DES initial permutation, expansion, subkey mixing and S-box substitution. Students then calculate the first-round P permutation and Feistel state, and verify the complete historical cipher against a known-answer vector. 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 initial permutation, expansion, subkey mixing and S-box substitution.
  • Calculate the first-round P permutation and Feistel state.
  • Verify the complete historical cipher against a known-answer vector.
  • 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 initial permutation, expansion, subkey mixing and S-box substitution, calculate the first-round P permutation and Feistel state, and verify the complete historical cipher against a known-answer vector.

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 the complete historical cipher against a known-answer vector. Separate predicted values from observations.

Prerequisite knowledge and related learning

Use the curriculum sequence and the Concepts section for prerequisite terminology. After completion, continue to DES · S-box row and column.

Environment and experimental methodology

A standard browser and the experiment-specific Python implementation or Colab notebook. Where the practical uses a protocol model, model results are distinguished from actual local cryptographic operations.

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.

01 · Experiment overview

CR03 · DES · permutations and complete round trace

DES consumes 64-bit blocks; PC-1 removes eight parity bits from the supplied 64-bit key. IP rearranges bits; E expands 32 to 48 bits; XOR with K, eight S-boxes compress to 32 bits; P permutes; 16 Feistel rounds, swap and IP inverse finish encryption. DES is historical only.

Before starting

Environment: standard computer, browser and Python/WSL.

Simulation: Editable JavaScript calculation

Technical scope: Classroom computation on a standard computer. Educational cipher code is not a production security implementation.

Complete the six stages in order. Use the same experiment inputs when comparing manual, browser and Python results.

02 · Concepts and mathematical foundations

DES consumes 64-bit blocks; PC-1 removes eight parity bits from the supplied 64-bit key. IP rearranges bits; E expands 32 to 48 bits; XOR with K, eight S-boxes compress to 32 bits; P permutes; 16 Feistel rounds, swap and IP inverse finish encryption. DES is historical only.

Learning objectives

Calculate the named operation, inspect its intermediate values, reproduce the result in Python, and explain one controlled change. Prerequisites: binary/hexadecimal arithmetic; complete preceding labs in the same topic where applicable.

Before starting

Environment: standard computer, browser and Python/WSL.

Simulation: Editable JavaScript calculation

Technical scope: Classroom computation on a standard computer. Educational cipher code is not a production security implementation.

DES round architecture

1 · Principles and purpose

DES uses 64-bit blocks, a supplied 64-bit key with eight parity bits, and sixteen Feistel rounds. IP and IP⁻¹ are public fixed permutations. Expansion duplicates boundary bits, allowing a 48-bit subkey to interact with a 32-bit half.

2 · Mathematical and algorithmic foundations

IP(P)=L0||R0; B=E(R)⊕K (48 bits); split B into eight six-bit groups, apply S1…S8, concatenate 32 output bits and permute with P. R′=L⊕P(S(B)); L′=R. Output IP⁻¹(R16||L16).

\[\begin{aligned}\operatorname{IP}(P)&=L_0\parallel R_0\\B_i&=E(R_{i-1})\oplus K_i\\L_i&=R_{i-1},\quad R_i=L_{i-1}\oplus P_{\mathrm{DES}}(S(B_i))\\C&=\operatorname{IP}^{-1}(R_{16}\parallel L_{16})\end{aligned}\]

3 · Worked teaching example

For standard plaintext 0123456789ABCDEF, IP yields CC00CCFFF0AAF0AA. Under key 133457799BBCDFF1, E(R0)=7A15557A1555, K1=1B02EFFC7072, XOR=6117BA866527. S outputs 5C82B597 and P gives 234AA9BB; R1=EF4A6544. DES is historical only.

Verified default trace · 36 intermediate states

Given parameters (teaching example):

{
  "plaintext": "0123456789ABCDEF",
  "key": "133457799BBCDFF1"
}
StageComputed values
1{ "step": "IP", "state": "CC00CCFFF0AAF0AA" }
2{ "step": "Round 1", "K": "1B02EFFC7072", "expanded": "7A15557A1555", "mixed": "6117BA866527", "sbox": "5C82B597", "P": "234AA9BB", "state": "F0AAF0AAEF4A6544" }
3{ "step": "Round 2", "K": "79AED9DBC9E5", "expanded": "75EA5430AA09", "mixed": "0C448DEB63EC", "sbox": "F8D03AAE", "P": "3CAB87A3", "state": "EF4A6544CC017709" }
4{ "step": "Round 3", "K": "55FC8A42CF99", "expanded": "E58002BAE853", "mixed": "B07C88F827CA", "sbox": "2710E16F", "P": "4D166EB0", "state": "CC017709A25C0BF4" }
5{ "step": "Round 4", "K": "72ADD6DB351D", "expanded": "5042F8057FA9", "mixed": "22EF2EDE4AB4", "sbox": "21ED9F3A", "P": "BB23774C", "state": "A25C0BF477220045" }
6{ "step": "Round 5", "K": "7CEC07EB53A8", "expanded": "BAE90400020A", "mixed": "C60503EB51A2", "sbox": "50C831EB", "P": "2813ADC3", "state": "772200458A4FA637" }
7{ "step": "Round 6", "K": "63A53E507B2F", "expanded": "C5425FD0C1AF", "mixed": "A6E76180BA80", "sbox": "41F34C3D", "P": "9E45CD2C", "state": "8A4FA637E967CD69" }
8{ "step": "Round 7", "K": "EC84B7F618BC", "expanded": "F52B0FE5AB53", "mixed": "19AFB813B3EF", "sbox": "107540AD", "P": "8C051C27", "state": "E967CD69064ABA10" }
9{ "step": "Round 8", "K": "F78A3AC13BFB", "expanded": "00C2555F40A0", "mixed": "F7486F9E7B5B", "sbox": "6C187CAE", "P": "3C0E86F9", "state": "064ABA10D5694B90" }
10{ "step": "Round 9", "K": "E0DBEBEDE781", "expanded": "6AAB52A57CA1", "mixed": "8A70B9489B20", "sbox": "110C5777", "P": "22367C6A", "state": "D5694B90247CC67A" }
11{ "step": "Round 10", "K": "B1F347BA464F", "expanded": "1083F960C3F4", "mixed": "A170BEDA85BB", "sbox": "DA045275", "P": "62BC9C22", "state": "247CC67AB7D5D7B2" }
12{ "step": "Round 11", "K": "215FD3DED386", "expanded": "5AFEABEAFDA5", "mixed": "7BA178342E23", "sbox": "7305D101", "P": "E104FA02", "state": "B7D5D7B2C5783C78" }
13{ "step": "Round 12", "K": "7571F59467E9", "expanded": "60ABF01F83F1", "mixed": "15DA058BE418", "sbox": "7B8B2635", "P": "C268CFEA", "state": "C5783C7875BD1858" }
14{ "step": "Round 13", "K": "97C5D1FABA41", "expanded": "3ABDFA8F02F0", "mixed": "AD782B75B8B1", "sbox": "9AD18B4F", "P": "DDBB2922", "state": "75BD185818C3155A" }
15{ "step": "Round 14", "K": "5F43B7F2E73A", "expanded": "0F16068AAAF4", "mixed": "5055B1784DCE", "sbox": "64799AF1", "P": "B7318E55", "state": "18C3155AC28C960D" }
16{ "step": "Round 15", "K": "BF918D3D3F0A", "expanded": "E054594AC05B", "mixed": "5FC5D477FF51", "sbox": "B2E88D3C", "P": "5B81276E", "state": "C28C960D43423234" }
17{ "step": "Round 16", "K": "CB3D8B0E17F5", "expanded": "206A041A41A8", "mixed": "EB578F14565D", "sbox": "A7832429", "P": "C8C04F98", "state": "434232340A4CD995" }
18{ "step": "Final swap + IP inverse", "ciphertext": "85E813540F0AB405" }
19{ "step": "Decrypt IP", "state": "0A4CD99543423234" }
20{ "step": "Decrypt Round 1", "K": "CB3D8B0E17F5", "expanded": "206A041A41A8", "mixed": "EB578F14565D", "sbox": "A7832429", "P": "C8C04F98", "state": "43423234C28C960D" }
21{ "step": "Decrypt Round 2", "K": "BF918D3D3F0A", "expanded": "E054594AC05B", "mixed": "5FC5D477FF51", "sbox": "B2E88D3C", "P": "5B81276E", "state": "C28C960D18C3155A" }
22{ "step": "Decrypt Round 3", "K": "5F43B7F2E73A", "expanded": "0F16068AAAF4", "mixed": "5055B1784DCE", "sbox": "64799AF1", "P": "B7318E55", "state": "18C3155A75BD1858" }
23{ "step": "Decrypt Round 4", "K": "97C5D1FABA41", "expanded": "3ABDFA8F02F0", "mixed": "AD782B75B8B1", "sbox": "9AD18B4F", "P": "DDBB2922", "state": "75BD1858C5783C78" }
24{ "step": "Decrypt Round 5", "K": "7571F59467E9", "expanded": "60ABF01F83F1", "mixed": "15DA058BE418", "sbox": "7B8B2635", "P": "C268CFEA", "state": "C5783C78B7D5D7B2" }
25{ "step": "Decrypt Round 6", "K": "215FD3DED386", "expanded": "5AFEABEAFDA5", "mixed": "7BA178342E23", "sbox": "7305D101", "P": "E104FA02", "state": "B7D5D7B2247CC67A" }
26{ "step": "Decrypt Round 7", "K": "B1F347BA464F", "expanded": "1083F960C3F4", "mixed": "A170BEDA85BB", "sbox": "DA045275", "P": "62BC9C22", "state": "247CC67AD5694B90" }
27{ "step": "Decrypt Round 8", "K": "E0DBEBEDE781", "expanded": "6AAB52A57CA1", "mixed": "8A70B9489B20", "sbox": "110C5777", "P": "22367C6A", "state": "D5694B90064ABA10" }
28{ "step": "Decrypt Round 9", "K": "F78A3AC13BFB", "expanded": "00C2555F40A0", "mixed": "F7486F9E7B5B", "sbox": "6C187CAE", "P": "3C0E86F9", "state": "064ABA10E967CD69" }
29{ "step": "Decrypt Round 10", "K": "EC84B7F618BC", "expanded": "F52B0FE5AB53", "mixed": "19AFB813B3EF", "sbox": "107540AD", "P": "8C051C27", "state": "E967CD698A4FA637" }
30{ "step": "Decrypt Round 11", "K": "63A53E507B2F", "expanded": "C5425FD0C1AF", "mixed": "A6E76180BA80", "sbox": "41F34C3D", "P": "9E45CD2C", "state": "8A4FA63777220045" }
31{ "step": "Decrypt Round 12", "K": "7CEC07EB53A8", "expanded": "BAE90400020A", "mixed": "C60503EB51A2", "sbox": "50C831EB", "P": "2813ADC3", "state": "77220045A25C0BF4" }
32{ "step": "Decrypt Round 13", "K": "72ADD6DB351D", "expanded": "5042F8057FA9", "mixed": "22EF2EDE4AB4", "sbox": "21ED9F3A", "P": "BB23774C", "state": "A25C0BF4CC017709" }
33{ "step": "Decrypt Round 14", "K": "55FC8A42CF99", "expanded": "E58002BAE853", "mixed": "B07C88F827CA", "sbox": "2710E16F", "P": "4D166EB0", "state": "CC017709EF4A6544" }
34{ "step": "Decrypt Round 15", "K": "79AED9DBC9E5", "expanded": "75EA5430AA09", "mixed": "0C448DEB63EC", "sbox": "F8D03AAE", "P": "3CAB87A3", "state": "EF4A6544F0AAF0AA" }
35{ "step": "Decrypt Round 16", "K": "1B02EFFC7072", "expanded": "7A15557A1555", "mixed": "6117BA866527", "sbox": "5C82B597", "P": "234AA9BB", "state": "F0AAF0AACC00CCFF" }
36{ "step": "Recovered", "plaintext": "0123456789ABCDEF" }

Recorded result

{
  "ciphertext": "85E813540F0AB405",
  "recovered": "0123456789ABCDEF"
}

Captured earlier local execution. Randomized values and timing can differ; compare the invariant.

4 · Verification and experimental interpretation

Step through the following visualization and compare the named operation with the corresponding computed state. Check the mathematical invariant, inverse operation or protocol acceptance condition. Change one input at a time; distinguish a measured output from a prediction.

Mathematical representation and interpretation

DES substitution and round processing

A six-bit input selects one of four rows using its outer bits and one of sixteen columns using its inner bits. S_j is the selected DES substitution table; v is a four-bit result.

\[r=2b_1+b_6,\qquad c=8b_2+4b_3+2b_4+b_5,\qquad v=S_j[r,c]\]

Input 011011 selects row 1 and column 13; use the selected table to read the output.

Concept animation · DES round transformations

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.

DES round — expansion, key XOR, S-boxes and permutationInitial permutation (64 bits)CC00CCFFF0AAF0AAL0CC00CCFFR0F0AAF0AADES round — expansion, key XOR, S-boxes and permutationExpansion E(R)7A15557A1555Round key1B02EFFC7072XOR6117BA866527Eight S-boxes · 32 bits5C82B597P permutation234AA9BBNext L and RF0AAF0AAEF4A6544DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)75EA5430AA09Round key79AED9DBC9E5XOR0C448DEB63ECEight S-boxes · 32 bitsF8D03AAEP permutation3CAB87A3Next L and REF4A6544CC017709DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)E58002BAE853Round key55FC8A42CF99XORB07C88F827CAEight S-boxes · 32 bits2710E16FP permutation4D166EB0Next L and RCC017709A25C0BF4DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)5042F8057FA9Round key72ADD6DB351DXOR22EF2EDE4AB4Eight S-boxes · 32 bits21ED9F3AP permutationBB23774CNext L and RA25C0BF477220045DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)BAE90400020ARound key7CEC07EB53A8XORC60503EB51A2Eight S-boxes · 32 bits50C831EBP permutation2813ADC3Next L and R772200458A4FA637DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)C5425FD0C1AFRound key63A53E507B2FXORA6E76180BA80Eight S-boxes · 32 bits41F34C3DP permutation9E45CD2CNext L and R8A4FA637E967CD69DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)F52B0FE5AB53Round keyEC84B7F618BCXOR19AFB813B3EFEight S-boxes · 32 bits107540ADP permutation8C051C27Next L and RE967CD69064ABA10DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)00C2555F40A0Round keyF78A3AC13BFBXORF7486F9E7B5BEight S-boxes · 32 bits6C187CAEP permutation3C0E86F9Next L and R064ABA10D5694B90DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)6AAB52A57CA1Round keyE0DBEBEDE781XOR8A70B9489B20Eight S-boxes · 32 bits110C5777P permutation22367C6ANext L and RD5694B90247CC67ADES round — expansion, key XOR, S-boxes and permutationExpansion E(R)1083F960C3F4Round keyB1F347BA464FXORA170BEDA85BBEight S-boxes · 32 bitsDA045275P permutation62BC9C22Next L and R247CC67AB7D5D7B2DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)5AFEABEAFDA5Round key215FD3DED386XOR7BA178342E23Eight S-boxes · 32 bits7305D101P permutationE104FA02Next L and RB7D5D7B2C5783C78DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)60ABF01F83F1Round key7571F59467E9XOR15DA058BE418Eight S-boxes · 32 bits7B8B2635P permutationC268CFEANext L and RC5783C7875BD1858DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)3ABDFA8F02F0Round key97C5D1FABA41XORAD782B75B8B1Eight S-boxes · 32 bits9AD18B4FP permutationDDBB2922Next L and R75BD185818C3155ADES round — expansion, key XOR, S-boxes and permutationExpansion E(R)0F16068AAAF4Round key5F43B7F2E73AXOR5055B1784DCEEight S-boxes · 32 bits64799AF1P permutationB7318E55Next L and R18C3155AC28C960DDES round — expansion, key XOR, S-boxes and permutationExpansion E(R)E054594AC05BRound keyBF918D3D3F0AXOR5FC5D477FF51Eight S-boxes · 32 bitsB2E88D3CP permutation5B81276ENext L and RC28C960D43423234DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)206A041A41A8Round keyCB3D8B0E17F5XOREB578F14565DEight S-boxes · 32 bitsA7832429P permutationC8C04F98Next L and R434232340A4CD995DES round — expansion, key XOR, S-boxes and permutationInitial permutation (64 bits)0A4CD99543423234L00A4CD995R043423234DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)206A041A41A8Round keyCB3D8B0E17F5XOREB578F14565DEight S-boxes · 32 bitsA7832429P permutationC8C04F98Next L and R43423234C28C960DDES round — expansion, key XOR, S-boxes and permutationExpansion E(R)E054594AC05BRound keyBF918D3D3F0AXOR5FC5D477FF51Eight S-boxes · 32 bitsB2E88D3CP permutation5B81276ENext L and RC28C960D18C3155ADES round — expansion, key XOR, S-boxes and permutationExpansion E(R)0F16068AAAF4Round key5F43B7F2E73AXOR5055B1784DCEEight S-boxes · 32 bits64799AF1P permutationB7318E55Next L and R18C3155A75BD1858DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)3ABDFA8F02F0Round key97C5D1FABA41XORAD782B75B8B1Eight S-boxes · 32 bits9AD18B4FP permutationDDBB2922Next L and R75BD1858C5783C78DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)60ABF01F83F1Round key7571F59467E9XOR15DA058BE418Eight S-boxes · 32 bits7B8B2635P permutationC268CFEANext L and RC5783C78B7D5D7B2DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)5AFEABEAFDA5Round key215FD3DED386XOR7BA178342E23Eight S-boxes · 32 bits7305D101P permutationE104FA02Next L and RB7D5D7B2247CC67ADES round — expansion, key XOR, S-boxes and permutationExpansion E(R)1083F960C3F4Round keyB1F347BA464FXORA170BEDA85BBEight S-boxes · 32 bitsDA045275P permutation62BC9C22Next L and R247CC67AD5694B90DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)6AAB52A57CA1Round keyE0DBEBEDE781XOR8A70B9489B20Eight S-boxes · 32 bits110C5777P permutation22367C6ANext L and RD5694B90064ABA10DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)00C2555F40A0Round keyF78A3AC13BFBXORF7486F9E7B5BEight S-boxes · 32 bits6C187CAEP permutation3C0E86F9Next L and R064ABA10E967CD69DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)F52B0FE5AB53Round keyEC84B7F618BCXOR19AFB813B3EFEight S-boxes · 32 bits107540ADP permutation8C051C27Next L and RE967CD698A4FA637DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)C5425FD0C1AFRound key63A53E507B2FXORA6E76180BA80Eight S-boxes · 32 bits41F34C3DP permutation9E45CD2CNext L and R8A4FA63777220045DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)BAE90400020ARound key7CEC07EB53A8XORC60503EB51A2Eight S-boxes · 32 bits50C831EBP permutation2813ADC3Next L and R77220045A25C0BF4DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)5042F8057FA9Round key72ADD6DB351DXOR22EF2EDE4AB4Eight S-boxes · 32 bits21ED9F3AP permutationBB23774CNext L and RA25C0BF4CC017709DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)E58002BAE853Round key55FC8A42CF99XORB07C88F827CAEight S-boxes · 32 bits2710E16FP permutation4D166EB0Next L and RCC017709EF4A6544DES round — expansion, key XOR, S-boxes and permutationExpansion E(R)75EA5430AA09Round key79AED9DBC9E5XOR0C448DEB63ECEight S-boxes · 32 bitsF8D03AAEP permutation3CAB87A3Next L and REF4A6544F0AAF0AADES round — expansion, key XOR, S-boxes and permutationExpansion E(R)7A15557A1555Round key1B02EFFC7072XOR6117BA866527Eight S-boxes · 32 bits5C82B597P permutation234AA9BBNext L and RF0AAF0AACC00CCFF

Step 1 of 34 · IP

Teaching example only; inspect live calculations or real practical evidence separately.

IP

state
CC00CCFFF0AAF0AA
Shared research workbenches · network designer & advanced studies
Concurrent-device simulation & Monte Carlo research
Distributed digital twin · topology, protocol & battery research

03 · Interactive simulation

Baseline diagram loaded. Interactive engine initializing…

Verified baseline reference — use the live workstation below to explore steps and compare inputs.
CR03 calculated stateDES · expansion, substitution and Feistel mixingPrevious RF0AAF0AAExpansion E7A15557A1555Round key K1B02EFFC7072XOR (48 bits)6117BA8665278 S-box outputs5C82B597P permutation234AA9BBXOR with old LEF4A6544Next L = old RF0AAF0AANew L || RF0AAF0AAEF4A6544Expansion and S-boxes change width; P only permutes bits.

Edit the fields and choose Recompute. Use step controls to inspect real calculated states. Hexadecimal byte fields are written without 0x; numeric fields accept decimal or 0x notation.

Calculated result

{
  "ciphertext": "85E813540F0AB405",
  "recovered": "0123456789ABCDEF"
}
All intermediate trace rows

Guided simulation activity

Use the baseline inputs shown above. Predict a result, advance one operation at a time, inspect the intermediate state, then change only the parameter specified in the Experiments view. Export the trace and compare it with your manual derivation.

Continue to practical experiments →

04 · Experiments and engineering investigations

Analytical preparation — before Python

DES consumes 64-bit blocks; PC-1 removes eight parity bits from the supplied 64-bit key. IP rearranges bits; E expands 32 to 48 bits; XOR with K, eight S-boxes compress to 32 bits; P permutes; 16 Feistel rounds, swap and IP inverse finish encryption. DES is historical only.

Predict the baseline result before revealing the calculated state. A controlled comparison changes the named input while keeping the other conditions fixed. Record an observed value separately from an expected value.

Part A · Independent theoretical exercises

Complete each question before running the simulator or Python. Show calculations or protocol traces. The teaching example is a method, not a substitute for the assigned values.

01 · Application and derivation

Application and derivation · Independent work

Use plaintext 0123456789ABCDEF and key 133457799BBCDFF1. Use the supplied DES permutation tables and trace the first round: IP, L0, R0, expansion, key XOR, S1 input/output and P. Explain the role of the final swap.

02 · Reverse reasoning

Reverse reasoning · Independent work

In a DES round, L'=0x000000AA, R'=0x000000F0, F(L',K)=0x0000000F. Recover L,R and explain why this does not invert an S-box.

Required evidence: state the expected invariant or acceptance condition; record hand-derived results, compare with the simulator or Python trace, and explain the first discrepancy. Do not report a predicted value as a measurement.

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.

Intermediate · Alternate configuration

Independent theoretical exercise · CR03-01

For the separate teaching-test configuration plaintext: 1123456789ABCDEF; key: 133457799BBCDFF1, predict recovered using the relevant operation or decision rule. Show intermediate work and state whether this is a deterministic result.

Intermediate · Interpret a computation state

Independent theoretical exercise · CR03-02

A teaching trace for DES · permutations and complete round trace contains step: Round 1; K: 1B02EFFC7072; expanded: 7A15557A1555; mixed: 6117BA866527; sbox: 5C82B597. Explain the role of state (recorded value F0AAF0AAEF4A6544) and identify the rule or input that determines it. Distinguish an intermediate state from the final result.

Advanced · Identify a terminal invariant

Independent theoretical exercise · CR03-03

The first teaching trace contains step: IP; state: CC00CCFFF0AAF0AA; the last contains step: Recovered; plaintext: 0123456789ABCDEF. Identify one distinction between the initial operation and completion. What additional condition must hold to use the result?

Challenging · Controlled algorithm verification

Independent theoretical exercise · CR03-04

Plan a comparison of plaintext: 0123456789ABCDEF; key: 133457799BBCDFF1 with plaintext: 1123456789ABCDEF; key: 133457799BBCDFF1. Record the dependent value recovered, identify the changed factor(s), and describe the verification and failure criterion without claiming a real security measurement.

Part B · Guided simulation and practical procedure

Before starting — tools and setup

Standard computer; extract the WSL toolkit into a new directory. For the browser activity, use the integrated workstation. Editable browser calculation

Install Python dependencies only if required by the selected toolkit README. Use its requirements file and virtual environment instructions.

Open complete, verified WSL commands in Part C ↓

01

Reconstruct a DES round

  1. Use the exact baseline input below and write a prediction.
  2. Use 0123456789ABCDEF and 133457799BBCDFF1. Record IP, then round 1 E, K, E XOR K, all eight S-box outputs, P and new halves. Compare round 16 and final permutation.
  3. Save the trace and compare it with the reference output.

Experimental inputs

Experimental reference · json
{"plaintext":"0123456789ABCDEF","key":"133457799BBCDFF1"}
Verified baseline reference (check after predicting)
Experimental reference · json
{"ciphertext":"85E813540F0AB405","recovered":"0123456789ABCDEF"}

IP=CC00CCFFF0AAF0AA; first subkey=1B02EFFC7072; default ciphertext=85E813540F0AB405.

Evidence to record

IP, round 1 and 16 internal fields, final ciphertext and recovered input.

Run baseline →
02

Part D · Controlled investigation

  1. Change plaintext to 0123456789ABCDEE; keep the supplied key fixed. Compare round 1 and final ciphertext. Restore default and inspect decryption trace.
  2. Record the conditions held fixed: 64-bit key
  3. Collect IP, round 1 and 16 internal fields, final ciphertext and recovered input. Compare the first differing intermediate step and explain the relationship.
TrialInput configurationPredictionObservedVerification
1{"plaintext":"0123456789ABCDEF","key":"133457799BBCDFF1"}
2{"plaintext":"1123456789ABCDEF","key":"133457799BBCDFF1"}

Use the table as a recording template; enter your own measured values in the field below or reproduce it in your report.

Return to simulation →
03

Part E/F · Independent Python verification and deliverables

  1. Download the notebook or toolkit and run the default example.
  2. Reproduce at least one changed input; compare the intermediate values with the browser where supported.
  3. Complete the independent assessment below without copying the worked baseline. Explain discrepancies and distinguish mathematical results from security claims.
Additional investigation instructions

A controlled comparison changes one independent input while holding other inputs fixed, then measures its effect on the dependent output. A baseline is the unmodified run. Evidence-based reasoning means citing the actual observed values, not merely asserting that an algorithm is secure.

  1. Run the supplied default values and record the first and final state.
  2. Predict the effect before changing anything. Change one hexadecimal plaintext digit. First verified alternate: {"plaintext": "1123456789ABCDEF"}.
  3. Keep 64-bit key.
  4. Measure IP, E, XOR, S, P, L||R and ciphertext; reverse-key recovery.
  5. Restore the baseline and repeat with another valid input. Locate the first differing calculation.
  6. Submit a comparison table, a trace JSON or screenshots of relevant steps, and a short conclusion with an explicit limitation.
TrialChanged inputFixed conditionsPredictionMeasured valueReason / limitation
BaselineNoneDefaultStudent predictionRecord traceExplain
Trial 1Specified changeUnchanged inputsStudent predictionRecord traceExplain

Part C · Python, Google Colab and WSL

The standalone implementation uses the same synthetic baseline and calculations as the browser. In Colab, download the notebook, open Colab and upload it using File → Upload notebook. Run all cells in order.

WSL / Linux execution workflow

Use Ubuntu or Kali WSL, not PowerShell. Download the toolkit above to your computer. If Python, venv or unzip is missing, install these prerequisites once (requires administrator permission and network access).

Optional prerequisites · bash
sudo apt update
sudo apt install -y python3 python3-venv unzip

In WSL, enter the actual downloaded ZIP path when prompted (for example, a file under /mnt/c/Users/…/Downloads). Extract to a new, dedicated directory. If this directory already exists from a previous extraction, use the existing verified toolkit or choose a clean directory rather than overwriting it.

Step 1 · Extract · bash
read -r -p "Full path to PSUT_V22_9_9_Cryptography_WSL.zip: " ZIP
DEST="$HOME/psut-crypto-v22.9.9"
if [ -f "$ZIP" ] && [ ! -e "$DEST" ]; then
    mkdir "$DEST" && unzip "$ZIP" -d "$DEST"
else
    echo "Check ZIP path and use a fresh destination."
fi

Create the isolated environment in the extracted toolkit root, activate it, then enter this experiment’s actual folder. Install only its declared dependencies. A comment-only requirements file requires no third-party packages.

Step 2 · Activate and install · bash
cd ~/psut-crypto-v22.9.9
python3 -m venv .venv
source .venv/bin/activate
cd CR03
ls
python -m pip install -r requirements.txt

Execute the default run and save the genuine program output. Then run the supplied regression test and the baseline fixture through the explicit input interface.

Step 3 · Run and verify · bash
python lab.py | tee my-results.json
python test_lab.py
python lab.py --params example-input.json
python -m json.tool my-results.json

To change inputs, copy example-input.json, edit the copy in a text editor and run the command below. The original fixture is preserved.

Step 4 · Change an input · bash
cp example-input.json my-input.json
# Edit my-input.json with your preferred editor.
python lab.py --params my-input.json

These scripts terminate normally. Use Ctrl+C to stop a long-running calculation if needed. When finished, leave the isolated virtual environment; no global service cleanup is required for these local examples.

Step 5 · Finish · bash
deactivate

Declared dependencies: # Standard library only for core experiment

Expected terminal output — captured local execution

This excerpt contains the actual first trace step and final result from python lab.py, followed by the actual regression test output. Full stdout is in CR03/verified-output.txt inside the toolkit. Timing, random signatures, keys, certificate fields and implementation-dependent sizes can vary; compare the invariant and record your own observations.

Verified execution excerpt · text
{
  "first_step": {
    "step": "IP",
    "state": "CC00CCFFF0AAF0AA"
  },
  "result": {
    "ciphertext": "85E813540F0AB405",
    "recovered": "0123456789ABCDEF"
  }
}

Test script output:
PASS

Check the output JSON and the test exit status. An assertion error means the expected invariant was not met. If Python reports a missing module, activate the environment and install the experiment’s requirements file; if a file is missing, check pwd and ls.

Inspect the documented Python implementation
Documented Python implementation · python
# ============================================================
# CR03 | Educational implementation and trace functions
# Copyright © 2026/2027 Dr. Mohammad Alja’afreh
# PSUT IoT Engineering Studio | Educational, synthetic inputs
# ============================================================
def hx(n,w=2): return f'{n:0{w}X}'

# Wrap shifted bits around the fixed word width instead of discarding them.
def rot(x,k,w): return ((x<<k)|(x>>(w-k)))&((1<<w)-1)

def row(label,**values): return {'step':label,**values}

# Standard DES lookup table: IP
IP=[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]

# Standard DES lookup table: E
E=[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]

# Standard DES lookup table: P
P=[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]

# Standard DES lookup table: PC1
PC1=[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]

# Standard DES lookup table: PC2
PC2=[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]

# Standard DES lookup table: S
S=[[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], [15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9], [10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12], [7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14], [2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3], [12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13], [4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12], [13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11]]

# Select bits by the standard one-based DES position table.
def perm(x,width,table):
    v=0
    for i in table: v=(v<<1)|((x>>(width-i))&1)
    return v

# Use outer input bits for row and middle four bits for column.
def dsbox(n,b):
    r=((b>>5)<<1)|(b&1); c=(b>>1)&15
    return r,c,S[n][16*r+c]

# Discard parity with PC-1, rotate C/D, select 48-bit subkeys with PC-2.
def deskeys(key):
    cd=perm(key,64,PC1); c,d=cd>>28,cd&0xfffffff; out=[]
    for i,n in enumerate([1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1]):
        c,d=rot(c,n,28),rot(d,n,28); k=perm((c<<28)|d,56,PC2)
        out.append((c,d,k,n))
    return out

# Apply IP, the 16 Feistel rounds and inverse IP; reverse subkeys for decryption.
def des(p,key,dec=False):
    v=perm(p,64,IP); l,r=v>>32,v&0xffffffff; trace=[row('IP',state=hx(v,16))]; keys=deskeys(key)[::(-1 if dec else 1)]
    for i,(c,d,k,n) in enumerate(keys,1):
        e=perm(r,32,E); x=e^k; sub=0
        for j in range(8): sub=(sub<<4)|dsbox(j,(x>>(42-6*j))&63)[2]
        f=perm(sub,32,P); l,r=r,l^f
        trace.append(row(f'Round {i}',K=hx(k,12),expanded=hx(e,12),mixed=hx(x,12),sbox=hx(sub,8),P=hx(f,8),state=hx((l<<32)|r,16)))
    result=perm((r<<32)|l,64,[IP.index(i)+1 for i in range(1,65)])
    return result,trace

def n(s): return int(s,0)

def b(s): return bytes.fromhex(s)

def exact(s,size):
    v=b(s)
    if len(v)!=size: raise ValueError(f'Expected {size} bytes')
    return v

def pack(result,trace): return {'result':result,'trace':trace}

EXTRA = {}

def run(p):
    v=int.from_bytes(exact(p['plaintext'],8),'big'); k=int.from_bytes(exact(p['key'],8),'big'); c,t=des(v,k); d,u=des(c,k,True)
    return pack({'ciphertext':hx(c,16),'recovered':hx(d,16)},t+[row('Final swap + IP inverse',ciphertext=hx(c,16))]+[dict(x,step='Decrypt '+x['step']) for x in u]+[row('Recovered',plaintext=hx(d,16))])

PARAMS = {'plaintext': '0123456789ABCDEF', 'key': '133457799BBCDFF1'}
EXPECTED = {'ciphertext': '85E813540F0AB405', 'recovered': '0123456789ABCDEF'}
ALT = {'plaintext': '1123456789ABCDEF', 'key': '133457799BBCDFF1'}
ALT_EXPECTED = {'ciphertext': 'B5A57C5026640ABA', 'recovered': '1123456789ABCDEF'}

if __name__ == "__main__":
    import argparse, json
    parser=argparse.ArgumentParser(description="CR03 synthetic cryptography exercise")
    parser.add_argument("--params", help="JSON parameter override file")
    parser.add_argument("--test", action="store_true")
    args=parser.parse_args()
    if args.test:
        assert run(PARAMS)["result"] == EXPECTED
        assert run(ALT)["result"] == ALT_EXPECTED
        print("CR03 default and changed input passed")
    else:
        parameters=PARAMS if not args.params else {**PARAMS,**json.load(open(args.params))}
        print(json.dumps(run(parameters),indent=2))
Verified default result
Reference result · json
{
  "ciphertext": "85E813540F0AB405",
  "recovered": "0123456789ABCDEF"
}

05 · Interactive flashcards

Recall before revealing. Review and mastery ratings remain on this device.

Browse all explanations
Why do 64 supplied key bits not imply a 64-bit effective key?

Eight parity bits are discarded by PC-1.

What is the dependent variable in this lab?

IP, E, XOR, S, P, L||R and ciphertext; reverse-key recovery

What must remain controlled?

64-bit key

What input settings define the baseline for this experiment?

plaintext = 0123456789ABCDEF; key = 133457799BBCDFF1

What is the first intermediate state in the baseline?

step: IP; state: CC00CCFFF0AAF0AA

What check must you reproduce before varying the inputs?

IP=CC00CCFFF0AAF0AA; first subkey=1B02EFFC7072; default ciphertext=85E813540F0AB405.

Which observations belong in your experimental record?

IP, round 1 and 16 internal fields, final ciphertext and recovered input.

06 · Knowledge assessment

Formative check

Which experimental design best isolates the effect of the specified input?

Responses are for instructor review; no grading key is provided here.

Independent assessment

Use plaintext 02468ACEECA86420 and key 0F1571C947D9E859. Calculate IP, round-1 E(R) and XOR independently; compare the final result and recovered plaintext. Use an additional valid trial, a calculation or a counterexample to support your reasoning. Submit evidence from both runtimes and explain what the experiment does not establish.

Part F · Engineering evidence record

Record the baseline, prediction, changed input, observed result, discrepancy and limitation. Save locally or export with the displayed result. This is not an official submission.

All Cryptography Engineering labsNext laboratory · CR04 →

How to investigate · CR03

Independent variable: one hexadecimal plaintext digit.

Controlled variables: 64-bit key.

Dependent evidence: IP, E, XOR, S, P, L||R and ciphertext; reverse-key recovery.

Weak conclusion: “The output changed.” Stronger reasoning: cite both measured values, name the transformation responsible, and state why the observation does or does not generalize.

Dr. Mohammad · CR03

Offline, deterministic, current-step tutoring. No external AI service or real hardware access.