willzeng
willzeng

Reputation: 935

How does iOS store persistent data with encryption?

Can an iPhone app encrypt its stored data? So that even a user with a Jailbroken iOS device cannot access the file. For example, game-center may sync with local data, you do not want the user manipulating the scores. You do not want your IAP be circumvented either.

Is there a simple way to encrypt your data before writing to the device?

Maybe my questions are not very clear. Indeed they are:

  1. When I'm using things like: [array writeToFile:path atomically:YES]; is there any auto-encryption that ensures only my app can access the file correctly?

  2. If not, what is the simplest way to achieve it?

PS: now I found NSData can do the job, but the NSDataWritingFileProtectionComplete flag requires #if __IPHONE_4_0 <= __IPHONE_OS_VERSION_MAX_ALLOWED. I wonder what happens on not-supported devices?

Upvotes: 1

Views: 4201

Answers (2)

Rory Alsop
Rory Alsop

Reputation: 1439

More information on iOS encryption in @GrahamLee's answer to this question and on other iOS tagged questions on security.stackexchange.com.

Basic summary is - based on iPhone controls alone:

  • If someone has the device and it isn't locked, they can access all the data
  • If someone has the device and it is locked, they can get most of the data, and possibly all (some exceptions may apply)

You could obfuscate, and use encryption within your app when storing data, but an attacker could reverse engineer that encryption code to decrypt.

You need to work out the value of such DRM techniques and decide whether they are worthwhile in this scenario.

Upvotes: 2

Related Questions