Skip to content

Check database readability without an encryption key - #608

Merged
SRombauts merged 5 commits into
masterfrom
534-fix-unencrypted-detection
Oct 24, 2026
Merged

SRombauts merged 5 commits into
masterfrom
534-fix-unencrypted-detection

Conversation

@SRombauts

@SRombauts SRombauts commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Resolves #534. Replace the misleading isUnencrypted() API with isReadableWithoutKey(), which queries the schema read-only and reports unreadable database formats without treating I/O errors as encryption.

Add hasSQLiteHeader() for the original 16-byte signature check, and cover plaintext-header unreadable files and empty files in tests. Targeted at the SQLiteCpp 4.0 API break.

@coveralls

coveralls commented Oct 24, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 99.735% (+0.005%) from 99.73% — 534-fix-unencrypted-detection into master

Expose the existing 16-byte header comparison as hasSQLiteHeader(),
so callers can request a cheap signature check without assuming the
database contents are unencrypted.
Query the schema through SQLite instead of treating its header
signature as proof that a database is unencrypted. This detects
ciphered databases that retain a plaintext header.
Use isReadableWithoutKey() to describe what the schema query tests.
Avoid implying that a failed read proves database encryption.
@SRombauts
SRombauts force-pushed the 534-fix-unencrypted-detection branch from 5f8b84a to f39ad2d Compare October 24, 2026 10:19
@SRombauts SRombauts changed the title Fix SQLite database format detection Check database readability without an encryption key Oct 24, 2026
@SRombauts
SRombauts force-pushed the 534-fix-unencrypted-detection branch from f39ad2d to 1de23d8 Compare October 24, 2026 10:32
Check SQLITE_BUSY and SQLITE_CORRUPT results explicitly and keep
unsupported formats unreadable. Remove unreachable fallback code.
Record the SQLite header probe and the renamed readability API
for SQLiteCpp 4.0 in the unreleased changelog.
@SRombauts
SRombauts force-pushed the 534-fix-unencrypted-detection branch from 1de23d8 to 1ac2c94 Compare October 24, 2026 10:39
@SRombauts
SRombauts merged commit 29ed995 into master Oct 24, 2026
72 checks passed
@SRombauts
SRombauts deleted the 534-fix-unencrypted-detection branch October 24, 2026 10:53
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.

Database::isEncrypted is not correct with sqlcipher / sqlite-m-c unencrypted first bytes

2 participants