I started to play a bit with the new features of SQLCipher 4. Using the new pragma cipher_plaintext_header_size, I stumbled over a problem which seems to be related to the key salt.
I opened a new, empty database, then issued
Then I created a table and entered a few values for testing purposes. Thereafter I closed and reopened the database connection, and entered again the 2 above pragma commands. However, on trying to access the test data I got the error message SQL logic error.
I started again from scratch, but now I used
to retrieve the key salt. I saved the key salt in my editor. I closed and reopened the database connection, but now I entered the following pragma commands:
PRAGMA cipher_salt=“x’saved key salt value’”;
This allowed me then to access the test data.
Obviously the key salt is not saved somewhere in the database, if one uses the pragma cipher_plaintext_header_size. Is this on purpose? If yes, it should be documented that one has to retrieve the key salt generated when creating the database, or that alternatively one has to generate the key salt and to set it explicitly manually on creating the database. Otherwise one ends up easily with an encrypted, but inaccessible database.