RFR: 8002277: Refactor two PBE classes to simplify maintenance [v2]

Valerie Peng valeriep at openjdk.java.net
Tue May 10 01:25:47 UTC 2022


On Fri, 6 May 2022 22:24:57 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Valerie Peng has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   update copyright year for PBES2Core.java
>
> src/java.base/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java line 314:
> 
>> 312:                     } else if (cipher instanceof DESedeCipher tripleDes) {
>> 313:                         tripleDes.engineInit(opmode, cipherKey, ivSpec, random);
>> 314:                     } else {
> 
> Can we combine the 2 if above? What else type can it be?

Currently, the specified CipherSpi object is one of RC4, RC2, DESede. The "else" part is for catching new PKCS12 PBE algorithms support which uses other cipher algorithms.
CipherSpi.engineInit(...) is protected, so that's why we use the instanceof to cast the CipherSpi object into the actual impl class in order to call the engineInit(...) since the actual impl class is in the same package of this class.

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

PR: https://git.openjdk.java.net/jdk/pull/8521



More information about the security-dev mailing list