-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8325448: Hybrid Public Key Encryption #18411
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
base: master
Are you sure you want to change the base?
Conversation
|
👋 Welcome back weijun! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@wangweij This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
/csr |
|
@wangweij has indicated that a compatibility and specification (CSR) request is needed for this pull request. @wangweij please create a CSR request for issue JDK-8325448 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
|
@wangweij This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@wangweij This pull request has been inactive for more than 16 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
|
/open |
|
@wangweij This pull request is now open |
|
@wangweij This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
src/java.base/share/classes/sun/security/util/SliceableSecretKey.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/snippet-files/PackageSnippets.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/snippet-files/PackageSnippets.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/snippet-files/PackageSnippets.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
| * of RFC 9180 and the | ||
| * <a href="https://www.iana.org/assignments/hpke/hpke.xhtml">IANA HPKE page</a>. | ||
| * <p> | ||
| * Once an {@code HPKEParameterSpec} object is created, additional methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
To avoid some of this potential confusion, I think it could help to expand on the description of "This is useful in the case where a random IV was created, or in the context of password-based encryption or decryption, where the IV is derived from a user-supplied password." to: "This is useful in the case where a random IV was created, or in the context of password-based encryption or decryption, where the IV is derived from a user-supplied password, or in the case of HPKE (Hybrid Public Key Encryption) where IV contains the encapsulation of the KEM shared secret." |
Good idea. Somehow I hesitate to update the base spec directly. Shall we put the whole paragraph into an |
Yes, making this text an API note, which is what it really is, is a really good idea. |
|
New commit pushed. The Reasons:
|
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/javax/crypto/spec/HPKEParameterSpec.java
Outdated
Show resolved
Hide resolved
| AlgorithmParameterSpec params, SecureRandom random) | ||
| throws InvalidKeyException, InvalidAlgorithmParameterException { | ||
| impl = new Impl(opmode); | ||
| if (!(key instanceof AsymmetricKey ak)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a null check needed for key and params? It appears Cipher leaves that to the SPI to accept or reject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If key is null, you will see "InvalidKeyException: Not an asymmetric key". I assume that's also OK?
I'll deal with params, there is a similar exception but unfortunately I called params.getClass() there.
| this.exporter_secret = exporter_secret; | ||
| } | ||
|
|
||
| SecretKey ExportKey(String algorithm, byte[] exporter_context, int L) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the methods in this class capitalized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like using the original function names from the RFC. If you don't like, I can modify them to Java-style.
| // deriveData must and can be called because all info to | ||
| // thw builder are just byte arrays. Any KDF impl can handle this. | ||
| var kdf = KDF.getInstance(kdfAlg); | ||
| var key_schedule_context = concat(new byte[]{(byte) mode}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is key_sechedule_context worth zero'ing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not? psk_id does not sound like a secret thing. I understand psk is.
Implement HPKE as defined in https://datatracker.ietf.org/doc/rfc9180/.

Progress
Issues
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18411/head:pull/18411$ git checkout pull/18411Update a local copy of the PR:
$ git checkout pull/18411$ git pull https://git.openjdk.org/jdk.git pull/18411/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18411View PR using the GUI difftool:
$ git pr show -t 18411Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18411.diff
Using Webrev
Link to Webrev Comment