Repository navigation
Conversation
This branch has not been deployed
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.
Precompute each S-box's P-permuted contribution at compile time, replacing runtime S-box assembly and the separate P permutation with eight
u32lookups. This removes work from every DES round, including all four 3DES variants. E expansion, key scheduling, key handling and public APIs are unchanged.The tradeoff is 512 B → 2 KiB of table data (+1,536 B), without per-key storage or heap allocation growth. With the measured toolchain, the
desarchive's.textshrinks 2,617 → 2,302 B and.rodatagrows 1,134 → 2,670 B: +1,221 B combined. These object-section sizes depend on compiler/target.Security tradeoff for maintainer review: each secret-indexed subtable grows from 64 to 256 bytes. With aligned 64-byte cache lines this spans four lines instead of one, potentially exposing more index information. Both implementations are non-constant-time; the larger tables can worsen cache-based leakage. This PR does not measure attack exploitability.
Measured
b99ebe6a2d394833a14a84b79aac60c0c0611577→a466d47d8546fc28c18f7cb24a05f86a776a2f19on an i7-13700KF / WSL2, pinned to logical CPU 2,nightly-2026-07-19, the same lockfile/harness, and unchanged Cargo bench settings (no CPU, optimization-level or LTO overrides). DES ran in preplanned A–B–B–A order; all results were retained.Before → after, µs per 1,024 blocks; key initialization is ns per constructor. “Single” uses 1,024 scalar calls; “batch” uses one batch call. Values are means of two runs per side; libtest adapts sample counts.
All 20 encryption/decryption cases take 35.8–38.0% less time (1.56–1.61× throughput). Initialization changes range from −1.26% to +1.21%; the key-schedule machine code is identical. These small changes remain visible in the raw results.
The full workspace benchmark suite completed 137/137 cases (324 measurements). The other 112 cases used byte-identical executables and varied −7.66% to +7.56%, with Twofish batch encryption the largest increase. This illustrates the environmental/harness variation; WSL2 guest affinity does not control host scheduling. No concurrent build/benchmark jobs were detected.
Validation:
thumbv7em-none-eabiandwasm32-unknown-unknown.Raw results, all per-case comparisons, fixture provenance and reproduction instructions. The benchmark additions cover initialization and all DES/3DES variants; one-off verification scripts are not part of this PR.