Repository navigation
ARM: vg_chacha20_poly1305_open_to sharing open's body, and decrypt on ARM - #4443
Closed
reaperhulk wants to merge 1 commit into
Closed
reaperhulk wants to merge 1 commit into
reaperhulk wants to merge 1 commit into
Conversation
reaperhulk
force-pushed
the
claude/determined-gates-p7sa7b-arm-open-to
branch
from
November 7, 2026 14:09
d5f7563 to
266c6ed
Compare
… ARM Out-of-place ChaCha20-Poly1305 decryption on ARM with no copy. The decryption body exists once: it reads the source at r10 and writes the destination kept in r6 (crypt passes it to vg_chacha20_xor in r5, zeroData zeroes from it), and reads the received tag through r4, so it reads no stack argument. Each entry is a prologue (the callee-saved registers saved, the arguments moved) ending in one instruction: seal and open set r6 := r10 (in place), open_to loads dst from its stack arguments. open_to is withStackScratchWiped 664 5 158, stack 672; seal and open keep their frames. The body's correctness and constant-time proofs are shared by open and open_to (openBody_ct, sealBody_ct); openTo_verified bridges to the shared openToScratchContract, with Verified.stackScratchWipedPre, whose hpostOut may assume the precondition (stackScratchWiped is now its corollary). ChaCha20Poly1305::decrypt, its unit test, the Wycheproof out-of-place check and the benchmark group are enabled on ARM. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwrECv53ESEcwjcHaU
reaperhulk
force-pushed
the
claude/determined-gates-p7sa7b-arm-open-to
branch
from
November 7, 2026 16:24
266c6ed to
d1c4123
Compare
Member
Author
|
Closing: this ARM change is now part of #4466, which carries x86 and ARM Generated by Claude Code |
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.
This is ARM's out-of-place ChaCha20-Poly1305 decryption without a copy. It is the counterpart of #4384 (RISC-V) and #4427 (PPC64LE). It builds on ARM's src/dst
vg_chacha20_xor(#4436). No change toTCB/orSpec/.Design: one body for
openandopen_tor10and writes the destination it keeps inr6.cryptpasses the destination tovg_chacha20_xor(mov r5, r6), andzeroDatazeroes fromr6.r4. As a result it reads no stack argument, andsealpasses the tag to finalize withmov r1, r4.prologue w t dst = entry w ++ save ++ moves t ++ [dst]. One definition generates the saves for both. The shared code starts atinitState:seal = inPlace; sealBodyopen = inPlace; openBody, whereinPlaceends withmov r6, r10openTo = toEntry; openBody, wheretoEntryends withldr r6, [sp, #8]open_toiswithStackScratchWiped 664 5 158, and its stack is 672. Its five stack arguments are src, len, dst, dst_len and tag.sealandopenkeep656 3 158, and their stack stays 664.seal_gatherreusesseal's code unchanged.Proofs
Stages.leanproves the body from the state the prologue leaves.APretakes membership facts,inout(in place, oropenonly with disjoint buffers), ando_*disjointness.Inv.frameis over the context, the destination and the stack below.EntryOk,EnteredandprologueA_okconnect the body to the function's entry, andAPre.ofIn/APre.ofToderive its precondition.crypt_okuses the kernel'sxor_call_to.openBody_ctis proven once and used byopen_ctandopenTo_ct;sealBody_ctlikewise.vg_chacha20_xor's secret stores through the destination make the analysis forget the public slots. Socryptandcompareare two taint runs, withr4/r6re-established from the invariant between them.open_to.openTo_verified, against the sharedopenToScratchContract Arm.abi 79 8, andopenTo_framed.Verified.stackScratchWipedPreis new inProof/Framework/Arm/StackScratchWipe.lean: itshpostOutmay assume the precondition (dst_len = len).Verified.stackScratchWipedis now its corollary, and its signature is unchanged.Rust
ChaCha20Poly1305::decryptis now enabled on ARM, alongside RISC-V and PPC64LE, with its unit testdecrypt_out_of_place, the Wycheproof out-of-place check and thechacha20poly1305-decrypt-out-of-placebenchmark group.Checks
Run before the rebase onto
main, which conflicted only in the Rustcfgs (merged with PPC64LE's):lake build,Emit.leanandEmit.lean --checkpass. The emitter changed only the ARM crate'schacha20poly1305.check_lean_public_imports.py.cargo test chachapasses onarmv7-unknown-linux-gnueabihfandthumbv7neon-unknown-linux-gnueabihf, with Wycheproof, includingdecrypt_out_of_placeand the out-of-place Wycheproof check.cargo fmt --checkpasses for the library and the bench crate, after the rebase too. Host clippy and armv7 clippy (--liband--all-targets) pass.Benchmarks: not run.
seal/openchange by a few register moves, and the stack loads of the tag become a register. A scoped manual Benchmarks run (ChaCha20-Poly1305 on ARM, including the new out-of-place group) should go with this PR; I have not triggered one.Generated by Claude Code