8000 enable secure delete on all encrypted databases · PHPDOTSQL/sqlcipher@c2f7cd7 · GitHub
[go: up one dir, main page]

Skip to content

Commit c2f7cd7

Browse files
committed
enable secure delete on all encrypted databases
1 parent 0e8cdf4 commit c2f7cd7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/crypto.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ int sqlite3CodecAttach(sqlite3* db, int nDb, const void *zKey, int nKey) {
239239

240240
codec_set_btree_to_codec_pagesize(db, pDb, ctx);
241241

242+
/* force secure delete. This has the benefit of wiping internal data when deleted
243+
and also ensures that all pages are written to disk (i.e. not skipped by
244+
sqlite3PagerDontWrite optimizations) */
245+
sqlite3BtreeSecureDelete(pDb->pBt, 1);
246+
242247
/* if fd is null, then this is an in-memory database and
243248
we dont' want to overwrite the AutoVacuum settings
244249
if not null, then set to the default */

test/crypto.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ file delete -force test.db
271271
# delete another 50%
272272
# then rekey it. Make sure it is immediately
273273
# readable. Then close it and make sure it can be
274-
# read back
274+
# read back. This test will ensure that Secure Delete
275+< 7F25 /span>
# is enabled and all pages are being written and are not
276+
# being optimized out by sqlite3PagerDontWrite
275277
do_test rekey-delete-and-query-1 {
276278
sqlite_orig db test.db
277279

@@ -311,7 +313,7 @@ do_test rekey-delete-and-query-1 {
311313
PRAGMA rekey = 'test321';
312314
SELECT count(*) > 1 FROM t1;
313315
}
314-
} {}
316+
} {1}
315317
db close
316318
file delete -force test.db
317319

0 commit comments

Comments
 (0)
0