IoTPSUT IoT Engineering StudioPrincess Sumaya University for Technology · Dr. Mohammad Alja’afreh
CRYPTOGRAPHY ENGINEERING · CR58 · ECC
IoT Security and Privacy
RSA versus ECC measured signature operations
Measure RSA-3072 and P-256 signature operations.
CR58 · Laboratory mentorAsk about the current operation and its intermediate values.
CR58 · Academic orientation
Scope and objectives
Scope of the experiment
RSA relies on integer-factorization-related hardness, ECC on the elliptic-curve discrete-log problem. Key bit lengths are not equivalent security strengths.
The focus of this experiment is to compare RSA and ECC signature operations at stated security levels. Students then calculate latency statistics from matched repeated trials, and interpret host measurements without claiming embedded-device performance. 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 RSA and ECC signature operations at stated security levels.
Calculate latency statistics from matched repeated trials.
Interpret host measurements without claiming embedded-device performance.
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 RSA and ECC signature operations at stated security levels, calculate latency statistics from matched repeated trials, and interpret host measurements without claiming embedded-device performance.
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 interpret host measurements without claiming embedded-device performance. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to Hashing versus encoding and digest families.
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
CR58 · RSA versus ECC measured signature operations
RSA-3072 and P-256 have roughly comparable 128-bit classical security strength. Measure implementations, not security. Same message and SHA-256; warm up, repeat measurements, report medians and signing standard deviation. Web Crypto ECDSA uses raw r||s; Python uses variable DER encoding.
Learning objectives
Measure RSA-3072 and P-256 signature operations. Predict a result, inspect intermediate states, verify the invariant and explain the specified boundary case.
RSA-3072 and P-256 have roughly comparable 128-bit classical security strength. Measure implementations, not security. Same message and SHA-256; warm up, repeat measurements, report medians and signing standard deviation. Web Crypto ECDSA uses raw r||s; Python uses variable DER encoding.
Learning objectives
Measure RSA-3072 and P-256 signature operations. Predict a result, inspect intermediate states, verify the invariant and explain the specified boundary case.
Mathematical verification and controlled comparison
Substitute the output into its defining equation or check the protocol invariant. A controlled comparison changes one input while holding others fixed. Cite actual trace values and identify the limitations of the evidence.
Before starting
Environment: standard computer, browser and Python/WSL.
Simulation: actual browser cryptographic API where supported; stored Python reference otherwise. Python is the independent execution path.
Technical scope: Actual local benchmark snapshots; repeat on own machine. No hardware measurements.
Comparable security and performance
1 · Principles and purpose
RSA relies on integer-factorization-related hardness, ECC on the elliptic-curve discrete-log problem. Key bit lengths are not equivalent security strengths.
2 · Mathematical and algorithmic foundations
P-256 and RSA-3072 are commonly compared at approximately 128-bit classical security. Measure generation, signing and verification separately, same backend/message/trials. Report median and variability, including serialization differences.
3 · Worked teaching example
A fixed-width raw P-256 signature consists of two 32-byte integers; DER representation may vary. RSA-3072 signature is 384 bytes. Actual timing must be measured, not inferred from these sizes.
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.
Step 1 of 2 · Calculated state 1
Calculated state 1
algorithm
RSA3072
trials
5
public_der_bytes
422
signature_bytes
384
keygen_median_ms
137.5879
sign_mean_ms
1.1594
sign_median_ms
1.1029
sign_sd_ms
0.1249
verify_median_ms
0.0779
signature_encoding
RSA fixed length
Calculated state 2
algorithm
P256
trials
5
public_der_bytes
91
signature_bytes
72
keygen_median_ms
0.0191
sign_mean_ms
0.0316
sign_median_ms
0.0305
sign_sd_ms
0.0028
verify_median_ms
0.0855
signature_encoding
ASN.1 DER
Teaching example only; inspect live calculations or real practical evidence separately.
Integrated IoT security benchmarking
A gateway performs different security operations: AES-GCM protects confidentiality and integrity, HMAC authenticates messages with a shared key, and signatures permit public verification. Measure key setup separately; use equal payload lengths and repeated trials on one host. An AES-GCM seal includes a fresh nonce and authentication tag; throughput is payload bytes divided by elapsed time. ECDSA and RSA-PSS sign/verify operations are comparable at approximately 128-bit classical security, not interchangeable with a MAC. The captured timings are host-specific, not measurements of ESP32 or Raspberry Pi.
Compare the three linked experiments to distinguish measured performance, application authentication and transport security.
Reference SVG (visible without scripts). Use the editable workstation below to calculate or run the experiment.
Choose a reference trial or edit the parameters. The workstation computes new results; practical cryptography uses Web Crypto when available and labels recorded Python references separately.
Verified baseline reference
Calculated result or labeled reference
{
"algorithms": 2,
"verified": true
}
Complete trace
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.
Throughput calculator; enter your measured latency. Default 10 µs is an illustrative input, not a measured timing.
Step 1
Ask Dr. Mohammad · current stage
For line-by-line implementation guidance, use the code mentor in Experiments.
Calculated result
Select Calculate / run.
04 · Experiments and engineering investigations
Analytical preparation — before Python
RSA-3072 signature is 384 bytes; P-256 browser raw signature is 64 bytes. Python DER signature length varies. Timings depend on runtime and device.
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
Construct a fair RSA-3072/P-256 signature benchmark design using the same message, backend and repetition count. Specify warm-up, median, variability, signature encoding and comparable security level; explain why timing is machine-specific.
Application and derivation — P-256 and RSA-3072 are commonly compared at approximately 128-bit classical security. Measure generation, signing and verification separately, same backend/message/trials. Report median and variability, including serialization differences. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Measurement analysis
Measurement analysis · Independent work
Hypothetical signing latencies are 10,11,12,13,54 µs. Calculate mean and median and interpret the difference.
Measurement analysis — Review the defining equations and compare the input restrictions and state transitions in Concepts. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
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 · CR58-01
For the separate teaching-test configuration trials: 10, predict verified 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 · CR58-02
A teaching trace for RSA versus ECC measured signature operations contains algorithm: P256; trials: 5; public_der_bytes: 91; signature_bytes: 72; keygen_median_ms: 0.0191. Explain the role of signature_encoding (recorded value ASN.1 DER) 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 · CR58-03
The first and final trace records show public_der_bytes = 422 and 91. 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 · CR58-04
Plan a comparison of trials: 5 with trials: 10. Record the dependent value algorithms, 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; run the integrated workstation or extracted toolkit. Browser cryptography requires a supported secure context; use Python if unavailable.
Install Python dependencies only if required by the selected toolkit README. Use its requirements file and virtual environment instructions.
Calculate five trials; record public DER size, signature encoding/size, median latencies and standard deviation.
Export the trace and compare the result with the reference.
Experimental inputs
Experimental reference · json
{"trials":5}
Verified baseline reference (check after predicting)
Experimental reference · json
{"algorithms":2,"verified":true}
Compare your baseline with the verified reference output below; for runtime-dependent results, compare invariants and report actual measurements instead of expecting identical timing or randomly generated values.
Evidence to record
Runtime/device, trial count, encoding, signature and key sizes, median timings and variability.
Part D · Controlled investigation — Measure RSA-3072 and P-256 signature operations
Run ten trials in the same browser. Independently run Python at five and ten trials; report runtimes separately.
Record fixed settings and complete the comparison table.
Measure Runtime/device, trial count, encoding, signature and key sizes, median timings and variability. Explain the first differing state or invariant.
Trial
Input configuration
Prediction
Observed
Verification
1
{"trials":5}
2
{"trials":10}
3
{"trials":2}
Use the table as a recording template; enter your own measured values in the field below or reproduce it in your report.
Part E/F · Independent Python verification and deliverables
Download the notebook or toolkit and run the default example.
Use python3 lab.py --inputs followed by the JSON from a trial. Compare exact math; for randomized or timed experiments compare invariants and report actual measurements separately.
Complete the independent assessment below without copying the worked baseline. Explain discrepancies and distinguish mathematical results from security claims.
Additional investigation instructions
Read the theory and prerequisite labs. Run the baseline and record the input and result.
Warm up both implementations; compare five and ten trials. Report median and variation. Do not extrapolate to ESP32 or Raspberry Pi.
Locate the first intermediate step where the two cases differ. Verify the defining equation or decision rule.
Submit a two-row comparison table, trace evidence and a conclusion with limitations.
Case
Input
Observed result
Verification
Limitation
Baseline
Record
Record
Derive
Explain
Changed
Record
Record
Derive
Explain
Integrated IoT engineering investigation
Run the benchmark three times with identical host and payloads. For AES-GCM seal and HMAC generation, compare medians at 32, 256 and 1024 bytes. Record the mean, standard deviation and median; compute decimal MB/s as bytes divided by median microseconds. Compare ECDSA and RSA-PSS sign/verify only with their matched operations at 256 bytes. Explain why these services are not substitutes.
Predict the baseline before running the program.
Change one named condition at a time and retain the remaining settings.
Record actual output, comparison and interpretation. Identify the boundary where the security service applies.
Trial / change
Prediction
Observed result
Reason / limitation
Trial 1
Trial 2
Trial 3
Trial 4
Trial 5
Copy observations to the Engineering evidence record or export the workstation JSON. Do not enter actual credentials.
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).
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 CR58
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.
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 --inputs "$(cat 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>=42
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 CR58/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.
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.
Download the notebook, open Google Colab and upload it using File → Upload notebook. For local Linux/WSL execution, follow the command blocks below in order.
Inspect Python source
Documented Python implementation · python
# ------------------------------------------------------------
# PSUT IoT Engineering Studio | CR58
# Experiment: rsa versus ecc measured signature operations
# Purpose: expose algorithm states and verify the experiment invariant.
# ------------------------------------------------------------
# CR58 | RSA versus ECC measured signature operations
# Execute the named operation; expose states and assert the laboratory invariant.
import json
DEFAULT={'trials': 5}
ALTERNATE={'trials': 10}
def run(overrides=None):
# Merge only explicitly supplied inputs with the reference baseline.
params={**DEFAULT, **(overrides or {})}
trials=params['trials']
if type(trials) is not int or not 2<=trials<=10: raise ValueError('Choose 2–10 trials')
import time,statistics
from cryptography.hazmat.primitives.asymmetric import rsa,ec,padding
from cryptography.hazmat.primitives import hashes,serialization
steps=[];msg=b'PSUT synthetic reading'
for name,gen in [('RSA3072',lambda:rsa.generate_private_key(public_exponent=65537,key_size=3072)),('P256',lambda:ec.generate_private_key(ec.SECP256R1()))]:
k=gen(); pub=k.public_key();sg=(lambda:k.sign(msg,padding.PSS(mgf=padding.MGF1(hashes.SHA256()),salt_length=32),hashes.SHA256())) if name=='RSA3072' else (lambda:k.sign(msg,ec.ECDSA(hashes.SHA256())));vf=(lambda sig:pub.verify(sig,msg,padding.PSS(mgf=padding.MGF1(hashes.SHA256()),salt_length=32),hashes.SHA256())) if name=='RSA3072' else (lambda sig:pub.verify(sig,msg,ec.ECDSA(hashes.SHA256())))
vf(sg());sign=[];verify=[];gen_times=[]
for i in range(trials):
t=time.perf_counter();gen();gen_times.append((time.perf_counter()-t)*1000);t=time.perf_counter();sig=sg();sign.append((time.perf_counter()-t)*1000);t=time.perf_counter();vf(sig);verify.append((time.perf_counter()-t)*1000)
steps.append({'algorithm':name,'trials':trials,'public_der_bytes':len(pub.public_bytes(serialization.Encoding.DER,serialization.PublicFormat.SubjectPublicKeyInfo)),'signature_bytes':len(sig),'signature_encoding':'RSA fixed length' if name=='RSA3072' else 'ASN.1 DER','keygen_median_ms':round(statistics.median(gen_times),4),'sign_mean_ms':round(statistics.mean(sign),4),'sign_median_ms':round(statistics.median(sign),4),'sign_sd_ms':round(statistics.stdev(sign),4),'verify_median_ms':round(statistics.median(verify),4)})
result={'algorithms':len(steps),'verified':True}
# Independently check the stated mathematical or protocol invariant.
assert result["verified"] and len(steps)==2, "verification failed"
return {"steps":steps,"result":result}
if __name__ == "__main__":
import argparse
parser=argparse.ArgumentParser();parser.add_argument("--inputs",default="{}");parser.add_argument("--test",action="store_true");args=parser.parse_args()
if args.test:
for case in [{},ALTERNATE]:run(case)
print("PASS")
else:print(json.dumps(run(json.loads(args.inputs)),indent=2))
Use the downloaded current WSL toolkit. The following commands assume the extraction directory from the workflow above.
Ubuntu/Kali WSL · bash
cd ~/psut-crypto-v22.9.9
source .venv/bin/activate
cd CR58
ls
python -m pip install -r requirements.txt
python iot_benchmark.py | tee integrated-results.json
python test_lab.py
Inspect the integrated practical implementation
iot_benchmark.py · python
# ------------------------------------------------------------
# PSUT IoT Engineering Studio | CR58 integrated benchmark
# Purpose: measure distinct security operations on the same host.
# Timings are measurements of this implementation, not universal rankings.
# ------------------------------------------------------------
import json, platform, statistics, time, secrets, hmac, hashlib
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.hazmat.primitives.asymmetric import ec, rsa, padding
from cryptography.hazmat.primitives import hashes
import cryptography
def run(repeats=40):
if not 5<=repeats<=200:raise ValueError('repeats must be 5..200')
ec_key=ec.generate_private_key(ec.SECP256R1());rsa_key=rsa.generate_private_key(public_exponent=65537,key_size=3072)
aes=AESGCM(secrets.token_bytes(16));mac_key=secrets.token_bytes(32);aad=b'psut-device01';pss=padding.PSS(mgf=padding.MGF1(hashes.SHA256()),salt_length=32)
results=[];counter=0;prefix=secrets.token_bytes(4)
def measure(label,op,payload,size):
for _ in range(5):op()
samples=[]
for _ in range(repeats):
start=time.perf_counter_ns();op();samples.append((time.perf_counter_ns()-start)/1000)
results.append({'operation':label,'payload_bytes':payload,'output_bytes':size,'median_us':round(statistics.median(samples),3),'mean_us':round(statistics.mean(samples),3),'stdev_us':round(statistics.stdev(samples),3),'trials':repeats})
for length in (32,256,1024):
msg=b'A'*length
def seal():
nonlocal counter
counter+=1;n=prefix+counter.to_bytes(8,'big');return n,aes.encrypt(n,msg,aad)
n,c=seal();assert aes.decrypt(n,c,aad)==msg
tag=hmac.digest(mac_key,msg,'sha256');assert hmac.compare_digest(tag,hmac.digest(mac_key,msg,'sha256'))
measure('AES-128-GCM seal',seal,length,length+16+12)
measure('AES-128-GCM open',lambda:aes.decrypt(n,c,aad),length,length)
measure('HMAC-SHA256 generate',lambda:hmac.digest(mac_key,msg,'sha256'),length,32)
msg=b'A'*256
for label,key,sign,verify in [('ECDSA P-256',ec_key,lambda:ec_key.sign(msg,ec.ECDSA(hashes.SHA256())),lambda s:ec_key.public_key().verify(s,msg,ec.ECDSA(hashes.SHA256()))),('RSA-3072 PSS',rsa_key,lambda:rsa_key.sign(msg,pss,hashes.SHA256()),lambda s:rsa_key.public_key().verify(s,msg,pss,hashes.SHA256()))]:
sig=sign();verify(sig);measure(label+' sign',sign,len(msg),len(sig) if label.startswith('RSA') else 'variable DER length');measure(label+' verify',lambda:verify(sig),len(msg),0)
return {'environment':{'platform':platform.platform(),'python':platform.python_version(),'cryptography':cryptography.__version__},'warmups_per_operation':5,'results':results,'note':'Only compare matched operations and payloads. ECDSA/RSA signing differs from AEAD and MAC; key generation excluded. AES output includes nonce and tag.'}
if __name__=='__main__':print(json.dumps(run(),indent=2))
Actual captured example output (timings and random fields can vary)
Recall before revealing. Review and mastery ratings remain on this device.
Browse all explanationsWhy these key sizes?
Comparable approximate classical strength.
Which summary resists outliers?
Median.
Can desktop timing predict ESP32?
No.
Why may browser and Python ECDSA lengths differ?
Different encoding (raw vs DER)
What evidence should be recorded?
Runtime/device, trial count, encoding, signature and key sizes, median timings and variability.
How should the comparison be controlled?
Run ten trials in the same browser. Independently run Python at five and ten trials; report runtimes separately.
06 · Knowledge assessment
Run ten trials in the same browser. Independently run Python at five and ten trials; report runtimes separately. Submit the stated measurements, a reasoned comparison and independent verification. Criteria: mathematical correctness 40%, reproducibility 30%, interpretation 20%, limitations 10%.
Formative knowledge check
Why may browser and Python ECDSA lengths differ?
Responses are for instructor review; no grading key is provided here.
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.