mirror of
https://github.com/tursodatabase/libsql.git
synced 2025-08-30 22:20:58 +00:00
It doesn't compile yet, we need to properly link some more encryption libs for it to work. Close though. What sqlite3MultipleCiphers does during compilation is the following: 1. They have a patched sqlite3patched.c amalgamation file, which adds a few lines to the stock amalgamation. I added sqlite3-mc-diff file for reference, that's the difference. 2. They have a sqlite3mc.c file, which is a "reverse amalgamation", a central file that #includes lots of .h and .c files. This file also #includes the sqlite3.c amalgamation. What I did in order to play with sqlite3MultipleCiphers is: 1. Applied the diff above to our sqlite3.c file - applies cleanly, good. 2. Removed "#include sqlite3patched.c" from their sqlite3mc.c file, and instead copy-pasted sqlite3mc.c to the end of our sqlite3.c amalgamation -- not great, but good for starters. 3. It compiles fine, but then fails the linking stage because of some missing encryption function symbols, so it's either because I did something wrong when copying over the C code, or we need to link with external libraries. We can also try it the other way round, so: 1. Apply the diff above to our sqlite3.c file as before 2. Copy over *all* of the sqlite3mc* source files to libsql-ffi/bundled/src 3. Build sqlite3mc.c instead of our sqlite3.c 4. Use it I also managed to succeed in building their shell by running ``` cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j12 ``` , and it works nicely, and it also properly encrypts WAL files. The `PRAGMA key = something` interface is quite brilliant. Good luck anyone taking over this effort! (And by anyone I mean Lucio, as always)