abfb97b5f3
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 |
||
---|---|---|
.github/workflows | ||
_example | ||
testdata | ||
upgrade | ||
util | ||
LICENSE | ||
MAINTENANCE | ||
Makefile | ||
README.md | ||
aes.c | ||
aesce.c | ||
aesce.h | ||
aesni.c | ||
aesni.h | ||
backup.go | ||
backup_test.go | ||
burn_stack.c | ||
callback.go | ||
callback_test.go | ||
cbc_decrypt.c | ||
cbc_done.c | ||
cbc_encrypt.c | ||
cbc_start.c | ||
compare_testvector.c | ||
convert.go | ||
crypt_argchk.c | ||
crypt_cipher_descriptor.c | ||
crypt_cipher_is_valid.c | ||
crypt_find_cipher.c | ||
crypt_find_hash.c | ||
crypt_hash_descriptor.c | ||
crypt_hash_is_valid.c | ||
crypt_prng_descriptor.c | ||
crypt_register_cipher.c | ||
crypt_register_hash.c | ||
crypt_register_prng.c | ||
doc.go | ||
error.go | ||
error_test.go | ||
flags.go | ||
fortuna.c | ||
go.mod | ||
go.sum | ||
hash_memory.c | ||
hmac_done.c | ||
hmac_init.c | ||
hmac_memory.c | ||
hmac_process.c | ||
mbtls_aes.c | ||
mbtls_aes.h | ||
pkcs_5_2.c | ||
sha1.c | ||
sha256.c | ||
sha512.c | ||
sqlcipher.go | ||
sqlcipher_test.go | ||
sqlite3.c | ||
sqlite3.go | ||
sqlite3.h | ||
sqlite3_context.go | ||
sqlite3_func_crypt.go | ||
sqlite3_func_crypt_test.go | ||
sqlite3_go18.go | ||
sqlite3_go18_test.go | ||
sqlite3_go113_test.go | ||
sqlite3_libsqlite3.go | ||
sqlite3_load_extension.go | ||
sqlite3_load_extension_omit.go | ||
sqlite3_load_extension_test.go | ||
sqlite3_opt_allow_uri_authority.go | ||
sqlite3_opt_app_armor.go | ||
sqlite3_opt_foreign_keys.go | ||
sqlite3_opt_fts3_test.go | ||
sqlite3_opt_fts5.go | ||
sqlite3_opt_icu.go | ||
sqlite3_opt_introspect.go | ||
sqlite3_opt_json1.go | ||
sqlite3_opt_preupdate.go | ||
sqlite3_opt_preupdate_hook.go | ||
sqlite3_opt_preupdate_hook_test.go | ||
sqlite3_opt_preupdate_omit.go | ||
sqlite3_opt_secure_delete.go | ||
sqlite3_opt_secure_delete_fast.go | ||
sqlite3_opt_stat4.go | ||
sqlite3_opt_unlock_notify.c | ||
sqlite3_opt_unlock_notify.go | ||
sqlite3_opt_unlock_notify_test.go | ||
sqlite3_opt_userauth.go | ||
sqlite3_opt_userauth_omit.go | ||
sqlite3_opt_userauth_test.go | ||
sqlite3_opt_vacuum_full.go | ||
sqlite3_opt_vacuum_incr.go | ||
sqlite3_opt_vtable.go | ||
sqlite3_opt_vtable_test.go | ||
sqlite3_other.go | ||
sqlite3_solaris.go | ||
sqlite3_test.go | ||
sqlite3_trace.go | ||
sqlite3_type.go | ||
sqlite3_usleep_windows.go | ||
sqlite3_windows.go | ||
static_mock.go | ||
tomcrypt.h | ||
tomcrypt_argchk.h | ||
tomcrypt_cfg.h | ||
tomcrypt_cipher.h | ||
tomcrypt_custom.h | ||
tomcrypt_hash.h | ||
tomcrypt_mac.h | ||
tomcrypt_macros.h | ||
tomcrypt_math.h | ||
tomcrypt_misc.h | ||
tomcrypt_pk.h | ||
tomcrypt_pkcs.h | ||
tomcrypt_private.h | ||
tomcrypt_prng.h | ||
track_go-sqlite3.sh | ||
track_libtomcrypt.sh | ||
zeromem.c |
README.md
go-sqlcipher
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:
- Go sqlite3 driver: https://github.com/mattn/go-sqlite3
- SQLite extension with AES-256 codec: https://github.com/sqlcipher/sqlcipher
- AES-256 implementation from: https://github.com/libtom/libtomcrypt
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.