Skip to content

AES-GCM x86-64: one proof of the VAES encryption loop, in place and out of place - #4409

Merged
reaperhulk merged 2 commits into
mainfrom
claude/gcm-enc-body-shared
Nov 7, 2026
Merged

reaperhulk merged 2 commits into
mainfrom
claude/gcm-enc-body-shared

Conversation

@reaperhulk

Copy link
Copy Markdown
Member

Follows pyca/verified-garbage#4391, which made the 256-bit out-of-place encryption loop (StitchTo) use the in-place batch. Its loop proofs (body, first group, loop, last group and stores) were still a separate copy of the in-place ones. Now one proof covers both outputs, and both sets of lemmas are its cases. The code is unchanged.

Proofs.

  • Stitch/Loop.lean:
    • EInvM ix is EInv over the output (wp ix, the data or the buffer at r10), with rdx at the output and, out of place, r8 holding src - dst.
    • bodyM_ok is the body for both, through batchM_ok in its load mode.
    • QG.keepW now takes any base for the blocks the GHASH loads read, so it keeps the hash of the ciphertext in the output, which the batch's writes skip by their offsets.
    • body_ok is the in-place case.
  • Stitch/Enc.lean: ReadyM, firstM_ok, cmpEM_ok, loopEM_from_ok, EPostM (the output block by block), finalM_ok and encTailM_ok. first_ok, cmpE_ok, loopE_from_ok, loopE_ok, final_ok and encTail_ok are the in-place cases.
  • StitchTo/Loop.lean: bodyTo_ok, firstTo_ok, loopE_ok, finalTo_ok and encTailTo_ok are the out-of-place cases, through EInvTo.toM, EInvM.toTo, ReadyTo.toM and EPostM.toEPostTo. Their statements are unchanged, so their users (StitchR/OnePass.lean, StitchR/RemETo.lean, Prepared/OutOfPlace.lean) are unchanged.
  • Stitch/Aes.lean: batchM_ok states rdx's base as wp ld s₀, the same term the loop invariants use.

Net, the proofs lose 123 lines. The 512-bit out-of-place encryption loops (StitchZTo, StitchZHTo) are the follow-up.

Trust. No Spec/ or TCB/ changes, and no change to the emitted code (Emit.lean --check), so there are no Rust, test or benchmark changes.


Generated by Claude Code

@github-actions github-actions Bot added the untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified. label Nov 7, 2026
@reaperhulk
reaperhulk added this pull request to stack #4420 November 7, 2026 09:41
@reaperhulk
reaperhulk enabled stacked auto-merge November 7, 2026 09:42
@reaperhulk
reaperhulk added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit d2f38e6 Nov 7, 2026
14 checks passed
@reaperhulk
reaperhulk deleted the claude/gcm-enc-body-shared branch November 7, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

untrusted-only This changes exclusively implementations and proofs, and thus is entirely formally verified.

Development

Successfully merging this pull request may close these issues.

2 participants