Skip to content

Spec: retire the Api of vg_rsa_pkcs1_encrypt_precomputed - #4377

Merged
alex merged 1 commit into
mainfrom
claude/audit-4139-pkcs1v15-ps
Nov 6, 2026
Merged

alex merged 1 commit into
mainfrom
claude/audit-4139-pkcs1v15-ps

Conversation

@alex

@alex alex commented Nov 6, 2026

Copy link
Copy Markdown
Member

Part of #4139 (finding 8: RSAES-PKCS1-v1_5 padding string)

This retires what #4355 left without a Rust caller, as #4303 did for RSA.

Trust change (removal only)

This PR removes trusted definitions from Spec/ and adds none. No contract that remains is weakened.

  • Spec/RsaPkcs1Enc/Precomputed.lean is deleted. It held encryptPrecomputedSig, encryptPrecomputedContract and encryptPrecomputedApi.
    • No Rust code calls vg_rsa_pkcs1_encrypt_precomputed or its _adx, _ifma and _umaal variants any more. Only the verified vg_rsa_pkcs1_encrypt_random calls them.
    • So the function becomes internal. Its signature and contract move, unchanged, to Proof/RsaPkcs1Enc/Contract.lean, which is untrusted, and the emitter now writes it under internal/.
  • Four dead definitions are deleted from Spec/RsaPkcs1Enc/Contract.lean: encryptSig, encryptContract, encryptSummary and encryptSafety.
    • They were left over from vg_rsa_pkcs1_encrypt's earlier retirement, and only the precomputed spec used them.
    • The file's docstring now names only decryption, and points to Spec/RsaPkcs1Enc/Random.lean for encryption.
  • Spec/RsaPkcs1Enc/Random.lean changes only its import and its docstring.
    • It now imports Spec/RsaPkcs1Enc/Contract.lean directly.
    • The docstring states the secrecy and timing policy itself, instead of pointing to the retired contract. The policy is the same: the public key, its precomputed values and the lengths are public; the message and PS are secret; and which of the tape's octets were zero may affect timing.
    • encryptRandomContract itself is unchanged.

Registrations and proofs

  • Registrations: the six encryptPrecomputedApi artifacts are removed, in Artifacts/RsaPkcs1Enc/{X86,PPC64LE,RISCV64}.lean and Generic/.../{X86_64,AArch64,Arm}/RsaPkcs1Enc.lean. As in Spec: retire the Apis of vg_rsa_private_checked, vg_rsa_public_precomputed_checked and vg_rsa_check_crt_key #4303, the callee needs no registration of its own: the emitter emits it from vg_rsa_pkcs1_encrypt_random's code.
  • Proofs: references move from Spec.RsaPkcs1Enc.encryptPrecomputed* to Proof.RsaPkcs1Enc.encryptPrecomputed*.
  • Proof deleted (only the removed registrations used it, as the build confirmed):
    • RISC-V's Enc.code_verified, with its sat, satState and sat_args.
    • x86's Pc.code_sp.
  • Proof kept: the other architectures' code_verified stay, because their Rnd proofs call the precomputed function by that theorem.

Generated code

On each target, rsa_pkcs1_enc.rs/.s lose the public vg_rsa_pkcs1_encrypt_precomputed* functions, which now appear under internal/, and each rsa.rs gains their mod lines.

Overlap: the open dead-code PRs (#4349, #4354 and #4362) don't touch RsaPkcs1Enc, and #4344 (RSA) has merged.

Testing

All of these ran locally, on current main (64c4f33):

  • lake build, then Emit.lean. Its audits passed: standard axioms only, and every VG.Spec definition is in Spec/.
  • Every step of the Static checks job, including check_variants.py.
  • check_lean_public_imports.py --base origin/main on the 36 edited modules.
  • cargo fmt --check and cargo clippy --all-targets -D warnings.
  • cargo test with Wycheproof.

No Rust changed, and the emitted code of every function still called is unchanged. Nothing here can affect speed, so there is no benchmark run.


Generated by Claude Code

No Rust code calls it any more: since #4355, encryption calls
vg_rsa_pkcs1_encrypt_random, which calls vg_rsa_pkcs1_encrypt_precomputed
(and its _adx, _ifma and _umaal variants). So it becomes an internal
function: its signature and contract move from
Spec/RsaPkcs1Enc/Precomputed.lean, which is deleted, to
Proof/RsaPkcs1Enc/Contract.lean, untrusted, and the emitter writes it under
internal/. Its registrations go, and so does what only they used: the
dead encryptSig, encryptContract, encryptSummary and encryptSafety of
Spec/RsaPkcs1Enc/Contract.lean (left from vg_rsa_pkcs1_encrypt's
retirement), RISC-V's code_verified and satisfiability witness, and x86's
code_sp. The other architectures' code_verified stay: the proofs of
vg_rsa_pkcs1_encrypt_random call it by it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKUFHHyzwQJxwPzPq89t3z
@alex
alex enabled auto-merge November 6, 2026 21:33
@alex
alex added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 71019f3 Nov 6, 2026
35 checks passed
@alex
alex deleted the claude/audit-4139-pkcs1v15-ps branch November 6, 2026 22:17
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