Repository navigation
Encrypt WinZip AES-CTR keystream with T-tables, two blocks at a time on ARM - #3
Merged
Merged
Conversation
…on ARM AES went a byte at a time: SubBytes, a ShiftRows permutation and MixColumns with xtime on every round, then one push per output byte. Each round is now sixteen lookups in four 256-word tables, built at compile time from the S-box, that do SubBytes, ShiftRows and MixColumns together, on big-endian state words, with the round count a const generic so the rounds unroll. CTR XORs whole 16-byte blocks in place. On 64-bit ARM two counter blocks go side by side so their lookups overlap (13% faster than four on the M4, 50% faster than one); x86-64 runs one, since its sixteen registers spill with more. AES-128-CTR: M4 242 -> 738 MB/s, M5 226 -> 705, i7-8700K 60 -> 243. AES-256-CTR: M4 175 -> 567, M5 163 -> 543, i7-8700K 44 -> 186. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
What
WinZip AES-CTR used to encrypt each counter block a byte at a time: per round, 16 S-box lookups, a ShiftRows permutation, and MixColumns via
xtime. It then pushed the output one byte at a time.TE0..TE3) are built at compile time from the existing S-box; one lookup does SubBytes, ShiftRows (by which byte is looked up) and MixColumns at once. The last round still uses the S-box.CTR_LANES). 64-bit ARM encrypts two counter blocks at once, so their lookups overlap. x86-64 does one at a time: its 16 registers spill with more.Interleaving measured per machine (AES-256-CTR, 8 MiB, best of 15–25):
Still no
unsafe, and no new dependency. Hardware AES (AES-NI, ARMv8 crypto) would need anunsafecall boundary even when the target already enables those features, so it stays out.Measured (fastest round,
examples/bench.rs)Those entry times predate #2, which cuts the derivation further.
Correctness
None.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass on aarch64-apple-darwin and x86_64-linux.🤖 Generated with Claude Code