Added RSAKey.makeKeyPair() and RSAKey.pemString #44
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.
Description
This pull request adds a new function to CryptorRSA:
Where
KeySize
is a new extensible struct representing the supported key sizes.This will generate an RSA public and private key pair for either 1024, 2048, 3073 or 4096 bits.
I have also added a field:
Which will return the pkcs#1 PEM string for either the public or private key.
I have also refactors the linux implementation to use
d2i_PrivateKey_bio
andd2i_PUBKEY_bio
which solves issue #7. This simplifies the code since both apple and linux take the DER format and saves you from unnecessarily adding and removing headers.Finally this fixes a bug with the AAD in GCM Encoding and decoding for 2048 and 3072 bit keys.
Motivation and Context
This solves issue #14 and #7 and has been implemented because users of SwiftJWT have requested the ability to dynamically generate RSA Keys for use in their projects.
How Has This Been Tested?
A new test has been added that generates keys for all the possible bits, exports the pemString and then uses the pemString to create new keys which are tested. This covers all the code paths added by this code.
Checklist: