Move all encoding and decoding of asymmetric keys to specific version files #168
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.
In order to prevent version specific conditions in many locations, I choose to make
Keys\AsymmetricSecretKey
andKeys\AsymmetricPublicKey
abstract classes. This forces all instances to be of a specific version. This is a BC-break though. With this PRnew Keys\AsymmetricSecretKey()
andnew Keys\AsymmetricPublicKey
are not possible anymore. I doubt if this BC-break makes a huge impact on the users of the library. Who would have instantiated these keys using its constructor directly? But still, it is a BC-break.If you insist in fixing this without any BC breaks, I can make that work too, but I doubt if that makes the code more maintainable. And the goal of this PR is to make the code more maintainable. With this PR you can clearly see if there are anymore bugs between encoding and decoding of the specific versions. And there are. A question that arises is what to do with
new Keys\SymmetricKey()
? It would be consistent to make that abstract too. I would definitely prefer to go for that.If this would be merged, I can make tests for all the encoding and decoding and add
importPem
method to both versions.