CryptoRuntime

class CryptoRuntime(stack: PlatformCryptoStack, storeRegistry: StoreRegistry = StoreRegistry(), log: KryptoLog = KryptoLog.NoOp)

Initializes platform crypto (key rotation + re-encrypt + post-init hooks) behind a mutex.

cipher is only safe to use after state is CryptoRuntimeState.Ready.

On rotation the order is: rotate → postRotationInit → StoreRegistry.reEncryptAll → postMigrationCleanup → Ready (REQ-ROT-02). Re-encrypt runs before cleanup so old key material can still decrypt existing ciphertext (notably iOS SecureKeyStore).

Constructors

Link copied to clipboard
constructor(stack: PlatformCryptoStack, storeRegistry: StoreRegistry = StoreRegistry(), log: KryptoLog = KryptoLog.NoOp)
constructor(keyRotator: KeyRotator, postRotationInit: suspend () -> Unit, postMigrationCleanup: suspend () -> Unit = {}, cipher: Cipher, storeRegistry: StoreRegistry = StoreRegistry(), log: KryptoLog = KryptoLog.NoOp)

Properties

Link copied to clipboard
Link copied to clipboard

Registry used for post-rotation re-encrypt; register encrypted stores here.

Link copied to clipboard
val state: StateFlow<CryptoRuntimeState>

Functions

Link copied to clipboard
suspend fun initialize()