Repository navigation
x86-64 HMAC finalize, BLAKE2 and SHA-3/SHAKE return without secret residue - #4898
Merged
Merged
Conversation
…et residue Follow each with scrubTail where the residue analysis handles its code, proving NoResidue, and drop their 38 lines from ci/residue_allowlist.txt: * SHA-3/SHAKE (Proof/Sha3/X86_64/Scrub.lean): every update, SHAKE's finalize and squeeze. * BLAKE2b/BLAKE2s update and finalize over each backend, through new optional analyses on Backend/BackendS (updateRes, finalizeRes), and vg_blake2s_init (Proof/Blake2/X86_64/Scrub.lean). * HMAC finalize over each MdHash variant, through a new optional MdHash.hmacFinRes and MdHash.hmacFinReg (ScrubStream.lean). Left listed: SHA-3's finalize (the analysis loses r12's frame pointer across the squeeze call), HMAC-SHA-384/512/512-224/512-256 finalize_avx2 (the analysis fails on the AVX2 SHA-512 code), vg_blake2b_init (Argon2 calls it by name). 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.
A residue burn-down, following #4892. It takes 38 lines off
ci/residue_allowlist.txt. No trust change: nothing underTCB/orSpec/changes.What is converted
updateandfinalize, scalar, AVX2 and AVX-512.init, andupdateandfinalize, scalar and AVX.vg_sha3_{224,256,384,512}_update,vg_shake128_{update,finalize,squeeze}andvg_shake256_{finalize,squeeze}.How
Functions emitted once per implementation take their analysis from the implementation, as
XorImpl.applyandBlocksImpl.updatedo for ChaCha20 and Poly1305 (#4836). Each is an optional field,nonewhere the analysis does not accept the code:MdHash.hmacFinRes, for HMAC finalize;Backend.updateRes/finalizeResandBackendS.updateRes/finalizeRes, for BLAKE2.Each variant file sets them from the analysis of its own code, which the kernel checks with
taint_decide.MdHash.hmacFinRegand the BLAKE2 builders scrub withwithScrub, and the registration files bind them.Proof/Pbkdf2/Md/X86_64/ScrubStream.leanholdshmacFinOutandMdHash.hmacFinReg.Proof/Blake2/X86_64/Scrub.leanandProof/Sha3/X86_64/Scrub.lean(new) hold thePostOutproofs and registrations.The SHA-512 family's scalar and SHA-NI
MdHashvalues are now defined inVariants/MdHash/X86_64/Sha512*.lean, next to their analyses.What stays listed, and why (12)
vg_sha3_{224,256,384,512}_finalize: the analysis rejects them. After the call tosqueeze, whose stores tooutit cannot bound, it no longer knows thatr12points into the frame. Converting them needs a change to the code.vg_hmac_{sha384,sha512,sha512_224,sha512_256}_finalize_avx2: the analysis does not complete on the SHA-512 AVX2 code, as with SHA-512's own AVX2 functions in x86-64 SHA-1, SHA-224, the SHA-512 family, MD5 and SM3 return without secret residue #4842.vg_blake2b_init: Argon2 calls it by name with its current code. Converting it needs the callers to call the unscrubbed code under a name of its own, as x86-64: the residue analysis and scrub, an allowlist that only shrinks, and SHA-256, Poly1305 and ChaCha20 apply without residue #4836 did forvg_poly1305_init_core.Checks
lake build(all modules),Emit.lean --check, the Static checks job,check_lean_public_imports.pyon the changed modules: pass.cargo fmt --check,cargo clippy --all-targets -- -D warnings: pass.cargo testwith Wycheproof, with every CPU feature and withVG_CPU_FEATURES=none: pass.Speed
Benchmarks run 42772093053: x86-64, the HMAC, BLAKE2, SHA-3 and SHAKE groups against
main, in each of the 10 configurations that choose among their implementations, one interleaved run each.This PR has a visible cost on small inputs for BLAKE2 and SHAKE.
updateandsqueezewipe 592 and 656 bytes of stack. The scrub writes those with 8-byte stores, which adds about 16–25 ns per call.Wiping with vector stores would cut this, and is planned as a separate change to the scrub itself.
aes,avx,avx2,pclmulqdq,ssse3. Their finalize wipes at most 576 bytes once per message, and each move is matched by moves of similar size in the opposite direction elsewhere, so I take those to be noise.🤖 Generated with Claude Code
https://claude.ai/code/session_015ajQWxYnEynffr2A7QLPVa