mirror of
https://github.com/status-im/sqlcipher.git
synced 2026-08-31 14:31:11 +00:00
implementation of PRAGMA cipher_integrity_check and associated tests
This commit is contained in:
@@ -531,84 +531,6 @@ do_test custom-pagesize-must-match {
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# 1. create a database and insert a bunch of data, close the database
|
||||
# 2. seek to the middle of a database page and write some junk
|
||||
# 3. Open the database and verify that the database is no longer readable
|
||||
do_test hmac-tamper-resistence {
|
||||
sqlite_orig db test.db
|
||||
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
CREATE table t1(a,b);
|
||||
BEGIN;
|
||||
}
|
||||
|
||||
for {set i 1} {$i<=1000} {incr i} {
|
||||
set r [expr {int(rand()*500000)}]
|
||||
execsql "INSERT INTO t1 VALUES($i,'value $r');"
|
||||
}
|
||||
|
||||
execsql {
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
db close
|
||||
|
||||
# write some junk into the hmac segment, leaving
|
||||
# the page data valid but with an invalid signature
|
||||
hexio_write test.db 1000 0000
|
||||
|
||||
sqlite_orig db test.db
|
||||
|
||||
catchsql {
|
||||
PRAGMA key = 'testkey';
|
||||
SELECT count(*) FROM t1;
|
||||
}
|
||||
|
||||
} {1 {file is not a database}}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# 1. create a database and insert a bunch of data, close the database
|
||||
# 2. seek to the middle of a database page and write some junk
|
||||
# 3. Open the database and verify that the database is still readable
|
||||
do_test nohmac-not-tamper-resistent {
|
||||
sqlite_orig db test.db
|
||||
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
PRAGMA cipher_use_hmac = OFF;
|
||||
PRAGMA cipher_page_size = 1024;
|
||||
CREATE table t1(a,b);
|
||||
BEGIN;
|
||||
}
|
||||
|
||||
for {set i 1} {$i<=1000} {incr i} {
|
||||
set r [expr {int(rand()*500000)}]
|
||||
execsql "INSERT INTO t1 VALUES($i,'value $r');"
|
||||
}
|
||||
|
||||
execsql {
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
db close
|
||||
|
||||
# write some junk into the middle of the page
|
||||
hexio_write test.db 2560 00
|
||||
|
||||
sqlite_orig db test.db
|
||||
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
PRAGMA cipher_use_hmac = OFF;
|
||||
PRAGMA cipher_page_size = 1024;
|
||||
SELECT count(*) FROM t1;
|
||||
}
|
||||
|
||||
} {1000}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# 1. create a database with WAL journal mode
|
||||
# 2. create table and insert operations should work
|
||||
|
||||
Reference in New Issue
Block a user