feat(store): encrypt the whole sqlite store with SQLCipher
All checks were successful
ci / test (pull_request) Successful in 3m35s
All checks were successful
ci / test (pull_request) Successful in 3m35s
The db held the ed25519 identity secret, friend pubkeys, locators, profiles and payment rows in the clear; only chat bodies were encrypted. Switch rusqlite to `bundled-sqlcipher-vendored-openssl` and open every store with `PRAGMA key = "x'<64 hex>'"` as the first statement after open, using the existing Argon2id output as a raw key (no second KDF pass). The per-install KDF salt moves out of the db into `store_salt` (0600) — a key cannot be derived from a salt that lives inside the file it opens. The per-message ChaCha20-Poly1305 + row-AAD layer is unchanged: whole-db encryption does not defend against ciphertext swapped between rows, the AAD does. v0.2.1 installs are plaintext. The first open with the right passphrase upgrades in place (WAL checkpoint, ATTACH ... KEY, sqlcipher_export) and only swaps the file after the new one opens, passes integrity_check and unwraps store_meta. A wrong passphrase leaves the plaintext file untouched; a missing `store_salt` next to an encrypted db refuses to open rather than guessing. SQLCipher's internal "hmac check failed" ERROR on a rejected key is suppressed (cipher_log_level = NONE) so a typo'd passphrase is not an error dump. docs/THREAT_MODEL.md: the store is now encrypted at rest; sqlcipher leaves the "Out of v1" list.
This commit is contained in:
parent
e6e2a158a8
commit
e7b37ccb40
5 changed files with 551 additions and 8 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -2295,6 +2295,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "91632f3b4fb6bd1d72aa3d78f41ffecfcf2b1a6648d8c241dbe7dbfaf4875e15"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"openssl-sys",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
|
@ -2692,6 +2693,15 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-src"
|
||||
version = "300.6.1+3.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46eb8fb9fb3b61ce1c0f8a026c4c1a0714d3a9e138e7fbde78753ce2babc3846"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.117"
|
||||
|
|
@ -2700,6 +2710,7 @@ checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695"
|
|||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"openssl-src",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue