0

I'm using the Android Room API and https://github.com/commonsguy/cwac-saferoom to encrypt the relevant database.

I would like to browse the encrypted DB file. I'm using DB Browser for SQLite 3.11.2 on Windows (the SQLCipher version of it) to try and browse this file.

Here is the code that creates the DB:

val encryption = SafeHelperFactory(charArrayOf('f', 'o', 'o'))

db = Room.databaseBuilder(
        Util.application!!,
        AppDatabase::class.java,
        "AppDatabase"
)
        .openHelperFactory(encryption)
        .build()

When I copy this file from the Android file system to the Windows file system, and attempt to open it with the DB browser, it asks me for a password and for the encryption settings.

I'm entering "foo" as the password, since that's the password that I encrypted it with. I'm leaving the encryption settings on "SQLCipher 4 defaults", since that's apparently what the latest version of CWAC-SafeRoom uses. Still, it just keeps asking me for the password again.

How do I open this file using the DB browser?

MikeT
  • 51,415
  • 16
  • 49
  • 68
Andrew Koster
  • 1,550
  • 1
  • 21
  • 31
  • Have you read [Encrypted Databases](https://github.com/sqlitebrowser/sqlitebrowser/wiki/Encrypted-Databases), perhaps the raw key mode as per [What are "Raw keys"?](https://github.com/sqlitebrowser/sqlitebrowser/wiki/Encrypted-Databases#what-are-raw-keys) – MikeT Sep 27 '19 at 22:07
  • I read that just now. Does Room/CWAC-SafeRoom use raw keys, or passphrases? I tried entering the key as a "raw key", but I can't copy and paste into that field, and I can't even see what I'm typing, and it only lets me type "f" but not "oo" (presumably because it's expecting a hex value). I have no idea what the algorithm is for translating my plaintext key into whatever hex format it's expecting. – Andrew Koster Sep 27 '19 at 22:34
  • It's really confusing to me that this isn't a completely normal thing to do. I would expect it to be documented somewhere, somewhere obvious even. It's weird that it's so easy to set the password in code, but so hard to enter it through the UI. – Andrew Koster Sep 27 '19 at 22:35
  • [sqlitebrowser](https://github.com/sqlitebrowser/sqlitebrowser) could also be at fault. too bad one cannot ping people on here. – Martin Zeitler Sep 28 '19 at 02:40
  • "Does Room/CWAC-SafeRoom use raw keys, or passphrases?" -- passphrases. IIRC, when I opened a SafeRoom database in SQLiteBrowser for macOS, I followed the same steps that you did. You might consider trying [this app and this database](https://github.com/commonsguy/cwac-saferoom/issues/58#issuecomment-504006040), ones that I successfully opened in SQLiteBrowser for macOS. – CommonsWare Sep 28 '19 at 11:08
  • Your sample DB works for me, I can open it with the passphrase `1234`. Thanks, @CommonsWare, I'll keep looking into this. – Andrew Koster Sep 29 '19 at 19:31
  • @AndrewKoster: I can't rule out that there is somehow a problem here, but without clear steps to reproduce the symptoms, I'm left with `¯\_(ツ)_/¯`. – CommonsWare Sep 29 '19 at 19:33

0 Answers0