jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8325448: Hybrid Public Key Encryption

Open wangweij opened this issue 1 year ago • 27 comments

Implement HPKE as defined in https://datatracker.ietf.org/doc/rfc9180/.

HPKEParameterSpec · 18 37 · 06-26


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] Change requires a CSR request matching fixVersion 26 to be approved (needs to be created)

Issue

  • JDK-8325448: Hybrid Public Key Encryption (Enhancement - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18411/head:pull/18411
$ git checkout pull/18411

Update a local copy of the PR:
$ git checkout pull/18411
$ git pull https://git.openjdk.org/jdk.git pull/18411/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18411

View PR using the GUI difftool:
$ git pr show -t 18411

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18411.diff

Using Webrev

Link to Webrev Comment

wangweij avatar Mar 20 '24 20:03 wangweij

:wave: Welcome back weijun! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Mar 20 '24 20:03 bridgekeeper[bot]

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Mar 20 '24 20:03 openjdk[bot]

@wangweij The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

openjdk[bot] avatar Mar 20 '24 20:03 openjdk[bot]

@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!

bridgekeeper[bot] avatar May 16 '24 01:05 bridgekeeper[bot]

/csr

wangweij avatar Jun 28 '24 13:06 wangweij

@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.

openjdk[bot] avatar Jun 28 '24 13:06 openjdk[bot]

@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!

bridgekeeper[bot] avatar Aug 23 '24 14:08 bridgekeeper[bot]

@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 pull request command.

bridgekeeper[bot] avatar Oct 18 '24 14:10 bridgekeeper[bot]

/open

wangweij avatar Nov 06 '24 18:11 wangweij

@wangweij This pull request is now open

openjdk[bot] avatar Nov 06 '24 18:11 openjdk[bot]

@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!

bridgekeeper[bot] avatar Jan 01 '25 21:01 bridgekeeper[bot]

@wangweij This pull request has been inactive for more than 8 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 pull request command.

bridgekeeper[bot] avatar Feb 26 '25 02:02 bridgekeeper[bot]

/open

wangweij avatar Feb 26 '25 03:02 wangweij

@wangweij This pull request is now open

openjdk[bot] avatar Feb 26 '25 03:02 openjdk[bot]

Initially, I was unsure whether to support mode_auth and mode_auth_psk since our KEM API does not support authenticated encapsulation. However, after looking at HPKE implementations from other vendors -- such as OpenSSL, Go, and Rust -- I found that most of them support it. In the latest commit, I’ve added support by directly invoking newly added methods in the DHKEM private class.

Note that DHKEM is a higher-level cryptographic algorithm built on lower-level primitives like DH key agreement and HKDF. As a result, even though it is implemented only in the SunJCE provider, it can handle keys or IKM values from other providers by leveraging DH and HKDF from those providers.

wangweij avatar Mar 04 '25 01:03 wangweij

I've just added a new HPKEParameterSpec::of that only takes KDF and AEAD ids. The reason is that these 2 are really user-choosable and KEM id is usually determined by the key type.

wangweij avatar Mar 11 '25 21:03 wangweij

usually determined by the key type.

Hm, might be a bit more complicated for PQ/T Hybrid KEMs. It can of course be added later on, as the implementations using that (like Xwing for HPKE with JOSE) are still in draft state.

ecki avatar Mar 11 '25 21:03 ecki

We still have the 3-argument of. Also, for future PQ/T Hybrid KEMs, it looks like the trend is that a Hybrid algorithm will have its own KeyPairGenerator (so the user does not need to assemble the key themselves) and the key's algorithm (or parameter set name) will also be its own. So it's quite likely that one key type still has only one kem_id. Let's wait.

wangweij avatar Mar 11 '25 23:03 wangweij

I’ve pushed a new commit that allows the sender to retrieve the actual algorithm identifiers used. These identifiers should typically be sent along with the key encapsulation message when establishing an HPKE encryption channel, enabling the receiver to construct the same HPKEParameterSpec to initialize their cipher. This is reflected in the updated example in the class spec.

Furthermore, I almost believe the receiver should not be allowed to initialize an HPKE cipher with an HPKEParameterSpec that has unspecified algorithm identifiers. This becomes especially important if different HPKE implementations have different defaults. What do you think? Please be noted that this means the receiver can no longer initialize a cipher with new IvParameterSpec(encap).

I think I now regret adding the two-argument of method. I'd like to only keep of() which is only for sender, and of(int,int,int) for both sender and receiver.

wangweij avatar Mar 13 '25 20:03 wangweij