2024-04-18 01:39:47 +01:00
|
|
|
# Go `"adiantum"` SQLite VFS
|
|
|
|
|
|
|
|
|
|
This package wraps an SQLite VFS to offer encryption at rest.
|
|
|
|
|
|
|
|
|
|
> [!WARNING]
|
|
|
|
|
> This work was not certified by a cryptographer.
|
|
|
|
|
> If you need vetted encryption, you should purchase the
|
|
|
|
|
> [SQLite Encryption Extension](https://sqlite.org/see),
|
|
|
|
|
> and either wrap it, or seek assistance wrapping it.
|
|
|
|
|
|
|
|
|
|
The `"adiantum"` VFS wraps the default SQLite VFS using the
|
|
|
|
|
[Adiantum](https://github.com/lukechampine/adiantum)
|
2024-04-23 01:37:21 +01:00
|
|
|
tweakable and length-preserving encryption.\
|
2024-04-18 01:39:47 +01:00
|
|
|
In general, any HBSH construction can be used to wrap any VFS.
|
|
|
|
|
|
|
|
|
|
The default Adiantum construction uses XChaCha12 for its stream cipher,
|
2024-04-23 01:37:21 +01:00
|
|
|
AES for its block cipher, and NH and Poly1305 for hashing.\
|
|
|
|
|
Additionally, we use [Argon2id](https://pkg.go.dev/golang.org/x/crypto/argon2#hdr-Argon2id)
|
|
|
|
|
to derive 256-bit keys from plain text.
|
2024-04-18 02:13:59 +01:00
|
|
|
|
2024-04-21 01:56:38 +01:00
|
|
|
The VFS encrypts all files _except_
|
|
|
|
|
[super journals](https://sqlite.org/tempfiles.html#super_journal_files):
|
2024-04-23 01:37:21 +01:00
|
|
|
they _never_ contain database data, only filenames,
|
2024-04-21 01:56:38 +01:00
|
|
|
and padding them to the block size is problematic.
|
|
|
|
|
Temporary files _are_ encrypted with **random** keys,
|
|
|
|
|
as they _may_ contain database data.
|
|
|
|
|
To avoid the overhead of encrypting temporary files,
|
|
|
|
|
keep them in memory:
|
|
|
|
|
|
|
|
|
|
PRAGMA temp_store = memory;
|
2024-04-18 01:39:47 +01:00
|
|
|
|
|
|
|
|
> [!IMPORTANT]
|
|
|
|
|
> Adiantum is typically used for disk encryption.
|
|
|
|
|
> The standard threat model for disk encryption considers an adversary
|
|
|
|
|
> that can read multiple snapshots of a disk.
|
2024-04-21 01:56:38 +01:00
|
|
|
> The only security property that disk encryption (and this package)
|
2024-04-23 01:37:21 +01:00
|
|
|
> provides is that all information such an adversary can obtain
|
|
|
|
|
> is whether the data in a sector has (or has not) changed over time.
|
|
|
|
|
|
|
|
|
|
> [!CAUTION]
|
|
|
|
|
> This package does not claim protect databases against forgery.
|
|
|
|
|
> Any encryption scheme that allows constant-time block updates
|
|
|
|
|
> can't prevent individual blocks from being reverted to former versions of themselves,
|
|
|
|
|
> so block-level authentication is of limited value.
|