DeviceAuthenticationKeyStore

The local device's authentication key pair (docs/server-authentication.md), separate from the messaging identity. There is at most one active key. It is replaced only by promoting a pending key after the server accepted it: the pending recovery key of a device recovery (docs/device-recovery.md), the pending rotation key of a routine rotation (docs/device-authentication-rotation.md) or the pending last-device recovery key of a last-device recovery (docs/last-device-recovery.md). The three pending slots are separate, and at most one of them is filled at a time.

Functions

Link copied to clipboard
abstract suspend fun awaitsUpgradeKey(): Boolean

true only for storage that held a local identity before device authentication keys existed (milestone 12) and has not stored a key since. Such an installation gets its first key from SecureMessageClient.initialize. For any other storage a missing key means it was lost, and a new one must not be created. Storing a key makes this false for good.

Link copied to clipboard
abstract suspend fun keyPair(): DeviceAuthenticationKeyPair?
Link copied to clipboard

The replacement key pair of a last-device recovery in progress (docs/last-device-recovery.md), or null. Never used to sign ordinary requests.

Link copied to clipboard

The replacement key pair of a device recovery in progress (docs/device-recovery.md), or null. Never used to sign ordinary requests.

Link copied to clipboard

The replacement key pair of a routine rotation in progress (docs/device-authentication-rotation.md), or null. Never used to sign ordinary requests.

Link copied to clipboard

In one atomic step: makes the pending last-device recovery key pair the active key (replacing the active key, or installing it if the active key was lost), removes the pending key and makes awaitsUpgradeKey false. Only for a pending key the server accepted. Throws IllegalStateException and changes nothing if there is no pending key.

Link copied to clipboard
abstract suspend fun promotePendingRecoveryKeyPair()

In one atomic step: makes the pending recovery key pair the active key (replacing the active key, or installing it if the active key was lost), removes the pending key and makes awaitsUpgradeKey false. Only for a pending key the server accepted. Throws IllegalStateException and changes nothing if there is no pending key.

Link copied to clipboard
abstract suspend fun promotePendingRotationKeyPair()

In one atomic step: makes the pending rotation key pair the active key (replacing the active key, or installing it if the active key was lost), removes the pending key and makes awaitsUpgradeKey false. Only for a pending key the server accepted. Throws IllegalStateException and changes nothing if there is no pending key.

Link copied to clipboard

Removes the pending last-device recovery key pair, if any. The active key and the other slots are not touched.

Link copied to clipboard
abstract suspend fun removePendingRecoveryKeyPair()

Removes the pending recovery key pair, if any. The active key is not touched.

Link copied to clipboard
abstract suspend fun removePendingRotationKeyPair()

Removes the pending rotation key pair, if any. The active key and a pending recovery key are not touched.

Link copied to clipboard
abstract suspend fun store(keyPair: DeviceAuthenticationKeyPair)

Stores the key pair. Throws IllegalStateException if one exists already, also an identical one: a key is never replaced silently.

Link copied to clipboard

Stores the replacement key pair of a last-device recovery. Throws IllegalStateException if one exists already (a pending key is never replaced silently) or if a device recovery or a routine rotation is pending. The active key is not touched.

Link copied to clipboard

Stores the replacement key pair of a device recovery. Throws IllegalStateException if one exists already (a pending key is never replaced silently) or if a routine rotation or a last-device recovery is pending. The active key is not touched.

Link copied to clipboard

Stores the replacement key pair of a routine rotation. Throws IllegalStateException if one exists already (a pending key is never replaced silently) or if a device recovery or a last-device recovery is pending. The active key is not touched.