sqlite-jdbc-crypt icon indicating copy to clipboard operation
sqlite-jdbc-crypt copied to clipboard

Doesn't open SQLCİpherV4 db files

Open aliyildiz1980 opened this issue 4 years ago • 6 comments

DB files encrypted with SqlCipher V3 can be opened successfully. However, V4 encrpyted files can not be opened. The following error is produced: File opened that is not a database file (file is not a database)

SQLiteMCSqlCipherConfig.getV3Defaults().withKey(Constants.DB_CIPHER).createConnection(url) opens V3 db files. SQLiteMCSqlCipherConfig.getV4Defaults().withKey(Constants.DB_CIPHER).createConnection(url) doesn't open V4 db files.

aliyildiz1980 avatar Oct 26 '21 17:10 aliyildiz1980

DB files are created with SQLite DB Browser compiled with SqlCipher support.

aliyildiz1980 avatar Oct 26 '21 17:10 aliyildiz1980

Which version did you use? In march a bug was fixed regarding V4 defaults. Maybe you used an older version?

Chris-SP365 avatar Oct 27 '21 06:10 Chris-SP365

I used both the latest version in maven, which 3.35.5.3 and latest release in github, which 3.36.0.

aliyildiz1980 avatar Oct 27 '21 06:10 aliyildiz1980

I'll be assuming version is 3.36.0 or 3.35.5.3

Last year, I reported an issue to the maintainer of SQLiteMc for something related to sqli cipher v4. We discovered that the configuration was not applied correctly and that the legacy parameters was important and must be the first. I looked into ou code and it seams that we might have the wrong order of parameters. But as it should all be defaults this shouldn't have any effect...

For testing purposes, you can try to open the database using parameters in the URL: file://mydbfile.db?cipher=sqlcipher&legacy=4&key=myKey

Willena avatar Oct 27 '21 06:10 Willena

Unfortunately, it doesn't work. Further, I tried with all versions down to v3.33.0. Only v3.33.0 opened the db. Even v3.33.0.1 didn't open. Hwoever, problem with v3.33.0 is that it is not possible to attach another unencrypted db file with the following sql command: <<ATTACH DATABASE user.db AS user KEY ''>>

aliyildiz1980 avatar Oct 27 '21 07:10 aliyildiz1980

This sql command works with SQLCipher Android driver provided the developer company. So I assumed the same would work. Is this a bug or is sql command to attach unencrypted dbs wrong?

aliyildiz1980 avatar Oct 27 '21 12:10 aliyildiz1980