Skip to content

aes: add parallel hazmat APIs#269

Merged
tarcieri merged 1 commit intomasterfrom
aes/hazmat-par
Jun 1, 2021
Merged

aes: add parallel hazmat APIs#269
tarcieri merged 1 commit intomasterfrom
aes/hazmat-par

Conversation

@tarcieri
Copy link
Member

@tarcieri tarcieri commented Jun 1, 2021

Adds the following parallel APIs:

  • hazmat::cipher_round_par
  • hazmat::equiv_inv_cipher_round_par

These APIs operate over ParBlocks instead of Blocks, leveraging either ILP with intrinsics, or the natural parallelism that results from fixslicing.

Not much effort has been put into optimizing, nor have benchmarks been performed. This implementation is just an end-to-end spike, and probably has some room for improvement.

There's also the possibility of parallelizing (inv_)mix_columns, however I left that out for now as encryption/decryption seem like the important functionality to parallelize.

cc @zer0x64 @peterdettman

@tarcieri
Copy link
Member Author

tarcieri commented Jun 1, 2021

As I suggested in #268, it's interesting that these APIs now provide a sort of common abstraction across AES implementations.

In the future, it might be interesting to try to use an API like this as the core of the overall implementation, which would get rid of a lot of redundant boilerplate that presently exists in the various per-backend Aes128/Aes192/Aes256 types and their associated trait impls.

Might be worth opening a tracking issue about.

cc @newpavlov

@tarcieri tarcieri mentioned this pull request Jun 1, 2021
Adds the following parallel APIs:

- `hazmat::cipher_round_par`
- `hazmat::equiv_inv_cipher_round_par`

These APIs operate over `ParBlocks` instead of `Blocks`, leveraging
either ILP with intrinsics, or the natural parallelism that results from
fixslicing.

Not much effort has been put into optimizing, nor have benchmarks been
performed. This implementation is just an end-to-end spike, and probably
has some room for improvement.

There's also the possibility of parallelizing `(inv_)mix_columns`,
however I left that out for now as encryption/decryption seem like the
important functionality to parallelize.
@tarcieri tarcieri merged commit ace7696 into master Jun 1, 2021
@tarcieri tarcieri deleted the aes/hazmat-par branch June 1, 2021 03:35
@tarcieri tarcieri mentioned this pull request Jun 1, 2021
@peterdettman
Copy link
Contributor

If I understand what you're proposing, I think the main thing missing to enable a "generic core" is to expose internal state types and load/store methods. The single-round case then would have to be load(_par)/cipher_round(_par)/store(_par), which might be annoying enough to warrant macros or something.

@tarcieri
Copy link
Member Author

tarcieri commented Jun 1, 2021

@peterdettman a little while ago I was experimenting with some portable SIMD buffer types which are backed by stdarch SIMD register types if available, and otherwise defer to a portable implementation:

https://github.com/RustCrypto/utils/pull/221/files#diff-a79c5b339f542394a99720ff44f1b2ed65a1e757ca206aa984392c5a60b857c1

I think types like that could potentially address the load/store problems, and also make it easier to do things like pass arrays of SIMD registers between crates (e.g. to pass freshly encrypted AES blocks to a UHF for authentication)

@tarcieri tarcieri mentioned this pull request Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants