tursodatabase / tursodatabase/libsql
Embedded replicas encryption doesn't work on SQLCipher cipher type
Open
@Horusiath is already working on this.
Since Mar 4, 2024.
bug
Embedded Replicas
encryption at rest
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
Reproducer:
docker run -d -p 8080:8080 ghcr.io/tursodatabase/libsql-server:latest
git checkout main
rm -rf libsql-ffi/bundled/SQLite3MultipleCiphers/build
cd bindings/c
carga b -j16 --release
cd ../go
LIBSQL_PRIMARY_URL=http://localhost:8080 go test -count=1 -run=TestEncryption -v ./...
Observed problem:
? github.com/libsql/go-libsql/examples [no test files]
=== RUN TestEncryption
libsql_test.go:34: goroutine 19 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x5e
github.com/libsql/go-libsql.T.FatalOnError({0xc0000b4210?}, {0x1005cf840, 0xc0000b0480})
/Users/haaawk/work/libsql/bindings/go/libsql_test.go:34 +0x3d
github.com/libsql/go-libsql.TestEncryption(0xc00009b040)
/Users/haaawk/work/libsql/bindings/go/libsql_test.go:548 +0x8ec
testing.tRunner(0xc00009b040, 0x100550178)
/usr/local/go/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 1
/usr/local/go/src/testing/testing.go:1648 +0x3ad
libsql_test.go:35: failed to execute query SELECT * FROM test_1650501895787664715_20240304110048
error code = 1: Error executing statement: SQLite failure: `malformed database schema (test_1650501895787664715_20240304110048) - near "T": syntax error`
--- FAIL: TestEncryption (1.10s)
FAIL
FAIL github.com/libsql/go-libsql 1.110s
FAIL
It seems that we are not able to open encrypted embedded replica.
The problem goes away after applying the following patch and repeating the reproducer steps:
diff --git a/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt b/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt
index 56d375279a..c56fe9cbf7 100644
--- a/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt
+++ b/libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt
@@ -133,7 +133,7 @@ set(SQLITE3MC_BASE_DEFINITIONS
HAVE_CIPHER_AES_128_CBC=0
HAVE_CIPHER_AES_256_CBC=1
HAVE_CIPHER_CHACHA20=0
- HAVE_CIPHER_SQLCIPHER=1
+ HAVE_CIPHER_SQLCIPHER=0
HAVE_CIPHER_RC4=0
HAVE_CIPHER_ASCON128=0
# $<$<BOOL:${SQLITE_USE_TCL}>:SQLITE_USE_TCL=1>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.