-
Notifications
You must be signed in to change notification settings - Fork 77
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
Optimize ChaCha20-Poly1305 initialization #652
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@keithc-ca please help to review |
Benchmarking results for ChaCha20-Poly1305 on a physical machine. Values in this table are in bytes per second throughput ( a higher value shows greater performance ):
|
214c1b3
to
ece054d
Compare
@jasonkatonica FYI |
keithc-ca
requested changes
Aug 30, 2023
closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java
Outdated
Show resolved
Hide resolved
closed/src/java.base/share/classes/com/sun/crypto/provider/NativeChaCha20Cipher.java
Outdated
Show resolved
Hide resolved
ece054d
to
680aace
Compare
keithc-ca
reviewed
Aug 30, 2023
The ChaCha20 initialization cost has been found to be expensive in the OpenSSL 3.x API compared to the OpenSSL 1.x API. In order to optimize the cost on OpenSSL 3.x, a flag is setup to distinguish two different types of initializations. One initialization would be a full initialization. It will perform the full initialization when the mode is switched between encrypt and decrypt, or a first time encryption or decryption. The other initialization would be a partial initialization. Once the mode is decided, the partial initialization will only use key and iv, but will NOT recreate and reinitialize the EVP context as what we have for now. The key and iv are required once per Cipher instance, the EVP context can be used whenever we are reusing a specific Java cipher object within methods such as Cipher.doFinal(). Signed-off-by: Jinhang Zhang <Jinhang.Zhang@ibm.com>
680aace
to
4fdf622
Compare
Jenkins test sanity.openjdk alinux64 jdknext |
keithc-ca
approved these changes
Aug 31, 2023
None of the test failures appear to be due to this change. |
tajila
pushed a commit
to tajila/openj9-openjdk-jdk
that referenced
this pull request
Mar 27, 2024
…nGranularly Expand OpenSSL Version granularity
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ChaCha20 initialization cost has been
found to be expensive in the OpenSSL 3.x
API compared to the OpenSSL 1.x API.
In order to optimize the cost on OpenSSL
3.x, a flag is setup to distinguish two
different types of initializations. One
initialization would be a full
initialization. It will perform the full
initialization when the mode is switched
between encrypt and decrypt, or a first
time encryption or decryption. The other
initialization would be a partial
initialization. Once the mode is decided,
the partial initialization will only use
key and iv, but will NOT recreate and
reinitialize the EVP context as what we
have for now. The key and iv are required
once per Cipher instance, the EVP context
can be used whenever we are reusing a
specific Java cipher object within methods
such as Cipher.doFinal().