Search code examples
sqlitecore-datarealm

How big is the performance hit when using NSFileProtectionComplete with Core Data?


I am currently comparing multiple data persistence frameworks for iOS. One important requirement we got is the possibility to encrypt the data we are working with. When using Realm there is an option to use encryption with the consequence of a 10% performance hit as you can read here

When using Core Data there are basically 3 Ways to encrypt your Data

  • Using iOS-Level Data Protection
  • SQLCipher
  • Transformable decryption

I would prefer to encrypt the Data on iOS Data Protection Level using the NSFileProtectionComplete Option on the File Manager.

My Question is:

How big is the performance Impact when using iOS-Level encryption? Are there any Statistics out there or do you have experienced a major decrease in performance? It would be really interesting to here about your experiences.

Thanks in Advance!


Solution

  • How big is the performance Impact when using iOS-Level encryption?

    This would be a great thing to benchmark. Just like Realm's 10% overhead number, your mileage will vary based on the type of work you do, how many reads vs writes, the size of the database, the device's storage controller, etc.

    I suspect that Apple has gone to great lengths to minimize the overhead of NSFileProtection crypto and would be surprised if it came close to Realm's 10% number.

    More than numbers from micro-benchmarks, you should probably be more concerned with the features and limitations of each approach.

    For example, NSFileProtectionComplete won't let you access a file when the device is locked, whereas SQLCipher and Realm's encryption let you access it as long as you have the encryption key. Also, if you export the file out of iOS, NSFileProtection won't apply there, so if you need to export an encrypted file, you should use SQLCipher or Realm's encryption.