ClientRecordCipher

Seals and opens the sensitive client storage records with one storage key (docs/storage-encryption.md). Storage adapters store the sealed bytes as they are; they never handle keys, formats or associated data themselves.

Every sealed record is bound to its record type and to the row key given here: a record opened as another type or under another key fails with StorageEncryptionException.AuthenticationFailed. Opening never returns a partial or default value; every failure throws a StorageEncryptionException.

Properties

Link copied to clipboard
abstract val keyId: StorageKeyId

The key this cipher seals with (the current storage key).

Link copied to clipboard

The keys this cipher opens records of: keyId and, during a storage key rotation, the retained previous key (docs/storage-key-rotation.md).

Functions

Link copied to clipboard
Link copied to clipboard
abstract suspend fun openIdentity(sealed: ByteArray): LocalIdentity
Link copied to clipboard
abstract suspend fun openOneTimePreKey(id: OneTimePreKeyId, sealed: ByteArray): OneTimePreKeyPair
Link copied to clipboard
abstract suspend fun openPendingFrame(recipient: DeviceAddress, id: LogicalMessageId, sealed: ByteArray): ByteArray
Link copied to clipboard
abstract suspend fun openPendingInboundFrame(sender: DeviceAddress, id: LogicalMessageId, sealed: ByteArray): ByteArray
Link copied to clipboard
abstract suspend fun openProcessedDigest(sender: DeviceAddress, id: LogicalMessageId, sealed: ByteArray): ByteArray
Link copied to clipboard
abstract suspend fun openSession(remote: DeviceAddress, sealed: ByteArray): SecureSession
Link copied to clipboard
abstract suspend fun openSignedPreKey(id: SignedPreKeyId, sealed: ByteArray): SignedPreKeyPair
Link copied to clipboard

The whole device authentication key pair (docs/server-authentication.md).

The whole pending replacement key pair of a last-device recovery (docs/last-device-recovery.md). Its own record type, so it never opens as the active, the recovery or the rotation key or the other way round.

Link copied to clipboard

The whole pending replacement key pair of a device recovery (docs/device-recovery.md). Its own record type, so it never opens as the active key or the other way round.

Link copied to clipboard

The whole pending replacement key pair of a routine device authentication key rotation (docs/device-authentication-rotation.md). Its own record type, so it never opens as the active or the recovery key or the other way round.

Link copied to clipboard
abstract suspend fun sealIdentity(identity: LocalIdentity): ByteArray

The whole identity key pair.

Link copied to clipboard
abstract suspend fun sealKeyCheck(): ByteArray

A record with no content that proves the key when opened.

Link copied to clipboard
abstract suspend fun sealMigrationIntent(): ByteArray

Seals the legacy plaintext migration intent (record type 13, S1): proof, under the storage key created for it, that this key was created for an interrupted plaintext → encrypted migration of a database from before record encryption. Its only content is a fixed marker.

Link copied to clipboard
abstract suspend fun sealOneTimePreKey(preKey: OneTimePreKeyPair): ByteArray

Public and private key, bound to the prekey ID.

Link copied to clipboard
abstract suspend fun sealPendingFrame(recipient: DeviceAddress, id: LogicalMessageId, frame: ByteArray): ByteArray

A pending message frame, bound to the recipient and the logical message ID.

Link copied to clipboard
abstract suspend fun sealPendingInboundFrame(sender: DeviceAddress, id: LogicalMessageId, frame: ByteArray): ByteArray

A received message frame not yet committed by the application (docs/application-delivery.md), bound to the sender and the logical message ID. Its own record type, so it never opens as a sent frame.

Link copied to clipboard
abstract suspend fun sealProcessedDigest(sender: DeviceAddress, id: LogicalMessageId, digest: ByteArray): ByteArray

The 32-byte content digest of a committed received message (docs/application-delivery.md), bound to the sender and the logical message ID.

Link copied to clipboard
abstract suspend fun sealSession(session: SecureSession): ByteArray

The session state, bound to the remote address.

Link copied to clipboard
abstract suspend fun sealSignedPreKey(preKey: SignedPreKeyPair): ByteArray

Public key, signature and private key, bound to the prekey ID.

Link copied to clipboard
abstract suspend fun verifyKeyCheck(sealed: ByteArray)

Throws StorageEncryptionException unless sealed is a key check sealed with this key.

Link copied to clipboard
abstract suspend fun verifyMigrationIntent(sealed: ByteArray)

Opens a migration intent sealed by sealMigrationIntent. Throws StorageEncryptionException if it was not sealed with this cipher's key as a migration intent (a key check or any other record does not count).