Investigate client-side file encryption, key wrapping, encrypted storage and authorized sharing, based on the teaching material.
The focus of this experiment is to design a hybrid secure-storage workflow separating data and key protection. Students then trace encryption, key wrapping and authenticated recovery, and verify tamper rejection and document trust and storage assumptions. 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
Design a hybrid secure-storage workflow separating data and key protection.
Trace encryption, key wrapping and authenticated recovery.
Verify tamper rejection and document trust and storage assumptions.
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 design a hybrid secure-storage workflow separating data and key protection, trace encryption, key wrapping and authenticated recovery, and verify tamper rejection and document trust and storage assumptions.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify tamper rejection and document trust and storage assumptions. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the foundational terminology in Concepts and confirm readiness using the existing setup instructions. After completion, continue to Ascon — lightweight authenticated encryption and hashing.
Environment and experimental methodology
The included teaching workstation and the listed Python/Colab or WSL implementation. Historical and small-number constructions are instructional, not deployment recommendations.
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.
How to investigate Optional capstone — Hybrid cryptographic secure storage
Investigate client-side file encryption, key wrapping, encrypted storage and authorized sharing, based on the supplementary project brief.
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: Investigate client-side file encryption, key wrapping, encrypted storage and authorized sharing, based on the supplementary project brief.
Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
Client/server architecture and user registration — complete its numbered steps and record the requested evidence.
Encryption, integrity and secure sharing — complete its numbered steps and record the requested evidence.
Compare observations with the reference checks and submit the required evidence.
Reference check: The genuine recipient recovers the original bytes; modifying the AES-GCM ciphertext fails authentication. The server-side object has no plaintext or raw AES session key.
Model boundary: Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser.
Independent task and submission evidence
2. Client/server architecture and user registration — complete its numbered steps and record the requested evidence. 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.
Design a client-side encrypted file service: the client encrypts and decrypts file bytes, while a server stores ciphertext and authenticated metadata. A local GUI or web client can submit an encrypted envelope to a Flask service. A Tkinter interface is optional; the laboratory workstation models the cryptographic workflow rather than a complete hosted application.
Hybrid encryption
Use a random symmetric file key and an authenticated encryption mode such as AES-GCM. Encrypt or wrap the file key with the intended recipient’s RSA-OAEP public key. AES-CBC plus an unkeyed hash is not an authenticated substitute; compare its properties with the authenticated design.
Sharing and integrity
The authorized owner unwraps the file key and wraps it for a verified recipient public key. A wrong key, modified ciphertext or invalid tag must not release plaintext. Test owner access, recipient recovery, nonrecipient rejection and tampered-envelope rejection independently.
Prerequisites: EC01–EC12 recommended.
Algorithm structure and data flow. Use the simulation to inspect the corresponding numerical transformations.
Engineering diagrams
Hybrid encryption protects payload and wraps the session key.
Scientific foundations and worked examples
Hybrid encryption architecture
A client generates a fresh symmetric session key, encrypts file bytes using authenticated encryption, and wraps the session key with the authorized recipient public key. The server stores ciphertext, nonce, authentication tag, wrapped key and necessary metadata. The recipient uses the private key to recover the session key, verifies the tag and only then releases plaintext. A secure transport channel does not eliminate the need for authenticated key identity.
Access control and experimental design
Separate authentication (who requests a file) from authorization (which file and actions are allowed). For sharing, wrap the session key independently for each authorized recipient. Removing a recipient does not revoke plaintext or keys they already possess. Evaluate the client/server workflow with an authorized receiver, wrong key, modified ciphertext and unavailable server. Record whether decryption and verification succeed without exposing secrets in logs.
Engineering principles · additional worked teaching example
Hybrid storage protects data with an AEAD data key; an asymmetric mechanism or key wrapping protects the data key. Store nonce, ciphertext and authentication tag; AAD binds metadata. Example a 32-byte payload with a 16-byte tag and 12-byte nonce yields 60 bytes before format and wrapped-key overhead.
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.
Worked engineering reasoning and boundary conditions
Hybrid secure storage uses a randomly generated content key for authenticated encryption and protected key encapsulation/wrapping for recipients. Verification must precede use. Key management and metadata are part of the security boundary.
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 · operation pathway
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 4 · Data
Data
Data
local disposable file
Generate
Data
local disposable file
Generate
random content key
Protect
Data
local disposable file
Generate
random content key
Protect
AEAD + authenticated metadata
Wrap
Data
local disposable file
Generate
random content key
Protect
AEAD + authenticated metadata
Wrap
recipient key; verify before recovery
Teaching example only; inspect live calculations or real practical evidence separately.
Interactive flashcards
Self-rated study progress is stored locally, not used for official grades.
Browse all explanationsWhy hybrid encryption?
Efficient symmetric encryption plus public-key key transport.
What does GCM tag check?
Authenticity of ciphertext and associated data.
What is OAEP for?
Randomized RSA encryption padding.
Why reject before releasing plaintext?
Unauthenticated plaintext may be manipulated.
Why use a hybrid construction?
Symmetric encryption handles bulk data and public-key encryption wraps the session key.
What does AES-GCM provide?
Confidentiality and authenticated integrity.
What is the purpose of RSA-OAEP?
Randomized public-key encryption of small secrets such as session keys.
Where should a private key remain?
With its authorized owner, protected from disclosure.
What does associated data protect?
Unencrypted metadata against undetected modification.
What is an encrypted envelope?
Ciphertext plus nonce, authentication tag, wrapped key and metadata.
How can an authorized recipient receive a session key?
The owner wraps it using the recipient's public key.
What must happen on authentication failure?
Reject the record without releasing plaintext.
Why is an unkeyed SHA digest not enough for authentication?
An adversary can recompute it after modifying content.
What is a negative control for secure sharing?
An unauthorized recipient or modified envelope must fail.
The recipient public key is replaced before key wrapping. Why is encryption alone insufficient?
The session key may be wrapped for an unintended recipient. Verify the identity and authenticity of the public key.
A modified GCM ciphertext arrives. Should plaintext be released before tag verification?
No. The receiver must reject a failed authentication check.
What role does the wrapped key play in the envelope?
It allows the intended private-key holder to recover the symmetric session key without exposing that key in plaintext.
Choose a workstation, edit the inputs, and observe recalculated results. Play or step through the actual calculation trace. Hash-search stations calculate successive candidates during playback. All inputs are fictional training data.
Where the browser requires Web Crypto, launch the local portal on localhost or use the HTTPS deployment. The classroom algorithms and keys are not intended for production use.
Independent theoretical exercises
Complete every question independently on paper or in the fields below before using the simulation or programming activities. Show formulas, intermediate steps, tables, proofs and units. Afterward verify your work using the simulator and Python, and explain discrepancies. Worked examples in Concepts do not replace your own derivation.
01 · Design
Draw client/server trust boundaries and label key generation, authenticated encryption, wrapping, storage and authorized decryption. Identify which entities can access each secret.
Engineering method — Hybrid storage protects data with an AEAD data key; an asymmetric mechanism or key wrapping protects the data key. Store nonce, ciphertext and authentication tag; AAD binds metadata. Example a 32-byte payload with a 16-byte tag and 12-byte nonce yields 60 bytes before format and wrapped-key overhead. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Experimental predictions
Before executing the capstone, predict results for authorized recipient, wrong key, modified ciphertext and missing server data. Explain why deleting a wrapped key cannot revoke previously obtained plaintext.
Engineering method — Hybrid storage protects data with an AEAD data key; an asymmetric mechanism or key wrapping protects the data key. Store nonce, ciphertext and authentication tag; AAD binds metadata. Example a 32-byte payload with a 16-byte tag and 12-byte nonce yields 60 bytes before format and wrapped-key overhead. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Design
Design · Independent work
For payload96 B, 12 B nonce and 16 B tag, calculate protected envelope size excluding wrapped key. Explain how to test corruption without exposing a secret.
Design — Hybrid storage protects data with an AEAD data key; an asymmetric mechanism or key wrapping protects the data key. Store nonce, ciphertext and authentication tag; AAD binds metadata. Example a 32-byte payload with a 16-byte tag and 12-byte nonce yields 60 bytes before format and wrapped-key overhead. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Responses are saved locally when browser storage is available. Export your work for submission. No automatic grading or remote upload occurs.
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.
Foundational · Apply the principle
Independent theoretical exercise · EC13-01
A 1 MiB file uses AEAD with 12-byte nonce and 16-byte tag. Count bare ciphertext plus overhead.
Intermediate · Calculate or trace
Independent theoretical exercise · EC13-02
Why does directly encrypting the entire file with textbook RSA fail?
Intermediate · Interpret the result
Independent theoretical exercise · EC13-03
A recipient key is replaced by an untrusted key. Which control fails?
Advanced · Analyze a condition
Independent theoretical exercise · EC13-04
A stored header is changed while ciphertext and tag are unchanged. How should the receiver behave if header is authenticated?
Advanced · Diagnose or compare
Independent theoretical exercise · EC13-05
How should new keys be distributed after a recipient loses authorization?
Challenging · Engineering verification
Independent theoretical exercise · EC13-06
Design evidence for a local storage test without real secrets.
Activity sequence
Follow the setup commands, then each named activity. The detailed instructions, given values and recording fields appear below.
Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
Compare observations with the reference checks and submit the required evidence.
Analytical preparation — before Python
Complete this written or hand-calculation activity first, then compare it with the simulator and executable implementation.
Draw the trust boundaries and label the cryptographic envelope. Explain which party can read the plaintext and predict the result of each negative control.
Evidence: show the derivation, intermediate values and independent checks; explain any mismatch with the practical result.
Practical laboratory manual
Scientific experimental protocol
Research question: Does authenticated hybrid encryption keep plaintext out of storage and detect modification?
Independent variables
Message, recipient key, tamper condition
Dependent observations
Wrapped-key length, ciphertext/tag, recovered plaintext, authentication status
Controls
Use fictional messages and newly generated session keys; compare unmodified and modified record.
Validation and evidence
Before running a trial, predict its output. Use the baseline conditions below to check your method, then vary one independent variable. Save calculated outputs or the actual Python trace. Keep browser results and local Python execution distinct.
Trial
Controlled configuration
Reference check
Student observation (editable)
Baseline
No tamper
Recipient recovers original message
Enter observation
Tamper
Change ciphertext byte
Authentication fails; no plaintext released
Enter observation
Storage boundary
Inspect server-side record
Only wrapped key, nonce, ciphertext/tag; no raw session key or plaintext
Enter observation
Analysis: Compare the CBC/SHA-256 project design to the authenticated local model. The portal does not implement or validate a deployed server.
Investigate client-side file encryption, key wrapping, encrypted storage and authorized sharing, based on the supplementary project brief.
Equipment and execution
Browser-based simulator, Python 3, notebook or local evidence folder. Use WSL Setup only if you need a Linux runtime.
3. Run the check before changing inputs. Record the exact Python version and any dependency error. Use Python visualizer to inspect the recorded traces; for edited code, generate and import a new trace using the instructions in that tab.
Complete the activities in order. Hold the controlled conditions fixed, record the input and actual output, and compare your observations with an independent calculation or test vector.
01
Client/server architecture and user registration
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Draw the client GUI/CLI, Flask API, public-key storage and encrypted-file storage. Define register user, load local keys, upload and list-authorized-files actions.
Use fictional users; generate local RSA key pairs and store only public keys on server. Confirm private keys and plaintext remain client-side.
Evidence to record
Architecture, key inventory and API design; application architecture is a design exercise, not a deployed service.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
02
Encryption, integrity and secure sharing
Open the exact workstation
Choose the relevant tab below, enter the assigned values in the activity steps, then use Step or Play to inspect intermediate calculations. Return to Experiment and record the results before changing the input.
Document provided AES-256-CBC/RSA-2048/SHA-256/Base64 design and its integrity limitation if hash is unauthenticated.
Use the existing authenticated teaching simulator (AES-GCM/RSA-OAEP) as an explicitly separate improvement. Encrypt a fictional file, wrap session key for owner, inspect stored record.
Model owner re-wrapping the key for an authorized recipient, verify recipient round trip and tampered ciphertext rejection. Compare the CBC-based design with the authenticated design.
Evidence to record
Encrypted envelope, authorization checks, recipient recovery and limitations.
Verification: Record the baseline and modified input separately, note the observed intermediate values, compare with the assigned calculation, and explain any mismatch. Do not replace observations with expected values.
Verification criteria
The genuine recipient recovers the bytes; modifying the AES-GCM ciphertext fails authentication. The server-side object has no plaintext or raw AES session key.
Deliverables
Submit architecture, local test evidence, recipient round trip, tamper rejection and security limitations.
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: Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# EC13 · Optional capstone — Hybrid cryptographic secure storage
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## 1. Scientific objective
Follow the setup commands, then each named activity. The detailed instructions, given values and recording fields appear below.
Complete the analytical worksheet in the portal first. Record your predictions before running this notebook. This notebook is a bounded local computational investigation; use the portal’s separate WSL, hardware or Remix procedure for real interfaces.
02Instructions · Markdown
## Experiment-specific preparation
Investigate client-side file encryption, key wrapping, encrypted storage and authorized sharing, based on the supplementary project brief.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
2. Client/server architecture and user registration — complete its numbered steps and record the requested evidence.
3. Encryption, integrity and secure sharing — complete its numbered steps and record the requested evidence.
4. Compare observations with the reference checks and submit the required evidence.
5. Draw the client GUI/CLI, Flask API, public-key storage and encrypted-file storage. Define register user, load local keys, upload and list-authorized-files actions.
**Evidence:** The genuine recipient recovers the original bytes; modifying the AES-GCM ciphertext fails authentication. The server-side object has no plaintext or raw AES session key.
**Boundary:** Fictional educational inputs. Browser algorithms and reference programs; no hardware or live-network measurements. Supplied starter notebooks may be incomplete; trace playback is recorded execution, not arbitrary Python running in browser.
03Instructions · Markdown
## 2. Reference configuration and investigation
1. Complete the analytical preparation below before programming. Show the intermediate mathematical calculations.
2. Client/server architecture and user registration — complete its numbered steps and record the requested evidence.
3. Encryption, integrity and secure sharing — complete its numbered steps and record the requested evidence.
4. Compare observations with the reference checks and submit the required evidence.
Run cells in order; do not substitute model results for physical measurements.
04Instructions · Markdown
### Environment
Colab usually provides cryptography. If imports fail, install dependencies in a separate Colab cell using `%pip install pycryptodome cryptography`, then restart the runtime. Local validation uses the installed backend. No actual secrets are used.
05Instructions · Markdown
## 3. Algorithm implementation
Read each definition and relate it to the equations and scientific SVGs in Concepts.
06Instructions · Markdown
### Implementation cell 1
Inspect the definitions, then execute to make them available for the investigation.
07Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC13 | Code cell 01 | Optional capstone — Hybrid cryptographic secure storage
# Purpose: Implementation cell 1 Inspect the definitions, then execute to make them available for the investigation.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
"""Optional capstone — local authenticated hybrid encryption; no network service."""
from cryptography.hazmat.primitives.asymmetric import rsa,padding
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.exceptions import InvalidTag
import secrets
# Define the reusable operation demo; keep its logic separate from the trial.
def demo(message):
recipient=rsa.generate_private_key(public_exponent=65537,key_size=2048)
session=AESGCM.generate_key(bit_length=256); nonce=secrets.token_bytes(12)
ct=AESGCM(session).encrypt(nonce,message,None)
oaep=padding.OAEP(mgf=padding.MGF1(hashes.SHA256()),algorithm=hashes.SHA256(),label=None)
wrapped=recipient.public_key().encrypt(session,oaep)
server_record={'nonce':nonce,'ciphertext':ct,'wrapped_key':wrapped}
recovered_key=recipient.decrypt(server_record['wrapped_key'],oaep)
assert AESGCM(recovered_key).decrypt(nonce,ct,None)==message
try: AESGCM(recovered_key).decrypt(nonce,bytes([ct[0]^1])+ct[1:],None)
except InvalidTag: pass
else: raise AssertionError('Tampered ciphertext unexpectedly accepted')
return {k:len(v) for k,v in server_record.items()}
## 4. Execute reference controls
The program checks selected algorithm outcomes. Record the observed output. These checks do not replace the independent calculation assignment.
09Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC13 | Code cell 02 | Optional capstone — Hybrid cryptographic secure storage
# Purpose: 4. Execute reference controls The program checks selected algorithm outcomes. Record the observed output. These checks do not replace the independent calculation assignment.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
print('Hybrid encryption round trip and tamper rejection:', demo(b'Fictional IoT record'))
## 5. Controlled variation
Predict the effect of the parameter changes below. Compare each actual result to your prediction.
11Python · executable cell
PYTHON · Code cell
# =====================================================================
# EC13 | Code cell 03 | Optional capstone — Hybrid cryptographic secure storage
# Purpose: 5. Controlled variation Predict the effect of the parameter changes below. Compare each actual result to your prediction.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Repeat the same operation for each configured input so observations are comparable.
for message in (b"short",b"longer fictional reading"):
print(len(message),demo(message))
## Experimental analysis and submission
1. Record the reference input, predicted output and actual result.
2. Modify one independent variable and run the relevant cells again.
3. Explain the result using the theory and identify model limitations.
4. Save the notebook with outputs and retain the separate theoretical worksheet.
**Your derivation and conclusion:**
(Complete independently.)
13Instructions · 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. Client/server architecture and user registration — complete its numbered steps and record the requested evidence. 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.
Python implementation
Download the complete practical toolkit and extract it to a new directory. Keep the code and challenges folders together.
For the practical tasks, install PyCryptodome in your virtual environment. The included Python programs also support the cryptography library; the optional capstone uses cryptography.
Explore actual CPython execution traces from the included laboratory programs. Play, pause, step, inspect the current line, local variable values, function call stack, return values and output. Green variable cells changed relative to the preceding event. Line events show state before the highlighted line executes.
Run and visualize your own modified Python program
Download the Essential Cryptography Toolkit, extract it, and open a terminal in its code directory. Run the worked example or edit a copy. The trace generator executes your actual local Python file and creates an importable JSON record. Only run trusted code and use fictional keys and data.
Choose Import your trace in the visualizer and select my-trace.json. This works offline; the portal does not execute arbitrary Python on its server. The optional external Python Tutor link is suitable for standalone standard-library code, but external dependencies or local imports may not work.
For AES/DES exercises, install either supported cryptographic backend in an isolated Python environment as described in the Python code tab. Native library internals are not traced; the algorithm-specific browser workstations display the intermediate mathematics.
Why is a raw digest insufficient for authentication?
What happens if a malicious server substitutes a recipient public key?
Submission: Submit architecture, local test evidence, recipient round trip, tamper rejection and security limitations.
Export actual calculated observations from each workstation. Record your own predictions and conclusions, and distinguish browser calculations from local or physical measurements.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research