Skip to content

Enable legacy AES API to use AESNI or VPAES if available - #11895

Closed
bernd-edlinger wants to merge 2 commits into
openssl:OpenSSL_1_1_1-stablefrom
bernd-edlinger:enable_aes_legacy_api_asm_support_1
Closed

bernd-edlinger wants to merge 2 commits into
openssl:OpenSSL_1_1_1-stablefrom
bernd-edlinger:enable_aes_legacy_api_asm_support_1

Conversation

@bernd-edlinger

Copy link
Copy Markdown
Member

When no assembler support is available, we fall back
to either the constant time implementation or the non-constant time
C code implementation.

This is controlled by -DOPENSSL_AES_CONST_TIME.
So this makes the legacy API completely constant time,
if OPENSSL_AES_CONST_TIME is defined, otherwise it uses constant time
assembler implementaions when available, and may fall back to the
non-constant time implementaion.

This works so far only for intel and aarch64 CPUs.

[extended tests]

Checklist
  • documentation is added or updated
  • tests are added or updated

@bernd-edlinger bernd-edlinger added the branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) label May 21, 2020
@bernd-edlinger
bernd-edlinger force-pushed the enable_aes_legacy_api_asm_support_1 branch from b38cb3f to a99c55e Compare May 21, 2020 10:47
@bernd-edlinger

Copy link
Copy Markdown
Member Author

Travis failure is unrelated.

@bernd-edlinger

bernd-edlinger commented May 21, 2020 •

Copy link
Copy Markdown
Member Author

Note that this is for 1.1.1 only at the moment, but it cannot be applied to master
as is because it depends on #9677 which
has not made any progress since more than 6 months.
While #9675 was merged into 1.1.1d that is rather unfortunate.
I abandoned #9677 by now, since I have other things to do.

When no assembler support is available, we fall back
to either the constant time C implementation or the
non-constant time C code implementation.

This is controlled by -DOPENSSL_AES_CONST_TIME.
So this makes the legacy API completely constant time,
if OPENSSL_AES_CONST_TIME is defined, otherwise it uses constant time
assembler implementations when available, and may fall back to the
non-constant time implementation.

This works so far only for intel and aarch64 CPUs.

[extended tests]
@bernd-edlinger
bernd-edlinger force-pushed the enable_aes_legacy_api_asm_support_1 branch from a99c55e to f4f6661 Compare May 21, 2020 18:50
This makes the legacy API AES_cbc_encrypt outperform the EVP API.

[extended tests]
@bernd-edlinger

Copy link
Copy Markdown
Member Author

With the second commit also the AES_cbc_encrypt API is able to use AESNI or VPAES.
This is very suprising by how much the LEGACY API is outperforming the EVP API:
LEGACY API: openssl speed aes

The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
aes-128 cbc     214020.15k   216315.86k   235227.05k   240226.30k   241702.23k   241696.77k
aes-192 cbc     182358.41k   184561.07k   197459.03k   200981.85k   201981.95k   202020.18k
aes-256 cbc     158889.29k   160572.27k   170269.87k   172872.36k   173618.52k   173626.71k

EVP API: openssl speed -evp aes-128-cbc

aes-128-cbc     148546.79k   193050.69k   227180.46k   238088.87k   241426.43k   241423.70k
aes-192-cbc     131881.39k   164745.30k   191568.47k   199358.46k   201667.93k   201736.19k
aes-256-cbc     119544.65k   144924.27k   165435.73k   171423.06k   167753.05k   169213.95k

@t8m t8m added the triaged: feature The issue/pr requests/adds a feature label Aug 4, 2021
@t8m t8m added this to the Post 3.0.0 milestone Sep 24, 2021
@t8m t8m closed this Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) triaged: feature The issue/pr requests/adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants