RFR: 8358076: KeyFactory.getInstance("EdDSA").generatePublic(null) throws NPE

Weijun Wang weijun at openjdk.org
Thu May 29 23:35:52 UTC 2025


On Thu, 29 May 2025 22:38:41 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:

> I need a code review to throw `InvalidKeySpecException` when null is passed with `generatePublic()` and `generatePrivate()`.  This change takes the opportunity to modernize the KeyFactory code by using `switch` syntax for `instanceof` checking, as well as, keeping the previous design of the implementation method handling the null case.  There are existing JCK test cover this case, so no regression test is added.

src/java.base/share/classes/sun/security/ec/ECKeyFactory.java line 223:

> 221:             }
> 222:             case null -> throw new InvalidKeySpecException(
> 223:                 "keySpec most not be null");

`s/most/must/`. Add every other `case null` in this PR.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25533#discussion_r2114892682


More information about the security-dev mailing list