Skip to content

AArch64: AES-GCM's powers of H from the key context, verified (vg_aes_gcm_store_powers_aes) - #4338

Merged
alex merged 1 commit into
mainfrom
claude/audit-4139-gcm-aarch64-powers
Nov 6, 2026
Merged

alex merged 1 commit into
mainfrom
claude/audit-4139-gcm-aarch64-powers

Conversation

@alex

@alex alex commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Part of #4139 (finding 5: AES-GCM on AArch64: the powers of H)

This implements vg_aes_gcm_store_powers (spec #4317) on AArch64 and deletes the Rust that did its work. There are no Spec/ or TCB changes.

Before

AesGcm::store_powers (src/aead/aes_gcm.rs) read the hash subkey out of the key context at a fixed offset (self.key()[30..]). It then called vg_ghash_store_powers_aes(h, &mut y, h, 0, scratch, &mut self.powers) over zero blocks, with a dummy y and a scratch buffer, only to get the powers. The _with_powers seal/open functions require those powers for their key context, and that held only because the Rust's offset arithmetic was right.

After

  • Impl/Gcm/AArch64/Pmull.lean: a new keyPowers, vg_aes_gcm_store_powers_aes(ctx, pw). It is straight-line and built from the existing PMULL pieces of vg_ghash_store_powers_aes:
    • load H from byte 240 of the context (ctxH);
    • twist it into H';
    • compute H'² to H'⁸ with powersS;
    • store all eight to pw at pwOff.
  • Proof/Gcm/AArch64/Pmull/Ghash.lean: keyPowers_verified, against Spec.Gcm.storePowersContract, including constant time (taint_decide). It follows ghashS's proof, with a smaller invariant KP for the powers, since no GHASH state is involved.
    • It lives in Ghash.lean rather than a new module: a new module importing Pmull/Ghash would be the 41st importer of Proof/Gcm/Poly.lean's algebra (check_lean_speed.py's limit is 40).
  • Artifacts/Gcm/AArch64.lean: registers it with suffix _aes and features ["aes"]. Every AArch64 backend with _with_powers instances has those features; the backend feature test now checks VG_AES_GCM_STORE_POWERS_AES_FEATURES instead of VG_GHASH_STORE_POWERS_AES_FEATURES.
  • Rust: store_powers is now a single call, vg_aes_gcm_store_powers_aes(ctx, &mut self.powers). The offset read of H, the zero-block GHASH call, the dummy y, the scratch buffer and the SCRATCH_WRITTEN assertion are deleted.
  • Unchanged:
    • vg_ghash_store_powers_aes stays, because the verified *_store_powers seal/open still call it.
    • x86-64 already does this in verified code (vg_aes_gcm_prepare*).
    • The other architectures have no _with_powers path.
    • README's "What is not verified" has no entry for this, so it is unchanged.

The only generated change is the new function in crates/verified-garbage-asm-aarch64/{src,assembly}/gcm.*.

Checks

  • Lean:

    • lake build of Artifacts.Gcm.AArch64 and every module that imports Pmull/Ghash (the Generic AES-GCM, AES-GCM-SIV and SM4-GCM AArch64 files); no warnings.
    • The full Emit.lean.
    • EmitOne --check Gcm.AArch64.
    • check_lean_public_imports.py on the edited modules.
    • Every script of the Static checks job.
  • Rust:

    • cargo fmt --check.
    • cargo clippy --target aarch64-unknown-linux-gnu --all-targets -D warnings.
    • The AES-GCM tests, Wycheproof included, under qemu-aarch64 with VG_CPU_FEATURES unset, none, aes and aes,sha3.
  • Benchmark: a scoped manual run on AArch64 (aes_gcm, default features and aes, against Spec: vg_aes_gcm_store_powers, GCM's eight powers of H from a key context #4317's merge commit): https://github.com/pyca/verified-garbage/actions/runs/42256280331. The change only affects key setup (AesGcm::new), and its speed is unchanged:

    Benchmark Default features aes
    aes-128-gcm-new/16 90 → 91 ns (0.4% slower) 90 → 91 ns (0.5% slower)
    aes-256-gcm-new/32 103 → 102 ns (1.4% faster) 103 → 102 ns (1.3% faster)

    Seal and open moved by at most 0.4%.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TKUFHFkei8WwGgosqeREs4

@alex
alex added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 408cf68 Nov 6, 2026
38 checks passed
@alex
alex deleted the claude/audit-4139-gcm-aarch64-powers branch November 6, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants