Closed simonjbeaumont closed 4 months ago
cc @ptoffy since we've implemented that ourselves in JWTKit - we should either wait for this or ensure our APIs are internal so we can switch over without an API break
@0xTim we have our own key wrapping SwiftCrypto's so we should be fine. We can switch to this without breaking anything
@swift-server-bot test this please
Motivation
We currently offer APIs to construct RSA keys from PEM and DER representations but we have no way of constructing they key from its constituent RSA parameters: n and e for public keys, and n, e, d, p, and q for private keys. Sometimes these are what you have to hand, e.g. in a JSON Web Key.
Modifications
Provide initializers for RSA keys from RSA parameters for all the RSA key types.
To implement this, we leverage the fact that we are making use of BoringSSL in
_CryptoExtras
on all platforms. We need this because there are no APIs to construct the underlying key type on Darwin platforms from these parameters. So we do this by first creating a BoringSSL key, serializing it to PEM format, and then constructing a platform-specific key from the PEM representation.Result
New APIs to construct RSA keys from RSA parameters.