Skip to content

Remove the LibTomCrypt PRNG lookups that nothing calls and the empty go.sum - #7

Merged
laodouya merged 2 commits into
developfrom
chore/remove-unused-files
Nov 6, 2026
Merged

laodouya merged 2 commits into
developfrom
chore/remove-unused-files

Conversation

@laodouya

@laodouya laodouya commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

crypt_find_prng.c and crypt_prng_is_valid.c define the LibTomCrypt functions find_prng and prng_is_valid, which nothing in the package calls: SQLCipher registers Fortuna with register_prng and then calls the fortuna_* functions directly, and the LibTomCrypt functions that look a PRNG up by name or index are not included. cgo still compiled both files and linked them into every binary. go.sum has been empty since go-sqlite3 dropped its last requirement (4120733, 2020), and go mod tidy does not recreate it, since the module has no dependencies.

How nothing references the two functions under any build tag was checked:

  • In the sources: the two names occur in no .c, .h or .go file of the repository (the cgo preambles and the per-platform files included) except in their definitions and in their declarations in tomcrypt_prng.h, and no macro pastes tokens into them. Build tags select Go files and cgo flags only, and every .c file is compiled under every tag set, so no tag set can add a caller.
  • In the objects, for each tag set listed under Testing: the cgo objects of develop (47 to 63 of them, depending on the tags) define the two functions in 2 objects and reference them in none, and the test binaries contain both as text symbols. On this branch the test binaries link under every tag set and contain neither.

develop and this branch compile the same SQLite and SQLCipher code, so query results cannot change; the corpus check below confirms it.

Left out: tomcrypt_prng.h keeps its declarations, as LibTomCrypt 1.18.2 ships it; a declaration without a caller links nothing.

Testing

On linux/amd64 (Debian trixie container cql-ci:go1.27 plus libsqlite3-dev), Go 1.27.3, --cpus 4. Tag sets: the four of .github/workflows/go.yaml (empty, libsqlite3, the full set, sqlite_vacuum_full), CovenantSQL's sqlite_omit_load_extension sqlite_omit_localtime, and its miner tags sqlite_omit_load_extension sqlite_omit_localtime sqlite_vtable sqlite_fts5 sqlite_icu.

  • For each tag set, on develop and on this branch: go build -work -tags "$TAGS" . with a throwaway Go file that forces cgo to compile every C file again, then nm -A --defined-only and nm -A -u over $WORK/b001/_x*.o; and go test -c -tags "$TAGS" followed by nm of the test binary. Results as described above.
  • go vet -tags "$TAGS" . and go test -race -count=1 -tags "$TAGS" . pass for each tag set. Only go vet with the full set fails, on call to (*testing.T).Fatal from a non-test goroutine in sqlite3_opt_unlock_notify_test.go, identically on develop.
  • go mod tidy leaves no go.sum.
  • Query results: a program runs about 60 statements over an encrypted WAL database opened with vfs=nocurrenttime and a Go function registered in a ConnectHook, as CovenantSQL's xenomint/sqlite does: types and conversions, numeric and text formatting, ICU case folding, LIKE, REGEXP and collation, date functions with and without the current time, JSON, window functions, FTS5 ranking, errors, EXPLAIN QUERY PLAN and the SQLCipher pragmas. It prints every value with its Go type, every error, rows affected and last insert IDs. Its output is byte-identical with develop and with all five open PRs of this repository merged (tree 74119820), for each tag set above and for the full set plus CovenantSQL's tags; with sqlite_os_trace, the VFS trace lines are identical once the temporary directory and the process ID are masked.

crypt_find_prng.c and crypt_prng_is_valid.c define find_prng and
prng_is_valid. Nothing in the package calls either: SQLCipher registers
Fortuna and calls the fortuna_* functions directly, and the LibTomCrypt
functions that look PRNGs up by name or index are not included. cgo
compiled and linked both files into every build all the same.
The module has no dependencies, so go.sum has been empty since
go-sqlite3 dropped its last requirement, and go mod tidy does not
recreate it.
@laodouya
laodouya merged commit a86d95e into develop Nov 6, 2026
18 checks passed
@laodouya
laodouya deleted the chore/remove-unused-files branch November 6, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant