RFR: 8353578: Refactor existing usage of internal HKDF impl to use the KDF API [v4]

Valerie Peng valeriep at openjdk.org
Fri Apr 25 18:43:02 UTC 2025


On Fri, 25 Apr 2025 15:36:26 GMT, Weijun Wang <weijun at openjdk.org> wrote:

>> Valerie Peng has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Undo the special workaround for JSSE in PKCS11 HKDF impl.
>
> src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java line 131:
> 
>> 129: 
>> 130:             // derive handshake secret
>> 131:             return hkdf.deriveKey(type, HKDFParameterSpec.ofExtract()
> 
> The line above may fail because the `hkdf` object has been used once on line 121 with zero-valued salt and IKM, which selected the software-based HKDF from SunJCE. At this point, however, `sharedSecret` is the result of ECDH and may be non-extractable if produced by an HSM, making it incompatible with the SunJCE implementation. To avoid this issue, get a new `hkdf` by calling `hkdf = KDF.getInstance(hashAlg.hkdfAlgorithm)` before this line.

Hmm, ok, interesting scenario. I add another `KDF.getInstance()` call as you suggested just to be safe.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24393#discussion_r2060720014


More information about the security-dev mailing list