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

Weijun Wang weijun at openjdk.org
Mon May 13 21:09:10 UTC 2024


On Fri, 10 May 2024 20:54:45 GMT, Kevin Driver <kdriver at openjdk.org> wrote:

>> src/java.base/share/classes/javax/crypto/spec/HKDFParameterSpec.java line 47:
>> 
>>> 45:     final class Builder {
>>> 46: 
>>> 47:         Extract extract = null;
>> 
>> No need to store an `extract` field. Just create one and return it in `extractOnly`.
>
> This field is required for checks in other functions.

This field is useless. Since the only place to create a builder is `return new Builder().createExtract()` in the `extract()` method, the field is always non null. But then when `exactOnly` is called you create a new one and return it. And when `andExpand` is call, you only check if it's null (which never is).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18924#discussion_r1599084176



More information about the security-dev mailing list