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
keyThe
PublicKeyalgorithmThe algorithm to use (
Data.Algorithm).Return Value
A new optional
EncryptedDatacontaining the encrypted data. -
Decrypt the data.
Declaration
Swift
public func decrypted(with key: PrivateKey, algorithm: Data.Algorithm) throws -> PlaintextData?Parameters
keyThe
PrivateKeyalgorithmThe algorithm to use (
Data.Algorithm).Return Value
A new optional
PlaintextDatacontaining the decrypted data.
-
Sign the data
Declaration
Swift
public func signed(with key: PrivateKey, algorithm: Data.Algorithm, usePSS: Bool = false) throws -> SignedData?Parameters
keyThe
PrivateKey.algorithmThe algorithm to use (
Data.Algorithm).usePSSBool stating whether or not to use RSA-PSS (Probabilistic signature scheme).
Return Value
A new optional
SignedDatacontaining the digital signature. -
Verify the signature
Declaration
Swift
public func verify(with key: PublicKey, signature: SignedData, algorithm: Data.Algorithm, usePSS: Bool = false) throws -> BoolParameters
keyThe
PublicKey.signatureThe
SignedDatacontaining the signature to verify against.algorithmThe algorithm to use (
Data.Algorithm).usePSSBool 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 -> DataParameters
algorithmAlgoririthm to use.
Return Value
Datacontaining the digest. -
String representation of message in specified string encoding.
Declaration
Swift
public func string(using encoding: String.Encoding) throws -> StringReturn Value
String representation of the message
RSAData Class Reference