Skip to Content
Platform.Ontology

File data protection classes

Files are encrypted at rest, and whether an app can read them while the phone is locked depends on a protection class.

Works without askingFiles and storageStorage securityAndroid and iPhoneIn the background

In one line

Can keep files locked until you unlock the phone, depending on how they are protected

Files are encrypted at rest, and whether an app can read them while the phone is locked depends on a protection class.

iOS has four data protection classes; Android has credential encrypted and device encrypted storage. This decides if background work can run before the first unlock.

What it can and can't do

What the user does: Nothing. You unlock your phone as usual

It can

  • Encrypt files at rest on Android and iPhone
  • Keep files unavailable until your first unlock after a restart on iPhone
  • Keep some files in device protected storage on Android for use before unlock
  • Run background tasks on iPhone after restart only with the lower protection class

It cannot

  • Open locked files from a boot task before you unlock, on Android credential storage
  • Skip protection by default on iPhone; the default is until first user authentication
  • Share locked files with other apps
  • Run iPhone background tasks on the strictest protected files after a reboot

How it differs between platforms: iPhone uses protection classes. Android uses device protected and credential protected storage.

On Android and iPhone

AndroidiPhone
StatusSupportedSupported
First versionAndroid 7.0 (API 24)iOS 4.0
Permission or entitlementNone (direct boot aware components)None
Protection levelnonenone
How access is grantednonenone
What the user seesNoneNone
How long it lastsDevice encrypted storage available at boot; credential encrypted storage only after first unlockClass A complete: locked unreadable; B complete unless open; C until first auth (default); D none
How to take it backn/an/a
Store policyNone listedNone listed
APIContext.createDeviceProtectedStorageContext(), isUserUnlocked()FileProtectionType, kSecAttrAccessible
NotesBoot receivers before unlock see only device protected storageDefault class is until first user authentication (C); background tasks after a reboot need C or lower

Data you get

What comes back: Protection class
Shape: enum
How often: Per file

FieldTypeUnitRangePrecision
classenumNonecomplete, completeUnlessOpen, untilFirstUserAuthentication, noneNot listed

Technical limits

  • Background tasks after reboot are limited by class

The story

What it is

Decides whether an app's files can be opened while the phone is locked.

For you

Your files are scrambled so that someone who steals your locked phone cannot read them. You may notice that some apps cannot sync until you unlock your phone after a restart.

For makers

Makers pick how strongly each file is protected. Strong protection keeps data safe but stops background work while locked, so they choose per file based on need.

Where you see it

TypeExampleApps
messagingA chat app protects stored messages so they cannot be read from a locked phone.None named
bankingA bank app keeps tokens locked until you unlock the phone.None named
healthA health app keeps heart data under strict protection while the phone is locked.None named
mediaA podcast app downloads new episodes in the background and needs a weaker protection class for that.None named
fitnessA workout app must save a run even when the screen locks, so it uses a class that works while locked.None named
smart-homeA home app lets a doorbell alert open before first unlock using only non sensitive data.None named
securityA forensic tool fails to read files from a locked phone because of these classes.None named

Risks

  • Background work may stop
  • Weak classes expose data

Android and iPhone in short

  • Android: Uses credential encrypted and device encrypted storage with direct boot.
  • iPhone: Four classes tied to the passcode, from complete protection to none.

What the platform says

  • Apple: Data Protection. Pitch: files are encrypted with keys tied to your passcode, and some can only be opened when the phone is unlocked.

Good uses and abuse

Legitimate uses

  • Protect sensitive files

Known abuse

  • None

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility3 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2010-06, iPhone iOS 4: Data protection classes introduced
  • 2016-08, Android 7.0 (API 24): File based encryption and Direct Boot introduced

Sources

How well checked: Based on official documentation.

On this page