PrivateKey
RSA.swift:167- iOS
- 13+
- macOS
- 10.15+
- tvOS
- 13+
- watchOS
- 6+
struct PrivateKey
struct PrivateKey
import _CryptoExtras
Provides additional cryptographic APIs that are not available in CryptoKit (and therefore the core Crypto library).
enum Signing
enum _RSA
Types associated with the RSA algorithm
struct KeySize
struct Padding
struct PublicKey
struct RSASignature
protocol Sendable
init<Bytes>(derRepresentation: Bytes) throws where Bytes : DataProtocol
Construct an RSA private key from a DER representation.
init(keySize: _RSA.Signing.KeySize) throws
Randomly generate a new RSA private key of a given size.
init(n: some ContiguousBytes, e: some ContiguousBytes, d: some ContiguousBytes, p: some ContiguousBytes, q: some ContiguousBytes) throws
Construct an RSA private key with the specified parameters.
init(pemRepresentation: String) throws
Construct an RSA private key from a PEM representation.
init<Bytes>(unsafeDERRepresentation derRepresentation: Bytes) throws where Bytes : DataProtocol
Construct an RSA public key from a DER representation.
init(unsafeKeySize keySize: _RSA.Signing.KeySize) throws
Randomly generate a new RSA private key of a given size.
init(unsafePEMRepresentation pemRepresentation: String) throws
Construct an RSA public key from a PEM representation.
static func _createFromNumbers(n: some ContiguousBytes, e: some ContiguousBytes, d: some ContiguousBytes) throws -> _RSA.Signing.PrivateKey
Construct a private key with the specified parameters.
var derRepresentation: Data { get }
var keySizeInBits: Int { get }
var pemRepresentation: String { get }
var pkcs8PEMRepresentation: String { get }
var publicKey: _RSA.Signing.PublicKey { get }
func signature<D>(for digest: D) throws -> _RSA.Signing.RSASignature where D : Digest
Generates an RSA signature with the given key using the default padding.
func signature<D>(for data: D) throws -> _RSA.Signing.RSASignature where D : DataProtocol
Generates an RSA signature with the given key using the default padding.
func signature<D>(for digest: D, padding: _RSA.Signing.Padding) throws -> _RSA.Signing.RSASignature where D : Digest
Generates an RSA signature with the given key.
func signature<D>(for data: D, padding: _RSA.Signing.Padding) throws -> _RSA.Signing.RSASignature where D : DataProtocol
Generates an RSA signature with the given key. SHA256 is used as the hash function.