aes: shrink AES round keys for AES fixslice backend - #594
Conversation
|
I don't think we need to introduce |
Just to be clear, even with the compact backend, the fixslice implementation still runs on the native word size. Enabling the compact backend does not force it into the u16 path for encryption/decryption.
The proposed changes are very similar to this except that we expand/broadcast the round keys one by one when they're needed instead of doing so at the start of the |
Yes, broadcasted keys are likely to be spilled to the stack (at least on register-starved x86), but it would reduce size of the |
5ad8541 to
ed6b822
Compare
Done. |
ed6b822 to
2c7ef09
Compare
Up until now, u32 was the smallest supported word size. With u32, the bitsliced soft backend can work on two blocks at the same time. A side- effect of this is that up until now our code assumes that two blocks is the smallest supported batch size and some of the constants are centered around that. In order to support a batch of 1, we need adjust accordingly by deduplicating the bits in the input for uniform_row and doubling or quadrupling the bits for u32 and u64 respectively.
Same as previous commit. Instead of assuming two blocks as the smallest common denominator, assume 1 and duplicate/quadruple accordingly.
Previously, we could use the same type for both of these because they contained the same data, but in the future, this will no longer be the case. This matches the VAES256 and VAES512 backends.
The round keys are expanded to the native word size when multiple blocks are processed in parallel.
2c7ef09 to
a07e3ac
Compare
newpavlov
left a comment
There was a problem hiding this comment.
For posterity, could you add a comment (in the PR discussion) explaining why the aes192, mix_columns, and utils changes were necessary?
The fixslice implementation uses the words like SIMD registers to encrypt multiple blocks in different lanes each at once. u32 can fit two lanes and u64 can fit four lanes. Because previously u32 with two lanes was the smallest denominator, some of the constants passed to There were two possible solutions: Either deduplicate the constants in the u16 implementation or adjust the code so that a single lane is the new common denominator and duplicate/quadruple the constants for the u32 and u64 implementations respectively. I chose the later approach. If you look at the constants passed to |
This PR does two things:
u16s. They are expanded into the full native words when the backend is created.a. On a targets with a 64-bit native word size, this reduces the size of the
Aes128,Aes192, andAes256types from 704, 832, and 960 to 176, 208, and 240 bytes respectively.Closes #191