7

Question

How can I ensure data is encrypted when using NSData.writeToFile:options:error: with the NSDataWritingFileProtectionComplete?

Background research: Enabling data encyption

According to Apple documentation:

Data protection is available on most iOS devices and is subject to the following requirements:

  • The file system on the user’s device must support data protection. This is true for newer devices, but for some earlier devices, the user might have to reformat the device’s disk and restore any content from a backup.

  • The user must have an active passcode lock set for the device.

https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AdvancedAppTricks/AdvancedAppTricks.html#//apple_ref/doc/uid/TP40007072-CH7-SW11

The requirements state that user must activate passcode lock for the device, this is reinforced by the following end user documentation:

Enable data protection by configuring a passcode for your device:

  1. Tap Settings > General > Passcode.
  2. Follow the prompts to create a passcode.
  3. After the passcode is set, scroll down to the bottom of the screen and verify that the text "Data protection is enabled" is visible.

Passcode lock screen

http://support.apple.com/kb/HT4175

Similar SO Questions:

How can I find out if the iPhone user currently has a passcode set and encryption enabled? seems like the answer to this question is no longer valid.

4

1 回答 1

1

The requirements state that user must activate passcode lock for the device, this is reinforced by the following end user documentation.

If user doesn't have any passcode enabled the encryption would be useless. The unwanted user can use the app directly then anyway.


A solution for your problem would be to manually implement encryption for app data and use a app specific password which you ask the user on every app launch.

I've seen that system at an online banking software for iOS, but I wouldn't recommend that system since it is very annoying for the user.

于 2014-02-08T17:38:28.690 回答