Fix MSCAPISignatureToken compatibility with RSASSA-PSS (SunMSCAPI delegation)#188
Open
gustavoam-asdf wants to merge 2 commits intoesig:masterfrom
Open
Fix MSCAPISignatureToken compatibility with RSASSA-PSS (SunMSCAPI delegation)#188gustavoam-asdf wants to merge 2 commits intoesig:masterfrom
gustavoam-asdf wants to merge 2 commits intoesig:masterfrom
Conversation
612f5c9 to
f811053
Compare
Contributor
|
Hello, Thank you for the ticket and identifying the issue. I indeed was able to reproduce it locally. It looks like a limitation in BouncyCastle, not explicitly supporting the MS-CAPI keystore. I have created a ticket #2280 addressing the issue. I stay reluctant on hardcoding the security provider and corresponding logic directly in DSS, and would prefer first to wait for a response from BouncyCastle. KR, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem Description
When using
MSCAPISignatureTokenwith certificates stored in the Windows Certificate Store (MY) with high level of security in Crypto API, signing operations fail with aDSSExceptionwhen attempting to use RSASSA-PSS algorithms (e.g.,SHA256withRSAandMGF1), even if the certificate itself is a standardSHA256withRSA.Observation
SHA256withRSA) works correctly because the default provider selection might favor a compatible engine or a simple RSA implementation.RSAPrivateKeyinstance, but the Windows Certificate Store provides native keys (CAPI/KSP) which are opaque handles.Error Stack Trace
Proposed Solution
The
MSCAPISignatureTokenis inherently tied to the Windows environment. To ensure maximum compatibility with native keys, it should prioritize theSunMSCAPIprovider for all signing operations.Key Changes
getSignatureInstanceto explicitly request theSunMSCAPIprovider. This ensures that the native Windows engine, which "owns" the key handle, is the one performing the cryptographic operation.MGF1orPSS) to the standardRSASSA-PSSname recognized bySunMSCAPI(available since Java 11).SunMSCAPIis not available or doesn't support the requested algorithm (e.g., on very old Java versions), it falls back to the default implementation inAbstractSignatureTokenConnection.Implementation
Benefits
SunMSCAPImight be restricted or outdated.