← All articles
FPGA · Security

AES-256-GCM on FPGA: bit-exact against the full NIST CAVP corpus

The only trustworthy way to claim a crypto core is correct is to hold it up against an oracle you did not write. Fog-Crypto Core now passes the full NIST CAVP GCM AES-256 corpus — 3,933 vectors — bit-exact, in simulation.

An independent oracle first

We started backwards. Before writing a single line of our own SystemVerilog, we vendored an independent golden reference: BLu85 AES-256-GCM (Apache-2.0, VHDL). We validated that against the NIST CAVP GCM AES-256 corpus (3,933 vectors, IV length 96) and a pycryptodome randomized sweep. Only a reference that is itself proven bit-exact can judge our implementation.

Then our own core, through the same seam

The testbench exposes a simulator-agnostic seam — run_vector(dut, key, iv, aad, data, enc_dec) → (out, tag) — so the same corpus drives both the VHDL oracle and our SystemVerilog DUT under Verilator + cocotb. Our aes256_gcm.sv datapath runs the whole corpus and diffs bit-exact against the oracle.

The GHASH lesson

The first GHASH was a combinational 128-iteration shift-and-add — a ~128-level XOR chain that cannot meet 150 MHz. It became a 4-stage carryless-multiply + polynomial-reduction pipeline (bit-reverse → CLMUL → reduction x¹²⁸ = x⁷+x²+x+1 → bit-reverse): one multiply per cycle, latency 4. That single change is what makes the line-rate target plausible.

Correctness is not security

A bit-exact GCM core can still leak plaintext if you wire decryption naively. The store-and-forward wrapper (aes256_gcm_saf.sv) enforces REQ-FOG-SEC-002: decryption buffers plaintext, verifies the received tag, releases only on tag_ok, and on mismatch zeroizes and asserts ERR_CRYPTO_FAULT. Encryption streams unchanged. Fault injection covers the fail-safe path.

What this does — and does not — prove

It proves the datapath is functionally correct for the full official corpus. It does not yet prove timing, area, or the on-board KPIs — those need the Vivado out-of-context synthesis gate and a ZU3EG bench. That is exactly the next step, and the script and XDC are already prepared.

The discipline generalises: vendor an oracle, prove the oracle, then diff your own implementation against it through one seam. Crypto on an FPGA is unforgiving — every vector must match, not most of them.