> Snapshot of projects/fog-crypto-core/testbench/README.md — 28 Nov 2026

# Fog-Crypto Core — Virtual test bench (VV)

Verification & Validation plan for CMMI-DEV v2.0, Level 3. Closes the audit and engineering
reviews #1–#4. Revision 1.4.

## Verification requirements

- **REQ-FOG-VV-001** — UVM: SVA assertions, functional coverage ≥ 95 %, constrained-random stimulus
  **plus fault injection**.
- **REQ-FOG-VV-002** — software golden-model co-simulation (bit-exact AES-256-GCM + fixed-point CIC).
- **REQ-FOG-VV-003** — hardware-in-the-loop / on-board benchmark on ZU3EG.

## Strategy

- **Unit (TDD)**: AES core (≥ 1 block/16 cycles), 4-stage GHASH (H⁴), CIC, moving average,
  descriptor rings, RTL AXI4-Lite TrustZone filter.
- **Integration**: ADC → DSP → `PL_PS_IRQ0` alert; Ethernet → AES-256-GCM enclave → split-cache
  SG-DMA → PL MAC.
- **Fault injection** (VV-001): truncated ingress frames, corrupted GCM tags, KAT failure, `tx_er`
  assertion, non-secure `AxPROT[1] == 1'b1` bus rejection, and store-and-forward `tag_ok` purge.
- **Security**: RTL AXI4-Lite TrustZone filter (not PG293), CSU-PUF + AES-256-KW key load, 96-bit IV
  monotonicity + reset session-key rotation, DOM share-merge TCL check, NIST CAVP + FIPS 140-3 KAT.
- **CDC/timing**: scoped XDC with `set_bus_skew`, OOC synthesis gate on ZU3EG (≤ 15 000 LUTs).

## Success criteria

Aligned with `requirements/REQ.md` acceptance criteria; measurements archived in `performance/`.

## Milestone 0 — Golden Reference Model A (done)

An independent, bit-exact AES-256-GCM oracle is now vendored and validated as the
cross-check target for our own SystemVerilog core (REQ-FOG-VV-002).

- **Location**: `golden_model_a/` (provenance + toolchain in `golden_model_a/VENDOR.md`).
- **What**: BLu85 AES-256-GCM (Apache-2.0), VHDL, configured mode=256 / size=L.
- **Validation** (all passing, cocotb 2.x + GHDL):
  - **NIST CAVP GCM AES-256, IVlen=96** — full corpus of **3,933 vectors** (2,625 encrypt
    + 1,308 decrypt, all Taglen 32–128 bits) bit-exact. A 263-vector representative sample
    is committed as the repeatable gate.
  - **pycryptodome** — 42-case randomized encrypt/decrypt sweep (lengths 0–512 B).
  - Upstream README's published AES-256 vector.
- **Run**: `golden_model_a/run_golden_a.sh` (self-contained: downloads GHDL, creates venv).

## Milestone 1 — cross-check harness (done)

The simulator-specific pieces are separated so the same corpus + oracle can drive
any AES-256-GCM DUT.

- `golden_model_a/tests/vectors.py` — canonical case format + CAVP loader +
  randomized generator + pycryptodome oracle (no cocotb/GHDL import).
- `golden_model_a/tests/crosscheck.py` — simulator-agnostic runner with a documented
  adapter contract: `run_vector(dut, key, iv, aad, data, enc_dec) -> (out, tag)`.
- `golden_model_a/tests/test_aes_gcm.py` — Model A adapter + thin cocotb tests.
- **SystemVerilog path proven**: Verilator 5.054 + cocotb 2.1.0 works
  (`golden_model_a/sv_smoke/`, built via `golden_model_a/setup_verilator.sh`).

M2 plugs our own SystemVerilog core in through the same adapter contract; M3 runs
this corpus against both and diffs.
