swift-crypto
swift-crypto copied to clipboard
extras: Add RSA primitives decoding API
Motivation:
At times we might need to get the raw elements of an RSA key, e.g when debugging.
Modifications:
Add a getKeyPrimitives method to the RSA (public and private) key structures that returns the elements.
To do this we leverage the built in BoringSSL methods (CCryptoBoringSSL_RSA_get0_n etc.) which return the raw elements of the key. In the Security version of the key we convert the key to a BoringSSL one and just call the BoringSSL method.
Once we get ASN.1 support in _CryptoExtras it might make sense switching the implementation of this method to decode the ASN.1 structure and returns the elements from there.
Result:
New APIs to fetch the key primitives.