Repository navigation
Update to SQLCipher 4.20.0 (SQLite 3.54.1) on go-sqlite3 v1.14.52 - #4
Merged
Merged
Conversation
Support returning any from callbacks
(For mattn#965.) This retraction will take effect when this commit is included in the latest v1 release (presumably v1.14.11).
This commit adds the `sqlite_os_trace` build tag which sets the `SQLITE_FORCE_OS_TRACE` and `SQLITE_DEBUG_OS_TRACE` compilation flags. This produces verbose debugging output of every operating system call made by SQLite.
Fixes a test which did not correctly exercise the multi-statement Queryer functionality
R.I.P. godoc.org
Always rollback on a commit error
Fix typo in README
Add support for SQLITE_ENABLE_MATH_FUNCTIONS compile-time option via the sqlite_math_functions build tag. Co-authored-by: Dominik Kraus <dominik.kraus@nktek.de>
…d add them manually.
# Enhancement Update `README.md` with new instructions for Mac OS cross compiling. # Why? The current suggested solution `xgo` is no longer maintained (GitHub archived repository). # Credits Credits go to Pieter Claerhout (@pieterclaerhout) and his blog post: https://www.yellowduck.be/posts/cross-compile-a-go-package-which-uses-sqlite3
Added documentation for sqlite_vtable build tag to the README.
As it was, the vtable example will give an error when adding any kind of SQL constraint in the SQL statement. Updating the BestIndex method will ensure that adding SQL constraints will not result in errors Signed-off-by: David Vassallo <davevassallo@gmail.com> Signed-off-by: David Vassallo <davevassallo@gmail.com>
Broken in mattn#1085
Add support for Serialize and Deserialize, which wrap sqlite3_serialize and sqlite3_deserialize.
…n#1069) * Add build tags to support both x86 and ARM compilation on macOS * Documentation fix: command line for build under macOS * Global replace 'macOS X' -> 'macOS'. Fix typo in -tags cmd line param * `README.md`: fix all `--tags` -> `-tags` --------- Co-authored-by: Denis Dmitriev <dmitriev@itspartner.net>
use same workaround as authelia/authelia#6404 before mattn#1177 fixes the build otherwise
Flush statement cache when the schema changes
Replace schema probe with eager first step for cached statements
Generated from the SQLCipher v4.20.0 sources (SQLite 3.54.1) with ./configure --with-tempstore=yes and make sqlite3.c, then wrapped the same way upgrade/upgrade.go wraps the official amalgamation.
SQLCipher uses LibTomCrypt for AES-256-CBC, HMAC and PBKDF2 with SHA1, SHA256 and SHA512, and the Fortuna PRNG. Vendoring them keeps the package buildable without a system crypto library.
The key is applied with PRAGMA key right after opening, before any other statement reads the database.
Static builds need libicudata and the C++ runtime as well, in this order.
hmac_init hashes long keys with hash_memory, and SQLCipher seeds its Fortuna PRNG from rng_get_bytes. Also skip the encryption test with the libsqlite3 tag, which links the system SQLite without SQLCipher.
This branch starts from go-sqlite3 v1.14.52 and replaces the SQLCipher 3.4.2 setup of develop, so none of the develop changes are kept.
It builds the OSS-Fuzz project of mattn/go-sqlite3, which clones the upstream repository and cannot find the commits of this fork, so it fails on every pull request here.
The fast path for Exec without arguments, added in 4954048, executes the statement without checking its parameters, so Exec("INSERT ... VALUES (?)") inserted NULL instead of failing with "not enough args to execute query" as before. Leave statements with parameters unexecuted in that path and return the same error.
SQLCipher writes a line to stderr on errors such as a wrong key, which a library should not do on its own. Applications can still enable it with PRAGMA cipher_log.
With the libsqlite3 tag and a plain system SQLite, PRAGMA key does nothing and the database was written in plain text. A NUL in the key cut the PRAGMA statement short, and the syntax error showed part of the key. Also check that a wrong or missing key fails with ErrNotADB.
It replaces the SQLCipher amalgamation with the official SQLite one, and upgrade.sh also commits, pushes and opens a pull request.
These tags come from go-sqlite3 and have no SQLCipher, so go get of the latest version gave a driver that ignores _crypto_key.
Drop the advice to run PRAGMA key, which only reaches one connection of the pool.
The checks need no connection, and running them after sqlite3_open_v2 left an empty database file behind when they failed.
No databases encrypted by earlier versions of this fork need migrating.
It comes from go-sqlite3; this repository has no v2 tags.
This was referenced Nov 4, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
developbundles SQLite 3.28.0 (April 2019) patched with SQLCipher 3.4.2. It cannot be updated by replacing the amalgamation: SQLite 3.32.0 removed theSQLITE_HAS_CODEChooks that patch relies on. This rebuilds the fork on top of go-sqlite3 v1.14.52 with the SQLite that SQLCipher itself maintains.Reviewing
GitHub shows 368 commits and about 167,000 changed lines because this also brings in the 347 go-sqlite3 commits between the old base of
develop(v1.10.0, May 2019) and v1.14.52; the regenerated amalgamation alone accounts for about 152,000 of the lines. The changes on top of go-sqlite3 v1.14.52 show only what this fork does: the generated amalgamation, the vendored LibTomCrypt sources, and about 235 added lines insqlite3.go, the tests,go.modand the README.The branch merges
developwith theoursstrategy, so this PR replaces the whole tree ofdevelopwhile keeping its history, and later go-sqlite3 updates only bring in the new upstream commits.Changes
sqlite3-binding.c,sqlite3-binding.handsqlite3ext.hare generated from the SQLCipher v4.20.0 sources (./configure --with-tempstore=yesandmake sqlite3.c) and wrapped the way go-sqlite3 wraps the official amalgamation.rng_get_bytes.develophad an untagged LibTomCrypt snapshot without SHA512, which SQLCipher 4 uses by default._crypto_key, carried over fromdevelop, is applied withPRAGMA keyon every new connection before any other statement. Opening now fails if the SQLite library is not SQLCipher, as with thelibsqlite3tag and a plain system SQLite, where the key used to be ignored and the database written in plain text. Keys containing NUL are rejected; they cut the statement short, and the syntax error showed part of the key. Both checks run before the database file is opened, so a rejected key leaves no file behind.Execwithout any arguments takes a fast path that skips the parameter check, soExec("INSERT INTO t VALUES (?)")inserted NULL instead of failing withnot enough args to execute query. CovenantSQL'sTestConnrelies on that error. The fast path now leaves statements with parameters unexecuted and returns the same error as before.sqlite3_opt_icu.goadds the libraries that a static link of ICU needs (libicudata, the C++ runtime), asdevelopdid. Dynamic linking keeps working.github.com/CovenantSQL/go-sqlite3-encrypt: v1.14.52 declaresgithub.com/mattn/go-sqlite3, which CovenantSQL could not require under this repository's path.go getof the latest version resolved to v1.9.0, which ignores_crypto_key. After merging, a v1.10.0 tag makesgo getresolve to this version.upgradetool, which would overwrite the SQLCipher amalgamation with the official one and then commit, push and open a pull request; the CIFuzz workflow, which builds the OSS-Fuzz project of go-sqlite3 and fails on every pull request here; the.gitignoreentries of the upgrade tool; and thesqlcipher.handsqlite3-binding.c.diffofdevelop, since the SQLCipher sources now produce the amalgamation directly.Not compatible with
developNew databases use the SQLCipher 4 defaults, and databases encrypted by
develop(SQLCipher 3) do not open. AConnectHookcannot setcipher_compatibilityeither, becauseOpenruns its own pragmas right after the key. CovenantSQL has no deployment to keep compatible, so neither an option for this nor a migration note is added.The README also documents two limits of SQLCipher itself: with
cache=shared, a connection with a wrong key or no key can read a database another connection of the process opened with the right key (CovenantSQL opens its shared-cache connections with the same key), and backups between an encrypted and a plain database fail.Testing
go vetandgo testpass with the default tags, with the tags CovenantSQL builds its miner with (sqlite_omit_load_extension sqlite_vtable sqlite_fts5 sqlite_icu), and withlibsqlite3against the Debian SQLite.TestCryptoKeychecks that a database written with_crypto_keyis not a plain SQLite file, that a wrong key or no key fails withErrNotADB, that it reads back with the key, and that a key containing a quote works.TestCryptoKeyWithNULand, with thelibsqlite3tag,TestCryptoKeyWithoutSQLCiphercover the new errors and check that no file is created, andTestNotEnoughArgsErrorMessagetheExecregression.-raceon Ubuntu and macOS with Go 1.24, 1.25 and 1.26. On Windows it only runsgo build, which does not link the package, so Windows is not verified.golang:1.27-alpineproduces working binaries.