Sqlite3_key confused comments


#1

I see the following comments in the source … what does this mean?
For the public release do we have to use PRAGMA key = ‘password’ instead?

#ifdef SQLITE_HAS_CODEC
/*
** Specify the key for an encrypted database. This routine should be
** called right after sqlite3_open().
**
** The code to implement this API is not available in the public release
** of SQLite.
*/
SQLITE_API int sqlite3_key(
sqlite3 db, / Database to be rekeyed */
const void pKey, int nKey / The key */
);
SQLITE_API int sqlite3_key_v2(
sqlite3 db, / Database to be rekeyed */
const char zDbName, / Name of the database */
const void pKey, int nKey / The key */
);


#2

Hello @mtissington - those comments in sqlite.h.in are referring to the public release of SQLite. That does not include any encrypted database implementation. SQLCipher does provide the code that implements the sqlite3_key API.


#3

Sorry I’m really confused by this … your docs say that PRAGMA key calls the internal implementation of sqlite3_key API …

If I build the community version of sqlcipher should it have sqlite3_key?
Or is the only way to specify the key by PRAGMA?


#4

@mtissington

The comment you referred to originates in the SQLite source. It is saying that encryption functionality and sqlite3_key is not present in the public release of SQLite (i.e. the one you’d download from sqlite.org).

SQLCipher, on the other hand, is an extension that exists specifically to implement encryption functionality. Thus, both sqlite3_key and PRAGMA key will work when using SQLCipher (including when built from the community edition sources of SQLCipher).

Let me know if that clears things up.


#5

Great, thanks - that does it.