Repository navigation
AES and modes: remove dead declarations and modules - #4332
Merged
reaperhulk merged 1 commit intoNov 6, 2026
Merged
Conversation
Remove the proof and implementation declarations of the AES family, its modes and CMAC (Proof/ and Impl/ under Aes, AesCbc, AesCcm, AesCfb8, AesCtr, AesOcb, AesSiv, AesXts, Modes, Ocb, Xts, Cmac, CmacAes, CmacTripleDes) that nothing reachable from the registrations uses: 439 declarations, 14 of them whole modules, including 58 top-level `Verified` proofs that no registration exports. No Spec/, TCB/ or generated crate changes; Emit.lean --check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWvk94BdaBuW7gdPFjj
reaperhulk
enabled auto-merge
November 6, 2026 16:47
reaperhulk
deleted the
claude/unify-random-bytes-crypto-xqmg0z-deadcode-aes-modes
branch
November 6, 2026 17:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Like #4305 (DSA) and #4314 (ECDSA), this removes the proof and implementation declarations that nothing reachable uses, for the AES family, its modes and CMAC. The scope is the directories under
Proof/andImpl/namedAes,AesCbc,AesCcm,AesCfb,AesCfb8,AesCtr,AesOcb,AesOfb,AesSiv,AesXts,Modes,Ocb,Siv,Xts,Cmac,CmacAesandCmacTripleDes.It removes 439 declarations (429 in
Proof/, 10 inImpl/):AesCfb,AesOfbandSivhad nothing dead.Spec/orTCB/file changes.Emit.lean --checkpasses, so the emitted code is identical.247 files, +79 / −4,142.
Per directory:
CmacAes54,Aes53,CmacTripleDes53,AesOcb49,AesSiv49,Modes46,AesXts44,AesCcm36,AesCbc19,Cmac16,Ocb8,AesCfb86,Xts3,AesCtr3.How "dead" was decided
This follows the method of the shared dead-code tooling, the same one #4305 and #4314 used.
.ileanfiles of a full build at880b9378c.Artifacts/,Generic/,Variants/,TCB/andVerifiedGarbageTest/;*.leanfiles import..ileanfiles don't record:Generic/AesBlocks,AesCtr32,AesGcm,AesXtsandCmacAesUpdategroups, AES-GCM(-SIV)'s registrations, and the other ciphers' modes. Here "another algorithm" was matched by path component, soAesdoes not coverAesGcm.Deleted modules
Proof/AesXts/Arm/VerifiedProof/Cmac/ContractandProof/Cmac/TripleDesContract: the contracts of the old internalsubkeys/update/finalizeandinitfunctions, which only the dead*_verifiedproofs used.Proof/CmacTripleDes/{AArch64,X86_64}/{CT,Implies}Proof/Modes/AArch64/{CbcEncrypt,CbcDecrypt},Proof/Modes/X86_64/{CbcEncrypt,CbcDecrypt}andProof/Modes/RISCV64/{Ctr,Ctr32}. Only the chained CBC variants are emitted, so these were proofs of unchained functions.Proof/Xts/ContractTrimmed
There are 388 further declarations, mostly:
*_wp/*_ctpieces and layout facts;Impl.Modes.{AArch64,X86_64}.Core.cbcEncrypt/cbcDecryptand their proofs;Impl.AesSiv.X86.initand a few other unusedImpldefinitions.Removed top-level
Verifiedproofs (58)Each is a
Verified <target>proof of a routine that no registration file exports on any target. The registrations export other proofs for these functions:vg_aes_ctr32andvg_aes_expand_key: their*_framed,expandKey3_verifiedand the generic variants' proofs;init/absorb/finish_framed;Unitproofs and generic groups.These routines are only reached as internal callees, and their correctness (
*_correct) and constant-time (*_ct) proofs stay. The emitted functions are unchanged.Aes.{AArch64, AArch64.Aese, Arm, PPC64LE, RISCV64, X86, X86.AesNi, X86_64, X86_64.AesNi, X86_64.Vaes}.ctr32_verified,Aes.PPC64LE.expandKey_verified,Aes.X86_64.AesNi.Key.expandKey_verifiedAesXts.{AArch64, AArch64.Aes, Arm, PPC64LE, RISCV64, X86, X86_64, X86_64.OnePassNi, X86_64.Vaes}.{encrypt,decrypt}_verifiedAesXts.AArch64.{encrypt,decrypt}_verified_ofCmacAes.{AArch64, Arm, PPC64LE, RISCV64, X86, X86_64}.{subkeys,update,finalize}_verifiedCmacAes.AArch64.Aese.verified,CmacAes.X86_64.AesNi.verifiedCmacTripleDes.{AArch64, X86_64}.{init,update,finalize}_verifiedKept on purpose
These 11 look dead to the analysis, but each is used in a way the
.ileanfiles don't record. A rerun of the analysis on the final build finds only these:simp only [...]lists name them, and macro expansions leave no reference in the index:AesCbc.AArch64.{read8,write8}andAesOcb.AArch64.{read8,write8}AesCcm.AArch64.{imm_lit,setWidth_8_32}{AesCcm,AesOcb,AesSiv}.X86.readW_writeB_offModes.byte_xor_zero', used byModes/Wide.lean's localarith_ifsmacroModes.Arm.tabsOk_nilis named inOfbCfb.lean's(ht : … := by exact tabsOk_nil _ _)default arguments. The ARM CBC/OFB/CFB proofs of TripleDes, IDEA, Blowfish, CAST5, Camellia, SEED and SM4 elaborate those at their call sites.Each of these now has a one-line comment saying why it stays.
Other edits that come with the removal
Artifacts/AesXts/Arm.lean(AES-XTS's own) only drops the import of the deletedProof/AesXts/Arm/Verified(check_registrationspasses).Proof/CmacTripleDes/Scratch.leannow imports directly what the deletedProof/Cmac/TripleDesContractpassed on (Spec.Aes,Spec.TripleDes,TCB.Mem).ci/lean_speed_allowed.py:CmacTripleDes/*/CT.leanentries;CmacTripleDes/Arm/CT.lean's bare-assumptioncount from 2 to 1, ascheck_lean_speed.pyrequires.omit … inlines, an emptysection/variableblock and an empty namespace block;Proof.Xts/Proof.Cmaccontracts,*_verified, the unchained CBC functions and removed lemmas.Dead
Spec/definitions noticed in scope (not changed here)VG.Spec.Ocb.encryptWith_ctxVG.Spec.Ocb.decryptWith_ctxNo other
Spec/definition in these directories is dead (Spec/Aes0/42,Spec/Cmac0/54,Spec/Xts0/29).Checks
lake build --log-level=warningpasses (28,913 jobs);Emit.lean --checkpasses, with the standard axiom audit;git status crates/is clean;check_lean_public_imports.py --base origin/main -m <modified modules>passes.check_lean_single_importer.py --base origin/mainandrun_unit_tests.py(641 tests).cargo fmt --checkandcargo clippy --all-targets -- -D warningspass. No Rust changed.sorry,admit,native_decide,bv_decideormaxHeartbeats.No benchmark: the emitted code is unchanged.
Generated by Claude Code