Repository navigation
ARMv7 SM4-CFB128: prepare encryption keys once per call - #3036
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
added this pull request to stack #3038
October 21, 2026 17:40
github-merge-queue
Bot
removed this pull request from the merge queue because a pull request earlier in the stack was removed
Oct 21, 2026
This was referenced Oct 21, 2026
Member
Author
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.
ARMv7 SM4-CFB128 encryption called the full ECB entry point for each feedback block, preparing the same round keys repeatedly. Prepare the bitsliced keys once per call and reuse them along the serial ciphertext feedback chain.
The generated ARM/Thumb implementation has complete functional and constant-time proofs against the unchanged shared encryption contract, including empty input, arbitrary block counts, continuation IVs, memory frames and ABI preservation. The verified stack wrapper wipes all 1512 bytes of working space; stack use falls from 1560 to 1520 bytes. Decryption keeps the batched implementation from #3033. No specification or TCB changes.
Validation: full Lean build (22419 jobs), scoped emitter generation/audits and generated-code checks, public-import checks for all nine changed modules, static checks, CFB integration tests, ARM/Thumb assembly compilation, ARM Clippy and Rustfmt. Native ARM/Thumb benchmark passed; Full CI passed, including native ARM/Thumb tests, Lean, emitter audits and static checks.
Stacked on #3033 for the prepared-key and workspace proof helpers. This PR's diff contains only serial CFB encryption changes. The serial cipher still computes eight lanes per feedback block; this change removes repeated key preparation and does not claim to close the entire OpenSSL gap.
Local Thumb disassembly confirms the hot round loop is word-aligned at function offset
0x780; the alignment padding is a verified identity.CFB encryption timings in microseconds, paired against the parent on Neoverse N2 (lower is better):
Bulk encryption improves by 17.4% on ARM and 18.3% on Thumb, but remains 6.4 times slower than OpenSSL. Decryption is unchanged in the paired benchmark and still beats OpenSSL at 1 KiB and 16 KiB.