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.
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
| Android | iPhone | |
|---|---|---|
| Status | Supported | Supported |
| First version | Android 7.0 (API 24) | iOS 4.0 |
| Permission or entitlement | None (direct boot aware components) | None |
| Protection level | none | none |
| How access is granted | none | none |
| What the user sees | None | None |
| How long it lasts | Device encrypted storage available at boot; credential encrypted storage only after first unlock | Class A complete: locked unreadable; B complete unless open; C until first auth (default); D none |
| How to take it back | n/a | n/a |
| Store policy | None listed | None listed |
| API | Context.createDeviceProtectedStorageContext(), isUserUnlocked() | FileProtectionType, kSecAttrAccessible |
| Notes | Boot receivers before unlock see only device protected storage | Default 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
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
class | enum | None | complete, completeUnlessOpen, untilFirstUserAuthentication, none | Not 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
| Type | Example | Apps |
|---|---|---|
| messaging | A chat app protects stored messages so they cannot be read from a locked phone. | None named |
| banking | A bank app keeps tokens locked until you unlock the phone. | None named |
| health | A health app keeps heart data under strict protection while the phone is locked. | None named |
| media | A podcast app downloads new episodes in the background and needs a weaker protection class for that. | None named |
| fitness | A workout app must save a run even when the screen locks, so it uses a class that works while locked. | None named |
| smart-home | A home app lets a doorbell alert open before first unlock using only non sensitive data. | None named |
| security | A 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
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 3 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough 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
Related capabilities
Related
- Run at startup. Can start itself in the background after your Android phone restarts
- Scoped storage and shared files. Can open its own folder and shared media only, not everyone's files, on Android
Sources
How well checked: Based on official documentation.