RFR: 8344144: AES/CBC slow at big payloads [v2]
Artur Barashev
abarashev at openjdk.org
Thu Nov 14 21:05:25 UTC 2024
On Thu, 14 Nov 2024 20:49:55 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:
>> src/java.base/share/classes/com/sun/crypto/provider/CipherBlockChaining.java line 222:
>>
>>> 220: processed +=
>>> 221: implDecrypt(cipher, cipherOffset, cipherLen, plain, plainOffset);
>>> 222: return processed;
>>
>> The `for` loop logic is the same for encrypt and decrypt operations, only different positioning of the arguments. How about creating a helper method `chunkOperation` that would take one additional encrypt/decrypt boolean argument based on which it would do either encrypt or decrypt operation.
>
> Given this is a performance change, I'm fine with leaving it as is. Jumping to a helper method with an encrypt/decrypt conditional check for every crypto op will costs performance. This is a case where more efficient code is more verbose syntax.
@ascarpino But a method call should be very cheap, we are adding a bunch of extra implEncrypt/implDecrypt calls here already. Besides, compiler/hotspot will optimize that call if needed. It will be just a method wrapping the `for` loop.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22086#discussion_r1842881324
More information about the security-dev
mailing list