[MOD-2521] Encrypted Database: Android: Add access to preKey and postKey hooks

GitHub Issuen/a
Affected Version/sn/a
Fix Version/sn/a
ComponentsEncrypted SQLite DB
Labelsandroid, encrypted_database, sqlite
ReporterJohn V Pataki


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

JSON Source