RFR: 8358451: SunJCE PBEKey impl should throw IllegalStateException when getEncoded() is called

Valerie Peng valeriep at openjdk.org
Wed Jun 4 13:19:19 UTC 2025


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.

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

Commit messages:
 - 8358451: SunJCE PBEKey impl should throw IllegalStateException when getEncoded() is called

Changes: https://git.openjdk.org/jdk/pull/25632/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25632&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8358451
  Stats: 73 lines in 3 files changed: 68 ins; 1 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/25632.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25632/head:pull/25632

PR: https://git.openjdk.org/jdk/pull/25632


More information about the security-dev mailing list