refactor(aes): machine-word generic fixslice#560
Open
sinui0 wants to merge 3 commits into
Open
Conversation
Drop the cpubits-based selection between width-specific fixslice modules in preparation for unifying both into a single width-generic implementation.
Refactor the fixslice AES implementation so the algorithm body is generic over a `Word` trait, with a single `impl Word for u32` carrying all width-specific code (row width, packing routines, bitslice/inv_bitslice). The three-pass delta-swap pipeline used by `bitslice` and `inv_bitslice` is extracted into a shared width-generic `bitslice_swaps` helper, with mask constants derived from a `Word::byte_repeat` method. Each impl now only carries the bytes-in/bytes-out routine. This is a purely mechanical refactor: no logic changes, no behavior changes, the only word width supported is still `u32`.
Add the second `Word` impl, `impl Word for u64`, which batches 4 blocks per state versus 2 for `u32`. The concrete re-exports and the hazmat helpers are gated by `target_pointer_width` via `cpubits!`, selecting `u32` on 16/32-bit targets and `u64` on 64-bit.
Member
|
This looks good to me as a general direction, though it may be some time before I can review it in detail. I'm a bit confused how this broke the build the way it did, it seems somehow with only changes to the soft backend it broke things in the NEON backend somehow? |
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.
This PR collapses the two fixslice impls into a single
fixslice.rsparameterized over aWordtrait that abstracts the machine-word width.I tried to structure the commits to make it clear to the reviewer that this introduces no changes to the existing implementation logic.
This PR was motivated by #559 to support larger machine-word (SIMD) implementations without introducing major duplication and maintenance burden.