diff --git a/src/crypto.c b/src/crypto.c index 33e0fc98..758b0fef 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -266,8 +266,25 @@ int sqlite3_key(sqlite3 *db, const void *pKey, int nKey) { } } -/* FIXME - this should change the password for the database! */ +/* sqlite3_rekey +** Given a database, this will reencrypt the database using a new key. +** There are two possible modes of operation. The first is rekeying +** an existing database that was not previously encrypted. The second +** is to change the key on an existing database. +** +** The proposed logic for this function follows: +** 1. Determine if there is already a key present +** 2. If there is NOT already a key present, create one and attach a codec (key would be null) +** 3. Initialize a ctx->new_key parameter of the codec +** 3. Create a transaction on the database +** 4. Iterate through each page, reading it and then writing it. +** 5. If that goes ok then commit and put ctx->new_key into ctx->key +** +** Note: this will require modifications to the sqlite3Codec to support new_key +** +*/ int sqlite3_rekey(sqlite3 *db, const void *pKey, int nKey) { + /* FIXME - this should change the password for the database! */ printf("sorry sqlite3_rekey is not implemented yet\n"); sqlite3_key(db, pKey, nKey); }