SQLite3 Multiple Ciphers Documentation
repository·main·Indexed 20 days ago
https://github.com/utelle/sqlite3multipleciphersAn encryption extension for SQLite (version 3.32.0 and later) that supports multiple cipher schemes using SQLite's VFS feature. This documentation covers build infrastructure using Autosetup and JimTCL, installation guides for POSIX and Windows (MSVC), and configuration options for dispatch tables to avoid linker conflicts via SQLITE3MC_USE_DISPATCH_TABLE.
What's inside SQLite3 Multiple Ciphers
- SQLite3 Multiple Ciphers is an encryption extension for SQLite that supports multiple cipher schemes. Unlike older encryption extensions that were tightly coupled with SQLite internals, this implementation uses SQLite's VFS (Virtual File System) feature. This design allows it to support SQLite version 3.32.0 and later by reducing coupling with the core SQLite code, though it makes accessing internal data structures more complex.
Design Convention: Avoiding Global Shared State
mainTo support builds that produce multiple deliverables, this project avoids modifying global flags like
CFLAGS,LDFLAGS, orLIBSduring feature tests. Instead, feature tests export their results into specific, well-defined variables.Example Pattern:
- Instead of modifying global
LDFLAGS, the zlib test exportsLDFLAGS_ZLIB. Makefile.inandmain.mkthen expose this asLDFLAGS.zlib.- The Makefile is responsible for applying and ordering these specific flags as needed.
This prevents one feature test from implicitly breaking another by polluting the global state.
- Instead of modifying global
Ensure TCL Compatibility with JimTCL
mainThe build process uses TCL scripts that must remain compatible with both canonical TCL and JimTCL. To ensure your scripts work in JimTCL (the interpreter provided by Autosetup), avoid JimTCL-specific features.
How to force JimTCL usage during configuration
- System Isolation: Build on a system where no
tclshis installed in the$PATH. The process will fall back to building the in-tree JimTCL. - Manual Build: Manually compile the in-tree JimTCL shell before running configure:
cc -o jimsh0 autosetup/jimsh0.cNote:
./jimsh0is different from./jimsh(used for code generation). Use[file-normalize](the Autosetup implementation) instead of[file normalize]in configure scripts to ensure portability.cc -o jimsh0 autosetup/jimsh0.c- System Isolation: Build on a system where no
Design Convention: Feature Flag Naming
mainThis project uses a dual-naming convention for feature flags to bridge the gap between Makefiles and C code:
- Makefile Variables (
X.y): Used within Makefiles for readability (e.g.,CFLAGS.readline,LDFLAGS.zlib). - C Preprocessor Defines (
X_Y): Used when exporting flags toMakefile.inandsqlite_cfg.h(e.g.,SQLITE_ENABLE_COLUMN_METADATA).
In
Makefile.in, flags are typically translated from the@X_Y@format into theX.yformat used by the rest of the build system.- Makefile Variables (
Access the Autosetup API Reference
mainThe Autosetup API documentation is extensive. You can view it directly in the terminal by running the configure script with the
--referenceflag. This command will include documentation from any TCL files in the./autosetupdirectory that use Autosetup's internal markup.Key configuration files in this project include:
proj.tcl: Project-agnostic utility code shared across the SQLite/Hwaci umbrella.sqlite-config.tcl: Project-specific utility code.auto.def: The primary driver for the./configureprocess.autoconf/auto.def: A trimmed-down version ofauto.defused for the 'autoconf' bundle.
#!/bin/bash ./configure --reference | lessBuild SQLite3 Multiple Ciphers on POSIX systems
mainTo build this package on POSIX-compliant systems, use the provided
configurescript andmake. This method is useful if you want to avoid installing TCL, as theconfigurescript uses an embedded copy of JimTCL.By default,
CFLAGSincludes debugging symbols, which results in larger binaries. To produce a smaller installation footprint, overrideCFLAGSduring the configuration step.Output Artifacts:
- Library name:
libsqlite3mc - SQLite shell executable:
sqlite3mc
# Standard build ./configure make # Build with optimization for a smaller footprint CFLAGS="-Os" ./configure make # Build with optimization and specific preprocessor defines CFLAGS="-Os -DSQLITE_OMIT_DEPRECATED" ./configure make- Library name:
Access documentation for ciphers and interfaces
mainFor detailed information regarding supported cipher schemes and the specific C and SQL interfaces, visit the official documentation website:
Build SQLite3 Multiple Ciphers with Microsoft Visual C++ on Windows
mainTo compile for Windows using Microsoft Visual C++ (version 2005 or later is recommended), use
nmakewith the providedMakefile.msc.You can specify preprocessor defines using the
OPTSmacro on the command line. Note that some defines (likeSQLITE_ENABLE_UPDATE_DELETE_LIMIT) require the amalgamation to have been built with them enabled and cannot be added viaOPTSat this stage.# Standard build nmake /f Makefile.msc # Build with preprocessor defines nmake /f Makefile.msc OPTS="-DSQLITE_ENABLE_STAT4=1 -DSQLITE_OMIT_JSON=1"Customize Autosetup for Vendor Branches
mainTo avoid merge conflicts in
sqlite-config.tclwhen managing vendor-specific branches, use a custom file namedautosetup/sqlite-custom.tclin your branch. This file allows you to override flag defaults and handle custom flags.Implementation Pattern
Create
autosetup/sqlite-custom.tclwith the following structure:# Define custom flag defaults and new flags proc sqlite-custom-flags {} { options-defaults { flag-name new-default-value } return { {*} { new-flag-name => {Help text} } }; } # Define custom flag handling logic proc sqlite-custom-handle-flags {} { # Custom logic goes here }sqlite-custom-handle-flagsis called late in the configure process, after significant processing but before filtered files are generated.proc sqlite-custom-flags {} { options-defaults { flag-name new-default-value } return { {*} { new-flag-name => {Help text} } }; } proc sqlite-custom-handle-flags {} { # Custom logic }Update Autosetup in the SQLite Tree
mainTo update the Autosetup infrastructure, follow these steps:
Clone/Update Autosetup:
git clone https://github.com/msteveb/autosetup cd autosetup # Or if already checked out: git pullInstall to Project: From the top-level directory of your SQLite checkout, run:
/path/to/autosetup-checkout/autosetup --install .Verify and Patch: Run
fossil statusto see modified files. Crucially, you must apply the project-specific patch for--autosetup-debug(to avoid conflicts with Autosetup's internal--debugflag) before checking in your changes.
# 1. Update autosetup repo cd /path/to/autosetup git pull # 2. Install into the SQLite project cd /path/to/sqlite-project /path/to/autosetup/autosetup --install .Install SQLite3 Multiple Ciphers
mainTo learn how to build and install the extension, refer to the installation guide:
https://utelle.github.io/SQLite3MultipleCiphers/docs/installation/install_overview/
Understand the SQLite3 Multiple Ciphers amalgamation archive
mainThe SQLite3 Multiple Ciphers amalgamation is a single-file source distribution that integrates multiple encryption ciphers into the SQLite source code.
Note: The original, unmodified SQLite sources are not included in this archive. If you require the original SQLite source files, you must download them separately from the official SQLite website using the version information provided in the release notes.