Self-contained Go sqlite3 driver with an AES-256 encrypted sqlite3 database
Go to file
Alex Jbanca d4fa1002f9
performance(sqlcipher): Fix burn_stack performance issue
Fixing status-im/status-desktop#10572

Implements a cross-platform version of OP-TEE/optee_os#3102

Remove recursion
Use memset instead of while loop
A description to understand introduced changes without reading the code.

zeromem weights about 50% of the total CPU time on M1 Macs and seems to be major performance offender.
It is used to clear the stack when using variables with sensitive information.
2023-05-09 16:21:44 +03:00
_example/simple use github.com/mutecomm/go-sqlcipher for example 2019-02-26 17:53:30 +00:00
sqlite3_test update code from github.com/mattn/go-sqlite3 2017-04-26 07:12:32 +00:00
.travis.yml travis: also download test dependencies 2019-02-27 14:42:48 +00:00
LICENSE add code 2015-04-29 01:56:53 +02:00
MAINTENANCE update code from github.com/sqlcipher/sqlcipher 2019-02-27 15:18:15 +00:00
Makefile add Makefile and activate modules 2019-02-26 17:54:51 +00:00
README.md mention SQLCipher 3.x releases in README 2019-02-27 15:23:16 +00:00
aes.c add code 2015-04-29 01:56:53 +02:00
aes_tab.h add code 2015-04-29 01:56:53 +02:00
burn_stack.c performance(sqlcipher): Fix burn_stack performance issue 2023-05-09 16:21:44 +03:00
cbc_decrypt.c add code 2015-04-29 01:56:53 +02:00
cbc_done.c add code 2015-04-29 01:56:53 +02:00
cbc_encrypt.c add code 2015-04-29 01:56:53 +02:00
cbc_start.c add code 2015-04-29 01:56:53 +02:00
crypt_argchk.c add code 2015-04-29 01:56:53 +02:00
crypt_cipher_descriptor.c add code 2015-04-29 01:56:53 +02:00
crypt_cipher_is_valid.c add code 2015-04-29 01:56:53 +02:00
crypt_find_cipher.c add code 2015-04-29 01:56:53 +02:00
crypt_find_hash.c add code 2015-04-29 01:56:53 +02:00
crypt_hash_descriptor.c add code 2015-04-29 01:56:53 +02:00
crypt_hash_is_valid.c add code 2015-04-29 01:56:53 +02:00
crypt_prng_descriptor.c add code 2015-04-29 01:56:53 +02:00
crypt_register_cipher.c add code 2015-04-29 01:56:53 +02:00
crypt_register_hash.c add code 2015-04-29 01:56:53 +02:00
crypt_register_prng.c add code 2015-04-29 01:56:53 +02:00
error.go update code from github.com/mattn/go-sqlite3 2017-04-26 07:12:32 +00:00
error_test.go update code from github.com/sqlcipher/sqlcipher 2019-02-27 15:18:15 +00:00
flags.go remove unnecssary flag 2017-09-20 22:46:53 +00:00
fortuna.c add code 2015-04-29 01:56:53 +02:00
go.mod add Makefile and activate modules 2019-02-26 17:54:51 +00:00
go.sum add Makefile and activate modules 2019-02-26 17:54:51 +00:00
hash_memory.c add code 2015-04-29 01:56:53 +02:00
hmac_done.c add code 2015-04-29 01:56:53 +02:00
hmac_init.c add code 2015-04-29 01:56:53 +02:00
hmac_memory.c add code 2015-04-29 01:56:53 +02:00
hmac_process.c add code 2015-04-29 01:56:53 +02:00
pkcs_5_2.c add code 2015-04-29 01:56:53 +02:00
sha1.c add code 2015-04-29 01:56:53 +02:00
sha256.c add code 2015-04-29 01:56:53 +02:00
sqlcipher.go document sqlite3.IsEncrypted() 2017-05-08 21:04:03 +00:00
sqlcipher_test.go goimports -w 2019-02-27 14:25:55 +00:00
sqlite3.c update code from github.com/sqlcipher/sqlcipher 2019-02-27 15:18:15 +00:00
sqlite3.go add missing pragmas 2017-05-08 18:54:00 +00:00
sqlite3.h update code from github.com/sqlcipher/sqlcipher 2019-02-27 15:18:15 +00:00
sqlite3_other.go update code from github.com/mattn/go-sqlite3 2015-04-29 02:10:36 +02:00
sqlite3_test.go update code from github.com/mattn/go-sqlite3 2017-04-26 07:12:32 +00:00
sqlite3_windows.go update code from github.com/mattn/go-sqlite3 2017-04-26 07:12:32 +00:00
tomcrypt.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_argchk.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_cfg.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_cipher.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_custom.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_hash.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_mac.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_macros.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_math.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_misc.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_pk.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_pkcs.h add code 2015-04-29 01:56:53 +02:00
tomcrypt_prng.h add code 2015-04-29 01:56:53 +02:00
track_libtomcrypt.sh add script to track libtomcrypt changes 2015-09-13 16:57:01 +02:00
zeromem.c performance(sqlcipher): Fix burn_stack performance issue 2023-05-09 16:21:44 +03:00

README.md

go-sqlcipher GoDoc Build Status

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.

go-sqlcipher currently only supports the SQLCipher 3.x releases.

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 1024 bytes).

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.