KeyValueStorageBackend

protocol KeyValueStorageBackend

A protocol defining a key-value storage backend. It basically is similar to the KeyValueStorage protocol but with encryped keys and encrypted values.

You can use this to implement a custom protocol for storing a secure key-value storage.

  • Store an encrypted value to the key-value storage backend for a given key.

    Declaration

    Swift

    func store(value: EncryptedValue, for key: EncryptedKey, callback: @escaping (Error?) -> Void)

    Parameters

    value

    The encrypted value that should be stored.

    key

    The key that identifies the value.

    callback

    A closure that is called asynchronuously once the operation is finished.

    error

    An optional error that might have occurred during storing.

  • Retrieve an encrypted value from the key-value backend for a given key.

    Postcondition

    (value = nil) ⊻ (error = nil)

    Declaration

    Swift

    func retrieve(for key: EncryptedKey, callback: @escaping (EncryptedValue?, Error?) -> Void)

    Parameters

    key

    The key that identifies the value.

    callback

    A closure that is called asynchronuously once the operation is finished.

    value

    The value if no error occurred, nil else.

    error

    An optional error that might have occurred during storing.

  • Remove the encrypted value from the key-value backend for a given key.

    Declaration

    Swift

    func remove(for key: EncryptedKey, callback: @escaping (Error?) -> Void)

    Parameters

    key

    The key that identifies the value.

    callback

    A closure that is called asynchronuously once the operation is finished.

    error

    An optional error that might have occurred during storing.