RFR: 8331008: Implement JEP 478: Key Derivation Function API (Preview) [v10]

Viktor Klang vklang at openjdk.org
Thu Sep 5 15:12:09 UTC 2024


On Fri, 16 Aug 2024 18:25:19 GMT, Kevin Driver <kdriver at openjdk.org> wrote:

>> src/java.base/share/classes/com/sun/crypto/provider/HkdfKeyDerivation.java line 144:
>> 
>>> 142:                 salt = consolidateKeyMaterial(salts);
>>> 143:             } catch (InvalidKeyException ike) {
>>> 144:                 throw (InvalidAlgorithmParameterException) new InvalidAlgorithmParameterException(
>> 
>> Why are you using `initCause()` here when there is a [constructor](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/InvalidAlgorithmParameterException.html#%3Cinit%3E(java.lang.String,java.lang.Throwable)) is available and the following catch uses the `NSAE` version of the constructor?
>> This isn't the only usage of `initCause()`
>
> I believe these are left over from when the exception type was different and such a constructor was not available for the previous type. I think this qualifies as a nit, since the resultant behavior is equivalent. I'll leave as-is, since we have debated this exception type previously, and it is possible that it may change again in the preview cycle.

@driverkt It'd make sense to add a TODO comment to make sure it isn't forgotten? But in adding such a comment, one might already make the change to avoid initCause and the cast.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20301#discussion_r1745730580


More information about the security-dev mailing list