Chapter 30 — Verification laboratory I
Lesson map
Lesson 30 published. Map, example, EX088.
flowchart TD
N0["Learning outcomes"]
N1["30.1 Purpose of verification"]
N2["30.2 Authenticity and replay tests"]
N3["Lab — Authenticity and replay verification"]
N4["30.3 Recording evidence"]
N5["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5
N5 --> EX["Worked example"]
EX --> Q["Exercise EX088"]
Logical drawing
flowchart LR
N0["Learning outcomes"]
N1["30.1 Purpose of verification"]
N2["30.2 Authenticity and replay tests"]
N3["Lab — Authenticity and replay verification"]
N4["30.3 Recording evidence"]
N5["Synthesis"]
N0 --> N1 --> N2 --> N3 --> N4 --> N5 --> Q["EX088"]
[Learning outcomes]
|
v
[30.1 Purpose of verification]
|
v
[30.2 Authenticity and replay tests]
|
v
[Lab — Authenticity and replay verification]
|
v
[30.3 Recording evidence]
|
v
[Synthesis]
|
v
[Worked example] --> [Exercise EX088]
Learning outcomes
You will (1) verify that implemented controls meet their specifications; (2) run positive and negative test cases for record authenticity and replay; (3) record verification evidence.
30.1 Purpose of verification
Verification asks whether the system was built as specified. In Verification Laboratory I, Sofia tests the ingestion component's authenticity and replay controls in an isolated lab with synthetic validators. Her test plan comes directly from the control specifications: each requirement has positive tests showing correct behaviour and negative tests showing that bad inputs are rejected. The lab environment uses synthetic keys and data only. Verification evidence will support the assurance case later, so every test records inputs, expected results, actual results, environment version and date in a consistent format.
30.2 Authenticity and replay tests
In the lab, validators authenticate tap records with a message authentication code using a key shared with ingestion, a simplified stand-in for the production signatures, implemented with Python's hmac module. Sofia's script sends four synthetic records: an authentic new record, a duplicate of it, a record with an altered amount and a record from a retired validator whose key has been removed. The lab below shows ingestion accepting only the first. She compares the results with expected outcomes and finds all four match. A mismatch would have been a defect to raise, not a test to adjust.
Lab — Authenticity and replay verification
# Lab ingestion check: HMAC stand-in for validator signatures + replay store. Synthetic keys only.
import hmac, hashlib
keys = {"V-101": b"lab-key-101", "V-102": b"lab-key-102"} # V-099 retired: key removed
seen = set()
def tag(k, rec): return hmac.new(k, rec, hashlib.sha256).hexdigest()
def ingest(vid, rec, t):
k = keys.get(vid)
if k is None: return "reject: unknown or retired validator"
if not hmac.compare_digest(tag(k, rec), t): return "reject: bad tag"
rid = rec.split(b",")[0]
if (vid, rid) in seen: return "reject: replay"
seen.add((vid, rid)); return "accept"
r = b"R-5521,C100,2.40"
t = tag(keys["V-101"], r)
print("authentic:", ingest("V-101", r, t))
print("duplicate:", ingest("V-101", r, t))
print("altered amount:", ingest("V-101", b"R-5522,C100,0.10", tag(keys["V-101"], b"R-5522,C100,2.40")))
print("retired validator:", ingest("V-099", b"R-7,C200,2.40", tag(b"old-099", b"R-7,C200,2.40")))
Run with python3 lab_ingest.py. Verified output:
authentic: accept
duplicate: reject: replay
altered amount: reject: bad tag
retired validator: reject: unknown or retired validator
30.3 Recording evidence
Sofia writes a verification report with a table of tests, outcomes and evidence links, and notes what was not verified: performance under peak load, behaviour during database failover and the production signature path, which uses a different mechanism. She signs and dates the report and stores it with a hash in the project's evidence repository. Daniel reminds her that verification shows conformance to specification; whether the specification itself is adequate is a separate question addressed by validation, which comes later in the course.
Worked example
Sofia runs four authenticity and replay tests in an isolated lab, finds all match expectations and records a report listing three areas not yet verified.
Synthetic case. The lab, keys and records are synthetic; HMAC stands in for production signatures.
Errors and limits
Lab environments differ from production in scale and timing. Passing tests depend on the quality of the test cases.
Exercises
- EX088 — Verification question. What question does verification answer? Rubric: 3 = was the system built as specified;; 2 = as specified;; 1 = is it useful;; 0 = none.
- EX089 — Lab outcomes. Which of the four lab records were accepted? Rubric: 3 = only the authentic new record; duplicate, altered and retired rejected;; 2 = only first;; 1 = several;; 0 = none.
- EX090 — Not verified. Name one area Sofia's report lists as not verified. Rubric: 3 = peak load, database failover or production signature path;; 2 = one;; 1 = vague;; 0 = none.
Synthesis
Verification tests controls against their specifications with positive and negative cases and records honest evidence of scope.
Continue studying — chapter 30 of 50
← Chapter 29 (draft) · Course chapter index · Chapter 31 (draft) →