SQLCipher is an SQLite extension that provides 256 bit AES encryption of database files. https://www.zetetic.net/sqlcipher/
Go to file
Stephen Lombardo 1001b72e9f use new API with libressl >2.7.0 2018-08-28 16:55:00 -04:00
.github Initial contributing, issue, and pull request template for Github 2016-02-24 15:40:16 -06:00
art track 3.7.12 2012-05-15 19:05:34 -04:00
autoconf Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
contrib track 3.7.6.2 2011-05-05 22:37:34 -04:00
doc Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
ext Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
macosx Fixed build related issues with included files and umbrella header. 2015-11-17 22:10:00 -08:00
mptest Revert "Merge sqlite-release(3.11.0) into prerelease-integration" 2016-12-02 16:24:56 -06:00
sqlcipher.xcodeproj Fixed build related issues with included files and umbrella header. 2015-11-17 22:10:00 -08:00
src use new API with libressl >2.7.0 2018-08-28 16:55:00 -04:00
test adds PRAGMA default_cipher_plaintext_header_size and tests 2018-01-18 10:22:12 -05:00
tool Merge sqlite-release(3.20.1) into prerelease-integration 2017-09-27 16:12:26 -05:00
vsixtest Snapshot of upstream SQLite 3.15.2 2016-12-05 14:29:15 -06:00
.gitignore Add PRAGMA cipher_profile support 2014-04-07 11:42:32 -05:00
CHANGELOG.md Update changelog 2017-12-21 13:31:28 -06:00
LICENSE add a prominent LICENSE file (to help make sure terms are clear) 2012-01-13 14:04:01 -05:00
Makefile.in Merge sqlite-release(3.20.1) into prerelease-integration 2017-09-27 16:12:26 -05:00
Makefile.linux-gcc Revert "Merge sqlite-release(3.11.0) into prerelease-integration" 2016-12-02 16:24:56 -06:00
Makefile.msc Merge sqlite-release(3.20.1) into prerelease-integration 2017-09-27 16:12:26 -05:00
README.md Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
SQLCipher.podspec.json update podspec to base 3.4.2 2018-01-18 10:44:00 -05:00
VERSION Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
aclocal.m4 Update from autoreconf 2016-02-22 12:38:50 -06:00
config.guess commit of sqlite 3.6.0 2008-07-30 09:15:43 -04:00
config.h.in Merge sqlite-release(3.15.2) into prerelease-integration 2016-12-06 13:10:27 -06:00
config.sub commit of sqlite 3.6.0 2008-07-30 09:15:43 -04:00
configure Merge sqlite-release(3.20.1) into prerelease-integration 2017-09-27 16:12:26 -05:00
configure.ac Merge sqlite-release(3.20.1) into prerelease-integration 2017-09-27 16:12:26 -05:00
install-sh commit of sqlite 3.6.0 2008-07-30 09:15:43 -04:00
ltmain.sh Update from autoreconf 2016-02-22 12:38:50 -06:00
magic.txt Snapshot of upstream SQLite 3.8.6 2014-09-30 08:40:45 -05:00
main.mk Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
manifest Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
manifest.uuid Snapshot of upstream SQLite 3.20.1 2017-09-27 16:07:03 -05:00
mkso.sh update baseline to sqlite version 3.6.1 2008-08-19 01:05:45 -04:00
spec.template commit of sqlite 3.6.0 2008-07-30 09:15:43 -04:00
sqlcipher-1.1.8-testkey.db Adjust sqlite3_test_control_pending_byte to test larger files 2013-09-23 16:37:04 -05:00
sqlcipher-2.0-be-testkey.db Adjust sqlcipher-2.0-be-testkey.db to 1 MB in size 2013-09-23 16:46:34 -05:00
sqlcipher-2.0-beta-testkey.db Bumping file size of sqlcipher-2.0-beta-testkey.db to 1 MB 2013-09-23 16:51:26 -05:00
sqlcipher-2.0-le-testkey.db Adjust file size of sqlcipher-2.0-le-testkey.db to over 1 MB 2013-09-23 16:41:34 -05:00
sqlcipher-3.0-testkey.db Adjust file size of sqlcipher-3.0-testkey.db to 1 MB 2013-09-23 16:55:46 -05:00
sqlcipher.1 Merge sqlite-release(3.8.8.3) into prerelease-integration 2015-03-20 09:37:39 -05:00
sqlcipher.pc.in SQLCipher headers are installed into ${includedir}/sqlcipher 2014-10-16 23:38:10 -04:00
sqlite.pc.in track sqlite 3.6.11 2009-02-20 15:33:35 -05:00

README.md

SQLCipher

SQLCipher extends the SQLite database library to add security enhancements that make it more suitable for encrypted local data storage such as on-the-fly encryption, tamper evidence, and key derivation. Based on SQLite, SQLCipher closely tracks SQLite and periodically integrates stable SQLite release features.

SQLCipher is maintained by Zetetic, LLC, the official site can be found here.

Features

  • Fast performance with as little as 5-15% overhead for encryption on many operations
  • 100% of data in the database file is encrypted
  • Good security practices (CBC mode, HMAC, key derivation)
  • Zero-configuration and application level cryptography
  • Algorithms provided by the peer reviewed OpenSSL crypto library.
  • Configurable crypto providers

Contributions

We welcome contributions, to contribute to SQLCipher, a contributor agreement needs to be submitted. All submissions should be based on the prerelease branch.

Compiling

Building SQLCipher is almost the same as compiling a regular version of SQLite with two small exceptions:

  1. You must define SQLITE_HAS_CODEC and SQLITE_TEMP_STORE=2 when building sqlcipher.
  2. If compiling against the default OpenSSL crypto provider, you will need to link libcrypto

Example Static linking (replace /opt/local/lib with the path to libcrypto.a). Note in this example, --enable-tempstore=yes is setting SQLITE_TEMP_STORE=2 for the build.

$ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
	LDFLAGS="/opt/local/lib/libcrypto.a"
$ make

Example Dynamic linking

$ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
	LDFLAGS="-lcrypto"
$ make

Encrypting a database

To specify an encryption passphrase for the database via the SQL interface you use a pragma. The passphrase you enter is passed through PBKDF2 key derivation to obtain the encryption key for the database

PRAGMA key = 'passphrase';

Alternately, you can specify an exact byte sequence using a blob literal. If you use this method it is your responsibility to ensure that the data you provide is a 64 character hex string, which will be converted directly to 32 bytes (256 bits) of key data without key derivation.

PRAGMA key = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";

To encrypt a database programatically you can use the sqlite3_key function. The data provided in pKey is converted to an encryption key according to the same rules as PRAGMA key.

int sqlite3_key(sqlite3 *db, const void *pKey, int nKey);

PRAGMA key or sqlite3_key should be called as the first operation when a database is open.

Changing a database key

To change the encryption passphrase for an existing database you may use the rekey pragma after you've supplied the correct database password;

PRAGMA key = 'passphrase'; -- start with the existing database passphrase
PRAGMA rekey = 'new-passphrase'; -- rekey will reencrypt with the new passphrase

The hex rekey pragma may be used to rekey to a specific binary value

PRAGMA rekey = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";

This can be accomplished programtically by using sqlite3_rekey;

sqlite3_rekey(sqlite3 *db, const void *pKey, int nKey)

Support

The primary avenue for support and discussions is the SQLCipher discuss site:

https://discuss.zetetic.net/c/sqlcipher

Issues or support questions on using SQLCipher should be entered into the GitHub Issue tracker:

https://github.com/sqlcipher/sqlcipher/issues

Please DO NOT post issues, support questions, or other problems to blog posts about SQLCipher as we do not monitor them frequently.

If you are using SQLCipher in your own software please let us know at support@zetetic.net!

License

Copyright (c) 2016, ZETETIC LLC All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the ZETETIC LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.