8328119: SunPKCS#11 implementation of HKDF #22215
Open
+1,616
−60
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We would like to propose an implementation of the HKDF algorithms for SunPKCS11, aligned with the KDF API proposed for JDK 24 (see JEP 478: Key Derivation Function API (Preview)).
This implementation will be under the Preview umbrella until the KDF API becomes stable in a future JDK release. The benefit of this early proposal is to gather more feedback about the KDF API for future improvements.
The
P11KDF
class has the core implementation and Java calls to the PKCS 11 API. Different native mechanism were used to merge key material: CKM_CONCATENATE_BASE_AND_DATA (key and data), CKM_CONCATENATE_BASE_AND_KEY (key and key) and CKM_CONCATENATE_DATA_AND_BASE (data and key). The implementation also supports merging data with data, at the Java level. List of HKDF algorithms supported: HKDFWithHmacSHA1, HKDFWithHmacSHA224, HKDFWithHmacSHA256, HKDFWithHmacSHA384, and, HKDFWithHmacSHA512.Derivation modes supported: extract, expand, and, extract-expand.
We further advanced the consolidation of algorithm and key info in the P11SecretKeyFactory map —this effort started with the PBE support enhancement and has helped to avoid duplication—. The map has now information about HMAC (
HMACKeyInfo
class) and HKDF (HKDFKeyInfo
class) algorithms. P11Mac is now aligned to take the information from the map.Generic keys now supported in SecretKeyFactory. Derived keys could be Generic.
Testing
TestHKDF.java test added
No regressions observed in jdk/sun/security/pkcs11 (114 tests passed, 0 failed)
A CSR will be proposed.
This proposal is a contribution of @martinuy and @franferrax .
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22215/head:pull/22215
$ git checkout pull/22215
Update a local copy of the PR:
$ git checkout pull/22215
$ git pull https://git.openjdk.org/jdk.git pull/22215/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22215
View PR using the GUI difftool:
$ git pr show -t 22215
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22215.diff
Using Webrev
Link to Webrev Comment