RSAData

public class RSAData

RSA Data Object: Allows for RSA Encryption/Decryption, Signing/Verification and various utility functions.

Enums

  • Denotes the type of data this represents.

    See more

    Declaration

    Swift

    public enum DataType

– Properties

  • 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/Decrypt

— Sign/Verification

  • 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

— Utility

  • 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