Skip to content

Commit f07c10d

Browse files
committed
Add SQLCipher tests to CI
Test accessing all legacy SQLCipher database versions
1 parent d163a47 commit f07c10d

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ script:
3939
- echo 'Testing...' && echo -en 'travis_fold:start:script.test\\r'
4040
- ./sqlite3shell test1.db3 ".read test/test1.sql"
4141
- ./sqlite3shell test2.db3 ".read test/test2.sql"
42+
- ./sqlite3shell dummy.db3 ".read test/sqlciphertest.sql"
4243
- echo -en 'travis_fold:end:script.test\\r'
4344

4445
# The "set +e" is a workaround for https://github.com/travis-ci/travis-ci/issues/6522

test/sqlciphertest.sql

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.echo on
2+
-- Test to access database encrypted with SQLCipher version 1
3+
-- Result: 75709 1 1 one one 1 2 one two 1 2
4+
.open test/sqlcipher-1.1.8-testkey.db
5+
pragma cipher='sqlcipher';
6+
pragma legacy=1;
7+
pragma key='testkey';
8+
SELECT COUNT(*) FROM t1;
9+
SELECT DISTINCT * FROM t1;
10+
11+
-- Test to access database encrypted with SQLCipher version 2
12+
-- using 4000 iterations for the HMAC key derivation and a HMAC salt mask of zero
13+
-- Result: 38768 test-0-0 test-0-1 test-1-0 test-1-1
14+
.open test/sqlcipher-2.0-beta-testkey.db
15+
pragma cipher='sqlcipher';
16+
pragma legacy=2;
17+
pragma fast_kdf_iter=4000;
18+
pragma hmac_salt_mask=0;
19+
pragma key='testkey';
20+
SELECT COUNT(*) FROM t1;
21+
SELECT DISTINCT * FROM t1;
22+
23+
-- Test to access database encrypted with SQLCipher version 2
24+
-- using the page number in big endian form (BE) for the HMAC calculation
25+
-- Result: 78536 1 1 one one 1 2 one two
26+
.open test/sqlcipher-2.0-be-testkey.db
27+
pragma cipher='sqlcipher';
28+
pragma legacy=2;
29+
pragma hmac_pgno=2;
30+
pragma key='testkey';
31+
SELECT COUNT(*) FROM t1;
32+
SELECT DISTINCT * FROM t1;
33+
34+
-- Test to access database encrypted with SQLCipher version 2
35+
-- using the page number in little endian form (LE) for the HMAC calculation
36+
-- Note: No change to the default initialization necessary
37+
-- Result: 78536 1 1 one one 1 2 one two
38+
.open test/sqlcipher-2.0-le-testkey.db
39+
pragma cipher='sqlcipher';
40+
pragma legacy=2;
41+
pragma key='testkey';
42+
SELECT COUNT(*) FROM t1;
43+
SELECT DISTINCT * FROM t1;
44+
45+
-- // Test to access database encrypted with SQLCipher version 3
46+
-- // Result: 78536 1 1 one one 1 2 one two
47+
.open test/sqlcipher-3.0-testkey.db
48+
pragma cipher='sqlcipher';
49+
pragma legacy=3;
50+
pragma key='testkey';
51+
SELECT COUNT(*) FROM t1;
52+
SELECT DISTINCT * FROM t1;
53+
54+
-- // Test to access database encrypted with SQLCipher version 4
55+
-- // Result: 78536 1 1 one one 1 2 one two
56+
.open test/sqlcipher-4.0-testkey.db
57+
pragma cipher='sqlcipher';
58+
pragma legacy=4;
59+
pragma key='testkey';
60+
SELECT COUNT(*) FROM t1;
61+
SELECT DISTINCT * FROM t1;

0 commit comments

Comments
 (0)