Repository navigation
Run WinZip AES key derivation on the SHA-1 instructions on 64-bit ARM - #7
Merged
Merged
Conversation
PBKDF2's 999 chained HMACs per block now run on ARMv8's SHA-1 instructions where the processor has them (checked at run time): SHA1C/SHA1P/SHA1M do four rounds each, SHA1H gives the next e, and SHA1SU0/SHA1SU1 extend the schedule, with each iteration's padded block built in registers from the previous digest. Without them, and on x86-64 (none of the machines measured has SHA-NI), the portable loop runs; a new test holds the two to the same results over random keys and iteration counts, and the RFC 6070 and reference tests now run through the fast path. AES-256 password check: M4 149 -> 41 us, M5 458 -> 77 us; a whole 1 MiB AES-256 entry on the M4 534 -> 194 us. 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 derives its key and password verifier with PBKDF2-HMAC-SHA1: 999 chained HMACs per 20-byte block, two SHA-1 compressions each. On 64-bit ARM processors that have the SHA-1 instructions (checked at run time with
is_aarch64_feature_detected!("sha2")), those iterations now run on them inaccel::pbkdf2_sha1_rest:SHA1C,SHA1PandSHA1Meach do four rounds with their round function.SHA1Hgives the nexte.SHA1SU0/SHA1SU1extend the message schedule four words at a time.HmacSha1::rest) runs as before.Measured (fastest round,
examples/bench.rs)Each compression now takes about 20 ns on the M4: the chain of twenty 4-round instructions, one after another.
Correctness
pbkdf2_iterations_agree_with_and_without_sha1_instructionsholds the instruction path to the portable loop. It uses 20 random keys of 0–89 bytes (crossing the 64-byte HMAC key-hashing boundary), random first MACs, and 1, 2, 3 and 1000 iterations.aes_derivecomparison all run through the fast path now.SHA1Minstead ofSHA1Pfor one group of rounds on purpose fails four tests.cargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo testpass on aarch64-apple-darwin and x86_64-linux.🤖 Generated with Claude Code