IOS Static lib decryption problem with traditional encrypted databases

93 views
Skip to first unread message

urbanios

unread,
Apr 26, 2013, 2:24:45 AM4/26/13
to sqlc...@googlegroups.com
Hello there,
I use sqlcipher since years on IOS,OSX and Windows, for the IOS I bought now the static library, to speed up builds and simplify the project. Works like a charm, but...

Now on IOS I can't open the Databases produced with Windows/OSX, nor with my old IOS project, I get error 26. I use a hex key for encryption.

What I tried so far:
Setting the key with: PRAGMA key = "x'f56...., PRAGMA key = 'f56.... and also sqlite3_key, without any luck

I set the following CFLags:
-DNS_BLOCK_ASSERTIONS=1 
-DSQLITE_HAS_CODEC 

and after some websearch I also tried this ones without any luck:
-DCIPHER_VERSION=2.0.6
-DSQLITE_TEMP_STORE=2

My product produces the databases on Windows/OSX from a desktop software and copies it on the iPad and sync it.

Any help or hint will be appreciated

Thanks in advance urban



Stephen Lombardo

unread,
Apr 26, 2013, 8:48:44 AM4/26/13
to sqlc...@googlegroups.com
Hi Urban,

Since it sound like you've been using SQLCipher for quite a while, it's very possible that your existing databases were created using SQLCipher 1.1.x, while your new iOS app with the static library is using the newer SQLCipher 2. By default version 1 and 2 have slightly different and incompatible database formats, with the latter adding a MAC.

You can check if this is the case by calling "PRAGMA cipher_use_hmac = OFF;" after opening the database on SQLCipher 2, before any queries. This will cause the SQLCipher 2.0 library to open a 1.1.x database with HMAC disabled, so it will be interoperable with the older version of SQLCipher you're using on the other platforms.

If that resolves the issue, you could continue to use it that way without issues. If you'd like to improve security across all your apps, you could consider upgrading the other platforms to SQLCipher 2. It's a bit more involved, but we provide a convenience function called sqlcipher_export() to make it easier to ATTACH and copy your data from an older database format to a new one. There are some good examples here:


Please let us know if that works for you. Thanks!

Cheers,
Stephen




--
 
---
You received this message because you are subscribed to the Google Groups "SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

urbanios

unread,
Apr 27, 2013, 4:38:47 AM4/27/13
to sqlc...@googlegroups.com
Hi Stephen,
thank you, that did the trick. I do update the chipher from time to time, but must have missed a Version 2 :-)

this is solved.

regards urban
Reply all
Reply to author
Forward
0 new messages