@@ -38,8 +38,6 @@ set testdir [file dirname $argv0]
3838source $testdir/tester.tcl
3939source $testdir/sqlcipher.tcl
4040
41- set old_pending_byte [sqlite3_test_control_pending_byte 0x40000000]
42-
4341# 1. create a database and insert a bunch of data, close the database
4442# 2. seek to the middle of the first database page and write some junk
4543# 3. Open the database and verify that the database is no longer readable
@@ -343,99 +341,4 @@ do_test integrity-check-plaintext-header {
343341} {{} 1 {{HMAC verification failed for page 1} {HMAC verification failed for page 2}}}
344342file delete -force test.db
345343
346- # verify that the default page size for the
347- # tests is 1024 (via makefile for testfixure. If
348- # the default pagesize is different it will breat
349- # the following tests
350- do_test default-page-size {
351- sqlite_orig db test.db
352- execsql {
353- CREATE TABLE t1(a,b);
354- PRAGMA page_size;
355- }
356- } {1024}
357-
358- # zero out the 65th page, verify the behavior of
359- # pragma integrity check on a plaintext database
360- do_test integrity-check-one-page-plaintext {
361- sqlite_orig db $sampleDir/sqlcipher-4.0-testkey.db
362- set rc {}
363-
364- execsql {
365- PRAGMA key = 'testkey';
366- ATTACH DATABASE 'plain-corrupt.db' AS plain KEY '';
367- SELECT sqlcipher_export('plain');
368- DETACH DATABASE plain;
369- }
370-
371- db close
372-
373- set txt ""
374- for {set i 0} {$i < 2048} {incr i} {
375- append txt "0"
376- }
377-
378- hexio_write plain-corrupt.db 65536 $txt
379-
380- sqlite_orig db plain-corrupt.db
381-
382- set DB [sqlite3_connection_pointer db]
383- set VM [sqlite3_prepare $DB {PRAGMA integrity_check;} -1 TAIL]
384- while {[sqlite3_step $VM] == "SQLITE_ROW"} {
385- lappend rc [sqlite3_column_text $VM 0]
386- }
387- sqlite3_finalize $VM
388-
389- lappend rc [catchsql {
390- PRAGMA integrity_check;
391- }]
392- } {{*** in database main ***
393- Page 65: btreeInitPage() returns error code 11} {1 {database disk image is malformed}}}
394- db close
395- file delete -force plain-corrupt.db
396-
397- # introduce a corruption in the 17th page then verify that
398- # both integrity checks only reports one corrupt page
399- # (not that all subsequent pages corrupt). Behavior of
400- # PRAGMA integrity check should be consistent with the plaintext database
401- # save that the page number will be different because page size for
402- # sqlcipher is 4096 under the testfixture instead of 1024
403- do_test version-4-integrity-check-one-page {
404- file copy -force $sampleDir/sqlcipher-4.0-testkey.db test.db
405-
406- set txt ""
407- for {set i 0} {$i < 8192} {incr i} {
408- append txt "0"
409- }
410-
411- hexio_write test.db 65536 $txt
412-
413- sqlite_orig db test.db
414- set rc {}
415- lappend rc [
416- execsql {
417- PRAGMA key = 'testkey';
418- PRAGMA cipher_integrity_check;
419- }
420- ]
421-
422- set DB [sqlite3_connection_pointer db]
423- set VM [sqlite3_prepare $DB {PRAGMA integrity_check;} -1 TAIL]
424- while {[sqlite3_step $VM] == "SQLITE_ROW"} {
425- lappend rc [sqlite3_column_text $VM 0]
426- }
427- sqlite3_finalize $VM
428-
429- lappend rc [
430- catchsql {
431- PRAGMA integrity_check;
432- }
433- ]
434- } {{ok {HMAC verification failed for page 17}} {*** in database main ***
435- Page 17: btreeInitPage() returns error code 11} {1 {database disk image is malformed}}}
436- db close
437- file delete -force test.db
438-
439- sqlite3_test_control_pending_byte $old_pending_byte
440-
441344finish_test
0 commit comments