Skip to main content

Crate sqlcipher_src

Crate sqlcipher_src 

Source
Expand description

§sqlcipher-src

CI CodeQL Coverage Quality gate SQLCipher release crates.io docs.rs license

The SQLCipher amalgamation as C source for -sys crates, on native targets and on wasm32-unknown-unknown through sqlite-wasm-rs, where it adds the libtomcrypt crypto provider.

Native builds compile AMALGAMATION_FILE with their own crypto provider and flags:

let dir = sqlcipher_src::source_dir();
assert!(dir.join(sqlcipher_src::AMALGAMATION_FILE).is_file());
assert!(dir.join(sqlcipher_src::HEADER_FILE).is_file());

sqlite-wasm-rs 0.6 compiles WASM_SOURCE_FILE instead of plain SQLite when SQLITE_WASM_RS_SOURCE_DIR points at the same directory, set in the environment or in [env] of .cargo/config.toml:

export SQLITE_WASM_RS_SOURCE_DIR="$(cargo metadata --format-version 1 \
  | jq -r '.packages[] | select(.name == "sqlcipher-src") | .manifest_path' \
  | xargs dirname)/sqlcipher"
cargo build --target wasm32-unknown-unknown

Shared-memory builds (+atomics) also need -mbulk-memory in CFLAGS_wasm32_unknown_unknown.

The sources are generated from signed SQLCipher and libtomcrypt releases by upgrade.sh. CI runs rusqlite’s SQLCipher tests on them natively, and checks that files written natively and in Node, Chrome and Firefox open on both sides.

The wrapper is MIT, SQLCipher is BSD-3-Clause, SQLite is public domain, and libtomcrypt is public domain or WTFPL.

Constants§

AMALGAMATION_FILE
SQLCipher amalgamation inside source_dir, for native builds that pick their own crypto provider.
HEADER_FILE
Public SQLCipher header inside source_dir.
LIBTOMCRYPT_VERSION
libtomcrypt release providing the ciphers, hashes and random generator.
SQLCIPHER_VERSION
SQLCipher release the vendored amalgamation is generated from.
SQLITE_VERSION
SQLite release that SQLCipher release is based on.
WASM_BINDINGS_FILE
Rust bindings for HEADER_FILE inside source_dir, from sqlite-wasm-rs’s bindgen setup with SQLITE_HAS_CODEC, so they declare sqlite3_key and sqlite3_rekey.
WASM_SOURCE_FILE
Single translation unit inside source_dir that compiles SQLCipher with libtomcrypt for Wasm.

Functions§

source_dir
Directory holding the sources, at the path this crate was compiled from.