Self-contained Go sqlite3 driver with an AES-256 encrypted sqlite3 database
Go to file
Siddarth Kumar abfb97b5f3
fix: android builds of statusgo for ndk r26b
Fix android builds of statusgo for ndk r26b

This PR fixes a build error which was generated after we upgraded our Android NDK from `25.2.9519653` to `26.1.10909125`

The following functions need to be compiled with target for both as `aes` and `crypto` :
- `aesce_encrypt_block`
- `aesce_decrypt_block`
- `aes_sub_word`
- `mbedtls_aesce_inverse_key`

ref : https://clang.llvm.org/docs/AttributeReference.html#target
2024-09-20 16:48:32 +05:30
.github/workflows add missing newline 2020-08-20 02:50:22 +00:00
_example make imported package name explicit 2020-08-20 03:22:35 +00:00
testdata upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
upgrade upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
util fix compilation of util directory 2020-12-07 17:57:41 +00:00
LICENSE update LICENSE file 2020-07-23 03:50:16 +00:00
MAINTENANCE upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
Makefile disable go vet in tests 2020-08-20 03:22:58 +00:00
README.md improve documentation for plain text passwords 2020-08-28 18:37:34 +00:00
aes.c [tomcrypt] replace AES implementation with mbedtls 2023-05-31 15:50:48 +03:00
aesce.c chore: explicitly set targets for compilation 2024-09-18 08:24:30 +05:30
aesce.h [tomcrypt] replace AES implementation with mbedtls 2023-05-25 06:52:48 +03:00
aesni.c [tomcrypt] replace AES implementation with mbedtls 2023-05-25 06:52:48 +03:00
aesni.h [tomcrypt] replace AES implementation with mbedtls 2023-05-25 06:52:48 +03:00
backup.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
backup_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
burn_stack.c chore(cherry-pick): Cherry-picking commit 5d5c005: Fix burn_stack performance issue 2023-05-23 13:46:41 +03:00
callback.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
callback_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
cbc_decrypt.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
cbc_done.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
cbc_encrypt.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
cbc_start.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
compare_testvector.c upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
convert.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
crypt_argchk.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_cipher_descriptor.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_cipher_is_valid.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_find_cipher.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_find_hash.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_hash_descriptor.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_hash_is_valid.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_prng_descriptor.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_register_cipher.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_register_hash.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
crypt_register_prng.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
doc.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
error.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
error_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
flags.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
fortuna.c upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
go.mod update modules 2020-12-07 17:58:31 +00:00
go.sum update modules 2020-12-07 17:58:31 +00:00
hash_memory.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
hmac_done.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
hmac_init.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
hmac_memory.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
hmac_process.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
mbtls_aes.c [tomcrypt] replace AES implementation with mbedtls 2023-05-25 06:52:48 +03:00
mbtls_aes.h [tomcrypt] replace AES implementation with mbedtls 2023-05-25 06:52:48 +03:00
pkcs_5_2.c upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
sha1.c performance(sqlcipher): provide optimized versions of `sha1_compress` 2023-05-23 13:56:48 +03:00
sha256.c upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
sha512.c upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
sqlcipher.go document sqlite3.IsEncrypted() 2017-05-08 21:04:03 +00:00
sqlcipher_test.go use url.QueryEscape() for documentation purposes 2020-08-28 18:39:39 +00:00
sqlite3.c chore(upgradeSQLCipher): Upgrading to sqlcipher v4.5.4 2023-05-31 16:52:39 +03:00
sqlite3.go chore(upgradeSQLCipher): Scanning NULL BLOB value should return nil 2023-06-06 15:26:21 +03:00
sqlite3.h chore(upgradeSQLCipher): Upgrading to sqlcipher v4.5.4 2023-05-31 16:52:39 +03:00
sqlite3_context.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_func_crypt.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_func_crypt_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_go18.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_go18_test.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
sqlite3_go113_test.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
sqlite3_libsqlite3.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
sqlite3_load_extension.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
sqlite3_load_extension_omit.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_load_extension_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_allow_uri_authority.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_app_armor.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_foreign_keys.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_fts3_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_fts5.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_icu.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_introspect.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_json1.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_preupdate.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_preupdate_hook.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_preupdate_hook_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_preupdate_omit.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_secure_delete.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_secure_delete_fast.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_stat4.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_unlock_notify.c update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_unlock_notify.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_unlock_notify_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_userauth.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_userauth_omit.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_userauth_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_vacuum_full.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_vacuum_incr.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_opt_vtable.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
sqlite3_opt_vtable_test.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_other.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_solaris.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_test.go upgrade go-sqlite3 to v1.14.5 2020-12-07 17:56:38 +00:00
sqlite3_trace.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_type.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_usleep_windows.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
sqlite3_windows.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
static_mock.go update github.com/mattn/go-sqlite3 to latest 2020-07-23 04:09:25 +00:00
tomcrypt.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_argchk.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_cfg.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_cipher.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_custom.h upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
tomcrypt_hash.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_mac.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_macros.h chore(compatibilityMode): Enable DB open in sqlcipher 3 compatibility mode 2023-05-24 19:08:34 +03:00
tomcrypt_math.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_misc.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_pk.h upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
tomcrypt_pkcs.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
tomcrypt_private.h upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
tomcrypt_prng.h upgrade SQLCipher to 4.4.0 2020-07-23 02:04:21 +00:00
track_go-sqlite3.sh fix typo 2020-08-20 03:05:33 +00:00
track_libtomcrypt.sh upgrade libtomcrypt 2020-12-07 17:45:45 +00:00
zeromem.c chore(cherry-pick): Cherry-picking commit 5d5c005: Fix burn_stack performance issue 2023-05-23 13:46:41 +03:00

README.md

go-sqlcipher

GoDoc CI

Description

Self-contained Go sqlite3 driver with an AES-256 encrypted sqlite3 database conforming to the built-in database/sql interface. It is based on:

SQLite itself is part of SQLCipher.

Incompatibilities of SQLCipher

The version tags of go-sqlcipher are the same as for SQLCipher.

SQLCipher 4.x is incompatible with SQLCipher 3.x!

go-sqlcipher does not implement any migration strategies at the moment. So if you upgrade a major version of go-sqlcipher, you yourself are responsible to upgrade existing database files.

See migrating databases for details.

To upgrade your Go code to the 4.x series, change the import path to

"github.com/mutecomm/go-sqlcipher/v4"

Installation

This package can be installed with the go get command:

go get github.com/mutecomm/go-sqlcipher

Documentation

To create and open encrypted database files use the following DSN parameters:

key := "2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99"
dbname := fmt.Sprintf("db?_pragma_key=x'%s'&_pragma_cipher_page_size=4096", key)
db, _ := sql.Open("sqlite3", dbname)

_pragma_key is the hex encoded 32 byte key (must be 64 characters long). _pragma_cipher_page_size is the page size of the encrypted database (set if you want a different value than the default size).

key := url.QueryEscape("secret")
dbname := fmt.Sprintf("db?_pragma_key=%s&_pragma_cipher_page_size=4096", key)
db, _ := sql.Open("sqlite3", dbname)

This uses a passphrase directly as _pragma_key with the key derivation function in SQLCipher. Do not forget the url.QueryEscape() call in your code!

See also PRAGMA key.

API documentation can be found here: http://godoc.org/github.com/mutecomm/go-sqlcipher

Use the function sqlite3.IsEncrypted() to check whether a database file is encrypted or not.

Examples can be found under the ./_example directory

License

The code of the originating packages is covered by their respective licenses. See LICENSE file for details.