Update changelog
[sqlcipher.git] / README.md
blob67cc7a7d48af8cab62cad3f7055c77a274ebd3d3
1 ## SQLCipher
3 SQLCipher extends the [SQLite](https://www.sqlite.org) 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.
5 SQLCipher is maintained by Zetetic, LLC, the official site can be found [here](https://www.zetetic.net/sqlcipher/).
7 ## Features
9 - Fast performance with as little as 5-15% overhead for encryption on many operations
10 - 100% of data in the database file is encrypted
11 - Good security practices (CBC mode, HMAC, key derivation)
12 - Zero-configuration and application level cryptography
13 - Algorithms provided by the peer reviewed OpenSSL crypto library.
14 - Configurable crypto providers
16 ## Contributions
18 We welcome contributions, to contribute to SQLCipher, a [contributor agreement](https://www.zetetic.net/contributions/) needs to be submitted.  All submissions should be based on the `prerelease` branch.
20 ## Compiling
22 Building SQLCipher is almost the same as compiling a regular version of 
23 SQLite with two small exceptions: 
25  1. You *must* define `SQLITE_HAS_CODEC` and `SQLITE_TEMP_STORE=2` when building sqlcipher. 
26  2. If compiling against the default OpenSSL crypto provider, you will need to link libcrypto
28 Example Static linking (replace /opt/local/lib with the path to libcrypto.a). Note in this 
29 example, `--enable-tempstore=yes` is setting `SQLITE_TEMP_STORE=2` for the build.
31         $ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
32                 LDFLAGS="/opt/local/lib/libcrypto.a"
33         $ make
35 Example Dynamic linking
37         $ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
38                 LDFLAGS="-lcrypto"
39         $ make
41 ## Encrypting a database
43 To specify an encryption passphrase for the database via the SQL interface you 
44 use a pragma. The passphrase you enter is passed through PBKDF2 key derivation to
45 obtain the encryption key for the database 
47         PRAGMA key = 'passphrase';
49 Alternately, you can specify an exact byte sequence using a blob literal. If you
50 use this method it is your responsibility to ensure that the data you provide a
51 64 character hex string, which will be converted directly to 32 bytes (256 bits) of 
52 key data without key derivation.
54         PRAGMA key = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";
56 To encrypt a database programatically you can use the `sqlite3_key` function. 
57 The data provided in `pKey` is converted to an encryption key according to the 
58 same rules as `PRAGMA key`. 
60         int sqlite3_key(sqlite3 *db, const void *pKey, int nKey);
62 `PRAGMA key` or `sqlite3_key` should be called as the first operation when a database is open.
64 ## Changing a database key
66 To change the encryption passphrase for an existing database you may use the rekey pragma
67 after you've supplied the correct database password;
69         PRAGMA key = 'passphrase'; -- start with the existing database passphrase
70         PRAGMA rekey = 'new-passphrase'; -- rekey will reencrypt with the new passphrase
72 The hex rekey pragma may be used to rekey to a specific binary value
74         PRAGMA rekey = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";
76 This can be accomplished programtically by using sqlite3_rekey;
77   
78         sqlite3_rekey(sqlite3 *db, const void *pKey, int nKey)
80 ## Support
82 The primary avenue for support and discussions is the SQLCipher discuss site:
84 https://discuss.zetetic.net/c/sqlcipher
86 Issues or support questions on using SQLCipher should be entered into the 
87 GitHub Issue tracker:
89 https://github.com/sqlcipher/sqlcipher/issues
91 Please DO NOT post issues, support questions, or other problems to blog 
92 posts about SQLCipher as we do not monitor them frequently.
94 If you are using SQLCipher in your own software please let us know at 
95 support@zetetic.net!
97 ## License
99 Copyright (c) 2016, ZETETIC LLC
100 All rights reserved.
102 Redistribution and use in source and binary forms, with or without
103 modification, are permitted provided that the following conditions are met:
104     * Redistributions of source code must retain the above copyright
105       notice, this list of conditions and the following disclaimer.
106     * Redistributions in binary form must reproduce the above copyright
107       notice, this list of conditions and the following disclaimer in the
108       documentation and/or other materials provided with the distribution.
109     * Neither the name of the ZETETIC LLC nor the
110       names of its contributors may be used to endorse or promote products
111       derived from this software without specific prior written permission.
113 THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
114 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
115 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
116 DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
117 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
118 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
119 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
120 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
121 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
122 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.