Add DefaultSecurityProviderConfig with Bouncy Castle disabled#861
Merged
hierynomus merged 4 commits intohierynomus:masterfrom Jul 20, 2023
Merged
Add DefaultSecurityProviderConfig with Bouncy Castle disabled#861hierynomus merged 4 commits intohierynomus:masterfrom
hierynomus merged 4 commits intohierynomus:masterfrom
Conversation
This was referenced May 23, 2023
85e64a0 to
20fd4c4
Compare
Contributor
Author
|
Thanks for rebasing this PR @hierynomus. What do you think about these changes? As stated in the description, the net effect is removing Bouncy Castle registration has a hard-coded requirement for the standard algorithms and key providers. At this time, Bouncy Castle is still required for some of the Private Key parsing, and also required for certain algorithms on Java 8, like ChaCha20-Poly1305 and X25519. However, it does move more in the direction of making it optional in some use cases. |
Owner
|
It's merged :) For now I think this is indeed the best to be done with removing the need for BC. |
Contributor
Author
|
Thanks @hierynomus! |
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.
This pull request address issue #782 with a new
DefaultSecurityProviderConfigthat extendsDefaultConfigand disables Bouncy Castle Security Provider registration in a static initializer.As described in the referenced issue,
SecurityUtils.isBouncyCastleRegistered()checks current Security Providers and attempts to register Bouncy Castle according to the default settings. TheDefaultConfigclass checks the status of Bouncy Castle registration to determine whether to configure standard factories, but this introduces unnecessary coupling between Bouncy Castle registration and standard algorithm factories.Changes in this pull request include removing the
SecurityUtils.isBouncyCastleRegistered()check from theDefaultConfigconstructor and registering all factories. TheinitCipherFactories()method already attempts to initialize configured Cipher Factories and disables factories when the corresponding cipher algorithm is not supported. The random factories do not depend on Bouncy Castle registration, and the Key File Provider factories may or may not need Bouncy Castle depending on the particular key protection algorithms. Removing the dependence of Bouncy Castle registration allows the rest of the library to attempt security operations as needed with the potential to support other Security Providers. It is important to note that theDefaultConfigwill attempt to register the Bouncy Castle Provider when calling otherSecurityUtilsmethods, but removing the registered check avoids tight coupling to the particular provider.With the changes to
DefaultConfig, the newDefaultSecurityProviderConfigincludes a static initializer to callSecurityUtils.setRegisterBouncyCastle(false). This changes subsequent behavior and thus expectsjava.securitysettings or other external components to setup the providers necessary.SecurityUtils.setRegisterBouncyCastle()could be called without the introduction of a new configuration class, but new class provides a clear indication of expected behavior, and simple replacement forDefaultConfigwhen necessary. Additional adjustments include removingSecurityUtils.isBouncyCastleRegistered()from several locations where it should not be required.