Charlesmchen/unencrypted headers#439
Conversation
| * You must use the 'YapDatabase/SQLCipher' subspec | ||
| * in your Podfile for this option to take effect. | ||
| * | ||
| * cipherUnencryptedHeaderLength will be ignored if you don't also set cipherKeyBlock and cipherSaltBlock. |
There was a problem hiding this comment.
I wrote a little essay.
|
Should this also be automatically handling the migration, or including a utility function? |
|
@chrisballinger Great question. We've got a utility class to handle the migration. |
|
I'm going to close this PR and re-open it with a few modifications. |
|
See: signalapp#1 |
|
Wow, great work on this ! I'm going to use it to convert the database in one of my apps very soon. |
|
Oh, quick question (since I know I'll get an email from the legal departments of various companies about it shortly after releasing the next version). There's a copyright at the top of YapDatabaseCryptoUtils. Are you cool with integrating this into the YapDatabase project, and having the code fall under the project license (2-clause BSD) ? |
|
@robbiehanson Hi - thanks for merging this. This PR was closed because I realized that the work wasn't "finished" - I plan/planned to make some additional refinements.
Anyhow, I will hopefully eventually find the time to open a follow-up PR with some of these refinements and improved documentation, etc. |
A more elegant solution may be to make use of the /**
* This notification is posted when a YapDatabase instance is deallocated,
* and has thus closed all references to the underlying sqlite files.
*
* If you intend to delete the sqlite file(s) from disk,
* it's recommended you use this notification as a hook to do so.
*
* More info:
* The YapDatabase class itself is just a retainer for the filepath, blocks, config, etc.
* And YapDatabaseConnection(s) open a sqlite connection to the database file,
* and rely on the blocks & config in the parent YapDatabase class.
* Thus a YapDatabaseConnection instance purposely retains the YapDatabase instance.
* This means that in order to fully close all references to the underlying sqlite file(s),
* you need to deallocate YapDatabase and all associated YapDatabaseConnections.
* While this may be simple in concept, it's generally difficult to know exactly when all
* the instances have been deallocated. Especially when there may be a bunch of asynchronous operations going.
*
* Therefore the best approach is to do the following:
* - destroy your YapDatabase instance (set it to nil)
* - destroy all YapDatabaseConnection instances
* - wait for YapDatabaseClosedNotification
* - use notification as hook to delete all associated sqlite files from disk
*
* The userInfo dictionary will look like this:
* @{
* YapDatabasePathKey : <NSString of full filePath to db.sqlite file>,
* YapDatabasePathWalKey : <NSString of full filePath to db.sqlite-wal file>,
* YapDatabasePathShmKey : <NSString of full filePath to db.sqlite-shm file>,
* }
*
* This notification is always posted to the main thread.
**/
extern NSString *const YapDatabaseClosedNotification;
extern NSString *const YapDatabasePathKey;
extern NSString *const YapDatabasePathWalKey;
extern NSString *const YapDatabasePathShmKey; |
PTAL @michaelkirk
NOTE: The current approach supplies the database password and key separately. We could supply a database "key spec" instead, but I'm not sure this is a perf hotspot.