Skip to content

Commit 2b2aca3

Browse files
Adding function useHMACPageProtection to disable/enable HMAC protection for further calls to open/create of SQLiteDatabase
1 parent eeca91c commit 2b2aca3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public class SQLiteDatabase extends SQLiteClosable {
7171
private static final String TAG = "Database";
7272
private static final int EVENT_DB_OPERATION = 52000;
7373
private static final int EVENT_DB_CORRUPT = 75004;
74+
private static boolean useHMACPageProtection = true;
75+
76+
public static void setUseHMACPageProtection(boolean value){
77+
SQLiteDatabase.useHMACPageProtection = value;
78+
}
7479

7580
private static void loadICUData(Context context) {
7681

@@ -1871,6 +1876,12 @@ public SQLiteDatabase(String path, String password, CursorFactory factory, int f
18711876
mFactory = factory;
18721877
dbopen(mPath, mFlags);
18731878

1879+
if(SQLiteDatabase.useHMACPageProtection){
1880+
execSQL("PRAGMA cipher_default_use_hmac = ON");
1881+
} else {
1882+
execSQL("PRAGMA cipher_default_use_hmac = OFF");
1883+
}
1884+
18741885
execSQL("PRAGMA key = '" + password + "'");
18751886

18761887
if (SQLiteDebug.DEBUG_SQL_CACHE) {

0 commit comments

Comments
 (0)