New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8272385: Enforce ECPrivateKey d value to be in the range [1, n-1] for SunEC provider #5324
Conversation
|
Webrevs
|
So the key is only validated before it's used? Why not when creating it? Do we need to validate public key as well? It might not be a problem since modular calculation should scale it back to normal. Our old native impl does have one at https://github.com/openjdk/jdk11u-dev/blob/master/src/jdk.crypto.ec/share/native/libsunec/impl/ec.c#L481. One more thing: I would prefer |
Good questions. Validating the public key might not be a bad idea. I could come up with a Java-based version of what's in libsunec and update the test to cover that as well. With respect to the synopsis, I'd prefer to leave it [1, n-1] because that's the notation used by FIPS 186-4, X9.62 and SEC 1. But the BigInteger.compareTo I will change as you suggested. |
@jnimeh This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
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 21 new commits pushed to the
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.
|
Looks fine. One nit: how about let checkPrivateKey
returning the key like Objects.requireNonNull()
does?
/integrate |
Going to push as commit 29e0f13.
Your commit was automatically rebased without conflicts. |
This fix adds an EC private key range check for the scalar value to be within the range [1, n-1] (n being the order of the generator) for the SunEC ECDSA Signature algorithms and ECDH KeyAgreement algorithms. While the SunEC KeyGenerator for EC keys will not generate private keys that sit outside the accepted range, it is possible to create and attempt to use ECPrivateKey objects that violate this range through a KeyFactory.
JBS: https://bugs.openjdk.java.net/browse/JDK-8272385
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5324/head:pull/5324
$ git checkout pull/5324
Update a local copy of the PR:
$ git checkout pull/5324
$ git pull https://git.openjdk.java.net/jdk pull/5324/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5324
View PR using the GUI difftool:
$ git pr show -t 5324
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5324.diff