Skip to documentation
KonclaveDocumentationSource snapshot · Apache 2.0
Browse documentation

Sealed secret storage

ADR 0002 separates key custody, authenticated sealing, and persistence: SecretSealer::share creates another handle to the same in-memory wrapping key...

GuideSource revision 8d0d3676e9fcView authoritative source

Repository-relative paths and “this checkout” refer to the Konclave source repository, not this website. The source link above identifies the exact revision used here.

On this page

ADR 0002 separates key custody, authenticated sealing, and persistence:

  1. a wrapping-key provider obtains one profile KEK;
  2. SecretSealer creates context-bound AES-256-GCM blobs;
  3. an MLS storage wrapper seals private bytes before delegating to a backend.

SecretSealer::share creates another handle to the same in-memory wrapping key without reloading custody or duplicating key bytes. Each handle owns a fresh operating-system random source for nonces. Daemon startup uses this to open its application and MLS databases under one key load and one profile lock.

Provider selection

Windows native daemon profiles use WindowsWrappingKeyProvider: one independent random KEK in custody/wrapping-key-1.dpapi under the profile directory, protected with current-user DPAPI and an owner-only DACL. The protected format and DPAPI context bind the canonical profile identifier and key slot. Creating additional profiles does not create additional Windows Credential Manager entries.

The native keyring provider remains the default on macOS/Linux. The caller holds the profile’s exclusive process lock before runtime key loading or creation on every platform. Windows creation is refused when any dependent or unexplained profile state already exists. The key file is written once, durably flushed, authenticated on readback and checked against the generated key before either database opens. Malformed or interrupted files fail rather than being overwritten.

An existing Windows profile without its DPAPI file is not automatically migrated from Credential Manager and never receives a replacement key. Retain the original runtime/custody if its identity matters. Resetting a disposable profile destroys that identity and requires explicit operator consent; empty application tables or an unlocked profile do not establish that it is disposable.

WindowsWrappingKeyProvider::verify_existing authenticates existing custody without creating files or opening databases; operator diagnostics use this read-only path. See ADR 0034 for the format and bounded recovery guarantees.

NativeEnrollmentCredentialStore uses a dedicated keyring service and internally derives its account name from a bounded installation identifier. It cannot address profile wrapping-key entries. Bounded reads never create and distinguish missing, malformed, and unavailable records. Writes create a missing record or verify an exact existing record, never replace a conflicting value, and read back newly stored endpoint-bound bytes. Relay enrollment uses this boundary so filesystem configuration cannot redirect a profile wrapping key or unbound bearer credential.

Native stores do not expose a portable create-if-absent transaction. Initialization therefore derives the installation identifier from both the enrollment authority and the normalized relay endpoint, so concurrent writers for one identifier carry identical endpoint-bound bytes.

Headless deployments disable the native-keyring feature and construct ExternalWrappingKeyProvider from exactly 32 bytes supplied by an external secret mechanism. The reader rejects short or trailing data. There is no environment-variable or plaintext-file fallback.

Provider failure is a startup error. Never respond to an unavailable credential store by generating a replacement key for an existing profile.

DPAPI key files remain protected by the Windows user’s DPAPI material even when copied with ciphertext databases; they are not portable raw keys. Moving a profile to another account or losing that user’s DPAPI material can make it unrecoverable. Same-account compromise and replaying an older valid protected file are not solved by DPAPI. Service identity and enrollment records remain installation-scoped native credentials; they do not allocate one record per harness session.

MLS storage

SealedMlsStorage<S> wraps any mls-rs GroupStateStorage or KeyPackageStorage:

  • current group snapshots and prior epochs are sealed as complete opaque values;
  • KeyPackage init and leaf private keys are sealed independently;
  • public KeyPackage bytes and expiration remain queryable but are included in the private-key associated-data digest, so tampering fails authentication;
  • group state, epoch inserts, and epoch updates are all sealed before one backend write call.

SealedSqliteMlsStorage is the file-backed adapter. It owns its ciphertext-only backend and commits one group-state update plus all epoch changes in a single SQLite transaction. SQLite rows never contain a wrapping key or private MLS byte.

SealedMlsStorageHandle shares an already-sealed backend through one owned synchronous handle. Construction accepts SealedMlsStorage<S> or the existing SQLite adapter, not an arbitrary unsealed provider. Clones share the backend and wrapping-key ownership rather than copying keys. A poisoned storage owner fails closed. Hosts still own backend atomicity, durability and blocking execution.

ConversationSigningMaterial seals the conversation-scoped signature key together with its authenticated device-root binding. Its associated data binds the local profile and conversation identifiers. Reopening verifies the binding signature, conversation identifier, and signing private/public key relationship before mls-rs receives the key.

MlsConversationClient::with_storage accepts a supplied sealed handle or any project sealed adapter convertible into it. Existing SQLite calls remain valid; generic sealed backends no longer require a SQLite/local-profile type in this constructor. It configures that same backend as both the mls-rs KeyPackage repository and group-state storage. The cryptographic wrapper persists:

  • new and joined groups before returning them;
  • outbound pending commits before they can cross the relay boundary;
  • accepted or rejected pending commits transactionally;
  • incoming commits before exposing their application transition;
  • sender ratchets before returning ciphertext.

Incoming application decryption is deliberately two-phase across the cryptographic and application boundaries. The daemon first durably records the decoded message and its idempotency identifier, then calls MlsConversation::persist to checkpoint the receiver ratchet. A crash between those writes replays against the prior MLS snapshot; the application deduplication record makes that recovery idempotent instead of losing plaintext.

A persisted join proof can restore its KeyPackage expectation after restart. A persisted pending next-state can restore and accept an outbound pending commit. An orphaned pending commit may be restored without next-state metadata solely to reject and recreate it. A removed endpoint stores a sealed tombstone snapshot one epoch behind the authenticated removal state, because MLS correctly withholds the new epoch secrets from that device; restored operations still fail as removed.

Active and pending restores compare the complete canonical conversation-state digest against the authenticated MLS GroupContext extension or applied Commit proposal. Matching only epoch and roster is insufficient because roles, joined epochs, protocol version, and consumed invitations are also authorization state.

The adapter uses mls-rs’s opaque storage values and does not enable its general serde feature. The daemon must still seal its policy snapshot, pending-operation metadata, relay credential, replay counters, and decrypted history, and must hold the profile lock before opening native custody.

Validation surfaces

The default feature set tests native custody plus SQLite. CI also tests:

  • --no-default-features for the minimal external-provider sealing path;
  • --no-default-features --features sqlite for headless file-backed storage;
  • locked fuzz parsing/opening of untrusted sealed blobs.

Cryptographic integration tests additionally reopen signing material, KeyPackages, groups, pending joins, pending commits, application ratchets, and removed-device tombstones across independent SQLite handles.

The draft-full Native storage conformance gate tests external-provider and SQLite sealed-storage modes, shared-handle ownership/failure behavior, and cryptographic client integration. A sealed in-memory backend proves composition, not process durability. This storage seam does not itself extract the daemon’s conversation journals, membership recovery, authorization or application orchestration into a complete standalone native session.

Content: Konclave,Apache-2.0. Revision: 8d0d3676e9fc746749a4fc04ddeb4499023c4104.