Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aes-soft: use fixslicing for AES encryption #176

Merged
merged 1 commit into from Oct 26, 2020

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Oct 25, 2020

Continuation of the work from #174.

Fixslicing is defined for AES-128/AES-256 (now with AES-192!) encryption only, but we can replace bitslicing in these capacities with the faster fixslicing approach.

This is useful for AES-CTR, which needs only the encryption operation.

Performance is improved by ~3X as measured on an Intel Core i9 (despite the fixslicing implementation being 32-bit only)

cc @peterdettman

Benchmarks

Before

test aes128_decrypt  ... bench:         619 ns/iter (+/- 53) = 25 MB/s
test aes128_decrypt8 ... bench:       3,313 ns/iter (+/- 602) = 38 MB/s
test aes128_encrypt  ... bench:         608 ns/iter (+/- 80) = 26 MB/s
test aes128_encrypt8 ... bench:       3,064 ns/iter (+/- 227) = 41 MB/s

test aes256_decrypt  ... bench:         878 ns/iter (+/- 114) = 18 MB/s
test aes256_decrypt8 ... bench:       4,524 ns/iter (+/- 269) = 28 MB/s
test aes256_encrypt  ... bench:         864 ns/iter (+/- 49) = 18 MB/s
test aes256_encrypt8 ... bench:       4,274 ns/iter (+/- 296) = 29 MB/s

After

test aes128_decrypt  ... bench:         570 ns/iter (+/- 65) = 28 MB/s
test aes128_decrypt8 ... bench:       2,904 ns/iter (+/- 123) = 44 MB/s
test aes128_encrypt  ... bench:         271 ns/iter (+/- 51) = 59 MB/s
test aes128_encrypt8 ... bench:       1,060 ns/iter (+/- 45) = 120 MB/s

test aes256_decrypt  ... bench:         840 ns/iter (+/- 35) = 19 MB/s
test aes256_decrypt8 ... bench:       4,194 ns/iter (+/- 242) = 30 MB/s
test aes256_encrypt  ... bench:         374 ns/iter (+/- 22) = 42 MB/s
test aes256_encrypt8 ... bench:       1,533 ns/iter (+/- 100) = 83 MB/s

(AES-192 is unchanged, as it still uses the original bitsliced implementation)

@tarcieri tarcieri force-pushed the aes-soft/integrate-fixsliced-impl branch 3 times, most recently from ca9534b to 2c62441 Compare October 25, 2020 16:55
Fixslicing is presently defined for encryption only.

However, accelerating just encryption is still useful for AES-CTR.

Performance is improved by ~3X as measured on an Intel Core i9
(despite the fixslicing implementation being 32-bit only)
@tarcieri tarcieri force-pushed the aes-soft/integrate-fixsliced-impl branch from 2c62441 to 3d3c595 Compare October 26, 2020 17:31
@tarcieri
Copy link
Member Author

Now with AES-192 (thanks @peterdettman!)

test aes192_decrypt  ... bench:         713 ns/iter (+/- 94) = 22 MB/s
test aes192_decrypt8 ... bench:       3,651 ns/iter (+/- 350) = 35 MB/s
test aes192_encrypt  ... bench:         338 ns/iter (+/- 73) = 47 MB/s
test aes192_encrypt8 ... bench:       1,355 ns/iter (+/- 79) = 94 MB/s

@tarcieri tarcieri changed the title aes-soft: use fixslicing for AES-128/AES-256 encryption aes-soft: use fixslicing for AES encryption Oct 26, 2020
@tarcieri
Copy link
Member Author

With AES-192 supported, I was able to continue using the macros to define the Aes128, Aes192, and Aes256 types, which makes me feel a lot better about this PR (i.e. fixslicing is used across the board for encryption, and bitslicing is used for decryption).

@tarcieri tarcieri merged commit 83dcffd into master Oct 26, 2020
@tarcieri tarcieri deleted the aes-soft/integrate-fixsliced-impl branch October 26, 2020 18:24
This was referenced Oct 26, 2020
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.

None yet

1 participant