Initializer
init(modulus:exponent:privateExponent:)
RSA.PrivateKey instance with modulus, exponent, and private exponent.init(modulus: String, exponent: String, privateExponent: String) throws
Parameters
modulusThe modulus of the RSA key, represented as a base64 URL encoded string.
exponentThe exponent of the RSA key, represented as a base64 URL encoded string.
Discussion
This convenience initializer creates an RSA key using the modulus, exponent, and private exponent. All these parameters are expected to be base64 URL encoded strings.
Throws
JWTError/genericwith the identifierRSAKeyif either the modulus or exponent cannot be decoded from their base64 URL encoded strings.RSAError/keyInitializationFailureif there is a failure in initializing the RSA key, especially when the private key components are involved.RSAError/keySizeTooSmallif the key size is less than 2048 bits.
Note
The provided modulus and exponent are key components for creating RSA public keys.
The private exponent is an additional parameter required for creating RSA private keys.