Complete K01 and K08, install the original Kali toolkit, then copy the updated advanced_security.py file into ~/kali-labs. Run as your normal Kali user. No public broker or external target is required.
Explain encryption and authentication cost.
Use warm-up, fixed trial count and consistent payload sizes.
Analyze median and P95 without claiming MCU performance.
K13 · Academic orientation
Scope and objectives
Scope of the experiment
Measure authenticated encryption round-trip latency at fixed payload size.
The focus of this experiment is to define matched payload, trial count and timing metrics for AEAD. Students then compare valid encryption/decryption measurements under fixed inputs, and report host-specific results and authentication outcomes. 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
Define matched payload, trial count and timing metrics for AEAD.
Compare valid encryption/decryption measurements under fixed inputs.
Report host-specific results and authentication outcomes.
Identify the configured inputs (Payload bytes; Repetitions) and record the corresponding observed outputs with units where applicable.
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 define matched payload, trial count and timing metrics for AEAD, compare valid encryption/decryption measurements under fixed inputs, and report host-specific results and authentication outcomes.
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 report host-specific results and authentication outcomes. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to K14 · Defensive sensor anomaly detection.
The specified isolated laboratory environment, with local synthetic inputs and authorized services only. Use the experiment-specific setup and verification instructions.
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.
Understand the experiment
AES-GCM benchmarking · Ordered timing samples
Illustrative timing fixture from the worksheet; not physical device measurements
Latency benchmarking depends on payload, host, warm-up and sampling. Median and P95 characterize different parts of a distribution.
Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.
Scientific theory · Measuring cryptographic performance
Latency depends on payload length, implementation, runtime, CPU and warm-up. Measure multiple independent operations under controlled conditions. Median describes central tendency while a percentile such as P95 describes the upper tail under a stated estimator. Authentication rejection should be verified separately from performance.
Worked example and engineering interpretation
For durations 1,2,3,4,10 ms, the median is 3 ms; nearest-rank P95 is 10 ms. Report the payload size, platform and timing method. Do not extrapolate browser or host timing to embedded hardware without measurements.
Engineering principles · additional worked teaching example
Benchmark latency is elapsed time for a defined operation. Median is middle sorted observation; P95 requires stated quantile convention. For times 4,5,5,6,20 µs, median5; the outlier matters to tail latency. Repeat paired conditions and report environment.
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.
How to investigate K13 · Authenticated encryption benchmarking
Measure host AES-GCM timings across payload sizes and report median and P95.
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: Measure host AES-GCM timings across payload sizes and report median and P95.
Set payload 128 B and 12 repetitions. Record individual durations, median and p95; the mean is measured in this browser, not a constant.
Run 1024 B with 12 repetitions. Compare latency distributions, not just means.
Use 30 repetitions at 128 B. Inspect host timing variability and keep other browser tasks stable.
Run the local advanced security benchmark; record platform and cryptographic library versions. Never compare host and embedded timing as if they share hardware.
Reference check:
Model boundary:
Independent task and submission evidence
2. Run 1024 B with 12 repetitions. Compare latency distributions, not just means. 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.
Worked engineering reasoning and boundary conditions
Engineering reference configuration: Payload bytes = 128; Repetitions = 12. In the classroom model, Round trips verified = 12; Mean round trip = 0.161618 ms; P95 round trip = 0.365189 ms; Ciphertext + tag = 144 B. Samples were actually timed with performance.now; repeat runs may differ. Actual browser Web Crypto AES-GCM timing; not Ascon, device power or physical ESP32 measurements.
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 · progressive data plot
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 7 · Observation 1
Observation 1
Elapsed ms
0.365189
Observation 3
Elapsed ms
0.260562
Observation 5
Elapsed ms
0.205833
Observation 7
Elapsed ms
0.121301
Observation 8
Elapsed ms
0.075989
Observation 10
Elapsed ms
0.088394
Observation 12
Elapsed ms
0.115796
Teaching example only; inspect live calculations or real practical evidence separately.
Recall the concept before revealing its explanation.
They may have different costs; each needs an independent timing distribution and correctness check.
K13 · 05 / 08Why record payload size and repeated trials?Reveal explanation
Engineering reasoning
Timing depends on input size and host state; repetitions and configuration records enable meaningful comparison.
K13 · 06 / 08AES-GCM runtime is measured on a host. Select every technically valid statement.
A. Record payload sizes and implementation conditions.
B. Median and P95 characterize different aspects of observed latency.
C. One timing value establishes a universal algorithm ranking.
D. Changing hardware cannot affect measured runtime.Reveal explanation
Applied scenario
Correct: A. Record payload sizes and implementation conditions.; B. Median and P95 characterize different aspects of observed latency.
K13 · 07 / 08Which engineering mechanism is tested by K13 · Authenticated encryption benchmarking, and what state or outcome is evaluated?Reveal explanation
Implementation recall
Measure host AES-GCM timings across payload sizes and report median and P95.
K13 · 08 / 08For K13 · Authenticated encryption benchmarking, which actual output or state confirms the prescribed practical run succeeded, and what does it not establish?Reveal explanation
Evidence & acceptance
Run in a fresh writable results directory (the script refuses to overwrite aes_trials.csv). Expect four sizes, 100 measured samples each, warm-ups excluded. Verify CSV has header plus 400 rows. Record host, Python, OpenSSL and units microseconds; these are combined encrypt/decrypt host times, not MCU or energy.
Loading experiment-specific apparatus…Previous model / additional reference tools
Simulation task
Measure host AES-GCM timings across payload sizes and report median and P95.
Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.
Predict the outcome, change either condition, then compare the modeled decision. This illustrates the selected control criteria, not a full implementation or measurement.
01 · InputBenchmark validity
→
02 · Evaluate2 of 2 checks
→
03 · OutcomeConditions met
CONTROL PATH · VIRTUAL INSTRUMENTCONDITIONS MET
Signal path illustrates a decision rule. The indicator is not actual network traffic, cryptographic verification or device measurement.
Compare median and P95 timings
Reference conditions selected.
Reference conditions selected.
Complete the actual local Kali procedure below. The workbench does not send packets, perform cryptography, inspect a device or establish that real controls are effective.
Closed two-condition teaching fixture; actual security validation requires the practical procedure.
Loading instrument…
Awaiting model display.
Experimental instrumentation · A/B
Compare two model conditions
Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.
Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.
Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.
Prepare a contextual AI prompt
0 characters
Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.
Prepare → review → copy & open your selected provider → paste and submit there.
Run & verify — acceptance checklist
Build verification: Actual AES-GCM benchmark 400 timing samples recorded.
Run in a fresh writable results directory (the script refuses to overwrite aes_trials.csv). Expect four sizes, 100 measured samples each, warm-ups excluded. Verify CSV has header plus 400 rows. Record host, Python, OpenSSL and units microseconds; these are combined encrypt/decrypt host times, not MCU or energy.
Record the actual output, source (mock/model or physical), and any error. A missing tool, timeout or untested external service is not a pass.
Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.
01 · Predict and derive using the given inputs
For sorted timings 1,2,3,4,5,6,7,8,9,20 ms, compute median and nearest-rank P95. Calculate throughput for a 128-byte message completed in 4 ms.
Engineering method — Benchmark latency is elapsed time for a defined operation. Median is middle sorted observation; P95 requires stated quantile convention. For times 4,5,5,6,20 µs, median5; the outlier matters to tail latency. Repeat paired conditions and report environment. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Design paired runs with fixed payload, key length and host conditions. Explain why host timing is not microcontroller energy.
Engineering method — Benchmark latency is elapsed time for a defined operation. Median is middle sorted observation; P95 requires stated quantile convention. For times 4,5,5,6,20 µs, median5; the outlier matters to tail latency. Repeat paired conditions and report environment. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Data analysis
Data analysis · Independent work
Five timings 7,9,10,11,30 µs; calculate median and arithmetic mean. Why is one fastest run an unsuitable baseline?
Data analysis — Benchmark latency is elapsed time for a defined operation. Median is middle sorted observation; P95 requires stated quantile convention. For times 4,5,5,6,20 µs, median5; the outlier matters to tail latency. Repeat paired conditions and report environment. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.
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 · Explain a changed-input result
Independent theoretical exercise · K13-01
Use the reference configuration (Payload bytes = 128; Repetitions = 12), but change Payload bytes = 130. One previously recorded run reported Mean round trip = 0.114558 ms. This is a runtime-dependent measurement, not a deterministic expected output. Explain which factors affect the measurement; propose repeated controlled trials and report their distribution instead of requiring this exact value.
Intermediate · Quantitative comparison
Independent theoretical exercise · K13-02
Two model observations of Mean round trip are 0.161618 ms (reference) and 0.114558 ms (changed condition). Compute signed change and, when the reference is nonzero, percentage change. Explain why units matter.
Intermediate · Interpret a technical trace
Independent theoretical exercise · K13-03
For Repetitions = 14, the model supplies this excerpt from Timing samples:
Trial · Elapsed ms
1 · 0.087053
2 · 0.128793
3 · 0.073515
4 · 0.416438
5 · 0.142833
Compute the range (maximum minus minimum) of the Elapsed ms column in these rows. Identify the maximum observation. Do not extrapolate beyond these rows.
Advanced · Reverse reasoning
Independent theoretical exercise · K13-04
An observation is Round trips verified = 14. Candidate A uses Payload bytes = 128; Repetitions = 12. Candidate B changes the listed settings (Repetitions = 14) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.
Advanced · Diagnose a reported mismatch
Independent theoretical exercise · K13-05
A student configures Payload bytes = 1024 while preserving all other reference settings, but copies the reference report of Mean round trip = 0.161618 ms. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · K13-06
Design a controlled comparison for K13 · Authenticated encryption benchmarking using reference Payload bytes = 128; Repetitions = 12 and test Payload bytes = 130. Specify the changed setting(s), measured metric Mean round trip, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Measure authenticated encryption round-trip latency at fixed payload size.
1 · Reference workbench configuration
Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.
Payload bytes128
Repetitions12
2 · Perform the investigation in order
Set payload 128 B and 12 repetitions. Record individual durations, median and p95; the mean is measured in this browser, not a constant.
Run 1024 B with 12 repetitions. Compare latency distributions, not just means.
Use 30 repetitions at 128 B. Inspect host timing variability and keep other browser tasks stable.
Run the local advanced security benchmark; record platform and cryptographic library versions. Never compare host and embedded timing as if they share hardware.
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
128-byte payload
Use reference inputs above
Round trips verified: 12
Record actual result
1024-byte payload
Payload bytes = 1024
Round trips verified: 12
Record actual result
30 repetitions
Repetitions = 30
Round trips verified: 30
Record actual result
4 · Analyze and report
Explain why cache, scheduling and browser overhead affect timings.
Required evidence: Per-trial samples and separate host/target provenance.
Model boundary: Actual browser Web Crypto AES-GCM timing; not Ascon, device power or physical ESP32 measurements.
Controlled investigation · reproducible evidence
Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.
Trial
Independent change
Dependent observation
128-byte payload
Use reference inputs above
Record actual outcome and units
1024-byte payload
Payload bytes = 1024
Record actual outcome and units
30 repetitions
Repetitions = 30
Record actual outcome and units
Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.
Loading laboratory-specific procedure…
Python / Google Colab notebook
Original local defensive reference; ephemeral keys/files. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
✓ Expected:A JSON summary and 400 trial records in aes_trials.csv. Times vary by host and load. Each decryption must reproduce its input. A fresh output directory prevents overwrite.
Experimental notebook
Record your own results. Values are not prefilled or independently verified.
Scientific method
Four payload lengths: 32, 128, 512 and 1024 bytes. Ten warm-up operations followed by 100 measured combined encrypt/decrypt operations per size. Fresh nonce each trial.
Import CSV into Research Studio; record library, processor and operating environment. Timing trials within one host session may be correlated; do not infer independent physical-device confidence intervals.
Keep actual outputs separate from expected results. Record only non-sensitive evidence and note unresolved controls.
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: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# K13 · K13 · Authenticated encryption benchmarking
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Measure host AES-GCM timings across payload sizes and report median and P95.
## How to run
1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook.
2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all.
3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell.
4. Save your own outputs and compare them to the portal Experiment tab.
**Execution boundary:** Original local defensive reference; ephemeral keys/files. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation
Measure host AES-GCM timings across payload sizes and report median and P95.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Set payload 128 B and 12 repetitions. Record individual durations, median and p95; the mean is measured in this browser, not a constant.
2. Run 1024 B with 12 repetitions. Compare latency distributions, not just means.
3. Use 30 repetitions at 128 B. Inspect host timing variability and keep other browser tasks stable.
4. Run the local advanced security benchmark; record platform and cryptographic library versions. Never compare host and embedded timing as if they share hardware.
**Evidence:**
**Boundary:**
03Instructions · Markdown
## 1. Objectives and reference condition
- Reproduce the specific computational mechanism in this laboratory.
- Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy.
- Distinguish actual local Python execution from mock, physical and external-service observations.
## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# K13 | Code cell 01 | K13 · Authenticated encryption benchmarking
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
## 3. Implementation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# K13 | Code cell 02 | K13 · Authenticated encryption benchmarking
# Purpose: 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import os, ssl, statistics, time, csv, platform
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
# Define the reusable operation benchmark; keep its logic separate from the trial.
def benchmark():
a=AESGCM(AESGCM.generate_key(bit_length=128)); rows=[]; summaries=[]
for size in [32,128,512,1024]:
msg=b'x'*size; times=[]
for trial in range(110):
n=os.urandom(12);start=time.perf_counter_ns();ct=a.encrypt(n,msg,b'PSUT');plain=a.decrypt(n,ct,b'PSUT');elapsed=time.perf_counter_ns()-start
assert plain==msg
if trial>=10:times.append(elapsed/1000);rows.append([str(size),trial-9,elapsed/1000])
summaries.append({'bytes':size,'trials':len(times),'median_us':statistics.median(times),'p95_us':sorted(times)[94]})
# Explicit local output in working directory; refuse overwrite.
with open('aes_trials.csv','x',newline='') as f:
w=csv.writer(f);w.writerow(['group','trial','value']);w.writerows(rows)
return {'source':'actual-local-host-timing','unit':'microseconds, combined encryption and decryption','python':platform.python_version(),'openssl':ssl.OPENSSL_VERSION,'platform':platform.machine(),'warmup_per_size':10,'summary':summaries,'csv':'aes_trials.csv'}
### Step 2 · Run the reference calculation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
08Python · executable cell
PYTHON · Code cell
# =====================================================================
# K13 | Code cell 03 | K13 · Authenticated encryption benchmarking
# Purpose: Step 2 · Run the reference calculation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import tempfile,os
# Set old for the next computation or reference condition.
old=os.getcwd()
# Limit resource lifetime to this block so files, sockets or temporary state are cleaned up.
with tempfile.TemporaryDirectory() as d:
os.chdir(d)
try: result=benchmark()
finally: os.chdir(old)
print(result)
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert result is not None and (not isinstance(result,dict) or result.get("pass",result.get("passed",True)))
## Original portal implementation (reference only)
These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all.
```bash
cd ~/kali-labs
results=$(mktemp -d "$HOME/psut-aes-study.XXXXXX")
cd "$results"
python3 ~/kali-labs/advanced_security.py benchmark > benchmark.json && cat benchmark.json && ls -l aes_trials.csv
```
10Instructions · Markdown
## 4. Results and analysis
Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result.
| Trial | Configuration | Observation | Interpretation |
|---|---|---|---|
| A | Reference | | |
| B | One controlled change | | |
| C | Reference repeat | | |
**Limitations:** Original local defensive reference; ephemeral keys/files. Notebook success does not certify external equipment or services.
11Instructions · 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. Run 1024 B with 12 repetitions. Compare latency distributions, not just means. 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.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research