Repository navigation
x86-64: SM4 key expansion returns without secret residue - #4966
Merged
Merged
Conversation
vg_sm4_expand_key is followed by scrubTail (withScrub, Proof/Sm4/X86_64/Scrub.lean), which wipes the one 8-byte granule of its stack the residue analysis finds may hold secrets. SM4-GCM's init, which calls it by name, now calls its unscrubbed code as an internal function of its own, vg_sm4_expand_key_core (Impl.Sm4Gcm.X86_64.keyFn). Its line leaves ci/residue_allowlist.txt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxYnEynffr2A7QLPVa
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.
vg_sm4_expand_keynow ends withscrubTail(withScrub,Proof/Sm4/X86_64/Scrub.lean). The tail wipes the one 8-byte stack granule that the residue analysis finds may hold secrets, and clears the registers. Its line leavesci/residue_allowlist.txt.SM4-GCM's init calls key expansion by name, and the emitter refuses a function called by name whose code changes. So it now calls the unscrubbed code as an internal function of its own,
vg_sm4_expand_key_core(Impl.Sm4Gcm.X86_64.keyFn). This is the same_corepattern as #4904 and #4951.Nothing under
TCB/orSpec/changes.Benchmarks
Run 43072205210: every
sm4benchmark on x86-64, in everyVG_CPU_FEATURESconfiguration, compared with 8564b91.sm4-ctr/64ataes,pclmulqdq,ssse3, 8.3% slower (3.38 → 3.66 µs). Within that same configuration,sm4-ofbandsm4-cfb128-encryptare faster, and the CTR row is flat in the others.Checks
All passed locally, after rebasing onto main with #4951 and #4962:
lake build;Emit.leanthen--check;check_lean_public_imports.py --base origin/main;cargo fmtandcargo clippy;cargo test, and theVG_CPU_FEATURES=nonerun.Generated by Claude Code