RFR: 8325448: Hybrid Public Key Encryption [v15]

Sean Mullan mullan at openjdk.org
Tue Apr 15 18:40:59 UTC 2025


On Fri, 11 Apr 2025 20:41:13 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Implement HPKE as defined in https://datatracker.ietf.org/doc/rfc9180/.
>> ![hpke](https://github.com/user-attachments/assets/4edc5d08-ef52-44c5-b5d5-e8890c2d2fce)
>
> Weijun Wang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   toString, exportData, spec in HPKEParameters must have algorithm identifiers specified

src/java.base/share/classes/com/sun/crypto/provider/HPKE.java line 103:

> 101:             return impl.aead.cipher.getBlockSize();
> 102:         } else {
> 103:             throw new IllegalStateException("No AEAD cipher");

Should this return 0 instead per spec? The spec is not defined to throw `IllegalStateException`.

src/java.base/share/classes/com/sun/crypto/provider/HPKE.java line 112:

> 110:             return impl.aead.cipher.getOutputSize(inputLen);
> 111:         } else {
> 112:             throw new IllegalStateException("No AEAD cipher");

The spec is not defined to throw `IllegalStateException`.

src/java.base/share/classes/com/sun/crypto/provider/HPKE.java line 156:

> 154:         impl = new Impl(opmode);
> 155:         if (!(key instanceof AsymmetricKey ak)) {
> 156:             throw new InvalidKeyException("Not asymmetric key");

Nit: "Not an asymmetric key"

src/java.base/share/classes/com/sun/crypto/provider/HPKE.java line 178:

> 176:             AlgorithmParameters params, SecureRandom random)
> 177:             throws InvalidAlgorithmParameterException {
> 178:         throw new InvalidAlgorithmParameterException(

Could you support this method by extracting the `HKDFParameterSpec` from the `AlgorithmParameters`?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18411#discussion_r2044491111
PR Review Comment: https://git.openjdk.org/jdk/pull/18411#discussion_r2044497136
PR Review Comment: https://git.openjdk.org/jdk/pull/18411#discussion_r2044506212
PR Review Comment: https://git.openjdk.org/jdk/pull/18411#discussion_r2044514837


More information about the security-dev mailing list