Wipe Secure Cell key copy on deallocation #612
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Secure Cell currently makes a copy of the master key it was given. Since Objective-C is fairly low level and exposes the
key
property, it makes sense to wipe the sensitive key from memory when it can no longer be used by Secure Cell.Do so by changing the underlying property type to NSMutableData and calling the wiping code in
dealloc
of TSCell.While we're here, improve API docs of the basic Secure Cell class that actually stores the key.
Note that in Objective-C the
key
property returns NSData which respects retain-release mechanics so the users get a reference to the same data object as used by Secure Cell. However, in Swift NSData is bridged into Data type which has value semantics and effectively copies our copy of the key. We obviously cannot and should not wipe the copies we are not aware of, so this is a best effort approach.Checklist
Benchmark results are attached(somewhat interesting, but hopefully irrelevant)