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
8023980: JCE doesn't provide any class to handle RSA private key in PKCS#1 #1787
Conversation
…KCS openjdk#1 Enhanced RSA KeyFactory impl of SunRsaSign and SunPKCS11 providers to accept RSA keys in PKCS#1 format and encoding
👋 Welcome back valeriep! A progress list of the required criteria for merging this PR into |
@valeriepeng The following label will be automatically applied to this pull request:
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. |
Webrevs
|
@valeriepeng This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Ping~ Anyone has time to looks at this? I will sync with the master since it's been a while... The changes are straight forward, just add support for PKCS#1 encoded RSA keys. There is already existing code parsing the PKCS#1 encoding underneath the PKCS#8 layer. This is more like code-refactoring. Comments? |
checkKeyAlgo(generated, type.keyAlgo); | ||
return generated; | ||
return RSAPrivateCrtKeyImpl.newKey(type, "PKCS#8", | ||
((PKCS8EncodedKeySpec)keySpec).getEncoded()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you clean up the getEncoded()
output or shall I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's better that you do it this time? Just so that the backport won't miss it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if you integrated before me, I will manually merge the changes and clean up the getEncoded() also.
src/java.base/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
Outdated
Show resolved
Hide resolved
/integrate |
@valeriepeng This PR has not yet been marked as ready for integration. |
Mailing list message from Michael StJohns on security-dev: Sorry - I'm coming to this a bit late. Any chance of adding the logic for generatePublic() from a PKCS8 RSA PKCS11 2.40 started requiring that the publicExponent be stored with the Mike On 1/14/2021 4:06 PM, Valerie Peng wrote: |
@valeriepeng 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:
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 54 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. ➡️ To integrate this PR with the above commit message to the |
You are correct that for RSA private CRT keys the necessary values are there for figuring out its corresponding public keys. This change is about adding support for PKCS#1 encoded RSA keys and be able to translate them into PKCS#8 encoded keys and/or extract various key specs out of them. If you already have PKCS#8 RSAPrivateCrtKey obj from SunRsaSign provider, you can call its getPublicExponent() method and use that to create a RSAPublicKeySpec and generate RSA public key with it. If you are using 3rd party impl which does not return the public exponent value somehow, then you can translate it using the RSA key factory impl from SunRsaSign provider and then repeat the fore-mentioned step. Will this address your need? If not, could you elaborate the usage that you have in mind? Not sure if you are suggesting a new KeyFactory.generatePublic() method which take a PrivateKey or else. |
Mike, Thanks! Valerie |
/integrate |
@valeriepeng Since your change was applied there have been 86 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 68cf65d. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Mailing list message from Michael StJohns on security-dev: On 1/17/2021 9:29 PM, Valerie Peng wrote: No worries - I got busy with other things for a few days. To answer your other question, I've had a few cases where the public key About 4 years or so ago (e.g. when 2.40 was released), the PKCS11 group That's a more general RFE than just updating the current implementing An interesting addition would be to have the Impl classes implement both |
Can someone help review this?
This change enhances RSA KeyFactory impl of SunRsaSign and SunPKCS11 providers to accept RSA keys in PKCS#1 format and encoding and translate them to provider-specific RSA keys. Updated the relevant tests with a sample PKCS#1 encoded key pair.
Thanks,
Valerie
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/1787/head:pull/1787
$ git checkout pull/1787