Skip to content

Commit 3992263

Browse files
Update suite to reference SQLCipher for Android 4.0.0
1 parent 51c0afd commit 3992263

18 files changed

+341
-207
lines changed

.idea/workspace.xml

Lines changed: 231 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/app.iml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
8989
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
9090
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
91+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
9192
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-libraries" />
9293
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
9394
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/checkDebugClasspath" />
@@ -122,6 +123,6 @@
122123
</content>
123124
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
124125
<orderEntry type="sourceFolder" forTests="false" />
125-
<orderEntry type="library" name="Gradle: android-database-sqlcipher-3.5.9:@aar" level="project" />
126+
<orderEntry type="library" name="Gradle: net.zetetic:android-database-sqlcipher-4.0.0" level="project" />
126127
</component>
127128
</module>

app/build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
2323

2424
// For testing zip-based distributions:
25-
// implementation files('libs/sqlcipher.jar')
25+
//implementation files('libs/sqlcipher.jar')
2626

27-
// For testing AAR packages:
28-
implementation (name: 'android-database-sqlcipher-3.5.9', ext: 'aar')
27+
// For testing local AAR packages:
28+
//implementation (name: 'android-database-sqlcipher-4.0.0', ext: 'aar')
29+
30+
// For testing on remote AAR references:
31+
implementation 'net.zetetic:android-database-sqlcipher:4.0.0@aar'
2932
}
-7.5 MB
Binary file not shown.
1000 KB
Binary file not shown.

app/src/main/java/net/zetetic/ZeteticApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void postKey(SQLiteDatabase database) {
115115
SQLiteDatabaseHook keyHook = new SQLiteDatabaseHook() {
116116
@Override
117117
public void preKey(SQLiteDatabase database) {
118-
//database.rawExecSQL("PRAGMA cipher_license = '';");
118+
database.rawExecSQL("PRAGMA cipher_license = '';");
119119
}
120120
public void postKey(SQLiteDatabase database) {
121121
}

app/src/main/java/net/zetetic/activities/TestScrollingCursorActivity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.sqlcipher.CustomCursorWindowAllocation;
1515
import net.sqlcipher.database.SQLiteCursor;
1616
import net.sqlcipher.database.SQLiteDatabase;
17+
import net.sqlcipher.database.SQLiteDatabaseHook;
1718
import net.zetetic.R;
1819
import net.zetetic.ScrollingCursorAdapter;
1920
import net.zetetic.ZeteticApplication;
@@ -29,6 +30,16 @@ public class TestScrollingCursorActivity extends Activity {
2930
RadioGroup options;
3031
Cursor cursor;
3132

33+
SQLiteDatabaseHook hook = new SQLiteDatabaseHook() {
34+
public void preKey(SQLiteDatabase database) {}
35+
public void postKey(SQLiteDatabase database) {
36+
database.execSQL("PRAGMA kdf_iter = 64000;");
37+
database.execSQL("PRAGMA cipher_page_size = 1024;");
38+
database.execSQL("PRAGMA cipher_hmac_algorithm = HMAC_SHA1;");
39+
database.execSQL("PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1;");
40+
}
41+
};
42+
3243
@Override
3344
protected void onCreate(Bundle savedInstanceState) {
3445
super.onCreate(savedInstanceState);
@@ -86,7 +97,7 @@ void initializeEnvironment(){
8697
File databasePath = getDatabasePath(databaseFilename);
8798
ZeteticApplication.getInstance().extractAssetToDatabaseDirectory(databaseFilename);
8899
database = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(),
89-
ZeteticApplication.DATABASE_PASSWORD, null, SQLiteDatabase.OPEN_READWRITE);
100+
ZeteticApplication.DATABASE_PASSWORD, null, SQLiteDatabase.OPEN_READWRITE, hook);
90101
} catch (Exception e){
91102
Log.e(getClass().getSimpleName(), e.toString());
92103
}

app/src/main/java/net/zetetic/tests/AES256GCMCipherTest.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

app/src/main/java/net/zetetic/tests/AttachExistingDatabaseTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ protected SQLiteDatabase createDatabase(File databasePath) {
1919
public void preKey(SQLiteDatabase database) {}
2020
public void postKey(SQLiteDatabase database) {
2121
database.execSQL("PRAGMA cipher_default_kdf_iter = 4000;");
22+
database.execSQL("PRAGMA cipher_default_page_size = 1024;");
23+
database.execSQL("PRAGMA cipher_default_hmac_algorithm = HMAC_SHA1;");
24+
database.execSQL("PRAGMA cipher_default_kdf_algorithm = PBKDF2_HMAC_SHA1;");
2225
}
2326
};
2427
return SQLiteDatabase.openOrCreateDatabase(databasePath,
@@ -58,6 +61,10 @@ protected void tearDown(SQLiteDatabase database) {
5861
ZeteticApplication.getInstance().delete1xDatabase();
5962
database.rawExecSQL(String.format("PRAGMA cipher_default_kdf_iter = %s", originalKdfLength));
6063
database.rawExecSQL("pragma cipher_default_use_hmac = on");
64+
database.execSQL("PRAGMA cipher_default_kdf_iter = 256000;");
65+
database.execSQL("PRAGMA cipher_default_page_size = 4096;");
66+
database.execSQL("PRAGMA cipher_default_hmac_algorithm = HMAC_SHA512;");
67+
database.execSQL("PRAGMA cipher_default_kdf_algorithm = PBKDF2_HMAC_SHA512;");
6168
}
6269

6370
@Override

app/src/main/java/net/zetetic/tests/CompileStatementSyntaxErrorMessageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public boolean execute(SQLiteDatabase database) {
2121
String message = e.getMessage();
2222
setMessage(message);
2323
// TBD missing error code etc.
24-
if (!message.matches("near \"VALUES\": syntax error: .*\\, while compiling: INSERT INTO mytable \\(mydata\\) VALUES")) {
24+
if (!message.matches("incomplete input: , while compiling: INSERT INTO mytable \\(mydata\\) VALUES")) {
2525
Log.e(ZeteticApplication.TAG, "NOT EXPECTED: INCORRECT exception message: " + message);
2626
return false;
2727
}

0 commit comments

Comments
 (0)