Protect content in the Documents folder

Can someone help me make the contents of the document directory safe?

+6
source share
5 answers

Using:

- (BOOL)writeToFile:(NSString *)path options:(NSDataWritingOptions)mask error:(NSError **)errorPtr 

with one of the file protection options:

 NSDataWritingFileProtectionComplete (iOS 4.0) NSDataWritingFileProtectionCompleteUnlessOpen (iOS 5.0) NSDataWritingFileProtectionCompleteUntilFirstUserAuthentication (iOS 5.0) 

See: Apple Documentation

 NSDataWritingFileProtectionComplete 

In this case, the file is stored in an encrypted format and can only be read or written when the device is unlocked. The rest of the time, attempts to read and write the file will fail.

Note. Performing your own encryption raises the key storage problem, and using Keychain is the best answer. Key handling is the biggest problem, and NSData methods handle it.

+8
source

We cannot protect the file in the document directory. We can save the file in the temp folder of the device. Access to it is impossible

+1
source

use encryption and decryption to create and read these files on iphone, take the idea here http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html

0
source

Alan Quatermain provides a toolkit that has some useful wrappers around cryptographic libraries to make encryption / decryption very simple.

Here is the link:

AlanQuatermain / aqtoolkit

No matter what you do, just make sure that you do not store the document on the device unencrypted even for a short time. Always store it in encrypted form. Perform any encryption operation in memory.

Make sure for any file operations that you do not cache. So, for example, with any download, etc. You want to make sure that no data is temporarily written to the disk.

Finally, for your encrypted documents, do not store the key on the device in any format. Do not store it in a keychain.

0
source

Try encrypting the contents. look Strong encryption for Cocoa / Cocoa Click

-1
source

Source: https://habr.com/ru/post/897612/


All Articles