Skip to content

RC2-CBC: delete the update functions, which nothing calls - #4877

Merged
alex merged 2 commits into
mainfrom
claude/vg-rc2-drop-update
Nov 10, 2026
Merged

alex merged 2 commits into
mainfrom
claude/vg-rc2-drop-update

Conversation

@alex

@alex alex commented Nov 9, 2026

Copy link
Copy Markdown
Member

Part of #4548. The Rust API and verified code never call vg_rc2_cbc_encrypt_update or vg_rc2_cbc_decrypt_update:

  • src/cipher/rc2/cbc.rs takes whole blocks only, through vg_rc2_cbc_init and the _chained functions.
  • Its context's pending bytes are "always empty at this API".

So this PR deletes the two functions, on all six targets, instead of making them internal.

What changes

Code (Impl/Rc2/<Target>/Stream.lean).

  • The update code goes, along with the copy loops and CBC calls only it used.
  • init is unchanged.
  • AArch64 keeps its byte copy (copy, copyBody), which ECDSA's verification uses (Impl/Ecdsa/AArch64/VerifyHash.lean).

Proofs (Proof/Rc2/<Target>/Stream/).

  • Deleted modules:
    • AArch64: Update and Prep
    • PPC64LE and RISC-V: Update and Copy
    • x86-64 and ARMv7: Long
    • x86: UpdateLong
  • Deleted declarations: the update contracts, correctness, constant-time and frame theorems and satisfying states, wherever they lived.
  • AArch64's Copy stays for ECDSA. init's proof now has the two small helpers it used from Prep.
  • ARMv7: two region lemmas init uses move from the deleted update section to Common.lean.
  • x86: helpers of the deleted section that init uses stay (test_ok, beq_zero, contains_prefix, the wide_pre/rc2_stream_narrow tactics, without their update lemmas).
  • Shared: Proof/Rc2/Scratch.lean loses cbcUpdateScratch* and the update *_local lemmas, and Proof/Rc2/Stream.lean loses update_eq, update_post_short and update_post_long, with the lemmas only they used.
  • Docs that described the update functions now describe init only.

Registrations (Artifacts/Rc2/<Target>.lean). The cbcEncryptUpdateApi and cbcDecryptUpdateApi entries go.

Generated crates.

  • The update functions, their dispatchers and declarations are gone.
  • So are the internal vg_rc2_cbc_encrypt and vg_rc2_cbc_decrypt that only they called.

Test (VerifiedGarbageTest/Internal.lean). Its fixture was the streaming functions, which called the internal CBC functions, which called the block functions. Now:

  • The fixture is all of RC2's AArch64 artifacts: init calls vg_rc2_expand_key, and rc2_cbc calls the block functions from a module other than rc2.
  • The internal-calls-internal case comes from AES-XTS, whose internal functions call AES's (now internal) block functions.

CI data.

  • ci/residue_allowlist.txt loses x86_64 vg_rc2_cbc_{en,de}crypt_update.
  • ci/lean_speed_allowed.py lowers two counts, since the patterns went with the deleted code.

No Spec/ or TCB/ change. The follow-up Spec PR deletes:

  • Spec.Rc2.cbcUpdateSig, cbcUpdatePre, cbcUpdatePost, cbcUpdateContract, cbcEncrypt/DecryptUpdateContract, cbcUpdateSafety and the two Apis;
  • Spec.Rc2.update;
  • init's summary text that points at the update functions.

init's contract keeps the context, contextAt included.

Checks

  • lake build (all modules), Emit.lean, and Emit.lean --check
  • the Static checks job's scripts
  • check_lean_public_imports.py on each edited module
  • cargo fmt --check, cargo clippy --all-targets -D warnings
  • cargo test with Wycheproof, and the RC2 tests with VG_CPU_FEATURES=none
  • All of the above ran before the rebase onto main, whose only change since was Spec: delete FFDH generate_key_cached's Api and contract #4876 (FFDH's Spec).

Generated by Claude Code

Neither Rust (src/cipher/rc2/cbc.rs takes whole blocks, through init and
the chained functions) nor verified code calls vg_rc2_cbc_encrypt_update
or vg_rc2_cbc_decrypt_update. Their code, proofs and registrations go on
all six targets, with the internal CBC functions only they called, the
shared update lemmas and scratch contracts, and their residue-allowlist
lines. AArch64 keeps its byte copy, which ECDSA's verification uses.

The internal-function test's fixture was the streaming functions; it now
takes all of RC2's AArch64 artifacts, and an internal function naming
another from AES-XTS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFjAR7Byf513R4zuFy
@alex
alex added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 1819da6 Nov 10, 2026
41 checks passed
@alex
alex deleted the claude/vg-rc2-drop-update branch November 10, 2026 02:56
alex pushed a commit that referenced this pull request Nov 10, 2026
#4877 deleted vg_rc2_cbc_encrypt_update and
vg_rc2_cbc_decrypt_update, which nothing called. Their signature, pre-
and postconditions, contracts, safety items and Apis go, with
Spec.Rc2.update and Spec.Rc2.blocks, which only they used. The module
doc describes initialization, which the chained functions continue from,
and init's summary points at the chained functions; the generated crates'
documentation of vg_rc2_cbc_init changes with it.

The spec test checks what the remaining contracts state, against the same
published vectors: CBC from the IV init keeps, split at every block
boundary and continued from Cbc.next, and init's limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHFjAR7Byf513R4zuFy
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