RSAData
public class RSAData
RSA Data Object: Allows for RSA Encryption/Decryption, Signing/Verification and various utility functions.
-
Denotes the type of data this represents.
See moreDeclaration
Swift
public enum DataType
-
Data of the message
Declaration
Swift
public let data: Data
-
Represents the type of data contained.
Declaration
Swift
public internal(set) var type: DataType { get }
-
Base64-encoded string of the message data
Declaration
Swift
public var base64String: String { get }
-
Encrypt the data.
Declaration
Swift
public func encrypted(with key: PublicKey, algorithm: Data.Algorithm) throws -> EncryptedData?
Parameters
key
The
PublicKey
algorithm
The algorithm to use (
Data.Algorithm
).Return Value
A new optional
EncryptedData
containing the encrypted data. -
Decrypt the data.
Declaration
Swift
public func decrypted(with key: PrivateKey, algorithm: Data.Algorithm) throws -> PlaintextData?
Parameters
key
The
PrivateKey
algorithm
The algorithm to use (
Data.Algorithm
).Return Value
A new optional
PlaintextData
containing the decrypted data.
-
Sign the data
Declaration
Swift
public func signed(with key: PrivateKey, algorithm: Data.Algorithm, usePSS: Bool = false) throws -> SignedData?
Parameters
key
The
PrivateKey
.algorithm
The algorithm to use (
Data.Algorithm
).usePSS
Bool stating whether or not to use RSA-PSS (Probabilistic signature scheme).
Return Value
A new optional
SignedData
containing the digital signature. -
Verify the signature
Declaration
Swift
public func verify(with key: PublicKey, signature: SignedData, algorithm: Data.Algorithm, usePSS: Bool = false) throws -> Bool
Parameters
key
The
PublicKey
.signature
The
SignedData
containing the signature to verify against.algorithm
The algorithm to use (
Data.Algorithm
).usePSS
Bool stating whether or not to use RSA-PSS (Probabilistic signature scheme).
Return Value
True if verification is successful, false otherwise
-
Retrieve a digest of the data using the specified algorithm.
Declaration
Swift
public func digest(using algorithm: Data.Algorithm) throws -> Data
Parameters
algorithm
Algoririthm to use.
Return Value
Data
containing the digest. -
String representation of message in specified string encoding.
Declaration
Swift
public func string(using encoding: String.Encoding) throws -> String
Return Value
String representation of the message