Documentation
¶
Overview ¶
codec.go — a read-write, os-backed SQLite VFS that encrypts every page with the SQLCipher-4 page format (github.com/hanzoai/sqlcipher), giving the pure-Go engine real at-rest encryption byte-compatible with C SQLCipher.
It is the write side the vendored engine's stock vfs package leaves null (it fills only xRead/xFileSize/xClose (read-only). Here codecio wires xWrite/xTruncate/ xSync too, backed by a real *os.File, and transforms page bytes with the codec on the way through.)
How it stays byte-compatible AND lets the engine's WAL round-trip ¶
SQLCipher's codec is normally a pager hook; here it is a VFS shim UNDER the pager, so the engine computes WAL frame checksums over the PLAINTEXT page, reserve region included. The codec overwrites that reserve with a fresh IV+HMAC on every write, so a naive decrypt would not reproduce the bytes the engine checksummed and WAL recovery would reject every frame. The fix, proven empirically: the engine zeros the full page buffer of NEW pages, and codecRead ZEROS the reserve of every page it returns — so every page the engine ever checksums has a zero reserve, the checksum is always taken over [data‖zeros], and the read-back reproduces it exactly. (the main database file carries no checksums, so zeroing the (pager- ignored) reserve there is invisible and the on-disk ciphertext is byte-identical to what C SQLCipher writes.
Fail-closed ¶
A wrong key or a tampered page fails Decrypt (HMAC) and is returned as an I/O error; plaintext is never produced. Rollback journals are refused (keyed databases run WAL-only); temp spill is kept in memory by the DSN. Plaintext never reaches disk.
Index ¶
Constants ¶
const ( SIGEV_SIGNAL = 0 SIGEV_NONE = 1 SIGEV_THREAD = 2 SIGEV_THREAD_ID = 4 )
const ( SEGV_MAPERR = 1 SEGV_ACCERR = 2 SEGV_BNDERR = 3 SEGV_PKUERR = 4 SEGV_ACCADI = 5 SEGV_ADIDERR = 6 SEGV_ADIPERR = 7 )
const ( BUS_ADRALN = 1 BUS_ADRERR = 2 BUS_OBJERR = 3 BUS_MCEERR_AR = 4 BUS_MCEERR_AO = 5 )
const ( CLD_EXITED = 1 CLD_KILLED = 2 CLD_DUMPED = 3 CLD_TRAPPED = 4 CLD_STOPPED = 5 CLD_CONTINUED = 6 )
const ( POLL_IN = 1 POLL_OUT = 2 POLL_MSG = 3 POLL_ERR = 4 POLL_PRI = 5 POLL_HUP = 6 )
const ( SI_ASYNCNL = -60 SI_DETHREAD = -7 SI_TKILL = -6 SI_SIGIO = -5 SI_ASYNCIO = -4 SI_MESGQ = -3 SI_TIMER = -2 SI_QUEUE = -1 SI_USER = 0 SI_KERNEL = 128 )
const ( ILL_ILLOPC = 1 ILL_ILLOPN = 2 ILL_ILLADR = 3 ILL_ILLTRP = 4 ILL_PRVOPC = 5 ILL_PRVREG = 6 ILL_COPROC = 7 ILL_BADSTK = 8 ILL_BADIADDR = 9 )
const ( FPE_INTDIV = 1 FPE_INTOVF = 2 FPE_FLTDIV = 3 FPE_FLTOVF = 4 FPE_FLTUND = 5 FPE_FLTRES = 6 FPE_FLTINV = 7 FPE_FLTSUB = 8 FPE_FLTUNK = 14 FPE_CONDTRAP = 15 )
const ( SS_ONSTACK = 1 SS_DISABLE = 2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS represents a SQLite read only file system backed by Go's fs.FS.
type Fts5ExtensionApi ¶
type Fts5ExtensionApi = Fts5ExtensionApi1
type Fts5ExtensionApi1 ¶
type Fts5ExtensionApi1 = struct {
// contains filtered or unexported fields
}
type Fts5PhraseIter ¶
type Fts5PhraseIter = Fts5PhraseIter1
type Fts5PhraseIter1 ¶
type Fts5PhraseIter1 = struct {
// contains filtered or unexported fields
}