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 · CR08 · MULTIPLE ENCRYPTION
IoT Security and Privacy

Double encryption · reduced meet-in-the-middle

A known synthetic pair can be matched by storing \(E_{1}\)(P) for a tiny keyspace, then comparing \(D_{2}\)(C).

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

Scope and objectives

Scope of the experiment

Composition can introduce a matching intermediate state. A reduced synthetic permutation illustrates the memory-versus-computation tradeoff without searching real keys.

The focus of this experiment is to trace a bounded toy double-encryption table and intermediate matches. Students then compare candidate counts and primitive evaluations, and explain the time-memory trade-off without equating the toy to real DES. 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 a bounded toy double-encryption table and intermediate matches.
  • Compare candidate counts and primitive evaluations.
  • Explain the time-memory trade-off without equating the toy to real DES.
  • 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 a bounded toy double-encryption table and intermediate matches, compare candidate counts and primitive evaluations, and explain the time-memory trade-off without equating the toy to real DES.

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 explain the time-memory trade-off without equating the toy to real DES. 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 Binary fields · coefficients and XOR.

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

CR08 · Double encryption · reduced meet-in-the-middle

A known synthetic pair can be matched by storing \(E_{1}\)(P) for a tiny keyspace, then comparing \(D_{2}\)(C). Time and memory trade off. This is a deliberately non-DES 8-bit toy permutation E(x,k)=(x+17k) mod 256, for 16 possible keys. Collisions illustrate why another pair is needed (this toy may still collide).

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

A known synthetic pair can be matched by storing \(E_{1}\)(P) for a tiny keyspace, then comparing \(D_{2}\)(C). Time and memory trade off. This is a deliberately non-DES 8-bit toy permutation E(x,k)=(x+17k) mod 256, for 16 possible keys. Collisions illustrate why another pair is needed (this toy may still collide).

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.

Why key length does not simply add

1 · Principles and purpose

Composition can introduce a matching intermediate state. A reduced synthetic permutation illustrates the memory-versus-computation tradeoff without searching real keys.

2 · Mathematical and algorithmic foundations

For double encryption the mathematical condition is E_K1(P)=D_K2(C). The same intermediate value alone is not proof that a candidate pair is unique; more independent examples distinguish equivalent pairs.

3 · Worked teaching example

For an educational permutation, two distinct key combinations can yield the same overall mapping. Interpret candidate counts as properties of this toy system, not as measurements of real DES security.

Verified default trace · 32 intermediate states

Given parameters (teaching example):

{
  "plaintext": "23",
  "key1": "3",
  "key2": "9"
}
StageComputed values
1{ "step": "Forward", "key": 0, "intermediate": 23 }
2{ "step": "Forward", "key": 1, "intermediate": 40 }
3{ "step": "Forward", "key": 2, "intermediate": 57 }
4{ "step": "Forward", "key": 3, "intermediate": 74 }
5{ "step": "Forward", "key": 4, "intermediate": 91 }
6{ "step": "Forward", "key": 5, "intermediate": 108 }
7{ "step": "Forward", "key": 6, "intermediate": 125 }
8{ "step": "Forward", "key": 7, "intermediate": 142 }
9{ "step": "Forward", "key": 8, "intermediate": 159 }
10{ "step": "Forward", "key": 9, "intermediate": 176 }
11{ "step": "Forward", "key": 10, "intermediate": 193 }
12{ "step": "Forward", "key": 11, "intermediate": 210 }
13{ "step": "Forward", "key": 12, "intermediate": 227 }
14{ "step": "Forward", "key": 13, "intermediate": 244 }
15{ "step": "Forward", "key": 14, "intermediate": 5 }
16{ "step": "Forward", "key": 15, "intermediate": 22 }
17{ "step": "Backward", "key": 0, "intermediate": 227, "matches": [ 12 ] }
18{ "step": "Backward", "key": 1, "intermediate": 210, "matches": [ 11 ] }
19{ "step": "Backward", "key": 2, "intermediate": 193, "matches": [ 10 ] }
20{ "step": "Backward", "key": 3, "intermediate": 176, "matches": [ 9 ] }
21{ "step": "Backward", "key": 4, "intermediate": 159, "matches": [ 8 ] }
22{ "step": "Backward", "key": 5, "intermediate": 142, "matches": [ 7 ] }
23{ "step": "Backward", "key": 6, "intermediate": 125, "matches": [ 6 ] }
24{ "step": "Backward", "key": 7, "intermediate": 108, "matches": [ 5 ] }
25{ "step": "Backward", "key": 8, "intermediate": 91, "matches": [ 4 ] }
26{ "step": "Backward", "key": 9, "intermediate": 74, "matches": [ 3 ] }
27{ "step": "Backward", "key": 10, "intermediate": 57, "matches": [ 2 ] }
28{ "step": "Backward", "key": 11, "intermediate": 40, "matches": [ 1 ] }
29{ "step": "Backward", "key": 12, "intermediate": 23, "matches": [ 0 ] }
30{ "step": "Backward", "key": 13, "intermediate": 6, "matches": [] }
31{ "step": "Backward", "key": 14, "intermediate": 245, "matches": [] }
32{ "step": "Backward", "key": 15, "intermediate": 228, "matches": [] }

Recorded result

{
  "ciphertext": 227,
  "candidates": [
    [
      12,
      0
    ],
    [
      11,
      1
    ],
    [
      10,
      2
    ],
    [
      9,
      3
    ],
    [
      8,
      4
    ],
    [
      7,
      5
    ],
    [
      6,
      6
    ],
    [
      5,
      7
    ],
    [
      4,
      8
    ],
    [
      3,
      9
    ],
    [
      2,
      10
    ],
    [
      1,
      11
    ],
    [
      0,
      12
    ]
  ],
  "evaluations": 32
}

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.

Concept animation · independent state notebook

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.

Double encryption · reduced meet-in-the-middle: independent state notebook15101419232832Forwardkey0intermediate23

Step 1 of 8 · Forward

Forward

step
Forward
key
0
intermediate
23

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

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.
CR08 calculated stateTiny classroom permutation · forward and inverse tablesKnown synthetic P23Known synthetic C227Forward: Eₖ(P)40Backward: Dₖ(C)Not yet comparedCompareStoreCurrent toy key / matching candidates1 / []16 keys per direction · deliberately non-DES classroom model

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": 227,
  "candidates": [
    [
      12,
      0
    ],
    [
      11,
      1
    ],
    [
      10,
      2
    ],
    [
      9,
      3
    ],
    [
      8,
      4
    ],
    [
      7,
      5
    ],
    [
      6,
      6
    ],
    [
      5,
      7
    ],
    [
      4,
      8
    ],
    [
      3,
      9
    ],
    [
      2,
      10
    ],
    [
      1,
      11
    ],
    [
      0,
      12
    ]
  ],
  "evaluations": 32
}
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

A known synthetic pair can be matched by storing \(E_{1}\)(P) for a tiny keyspace, then comparing \(D_{2}\)(C). Time and memory trade off. This is a deliberately non-DES 8-bit toy permutation E(x,k)=(x+17k) mod 256, for 16 possible keys. Collisions illustrate why another pair is needed (this toy may still collide).

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 the small classroom permutation from the simulator, not real DES. Construct a table of intermediate encryptions for its first four key candidates and compare with the matching decryption values for its first four second-key candidates. Explain the time–memory tradeoff.

02 · Complexity reasoning

Complexity reasoning · Independent work

For a classroom double-encryption model with N=32 candidates per key, compare exhaustive pair trials with forward/backward intermediate table evaluations ignoring collisions and verification costs.

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 · CR08-01

For the separate teaching-test configuration plaintext: 23; key1: 3; key2: 4, predict ciphertext 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 · CR08-02

A teaching trace for Double encryption · reduced meet-in-the-middle contains step: Forward; key: 1; intermediate: 40. Explain the role of intermediate (recorded value 40) and identify the rule or input that determines it. Distinguish an intermediate state from the final result.

Intermediate · Compare two recorded states

Independent theoretical exercise · CR08-03

The first and final trace records show key = 0 and 15. Calculate the signed difference and explain whether it is an operation count, a state value or a measurement.

Challenging · Controlled algorithm verification

Independent theoretical exercise · CR08-04

Plan a comparison of plaintext: 23; key1: 3; key2: 9 with plaintext: 23; key1: 3; key2: 4. Record the dependent value evaluations, 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

Investigate a tiny synthetic table collision

  1. Use the exact baseline input below and write a prediction.
  2. Use the provided 8-bit toy permutation with P=23 and classroom keys 3 and 9. Inspect the supplied forward and backward tables and count matching pairs.
  3. Save the trace and compare it with the reference output.

Experimental inputs

Experimental reference · json
{"plaintext":"23","key1":"3","key2":"9"}
Verified baseline reference (check after predicting)
Experimental reference · json
{"ciphertext":227,"candidates":[[12,0],[11,1],[10,2],[9,3],[8,4],[7,5],[6,6],[5,7],[4,8],[3,9],[2,10],[1,11],[0,12]],"evaluations":32}

Both directions inspect 16 entries; 32 toy evaluations. This additive toy may have structurally equivalent key pairs.

Evidence to record

Candidate count, forward and backward table sizes, comparison count and whether another toy plaintext distinguishes the equivalences.

Run baseline →
02

Part D · Controlled investigation

  1. Compare the built-in alternate key2=4 with default, then P=101 using the same toy keys. Remain within the 16-value synthetic keyspace.
  2. Record the conditions held fixed: plaintext and key1, keyspace 0–15
  3. Collect Candidate count, forward and backward table sizes, comparison count and whether another toy plaintext distinguishes the equivalences. Compare the first differing intermediate step and explain the relationship.
TrialInput configurationPredictionObservedVerification
1{"plaintext":"23","key1":"3","key2":"9"}
2{"plaintext":"23","key1":"3","key2":"4"}

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 key2 from 9 to 4. First verified alternate: {"key2": "4"}.
  3. Keep plaintext and key1, keyspace 0–15.
  4. Measure intermediate values, candidate pairs and work count.
  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 CR08
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 CR08/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": "Forward",
    "key": 0,
    "intermediate": 23
  },
  "result": {
    "ciphertext": 227,
    "candidates": [
      [
        12,
        0
      ],
      [
        11,
        1
      ],
      [
        10,
        2
      ],
      [
        9,
        3
      ],
      [
        8,
        4
      ],
      [
        7,
        5
      ],
      [
        6,
        6
      ],
      [
        5,
        7
      ],
      [
        4,
        8
      ],
      [
        3,
        9
      ],
      [
        2,
        10
      ],
      [
        1,
        11
      ],
      [
        0,
        12
      ]
    ],
    "evaluations": 32
  }
}

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
# ============================================================
# CR08 | Educational implementation and trace functions
# Copyright © 2026/2027 Dr. Mohammad Alja’afreh
# PSUT IoT Engineering Studio | Educational, synthetic inputs
# ============================================================
def row(label,**values): return {'step':label,**values}

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

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

EXTRA = {}

def run(p):
    v=n(p['plaintext']);k1=n(p['key1']);k2=n(p['key2'])
    if not 0<=v<256 or not 0<=k1<16 or not 0<=k2<16: raise ValueError('Byte input, tiny keys 0–15')
    c=(v+17*k1+17*k2)%256; table={}; t=[]
    for k in range(16):
        mid=(v+17*k)%256; table.setdefault(mid,[]).append(k); t.append(row('Forward',key=k,intermediate=mid))
    pairs=[]
    for k in range(16):
        mid=(c-17*k)%256; matches=table.get(mid,[]); pairs.extend([[j,k] for j in matches]); t.append(row('Backward',key=k,intermediate=mid,matches=matches))
    return pack({'ciphertext':c,'candidates':pairs,'evaluations':32},t)

PARAMS = {'plaintext': '23', 'key1': '3', 'key2': '9'}
EXPECTED = {'ciphertext': 227, 'candidates': [[12, 0], [11, 1], [10, 2], [9, 3], [8, 4], [7, 5], [6, 6], [5, 7], [4, 8], [3, 9], [2, 10], [1, 11], [0, 12]], 'evaluations': 32}
ALT = {'plaintext': '23', 'key1': '3', 'key2': '4'}
ALT_EXPECTED = {'ciphertext': 142, 'candidates': [[7, 0], [6, 1], [5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7]], 'evaluations': 32}

if __name__ == "__main__":
    import argparse, json
    parser=argparse.ArgumentParser(description="CR08 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("CR08 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": 227,
  "candidates": [
    [
      12,
      0
    ],
    [
      11,
      1
    ],
    [
      10,
      2
    ],
    [
      9,
      3
    ],
    [
      8,
      4
    ],
    [
      7,
      5
    ],
    [
      6,
      6
    ],
    [
      5,
      7
    ],
    [
      4,
      8
    ],
    [
      3,
      9
    ],
    [
      2,
      10
    ],
    [
      1,
      11
    ],
    [
      0,
      12
    ]
  ],
  "evaluations": 32
}

05 · Interactive flashcards

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

Browse all explanations
Why can a match be insufficient to identify a key pair?

Several pairs can produce the same intermediate/output; verify more known pairs and note toy structural equivalence.

What is the dependent variable in this lab?

intermediate values, candidate pairs and work count

What must remain controlled?

plaintext and key1, keyspace 0–15

What input settings define the baseline for this experiment?

plaintext = 23; key1 = 3; key2 = 9

What is the first intermediate state in the baseline?

step: Forward; key: 0; intermediate: 23

What check must you reproduce before varying the inputs?

Both directions inspect 16 entries; 32 toy evaluations. This additive toy may have structurally equivalent key pairs.

Which observations belong in your experimental record?

Candidate count, forward and backward table sizes, comparison count and whether another toy plaintext distinguishes the equivalences.

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

Choose plaintext 101 and toy keys 2 and 6. Build the forward table, find candidate pairs, then use another plaintext and explain whether the toy permutation can distinguish the pairs. 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 · CR09 →

How to investigate · CR08

Independent variable: key2 from 9 to 4.

Controlled variables: plaintext and key1, keyspace 0–15.

Dependent evidence: intermediate values, candidate pairs and work count.

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 · CR08

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