ibmruntimes / openj9-openjdk-jdk11

Extensions for OpenJDK 11 for Eclipse OpenJ9
GNU General Public License v2.0
31 stars 112 forks source link

Optimize AES/GCM cipher and IV initialization and improve array cleanup code #703

Closed KostasTsiounis closed 1 year ago

KostasTsiounis commented 1 year ago

The cipher initialization cost has been found to be computationally expensive, especially in the OpenSSL 3.x API.

In order to optimize the cost of using OpenSSL to perform consecutive AES/GCM encryption and decryption operations, two flags are set and passed as parameters.

The first flag indicates whether a different cipher is required for the upcoming operations (i.e., the key size has changed). If that is the case, a cipher is initialized and set to the provided context. If not, those steps are omitted, thus reducing the time required for the operation.

The second flag indicates whether the IV length has changed and is used in a similar way as the first flag.

The rest of the steps required for the operation are performed regardless of the flags.

The handling of freeing arrays that were part of that functionality is, also, updated to comply with the newer approach to cleanup code.

Back-ported from: https://github.com/ibmruntimes/openj9-openjdk-jdk/pull/655

Signed-off by: Kostas Tsiounis kostas.tsiounis@ibm.com

keithc-ca commented 1 year ago

Jenkins test sanity amac jdk11

keithc-ca commented 1 year ago

Additional testing at https://openj9-jenkins.osuosl.org/job/Grinder/2884 also passed.