Module index_meta

Module index_meta 

Source
Expand description

Metadata and encryption key management for password-protected Turso indexes using companion *.cscidxmeta files.

Structs§

FsIndexMeta
Metadata stored in companion *.cscidxmeta files for password-protected indexes.
IndexKekParams
Parameters for Argon2id key derivation stored in *.cscidxmeta.

Functions§

acquire_password
Securely acquires a password from CLI flags, environment variable, or terminal prompt.
create_encrypted_index_meta
Securely generates a new random DEK, derives an Argon2id KEK from the password, wraps the DEK under AES-256-GCM, and returns both the metadata structure and raw DEK.
find_meta_path
Discovers an existing *.cscidxmeta file for the database. Checks the standard <stem>.cscidxmeta first, then <db_path>.cscidxmeta.
is_database_encrypted
Inspects the first 5 bytes of a file to check if it matches Turso’s encrypted page header (b"Turso"). Returns false if the file does not exist or has fewer than 5 bytes.
load_index_meta
Loads and parses index metadata from the specified path.
open_index_database
Opens or creates a Turso SQLite database, automatically detecting whether encryption is present or requested, loading companion *.cscidxmeta metadata, and configuring page-level AEAD encryption.
resolve_meta_path
Computes the expected companion *.cscidxmeta path for a given database path. E.g. foo.cscindex.sqlite -> foo.cscidxmeta, bar.db -> bar.cscidxmeta.
save_index_meta
Saves index metadata as formatted JSON to the specified path.
unlock_index_dek
Derives the KEK from the password using the salt and parameters stored in meta, then unwraps and authenticates the DEK using AES-256-GCM.