Hashing, message authentication, encryption and signatures serve different goals. Verification depends on exact bytes and the appropriate key.
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.
Related course access:IoT Security and Privacy — same laboratory, notebook and completion record.
BC-M02 · Academic orientation
Scope and objectives
Scope of the experiment
Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
The focus of this experiment is to distinguish digest, encryption and keyed authentication. Students then calculate and compare hash avalanche observations, and verify integrity and explain the trust requirement for reference values. 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
Distinguish digest, encryption and keyed authentication.
Calculate and compare hash avalanche observations.
Verify integrity and explain the trust requirement for reference values.
Identify the configured inputs (Original message; Receiver message; Sender demo HMAC key; Verifier demo HMAC key; Additional operation) 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 distinguish digest, encryption and keyed authentication, calculate and compare hash avalanche observations, and verify integrity and explain the trust requirement for reference values.
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 integrity and explain the trust requirement for reference values. 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 Decentralization, replication and CAP.
Environment and experimental methodology
The listed browser model and experiment-specific local Python, Solidity or EVM workflow, where provided. Do not treat a model as a deployed ledger.
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.
Scientific theory · Cryptographic primitive distinctions
A hash commits bytes without a key; a MAC uses a shared key to authenticate; a signature uses a private key with public verification; encryption protects confidentiality. AEAD combines encryption and authentication including associated data. Avalanche describes sensitivity of output to changes, not a proof of collision resistance.
Worked example and engineering interpretation
Changing a single input bit usually changes many digest bits. Compare two SHA-256 digests using XOR and Hamming distance; the distance lies between 0 and 256. A shared-key MAC can be produced by any key holder, unlike a signature verified against an independently trusted public key.
Engineering principles · additional worked teaching example
A digest compares exact byte sequences against a trusted reference; HMAC uses a shared secret to authenticate them. Hamming distance counts XOR set bits: 0xA5 XOR 0xA1=0x04, one differing bit. This small example explains the metric, not SHA-256 output.
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
Engineering reference configuration: Original message = temperature=25; Receiver message = temperature=25; Sender demo HMAC key = lab-key; Verifier demo HMAC key = lab-key; Additional operation = ECDSA signature. In the classroom model, Changed SHA-256 bits = 0; Changed SHA-512 bits = 0; HMAC verifies = Yes; Signature verifies = Yes. The same message can have a matching digest but fail HMAC when the verification key is wrong. Digital signature and encryption use different key operations. Actual browser Web Crypto and SHA-256 fallback; ephemeral teaching keys. RSA-OAEP plaintext is bounded by the RSA-2048/SHA-256 message limit.
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 · 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.
Teaching example only; inspect live calculations or real practical evidence separately.
How to investigate Hashing, authentication and avalanche
Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
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: Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
Enter identical original and candidate text. Inspect UTF-8 bytes, both SHA sizes and the changed-bit count (0).
Change one character, then add one space instead. Compare actual 256- and 512-bit Hamming distances; avalanche is a statistical property, not exactly half every time.
Keep candidate identical but change verifier HMAC key. Verify hash equality remains true while authentication fails.
Select ECDSA and modify candidate again; observe signature verification. The verifier does not need the private key.
Reference check: Identical strings yield the same digest and zero changed bits. A changed sample yields a different digest; bit distance is measured, not prescribed.
Model boundary: An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed.
Independent task and submission evidence
2. Change one character, then add one space instead. Compare actual 256- and 512-bit Hamming distances; avalanche is a statistical property, not exactly half every time. 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.
Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
Learning goals
Explain the mechanism using the actual intermediate states in this experiment.
Predict and verify the reference and modified conditions described below.
Interpret the acceptance criteria and identify the limits of the model.
Module flashcards · 12 questions
Browse all 12 questions and explanationsHow many bits are in SHA-256 and SHA-512 digests?
256 and 512 respectively.
Is a SHA-256 digest a MAC?
No. A MAC requires a secret key and provides a different security property.
What does avalanche mean?
A small input change tends to cause a large digest change; not exactly 128 bits for every pair.
Why hash UTF-8 bytes consistently?
Different encodings can represent different byte strings and therefore different digests.
How many hexadecimal characters represent SHA-256?
64, since each hex digit represents four bits.
How do we calculate the bit distance?
XOR corresponding digest bits and count the one bits.
Does hashing encrypt the original message?
No; it is a one-way digest function, not reversible encryption.
What can HMAC provide that a bare digest cannot?
Message authentication with a shared secret key, subject to key security and freshness controls.
What is the bit distance when both inputs are temperature=25?
Zero, because the SHA-256 digests are identical.
What does changing temperature=25 to temperature=26 test?
Avalanche behavior; compare the calculated digest bits.
Must every one-character change flip exactly 128 bits?
No. The observed Hamming distance varies.
Why test a trailing space separately?
It changes the UTF-8 byte sequence even if the visible text looks similar.
Engineering diagram · BC-M02. Use the interactive workstation to investigate the calculated state.Loading experiment-specific apparatus…Previous model / additional reference tools
Loading computational workbench…
Independent theoretical exercises
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 temperature=25 and temperature=26, write the UTF-8 inputs and explain expected SHA and HMAC differences. Calculate SHA-256 and SHA-512 output sizes in bytes and hex digits.
Engineering method — A digest compares exact byte sequences against a trusted reference; HMAC uses a shared secret to authenticate them. Hamming distance counts XOR set bits: 0xA5 XOR 0xA1=0x04, one differing bit. This small example explains the metric, not SHA-256 output. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
Construct an operation/key table for HMAC, ECDSA and public-key encryption. Predict outcomes for wrong key and altered message.
Engineering method — A digest compares exact byte sequences against a trusted reference; HMAC uses a shared secret to authenticate them. Hamming distance counts XOR set bits: 0xA5 XOR 0xA1=0x04, one differing bit. This small example explains the metric, not SHA-256 output. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Security analysis
Security analysis · Independent work
A receiver obtains an altered telemetry record and its newly calculated unkeyed hash. Why does matching that hash not establish sender authenticity? What does a correct HMAC check add?
Security analysis — A digest compares exact byte sequences against a trusted reference; HMAC uses a shared secret to authenticate them. Hamming distance counts XOR set bits: 0xA5 XOR 0xA1=0x04, one differing bit. This small example explains the metric, not SHA-256 output. 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 · BC-M02-01
Use the reference configuration (Original message = temperature=25; Receiver message = temperature=25; Sender demo HMAC key = lab-key; Verifier demo HMAC key = lab-key; Additional operation = ECDSA signature), but change Receiver message = temperature=26. The model reports Changed SHA-256 bits = 128. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Quantitative comparison
Independent theoretical exercise · BC-M02-02
Two model observations of Changed SHA-256 bits are 0 (reference) and 128 (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 · BC-M02-03
For Verifier demo HMAC key = wrong-key, the model supplies this excerpt from Exact cryptographic inputs and outputs:
Operation · Original · Candidate
Input hex · 74656d70657261747572653d3235 · 74656d70657261747572653d3235
SHA-256 · 3ad08815cc298024402a45e89c9e4737b6926d7dd49bb3fb92e902362541cfc2 · 3ad08815cc298024402a45e89c9e4737b6926d7dd49bb3fb92e902362541cfc2
SHA-512 · 1ff5be5c67cf5d4f4513a3873597549b25c12d93b573638b361172a8e9dbf0e1c0761682e3b72c3b90ce… · 1ff5be5c67cf5d4f4513a3873597549b25c12d93b573638b361172a8e9dbf0e1c0761682e3b72c3b90ce…
HMAC-SHA-256 · b2545705b003e606b6ecf8e694077b9bbabe2d750d9ea3f1824702e888b38c6b · 0cd9a532f67410c8505acd40b4a070b72291a57db653515a972b602033427bcd
Count rows whose Original value is exactly “74656d70657261747572653d3235”, and identify the displayed row numbers. Explain what the count describes.
Advanced · Reverse reasoning
Independent theoretical exercise · BC-M02-04
An observation is HMAC verifies = No. Candidate A uses Original message = temperature=25; Receiver message = temperature=25; Sender demo HMAC key = lab-key; Verifier demo HMAC key = lab-key; Additional operation = ECDSA signature. Candidate B changes the listed settings (Verifier demo HMAC key = wrong-key) 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 · BC-M02-05
A student configures Verifier demo HMAC key = wrong-key while preserving all other reference settings, but copies the reference report of HMAC verifies = Yes. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · BC-M02-06
Design a controlled comparison for Hashing, authentication and avalanche using reference Original message = temperature=25; Receiver message = temperature=25; Sender demo HMAC key = lab-key; Verifier demo HMAC key = lab-key; Additional operation = ECDSA signature and test Receiver message = temperature=26. Specify the changed setting(s), measured metric Changed SHA-256 bits, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Experimentally distinguish digest properties, authentication, digital signatures and confidentiality.
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.
Original messagetemperature=25
Receiver messagetemperature=25
Sender demo HMAC keylab-key
Verifier demo HMAC keylab-key
Additional operationECDSA signature
2 · Perform the investigation in order
Enter identical original and candidate text. Inspect UTF-8 bytes, both SHA sizes and the changed-bit count (0).
Change one character, then add one space instead. Compare actual 256- and 512-bit Hamming distances; avalanche is a statistical property, not exactly half every time.
Keep candidate identical but change verifier HMAC key. Verify hash equality remains true while authentication fails.
Select ECDSA and modify candidate again; observe signature verification. The verifier does not need the private key.
Select RSA-OAEP encryption, then AES-GCM encryption. Inspect actual ciphertext sizes and successful decryption. Compare public-key versus shared-key roles and distinguish these operations from signatures.
Use only fictional messages; record exact bytes, not just displayed glyphs.
Explain preimage/collision resistance, digest versus MAC, and why neither hashing nor signing encrypts the message.
Required evidence: Comparison of digest, MAC, signature and encrypted-data observations.
Model boundary: Actual browser Web Crypto and SHA-256 fallback; ephemeral teaching keys. RSA-OAEP plaintext is bounded by the RSA-2048/SHA-256 message limit.
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
Identical bytes
Use reference inputs above
Record actual outcome and units
One character
Receiver message = temperature=26
Record actual outcome and units
Different verifier key
Verifier demo HMAC key = wrong-key
Record actual outcome and units
RSA encryption
Additional operation = RSA-OAEP encryption
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 module reference toolkit; genuine SHA-256 and bounded search. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
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: An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed. Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# BC-M02 · Hashing, authentication and avalanche
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
## 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 module reference toolkit; genuine SHA-256 and bounded search. 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
Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Enter identical original and candidate text. Inspect UTF-8 bytes, both SHA sizes and the changed-bit count (0).
2. Change one character, then add one space instead. Compare actual 256- and 512-bit Hamming distances; avalanche is a statistical property, not exactly half every time.
3. Keep candidate identical but change verifier HMAC key. Verify hash equality remains true while authentication fails.
4. Select ECDSA and modify candidate again; observe signature verification. The verifier does not need the private key.
5. Select RSA-OAEP encryption, then AES-GCM encryption. Inspect actual ciphertext sizes and successful decryption. Compare public-key versus shared-key roles and distinguish these operations from signatures.
**Evidence:** Identical strings yield the same digest and zero changed bits. A changed sample yields a different digest; bit distance is measured, not prescribed.
**Boundary:** An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed.
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
# =====================================================================
# BC-M02 | Code cell 01 | Hashing, authentication and avalanche
# 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
# =====================================================================
# BC-M02 | Code cell 02 | Hashing, authentication and avalanche
# Purpose: implement only the mechanism named in this laboratory.
# Inputs: the explicit fictional fixture and reference parameters below.
# Output: printed observations and assertions for the controlled trial.
# =====================================================================
import hashlib,hmac
message=b'temperature=25';candidate=b'temperature=26';key=b'public classroom key'
for algorithm in (hashlib.sha256,hashlib.sha512):
a,b=algorithm(message).digest(),algorithm(candidate).digest()
print(algorithm().name,len(a)*8,'bits; changed bits',sum((x^y).bit_count() for x,y in zip(a,b)))
assert not hmac.compare_digest(hmac.digest(key,message,'sha256'),hmac.digest(key,candidate,'sha256'))
print('HMAC verification rejects changed message')
## 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
python3 reference.py hash --message "temperature=25" --candidate "temperature=26"
```
08Instructions · 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 module reference toolkit; genuine SHA-256 and bounded search. Notebook success does not certify external equipment or services.
09Instructions · 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. Change one character, then add one space instead. Compare actual 256- and 512-bit Hamming distances; avalanche is a statistical property, not exactly half every time. 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.
Formative assessment
Explain the following without looking at the simulation output, then reveal the reference response.
How many bits are in SHA-256 and SHA-512 digests?
256 and 512 respectively.
Is a SHA-256 digest a MAC?
No. A MAC requires a secret key and provides a different security property.
What does avalanche mean?
A small input change tends to cause a large digest change; not exactly 128 bits for every pair.
Why hash UTF-8 bytes consistently?
Different encodings can represent different byte strings and therefore different digests.
Applied task
Change one character and rebuild. Inspect UTF-8 bytes, full hashes and XOR bit count.
Submit your reference and modified observations with a justification.
The original tutor and adaptive examination retain their existing 102-lab catalogue. Use the module-specific study questions above and copy this contextual prompt into your chosen AI assistant if needed.
Explain the engineering mechanism in BC-M02 · Hashing, authentication and avalanche. My task: Distinguish a digest from confidentiality and origin authentication. Observe SHA-256 and SHA-512 concepts, digest comparison and avalanche effects using actual SHA-256 computations.. Acceptance: Identical strings yield the same digest and zero changed bits. A changed sample yields a different digest; bit distance is measured, not prescribed.. Model boundary: An unkeyed hash is not a MAC, signature or encryption. SHA-512 and signature examples remain conceptual unless separately executed.. Ask me for my actual observations and distinguish model predictions from real measurements.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research