RFR: 8305310: Calculate PublicKey from PrivateKey

Matthew Donovan duke at openjdk.org
Fri Mar 31 11:18:16 UTC 2023


On Thu, 30 Mar 2023 19:31:47 GMT, Weijun Wang <weijun at openjdk.org> wrote:

> This code change is for DHKEM, which requires the function
> 
> pk(skX): The KEM public key corresponding to the KEM private key skX.
> 
> Only implemented for EC and XDH. Might add PKCS #11 support later.

src/jdk.crypto.ec/share/classes/sun/security/ec/ECPrivateKeyImpl.java line 217:

> 215:             return new ECPublicKeyImpl(w, ecParams);
> 216:         } catch (InvalidKeyException e) {
> 217:             throw new ProviderException("Should not happen", e);

On the remote chance that this exception is thrown, the message doesn't help the user.  A better message might be "Unexpected error creating public key" or even just not having a message and using the `ProviderException(Throwable)`constructor. 

This message is also used in XDHPrivateKeyimpl.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13250#discussion_r1154349583



More information about the security-dev mailing list