CryptoProvider

public protocol CryptoProvider : AnyObject

Provides utility functions for cryptographic operations.

  • Encrypts the given data using the specified key and encryption algorithm.

    Declaration

    Swift

    func encrypt(keyId: String, algorithm: SymmetricKeyEncryptionAlgorithm, data: Data) throws -> Data

    Parameters

    keyId

    ID of the encryption key to use.

    algorithm

    Encryption algorithm to use.

    data

    Data to encrypt.

    Return Value

    Encrypted data.

  • Encrypts the given data using the specified key and encryption algorithm.

    Declaration

    Swift

    func decrypt(keyId: String, algorithm: SymmetricKeyEncryptionAlgorithm, data: Data) throws -> Data

    Parameters

    keyId

    ID of the encryption key to use.

    algorithm

    Encryption algorithm to use.

    data

    Data to decrypt.

    Return Value

    Decrypted data.

  • Generate an encryption key to use for encrypting Sudo claims. Any existing keys are not removed to be able to decrypt existing claims but new claims will be encrypted using the newly generated key.

    Declaration

    Swift

    func generateEncryptionKey() throws -> String

    Return Value

    Unique ID of the generated key.

  • Get the current (most recently generated) symmetric key ID.

    Declaration

    Swift

    func getSymmetricKeyId() throws -> String?

    Return Value

    Symmetric Key ID.

  • Import encyrption keys to use for encrypting and decrypting Sudo claims.

    Declaration

    Swift

    func importEncryptionKeys(keys: [EncryptionKey], currentKeyId: String) throws

    Parameters

    keys

    Keys to import.

    currentKeyId

    ID of the key to use for encrypting new claims..

  • Export encryption keys used for encrypting and decrypting Sudo claims.

    Declaration

    Swift

    func exportEncryptionKeys() throws -> [EncryptionKey]

    Return Value

    Encryption keys.

  • Removes all keys associated with this provider.

    Declaration

    Swift

    func reset() throws