You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On c19c72f I cannot perform any operation on encrypted databases. As soon as PRAGMA key = 'some_key'; is executed, then next SQL operation fails with "Error: SQL logic error or missing database". This error also occurs after performing an ATTACH with a KEY specified.
I am on OSX 10.8.2. I used Xcode 4.6 (with the repo provided project) to generate an amalgamation. I then used the CMakeLists.txt file below to compile shell.c and sqlite3.c, and linked it with the OS provide libcrypto from OpenSSL.
I've built SQLCipher using CMake exactly as you've described. I've verified both the standard operations on a single encrypted database and the use of an attached database with sqlcipher_export(). Everything works without issues.
That said, we've seen similar errors to what you described in the past due to mismatched OpenSSL headers. For instance, if you include OpenSSL headers for one version but then another version is dynamically loaded at runtime you can see this behavior. Can you please make sure that you don't have any OpenSSL headers in the include path other than the ones in /usr/include/openssl?
Thanks! That was the problem (MacPorts headers with system .dylib).
One more question. I'm going to have some people using the database files through the shell, and this came up:
Is this the correct behavior?
$ ./sqlite3 encrypted.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from blah;
Error: file is encrypted or is not a database
sqlite> PRAGMA key = 'testkey';
sqlite> select * from blah;
Error: file is encrypted or is not a database
It works correctly if "PRAGMA key ..." is first, but if not, then it doesn't attempt to try to use the database again after a correct "PRAGMA key ..." is given. Is it a requirement that the database be detached and reattached if the user forgot to give the key at first, or is this a bug?
Yes, it is a requirement to provide the key (and any other sqlcipher pragmas) as the first operation. Automatically re-initializing the database after it is used, e.g. supplying a key after an operation has already failed, is fairly complex, and not possible at this time. We may try to improve this at some point in the future, but for now please provide the key first. Thanks!
Activity
sjlombardo commentedon Mar 13, 2013
I've built SQLCipher using CMake exactly as you've described. I've verified both the standard operations on a single encrypted database and the use of an attached database with sqlcipher_export(). Everything works without issues.
That said, we've seen similar errors to what you described in the past due to mismatched OpenSSL headers. For instance, if you include OpenSSL headers for one version but then another version is dynamically loaded at runtime you can see this behavior. Can you please make sure that you don't have any OpenSSL headers in the include path other than the ones in /usr/include/openssl?
Type1J commentedon Mar 13, 2013
Thanks! That was the problem (MacPorts headers with system .dylib).
One more question. I'm going to have some people using the database files through the shell, and this came up:
Is this the correct behavior?
$ ./sqlite3 encrypted.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from blah;
Error: file is encrypted or is not a database
sqlite> PRAGMA key = 'testkey';
sqlite> select * from blah;
Error: file is encrypted or is not a database
It works correctly if "PRAGMA key ..." is first, but if not, then it doesn't attempt to try to use the database again after a correct "PRAGMA key ..." is given. Is it a requirement that the database be detached and reattached if the user forgot to give the key at first, or is this a bug?
By the way, thanks for making SQLCipher!
sjlombardo commentedon Mar 14, 2013
Yes, it is a requirement to provide the key (and any other sqlcipher pragmas) as the first operation. Automatically re-initializing the database after it is used, e.g. supplying a key after an operation has already failed, is fairly complex, and not possible at this time. We may try to improve this at some point in the future, but for now please provide the key first. Thanks!