[MOD-2521] Encrypted Database: Android: Add access to preKey and postKey hooks
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | None |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Encrypted SQLite DB |
Labels | android, encrypted_database, sqlite |
Reporter | John V Pataki |
Assignee | Unknown |
Created | 2019-05-22T21:19:37.000+0000 |
Updated | 2019-05-28T19:19:18.000+0000 |
Description
The code base used in the Encrypted Database module is sqlcipher.
Currently the module relies on the java openOrCreateDatabase() method which passes in the key at the java level (not at the javascript level) wrapped up in the open() function called in javascript. This means you can't set any PRAGMAs just before or just after the key is set. There are valid reasons (I will articulate in another ticket an actual issue found) for why you may want to set a PRAGMA before or after the key is provided, but before the other operations (like the test against sqlite_master) in openOrCreateDatabase().
There exists already accepts these two hooks that can be called in the sqlcipher code for preKey() and postKey() and a construct for handling it as [SQLiteDatabaseHook](https://github.com/sqlcipher/android-database-sqlcipher/blob/master/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabaseHook.java) and you can see in this method [keyDatabase](https://github.com/sqlcipher/android-database-sqlcipher/blob/79bfeedaedfc5329e31c70a47666c9f7eaf20d87/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java#L2633) the way those hooks are applied before and after the actual key "run" step.
This will open up the ability to perform operations before or after the key is provided within the open() function / openOrCreateDatabase() method.
No comments