Skip to content

x86-64 Blowfish and IDEA return without secret residue - #4892

Merged
reaperhulk merged 1 commit into
mainfrom
claude/residue-blowfish-idea
Nov 10, 2026
Merged

reaperhulk merged 1 commit into
mainfrom
claude/residue-blowfish-idea

Conversation

@reaperhulk

@reaperhulk reaperhulk commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

A residue burn-down, following #4836 and #4842. It converts every x86-64 Blowfish and IDEA function, taking 22 lines off ci/residue_allowlist.txt. No trust change: nothing under TCB/ or Spec/ changes.

What is converted

  • Blowfish (11): expand_key; ecb_encrypt and ecb_decrypt; cbc_encrypt_chained and cbc_decrypt_chained; cfb64_encrypt, cfb64_decrypt and their _final forms; ofb and ofb_final.
  • IDEA (11): expand_key and invert_key; ecb; cbc_encrypt_chained and cbc_decrypt_chained; cfb64_encrypt, cfb64_decrypt and their _final forms; ofb and ofb_final.

Each function is scrubbed with X86_64.Scrub.withScrub, as #4842 did for MD5 and SM3. Its code is followed by scrubTail, which clears what the residue analysis finds may hold secrets. The kernel checks that analysis (taint_decide), and the registration's own stack is used for it.

Proofs

  • Proof/Blowfish/X86_64/Scrub.lean and Proof/Idea/X86_64/Scrub.lean (new): one PostOut proof per contract, via postOut_of_local. Each says the postcondition reads memory on return only within the buffers: the blocks, the chaining value and, for key expansion, the schedule (scheduleAt_congr).
  • The eight registration files (Artifacts/{Blowfish,BlowfishCbc,BlowfishCfb,BlowfishOfb,Idea,IdeaCbc,IdeaCfb,IdeaOfb}/X86_64.lean) now only bind the scrubbed registrations. Imports they no longer need are dropped.

Checks

  • lake build (all modules), Emit.lean --check, the Static checks job, check_lean_public_imports.py on the changed modules: pass.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings: pass.
  • cargo test with Wycheproof, with every CPU feature and with VG_CPU_FEATURES=none: pass.

Speed

Benchmarks run 42761432349: x86-64, blowfish idea against main, one interleaved run. The scrub is a fixed cost per call, and it does not show:

  • Blowfish: every mode within ±0.4% from 64 B to 16 KiB, except CFB encryption at 1 KiB, 1.3% slower (1.49 → 1.51 ms). Each benchmark includes the key schedule.
  • IDEA: CBC, CFB and OFB at 64 B within ±0.6%.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ajQWxYnEynffr2A7QLPVa

Key expansion (and IDEA's key inversion) and the ECB, CBC, CFB64 and OFB
functions of both ciphers on x86-64 are followed by the residue scrub
(`X86_64.Scrub.withScrub`), with their postconditions shown to read the
memory on return only within the buffers (`PostOut`), in
`Proof/Blowfish/X86_64/Scrub.lean` and `Proof/Idea/X86_64/Scrub.lean`. The
registration files bind them, and the 22 functions leave
`ci/residue_allowlist.txt`.

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