RFR: 8358451: SunJCE PBEKey impl should throw IllegalStateException when getEncoded() is called
Kevin Driver
kdriver at openjdk.org
Fri Jun 27 17:56:43 UTC 2025
On Wed, 4 Jun 2025 03:10:29 GMT, Valerie Peng <valeriep at openjdk.org> wrote:
> Update the `PBEKey` class of the SunJCE provider which override the `javax.security.auth.Destroyable` interface to
>
> 1. throw `IllegalStateException` if `getEncoded()` is called after key is destroyed
> 2. serialization of such destroyed `PBEKey` object will lead to exception.
>
> Also update the `PBEKeyFactory` class of the SunJCE provider to check for destroyed keys and throw exceptions per the method javadoc.
src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java line 85:
> 83: try {
> 84: if (isDestroyed()) {
> 85: throw new IllegalStateException("key is destroyed");
nit: for uniformity, you may want to capitalize key since it is capitalized elsewhere
src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java line 209:
> 207: try {
> 208: if (isDestroyed()) {
> 209: throw new NotSerializableException("key is destroyed");
nit: for uniformity, you may want to capitalize `key` since it is capitalized elsewhere
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25632#discussion_r2172563144
PR Review Comment: https://git.openjdk.org/jdk/pull/25632#discussion_r2172562131
More information about the security-dev
mailing list