Repository navigation
Run WinZip AES-CTR on the processor's AES instructions - #6
Merged
Merged
Conversation
zipview no longer forbids unsafe: its inflate backend already relies on it, and the processor's AES instructions need it. src/accel.rs runs the CTR keystream on ARMv8 AES (AESE/AESMC) or x86 AES-NI (AESENC/AESENCLAST), eight counter blocks at a time so the AES unit never waits on a single block, after checking for the instructions at run time; without them the T-table code runs as before. The unsafe is limited to that module's intrinsic calls and 16-byte loads and stores, each with a SAFETY comment, which clippy::undocumented_unsafe_blocks now requires. rust-version goes to 1.87, where intrinsics are safe to call inside a target_feature function. The reference test now checks both the public function and the portable path. AES-128-CTR: M4 921 -> 13984 MB/s, M5 415 -> 6386, i7-8700K 241 -> 2449. 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
zipview no longer forbids
unsafe. Its inflate backend (zlib-rs) already relies onunsafe, and the processor's AES instructions can't be used without it.src/accel.rs. It runs the WinZip AES-CTR keystream on the CPU's AES instructions:AESE+AESMC, andAESE+ XOR for the last round.AESENCandAESENCLAST.is_aarch64_feature_detected!("aes")/is_x86_feature_detected!("aes"). Without them, the existing T-table code runs.unsafeis allowed. It is confined to that module: the call into the#[target_feature]function after the check, plus 16-byte loads and stores inside arrays and chunks of known size. Each has aSAFETYcomment.#![forbid(unsafe_code)]becomes#![deny(unsafe_op_in_unsafe_fn)]plusclippy::undocumented_unsafe_blocks.rust-version. 1.85 → 1.87: from 1.87, intrinsics are safe to call inside a#[target_feature]function, so only the pointer loads and stores needunsafeblocks.unsafeis and why.Measured (fastest round,
examples/bench.rs)What remains of a whole entry's time is PBKDF2, which the next change moves onto the SHA-1 instructions.
Correctness
ctr_matches_the_bytewise_referencechecksdecrypt_winzip_ctragainst the byte-wise reference for all three key sizes. That covers a 1 MiB + 4133-byte buffer, every length 0–199, and lengths around 4 KiB and 64 KiB, so it exercises the hardware path wherever the CPU has AES (Apple M-series, the i7-8700K, GitHub's runners). It now also checks the portable T-table path directly.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass on aarch64-apple-darwin and x86_64-linux.🤖 Generated with Claude Code