Latest 1.2.7
Homepage https://github.com/Pircate/sqlcipher
License BSD
Platforms watchos 2.0, tvos 9.0, osx 10.9, ios 8.0
Frameworks Security, Foundation
Authors

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 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
[email protected]!

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.

Latest podspec

{
    "name": "WCDBSQLCipher",
    "version": "1.2.7",
    "summary": "Full Database Encryption for SQLite and optimized by WCDB.",
    "description": "SQLCipher is an open source extension to SQLite that provides transparent 256-bit AES encryption of database files.nnThis is optimized version by WCDB, which is an efficient, complete, easy-to-use mobile database framework.",
    "homepage": "https://github.com/Pircate/sqlcipher",
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    },
    "authors": {
        "sanhuazhang": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Pircate/sqlcipher.git",
        "tag": "1.2.7"
    },
    "public_header_files": [
        "sqlite3.h",
        "ext/fts3/fts3_tokenizer.h"
    ],
    "source_files": [
        "src/callback.c",
        "src/loadext.c",
        "src/rowset.c",
        "src/treeview.c",
        "ext/userauth.c",
        "src/vtab.c",
        "src/btmutex.c",
        "src/btree.c",
        "src/btreeInt.h",
        "src/btree.h",
        "fts5.c",
        "fts5.h",
        "ext/fts3/fts3_aux.c",
        "ext/fts3/fts3_expr.c",
        "ext/fts3/fts3_hash.c",
        "ext/fts3/fts3_hash.h",
        "ext/fts3/fts3_icu.c",
        "ext/fts3/fts3_porter.c",
        "ext/fts3/fts3_snippet.c",
        "ext/fts3/fts3_tokenize_vtab.c",
        "ext/fts3/fts3_tokenizer.c",
        "ext/fts3/fts3_tokenizer1.c",
        "ext/fts3/fts3_unicode.c",
        "ext/fts3/fts3_unicode2.c",
        "ext/fts3/fts3_write.c",
        "ext/fts3/fts3.c",
        "ext/fts3/fts3.h",
        "ext/fts3/fts3Int.h",
        "src/backup.c",
        "src/legacy.c",
        "src/main.c",
        "src/notify.c",
        "src/vdbeapi.c",
        "src/table.c",
        "src/wal.c",
        "src/wal.h",
        "src/status.c",
        "src/prepare.c",
        "src/malloc.c",
        "src/mem0.c",
        "src/mem1.c",
        "src/mem2.c",
        "src/mem3.c",
        "src/mem5.c",
        "src/memjournal.c",
        "src/mutex_unix.c",
        "src/mutex_noop.c",
        "src/mutex.c",
        "src/mutex.h",
        "src/os_common.h",
        "src/os_setup.h",
        "src/os_unix.c",
        "src/queue.c",
        "src/queue.h",
        "src/os_wcdb.c",
        "src/os_wcdb.h",
        "src/mutex_wcdb.c",
        "src/mutex_wcdb.h",
        "src/os.c",
        "src/os.h",
        "src/threads.c",
        "src/bitvec.c",
        "src/pager.c",
        "src/pager.h",
        "src/pcache.c",
        "src/pcache.h",
        "src/pcache1.c",
        "ext/rtree/rtree.c",
        "ext/rtree/rtree.h",
        "ext/rtree/sqlite3rtree.h",
        "src/complete.c",
        "src/tokenize.c",
        "src/resolve.c",
        "parse.c",
        "parse.h",
        "src/analyze.c",
        "src/func.c",
        "src/wherecode.c",
        "src/whereexpr.c",
        "src/whereInt.h",
        "src/alter.c",
        "src/attach.c",
        "src/auth.c",
        "src/build.c",
        "src/delete.c",
        "src/expr.c",
        "src/insert.c",
        "src/pragma.c",
        "src/pragma.h",
        "src/select.c",
        "src/trigger.c",
        "src/update.c",
        "src/vacuum.c",
        "src/walker.c",
        "src/where.c",
        "opcodes.c",
        "opcodes.h",
        "src/sqlcipher.h",
        "sqlite3.h",
        "ext/rbu/sqlite3rbu.c",
        "ext/rbu/sqlite3rbu.h",
        "ext/userauth/sqlite3userauth.h",
        "ext/misu/json1.c",
        "ext/icu/icu.c",
        "ext/icu/sqliteicu.h",
        "src/global.c",
        "src/ctime.c",
        "src/hwtime.h",
        "src/date.c",
        "src/dbstat.c",
        "src/fault.c",
        "src/fkey.c",
        "src/sqliteInt.h",
        "src/sqliteLimit.h",
        "src/sqlite3ext.h",
        "src/hash.c",
        "src/hash.h",
        "src/printf.c",
        "src/random.c",
        "src/utf.c",
        "src/util.c",
        "src/crypto_cc.c",
        "src/crypto_impl.c",
        "src/crypto_libtomcrypt.c",
        "src/crypto.c",
        "src/crypto.h",
        "src/vdbe.c",
        "src/vdbe.h",
        "src/vdbeaux.c",
        "src/vdbeblob.c",
        "src/vdbeInt.h",
        "src/vdbemem.c",
        "src/vdbesort.c",
        "src/vdbetrace.c",
        "src/msvc.h",
        "src/vxworks.h",
        "ext/fts3/fts3_tokenizer.h",
        "keywordhash.h"
    ],
    "platforms": {
        "watchos": "2.0",
        "tvos": "9.0",
        "osx": "10.9",
        "ios": "8.0"
    },
    "frameworks": [
        "Security",
        "Foundation"
    ],
    "requires_arc": false,
    "pod_target_xcconfig": {
        "GCC_PREPROCESSOR_DEFINITIONS": "SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_API_ARMOR SQLITE_OMIT_BUILTIN_TEST SQLITE_OMIT_AUTORESET SQLITE_ENABLE_UPDATE_DELETE_LIMIT SQLITE_ENABLE_RTREE SQLITE_ENABLE_LOCKING_STYLE=1 SQLITE_SYSTEM_MALLOC SQLITE_OMIT_LOAD_EXTENSION SQLITE_CORE SQLITE_THREADSAFE=2 SQLITE_DEFAULT_CACHE_SIZE=250 SQLITE_DEFAULT_CKPTFULLFSYNC=1 SQLITE_DEFAULT_PAGE_SIZE=4096 SQLITE_OMIT_SHARED_CACHE SQLITE_HAS_CODEC SQLCIPHER_CRYPTO_CC USE_PREAD=1 SQLITE_TEMP_STORE=2 SQLCIPHER_PREPROCESSED HAVE_USLEEP SQLITE_MALLOC_SOFT_LIMIT=0 SQLITE_WCDB_SIGNAL_RETRY=1 SQLITE_DEFAULT_MEMSTATUS=0 SQLITE_ENABLE_COLUMN_METADATA SQLITE_DEFAULT_WAL_SYNCHRONOUS=1 SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_MAX_EXPR_DEPTH=0 SQLITE_OMIT_DEPRECATED SQLITE_OMIT_PROGRESS_CALLBACK SQLITE_OMIT_SHARED_CACHE OMIT_CONSTTIME_MEM OMIT_MEMLOCK SQLITE_ENABLE_FTS3_TOKENIZER SQLITE_WCDB_CHECKPOINT_HANDLER SQLITE_MMAP_READWRITE SQLITE_ENABLE_DBSTAT_VTAB SQLITE_ENABLE_FTS5",
        "CLANG_WARN_CONSTANT_CONVERSION": "YES",
        "GCC_WARN_64_TO_32_BIT_CONVERSION": "NO",
        "CLANG_WARN_UNREACHABLE_CODE": "NO",
        "GCC_WARN_UNUSED_FUNCTION": "NO",
        "GCC_WARN_UNUSED_VARIABLE": "NO",
        "CLANG_WARN_COMMA": "NO",
        "CLANG_WARN_STRICT_PROTOTYPES": "NO",
        "APPLICATION_EXTENSION_API_ONLY": "YES"
    },
    "header_dir": "SQLCipher"
}

Pin It on Pinterest

Share This