3 SQLCipher is an SQLite extension that provides transparent 256-bit AES encryption of
4 database files. Pages are encrypted before being written to disk and are decrypted
5 when read back. Due to the small footprint and great performance it’s ideal for
6 protecting embedded application databases and is well suited for mobile development.
8 The official SQLCipher software site is http://sqlcipher.net
10 SQLCipher was initially developed by Stephen Lombardo at Zetetic LLC
11 (sjlombardo@zetetic.net) as the encrypted database layer for Strip,
12 an iPhone data vault and password manager (http://getstrip.com).
16 - Fast performance with as little as 5-15% overhead for encryption on many operations
17 - 100% of data in the database file is encrypted
18 - Good security practices (CBC mode, key derivation)
19 - Zero-configuration and application level cryptography
20 - Algorithms provided by the peer reviewed OpenSSL crypto library.
21 - Configurable crypto providers
25 Building SQLCipher is almost the same as compiling a regular version of
26 SQLite with two small exceptions:
28 1. You must define SQLITE_HAS_CODEC and SQLITE_TEMP_STORE=2 when building sqlcipher
29 2. You need to link against a OpenSSL's libcrypto
31 Example Static linking (replace /opt/local/lib with the path to libcrypto.a)
33 $ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
34 LDFLAGS="/opt/local/lib/libcrypto.a"
37 Example Dynamic linking
39 $ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
43 [Encrypting a database]
45 To specify an encryption passphrase for the database via the SQL interface you
46 use a pragma. The passphrase you enter is passed through PBKDF2 key derivation to
47 obtain the encryption key for the database
49 PRAGMA key = 'passphrase';
51 Alternately, you can specify an exact byte sequence using a blob literal. If you
52 use this method it is your responsibility to ensure that the data you provide a
53 64 character hex string, which will be converted directly to 32 bytes (256 bits) of
54 key data without key derivation.
56 PRAGMA key = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";
58 To encrypt a database programatically you can use the sqlite3_key function.
59 The data provided in pKey is converted to an encryption key according to the
60 same rules as PRAGMA key.
63 int sqlite3_key(sqlite3 *db, const void *pKey, int nKey);
65 PRAGMA key or sqlite3_key should be called as the first operation when a database is open.
67 [Changing a database key]
69 To change the encryption passphrase for an existing database you may use the rekey pragma
70 after you've supplied the correct database password;
72 PRAGMA key = 'passphrase'; -- start with the existing database passphrase
73 PRAGMA rekey = 'new-passphrase'; -- rekey will reencrypt with the new passphrase
75 The hexrekey pragma may be used to rekey to a specific binary value
77 PRAGMA rekey = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";
79 This can be accomplished programtically by using sqlite3_rekey;
81 sqlite3_rekey(sqlite3 *db, const void *pKey, int nKey)
85 The primary avenue for support and discussions is the SQLCipher users mailing list:
87 http://groups.google.com/group/sqlcipher
89 Issues or support questions on using SQLCipher should be entered into the
92 http://github.com/sjlombardo/sqlcipher/issues
94 Please DO NOT post issues, support questions, or other problems to blog
95 posts about SQLCipher as we do not monitor them frequently.
97 If you are using SQLCipher in your own software please let us know at
102 Copyright (c) 2008, ZETETIC LLC
105 Redistribution and use in source and binary forms, with or without
106 modification, are permitted provided that the following conditions are met:
107 * Redistributions of source code must retain the above copyright
108 notice, this list of conditions and the following disclaimer.
109 * Redistributions in binary form must reproduce the above copyright
110 notice, this list of conditions and the following disclaimer in the
111 documentation and/or other materials provided with the distribution.
112 * Neither the name of the ZETETIC LLC nor the
113 names of its contributors may be used to endorse or promote products
114 derived from this software without specific prior written permission.
116 THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
117 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
118 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
119 DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
120 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
121 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
122 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
123 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
124 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
125 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
129 This directory contains source code to
131 SQLite: An Embeddable SQL Database Engine
133 To compile the project, first create a directory in which to place
134 the build products. It is recommended, but not required, that the
135 build directory be separate from the source directory. Cd into the
136 build directory and then from the build directory run the configure
137 script found at the root of the source tree. Then run "make".
141 tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite"
142 mkdir bld ;# Build will occur in a sibling directory
143 cd bld ;# Change to the build directory
144 ../sqlite/configure ;# Run the configure script
145 make ;# Run the makefile.
146 make install ;# (Optional) Install the build products
148 The configure script uses autoconf 2.61 and libtool. If the configure
149 script does not work out for you, there is a generic makefile named
150 "Makefile.linux-gcc" in the top directory of the source tree that you
151 can copy and edit to suit your needs. Comments on the generic makefile
152 show what changes are needed.
154 The linux binaries on the website are created using the generic makefile,
155 not the configure script. The windows binaries on the website are created
156 using MinGW32 configured as a cross-compiler running under Linux. For
157 details, see the ./publish.sh script at the top-level of the source tree.
158 The developers do not use teh configure script.
160 SQLite does not require TCL to run, but a TCL installation is required
161 by the makefiles. SQLite contains a lot of generated code and TCL is
162 used to do much of that code generation. The makefile also requires
167 http://www.sqlite.org/