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 · CR28 · COMPARISON
IoT Security and Privacy

Block ciphers · architecture and fair comparison

DES (64/56/16), TDEA (64/112 or 168 nominal/48 DES rounds), AES (128/128–256/10–14), Blowfish (64/32–448/16), Twofish (128/128–256/16).

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

Scope and objectives

Scope of the experiment

Block size affects birthday-bound concerns and key size affects brute-force cost, but neither alone describes security. DES/3DES and Blowfish use 64-bit blocks; AES and Twofish use 128-bit blocks.

The focus of this experiment is to compare historical and modern block-cipher structures under matched inputs. Students then interpret block size, effective key size and round behavior, and distinguish functional checks and performance metrics from security claims. 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

  • Compare historical and modern block-cipher structures under matched inputs.
  • Interpret block size, effective key size and round behavior.
  • Distinguish functional checks and performance metrics from security claims.
  • 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 compare historical and modern block-cipher structures under matched inputs, interpret block size, effective key size and round behavior, and distinguish functional checks and performance metrics from security claims.

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 distinguish functional checks and performance metrics from security claims. 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 Randomness · statistical appearance and predictability.

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

CR28 · Block ciphers · architecture and fair comparison

DES (64/56/16), TDEA (64/112 or 168 nominal/48 DES rounds), AES (128/128–256/10–14), Blowfish (64/32–448/16), Twofish (128/128–256/16). Compare structure and effective limitations; benchmark same backend and workload only. Historical algorithms are not recommendations.

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 (64/56/16), TDEA (64/112 or 168 nominal/48 DES rounds), AES (128/128–256/10–14), Blowfish (64/32–448/16), Twofish (128/128–256/16). Compare structure and effective limitations; benchmark same backend and workload only. Historical algorithms are not recommendations.

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.

Fair comparison of block ciphers

1 · Principles and purpose

Block size affects birthday-bound concerns and key size affects brute-force cost, but neither alone describes security. DES/3DES and Blowfish use 64-bit blocks; AES and Twofish use 128-bit blocks.

2 · Mathematical and algorithmic foundations

Throughput=payload bytes/elapsed seconds; report timing distribution after warm-up with equal payloads, comparable backends and measured environment. Distinguish algorithm properties from software acceleration.

3 · Worked teaching example

If two implementations process equal payloads in 2 and 4 ms, observed throughput ratio is 2:1 on that setup; do not claim universal superiority. Legacy designs should not be selected for new deployments.

Verified default trace · 5 intermediate states

Given parameters (teaching example):

{
  "blocks": "16",
  "repetitions": "5"
}
StageComputed values
1{ "step": "DES", "block_bits": 64, "key_bits": "56", "rounds": "16" }
2{ "step": "3DES", "block_bits": 64, "key_bits": "112/168 nominal", "rounds": "48" }
3{ "step": "AES", "block_bits": 128, "key_bits": "128/192/256", "rounds": "10/12/14" }
4{ "step": "Blowfish", "block_bits": 64, "key_bits": "32–448", "rounds": "16" }
5{ "step": "Twofish", "block_bits": 128, "key_bits": "128/192/256", "rounds": "16" }

Recorded result

{
  "workload_bytes": 256,
  "repetitions": 5,
  "note": "Structural comparison; use separate verified library benchmark cell."
}

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.

Block ciphers · architecture and fair comparison: independent state notebook12345DESblock_bits64key_bits56rounds16

Step 1 of 5 · DES

DES

step
DES
block_bits
64
key_bits
56
rounds
16

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.
CR28 calculated stateArchitecture and equal-workload comparisonDES64 bits56163DES64 bits112/168 nominal48AES128 bits128/192/25610/12/14Blowfish64 bits32–44816Twofish128 bits128/192/25616Workload 256 bytes · 5 repeats · timing measured in Python

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

{
  "workload_bytes": 256,
  "repetitions": 5,
  "note": "Structural comparison; use separate verified library benchmark cell."
}
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 (64/56/16), TDEA (64/112 or 168 nominal/48 DES rounds), AES (128/128–256/10–14), Blowfish (64/32–448/16), Twofish (128/128–256/16). Compare structure and effective limitations; benchmark same backend and workload only. Historical algorithms are not recommendations.

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

Create a comparison table for DES, 3DES, AES, Blowfish and Twofish listing block size, key size and architecture. Explain how to hold payload, implementation type and platform constant in a benchmark; distinguish measured timing from algorithmic security.

02 · Benchmark design

Benchmark design · Independent work

A DES run encrypts 800 bytes in 2 ms and AES run encrypts 1600 bytes in 3 ms. Compute throughputs and state two controls needed for a defensible comparison.

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

For the separate teaching-test configuration blocks: 32; repetitions: 5, predict workload_bytes 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 · CR28-02

A teaching trace for Block ciphers · architecture and fair comparison contains step: 3DES; block_bits: 64; key_bits: 112/168 nominal; rounds: 48. Explain the role of rounds (recorded value 48) 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 · CR28-03

The first and final trace records show block_bits = 64 and 128. 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 · CR28-04

Plan a comparison of blocks: 16; repetitions: 5 with blocks: 32; repetitions: 5. Record the dependent value workload_bytes, 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

Compare architecture and measured workload fairly

  1. Use the exact baseline input below and write a prediction.
  2. Set blocks=16 and repetitions=5. Record block sizes, key sizes and rounds from the browser structural comparison. In the notebook execute the available same-library benchmark.
  3. Save the trace and compare it with the reference output.

Experimental inputs

Experimental reference · json
{"blocks":"16","repetitions":"5"}
Verified baseline reference (check after predicting)
Experimental reference · json
{"workload_bytes":256,"repetitions":5,"note":"Structural comparison; use separate verified library benchmark cell."}

Browser reports 16×16=256 workload bytes by default. Timing is measured in Python, not simulated. Use 16-byte aligned workloads; report actual timing units.

Evidence to record

Algorithm, backend, payload bytes, repetitions, median latency, standard deviation, throughput and missing-data notes.

Run baseline →
02

Part D · Controlled investigation

  1. Change blocks to 64 and repetitions to 7; hold machine, library, mode, keys and warm-up constant. Do not invent measurements for unsupported algorithms.
  2. Record the conditions held fixed: backend, ECB primitive workload, fixed test keys, warm-up
  3. Collect Algorithm, backend, payload bytes, repetitions, median latency, standard deviation, throughput and missing-data notes. Compare the first differing intermediate step and explain the relationship.
TrialInput configurationPredictionObservedVerification
1{"blocks":"16","repetitions":"5"}
2{"blocks":"32","repetitions":"5"}

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 blocks 16 to 32 and repetitions 5 to 7. First verified alternate: {"blocks": "32"}.
  3. Keep backend, ECB primitive workload, fixed test keys, warm-up.
  4. Measure median latency and throughput for available same-library ciphers; unsupported algorithms explicitly marked.
  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 CR28
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: cryptography>=44,<48

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 CR28/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": "DES",
    "block_bits": 64,
    "key_bits": "56",
    "rounds": "16"
  },
  "result": {
    "workload_bytes": 256,
    "repetitions": 5,
    "note": "Structural comparison; use separate verified library benchmark cell."
  }
}

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
# ============================================================
# CR28 | Educational implementation and trace functions
# Copyright © 2026/2027 Dr. Mohammad Alja’afreh
# PSUT IoT Engineering Studio | Educational, synthetic inputs
# ============================================================
import time

import statistics

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):
    blocks=n(p['blocks']);reps=n(p['repetitions'])
    if not 1<=blocks<=256 or not 1<=reps<=20: raise ValueError('Blocks 1–256, repetitions 1–20')
    properties=[('DES',64,'56','16'),('3DES',64,'112/168 nominal','48'),('AES',128,'128/192/256','10/12/14'),('Blowfish',64,'32–448','16'),('Twofish',128,'128/192/256','16')];t=[row(name,block_bits=bb,key_bits=kb,rounds=r) for name,bb,kb,r in properties]
    return pack({'workload_bytes':blocks*16,'repetitions':reps,'note':'Structural comparison; use separate verified library benchmark cell.'},t)

def library_benchmark(blocks=16,repetitions=5):
    from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
    from cryptography.hazmat.decrepit.ciphers import algorithms as legacy
    data=bytes(blocks*16); rows=[]
    cases=[('DES via equal-key TDEA',legacy.TripleDES,bytes.fromhex('133457799BBCDFF1')*3),('3DES',legacy.TripleDES,bytes(range(24))),('AES-128',algorithms.AES,bytes(range(16))),('Blowfish',legacy.Blowfish,bytes(range(16)))]
    for name,alg,key in cases:
        try:
            cipher=Cipher(alg(key),modes.ECB()); enc=cipher.encryptor(); ct=enc.update(data)+enc.finalize(); dec=cipher.decryptor(); assert dec.update(ct)+dec.finalize()==data
            et=[];dt=[]
            for _ in range(repetitions):
                start=time.perf_counter_ns();e=cipher.encryptor();e.update(data);e.finalize();et.append((time.perf_counter_ns()-start)/1000)
                start=time.perf_counter_ns();d=cipher.decryptor();d.update(ct);d.finalize();dt.append((time.perf_counter_ns()-start)/1000)
            med=statistics.median(et);rows.append(dict(cipher=name,median_encrypt_us=med,median_decrypt_us=statistics.median(dt),mean_encrypt_us=statistics.mean(et),stdev_encrypt_us=statistics.pstdev(et),throughput_MBps=len(data)/med))
        except Exception as exc: rows.append(dict(cipher=name,status='unavailable: '+str(exc)))
    rows.append(dict(cipher='Twofish',status='not available in selected backend; not benchmarked'))
    return rows

PARAMS = {'blocks': '16', 'repetitions': '5'}
EXPECTED = {'workload_bytes': 256, 'repetitions': 5, 'note': 'Structural comparison; use separate verified library benchmark cell.'}
ALT = {'blocks': '32', 'repetitions': '5'}
ALT_EXPECTED = {'workload_bytes': 512, 'repetitions': 5, 'note': 'Structural comparison; use separate verified library benchmark cell.'}

if __name__ == "__main__":
    import argparse, json
    parser=argparse.ArgumentParser(description="CR28 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("CR28 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
{
  "workload_bytes": 256,
  "repetitions": 5,
  "note": "Structural comparison; use separate verified library benchmark cell."
}

05 · Interactive flashcards

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

Browse all explanations
Why cannot a Python toy vs accelerated library timing rank algorithms?

Implementation, runtime and hardware confound the result.

What is the dependent variable in this lab?

median latency and throughput for available same-library ciphers; unsupported algorithms explicitly marked

What must remain controlled?

backend, ECB primitive workload, fixed test keys, warm-up

What input settings define the baseline for this experiment?

blocks = 16; repetitions = 5

What is the first intermediate state in the baseline?

step: DES; block_bits: 64; key_bits: 56; rounds: 16

What check must you reproduce before varying the inputs?

Browser reports 16×16=256 workload bytes by default. Timing is measured in Python, not simulated. Use 16-byte aligned workloads; report actual timing units.

Which observations belong in your experimental record?

Algorithm, backend, payload bytes, repetitions, median latency, standard deviation, throughput and missing-data notes.

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

Benchmark 256 and 1024 bytes with 7 repetitions for available algorithms in the same backend. Report median and standard deviation and explain why equivalent-key TDEA is not native DES timing and why missing Twofish is not a zero latency. 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 · CR29 →

How to investigate · CR28

Independent variable: blocks 16 to 32 and repetitions 5 to 7.

Controlled variables: backend, ECB primitive workload, fixed test keys, warm-up.

Dependent evidence: median latency and throughput for available same-library ciphers; unsupported algorithms explicitly marked.

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

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