Skip to content

Conversation

@djelinski
Copy link
Member

@djelinski djelinski commented Sep 25, 2025

The DiffieHellman KeyAgreement supports 2 key algorithms: TlsPremasterSecret and Generic. The Generic algorithm is supposed to generate keys of a constant length, keeping leading zeroes as appropriate.

This PR changes the SunPKCS11 implementation to pass a CKA_VALUE_LEN attribute when a fixed length is needed; when the attribute is absent, the PKCS11 provider strips the leading zeroes.

Added a check to the existing test cases to verify the fix. The check passes with the fix, fails without it. Other tier1-3 tests continue to pass.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8368694: PKCS11-NSS generic keys generated by DH have leading zeroes stripped (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27494/head:pull/27494
$ git checkout pull/27494

Update a local copy of the PR:
$ git checkout pull/27494
$ git pull https://git.openjdk.org/jdk.git pull/27494/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 27494

View PR using the GUI difftool:
$ git pr show -t 27494

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27494.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 25, 2025

👋 Welcome back djelinski! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 25, 2025

@djelinski This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8368694: PKCS11-NSS generic keys generated by DH have leading zeroes stripped

Reviewed-by: valeriep

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 206 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title 8368694 8368694: PKCS11-NSS generic keys generated by DH have leading zeroes stripped Sep 25, 2025
@openjdk openjdk bot added the security security-dev@openjdk.org label Sep 25, 2025
@openjdk
Copy link

openjdk bot commented Sep 25, 2025

@djelinski The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@djelinski djelinski marked this pull request as ready for review September 25, 2025 18:00
@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 25, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 25, 2025

Webrevs

attributes = new CK_ATTRIBUTE[]{
new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY),
new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType),
new CK_ATTRIBUTE(CKA_VALUE_LEN, secretLen),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about attributes in another xxxGenerateSecret(...) method? Should we also add CKA_VALUE_LEN attribute with secretLen value there as well, i.e. line 200-203,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @valeriepeng for the review. I added CKA_VALUE_LEN to the paramterless overload now.

Copy link
Contributor

@valeriepeng valeriepeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 8, 2025
@djelinski
Copy link
Member Author

Thanks @valeriepeng for the re-review.

/integrate

@openjdk
Copy link

openjdk bot commented Oct 9, 2025

Going to push as commit 914b44e.
Since your change was applied there have been 213 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 9, 2025
@openjdk openjdk bot closed this Oct 9, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 9, 2025
@openjdk
Copy link

openjdk bot commented Oct 9, 2025

@djelinski Pushed as commit 914b44e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@djelinski djelinski deleted the pkcs11-dh-zeroes branch October 9, 2025 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated security security-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

2 participants