RFR: 8358451: SunJCE PBEKey impl should throw IllegalStateException when getEncoded() is called
Kevin Driver
kdriver at openjdk.org
Mon Jun 16 14:44:31 UTC 2025
On Fri, 6 Jun 2025 21:36:06 GMT, Valerie Peng <valeriep at openjdk.org> wrote:
>> src/java.base/share/classes/com/sun/crypto/provider/PBEKey.java line 82:
>>
>>> 80: }
>>> 81:
>>> 82: public byte[] getEncoded() {
>>
>> I understand this is not a public API class so there is no need to provide `@throws` in the spec. But, on the other hand, do we need to provide one in its super class `java.security.key`? I have no opinion.
>
> Well, I am not sure. `java.securityKey` is the super interface for all keys, including private, public, and secret keys. The Exception is due to implementing the `javax.security.auth.Destroyable` interface, so the `@throws` spec should goes to the class which implements both `Destroyable` and `Key` interfaces. `PBEKey` is not a public API class, so perhaps we can documenting this in the `SunJCE` provider section as this is implementation-specific?
Also, `PublicKey` does not implement (or implement by inheritance) `Destroyable`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25632#discussion_r2150187408
More information about the security-dev
mailing list