Repository navigation
ARM: vg_chacha20_xor from a source to a destination - #4436
Merged
Merged
Conversation
vg_chacha20_xor(state, src, len, buf, dst) now writes src XORed with the keystream to dst, which is src itself or a buffer apart from it. dst comes in r5 (AAPCS passes four arguments in registers): vg_chacha20_apply keeps the data there already, and seal and open set it to the data. The kernel keeps dst in r7, saved with r4-r6 and lr in buf[256, 276). The proof states the contract over src and dst (Dst: the destination's bytes done; Src: the source after them intact), with xor_call_to and the in-place xor_call for the callers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWwrECv53ESEcwjcHaU
This was referenced Nov 7, 2026
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 the ARM counterpart of #4381 (RISC-V) and #4424 (PPC64LE). It generalizes the ChaCha20 XOR kernel to read from
srcand write todst.dstis eithersrcitself or a buffer disjoint from it. This is the groundwork for ARM'svg_chacha20_poly1305_open_to, which will shareopen's body, in a follow-up PR. No change toTCB/orSpec/.Code
dstargument. The new signature isvg_chacha20_xor(state = r0, src = r1, len = r2, buf = r3, dst = r5). AAPCS passes only four arguments in registers, and this function is internal, sodstcomes inr5.vg_chacha20_applyalready keeps the data inr5, so its code is unchanged.sealandopenadd onemov r5, r10before the call (crypt).dstinr7, and savesr7withr4–r6andlrinbuf[256, 276). No stack is used, as before.xorTo) loads each source byte before it stores the destination's.xorLoop, which works in place, stays forapply's bytes of a buffered block.vg_chacha20_xorandchacha20poly1305.Proofs
Proof/ChaCha20/Arm/Xor.leanstates the contract over the source and the destination:XPre.aliasrequires thatdst = srcor that the two regions are disjoint.Dstsays the destination's bytes done so far are correct, andSrcsays the source after them is intact.src_stepcarriesSrcthrough each step.xor_call_tocovers calls from source to destination, andxor_callcovers in-place calls. The callers use them: Stream'sApply/ApplyCT/Calls, and ChaCha20-Poly1305'sStages/Verified.Checks
lake buildpasses, and so does the fullEmit.lean. I ran both on the commit before rebasing onto currentmain; none of the filesmainchanged since touch ARM or ChaCha20 Lean.check_lean_public_imports.pyand every step of the Static checks job pass.cargo testpasses for the ChaCha20 and ChaCha20-Poly1305 tests, including Wycheproof, onarmv7-unknown-linux-gnueabihfand onthumbv7neon-unknown-linux-gnueabihf(T32).Benchmarks: not run.
seal/opengain onemov, and the kernel saves and restores one more register and advances one more pointer per byte. A scoped manual Benchmarks run (ChaCha20 and ChaCha20-Poly1305 on ARM) should go with this PR; I have not triggered one.Generated by Claude Code