← Back to Recovery methods

iPhone Data Protection and Secure Enclave Recovery

Modern iPhone recovery depends on whether the key hierarchy that turns encrypted files back into plaintext can still be used — on the original device, in a suitable lock state, with the owner’s credential — or whether an independent copy such as a backup already holds what is needed. Raw NAND access alone is not equivalent to data access.

In short
  • Each file has its own key, wrapped by a class key tied to the device UID and sometimes the passcode.
  • “After first unlock” is not full access: Class A keys are discarded on lock; Class B depends on open files.
  • Class D “No Protection” is still encrypted on iPhone: its key is UID-protected and removed by an erase, not plaintext NAND.
  • An encrypted computer backup uses the backup password, not the passcode, and is not device-bound, except for non-migratory Keychain items.
  • Record model, iOS version and state without testing them; an existing authorized backup can outweigh raw acquisition, if checked.
Diagram of the Secure Enclave and keybag combining a hardware-bound device secret and the user's passcode to manage protection-class keys whose availability depends on the device's boot and unlock state.
Acquiring encrypted storage is not the same as acquiring usable decryption state — which protection class a file belongs to determines when its class key is available, for example at boot, after first unlock, or only while the relevant protection state is unlocked.

Files are encrypted per-file, not with one device-wide key

Apple’s Data Protection creates a per-file encryption key for each file, and APFS can go a step further with per-extent keys. That granularity is deliberate: it’s what lets the system apply different protection rules to different files rather than treating the whole disk as one all-or-nothing encrypted blob.

Apple describes the chain in layers: the per-file (or per-extent) key is wrapped with a class key, the wrapped key is stored in the file’s metadata, and that metadata is in turn encrypted with a file system key that is itself wrapped by an effaceable key designed to be erased quickly (Data Protection in Apple devices). An intact wrapped key is still useless without the class key that protects it.

Class keys decide when a file can be read

The app that creates a file assigns its Data Protection class, and the class decides when the key is usable. For recovery, what matters is what each class means for a device in a given state:

Scroll horizontally to see the full table →

Apple’s documented behavior of the four Data Protection classes on iPhone and iPad, and what it means for recovery.
ClassWhen the key is usableRecovery consequence
A — Complete ProtectionClass key derived from the passcode and the UID; the decrypted key is discarded shortly after the device locksReadable only while the device is unlocked; a locked device, even after first unlock, does not expose it
B — Protected Unless OpenFiles can be created and written while locked, using key agreement; a file’s per-file key is wiped from memory when the file is closed, and reopening needs the class private keyA file being written while locked does not show that other Class B files can be read in the same state
C — Protected Until First User AuthenticationLike Class A, but the decrypted class key stays in memory when the device locks; the default for third-party app data not otherwise assignedMuch ordinary app data falls here, which is why the first unlock matters; a restart returns it to the locked state
D — No ProtectionClass key protected only by the UID and kept in Effaceable Storage; Apple uses it mainly to allow fast remote wipeStill encrypted on the NAND and tied to the original device; not readable as plaintext from a chip, and removed by an erase

Apple’s Mac-specific notes on the same page (a volume key, no Class D on Apple silicon) do not describe iPhone. And because the classes reach their keys by different routes, “the Secure Enclave decrypts everything once unlocked” is not an accurate model of what is reachable.

The hardware UID and the Secure Enclave

Apple describes the Secure Enclave as a dedicated secure subsystem integrated into Apple SoCs and isolated from the main processor. Its UID is a root key fused into the SoC at manufacturing, not accessible to Apple or its suppliers, and it lets data be cryptographically tied to a particular device; Apple states that if internal storage is physically moved to another device, the files are inaccessible (The Secure Enclave).

A damaged logic board therefore does not by itself mean the key hierarchy is gone: if the SoC and storage survive, repairing the original board for an authorized export keeps that dependency. Replacing the board does not carry it over. Mobile Device Recovery State and Board-Level Preservation covers why the original board usually matters.

Different keybags, different dependencies

Apple’s keybags hold wrapped class keys, and each type exists for a different purpose with different protection (Keybags for Data Protection):

  • User and device keybags. On a single-user iPhone or iPad these are the same keybag, protected by the passcode and managed by the Secure Enclave. This is the bag bound to the device.
  • Backup keybag. Created with an encrypted Finder or iTunes backup. Data is re-encrypted to new keys protected by the backup password, with no tie to a specific device — except non-migratory Keychain items, which stay UID-wrapped and restore only to the original device. Without a backup password, files are not encrypted, and the Keychain stays UID-protected and does not migrate.
  • Escrow keybag. Lets a previously connected computer or a device management service back up without the passcode each time; it is split between device and host, and after a restart the passcode is needed before the first backup.
  • iCloud Backup keybag. Serves iCloud Backup, with asymmetric class keys; it should not be assumed to share the dependencies of either of the others.

A keybag is metadata about the key hierarchy, not a way around it, and the device keybag’s hardware binding does not extend to every copy. The backup password and the passcode are different credentials. A backup is not a clone of the current device either: it holds what that backup type included when it was made.

Keychain is a separate availability system

Keychain items are stored in one SQLite database and encrypted with two different AES-256-GCM keys: a table key for metadata, protected by the Secure Enclave but cached in the Application Processor for fast queries, and a per-row key for the secret value, which always requires a round trip through the Secure Enclave. Items have their own accessibility classes, and “this device only” variants are UID-wrapped in backups and unusable on another device; items in the kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly class are not backed up at all (Keychain data protection).

A recovered Keychain database file is therefore not access to its secrets, and a restored backup can lack items that never migrate. Some apps also add their own encryption, with keys in Keychain or tied to an online account, so a file that decrypts at the Data Protection layer can still be unusable without the app’s key.

BFU, AFU and what to preserve

A phone that has booted but not yet been unlocked (BFU) and the same phone after the user has entered the passcode once since boot (AFU) are in different cryptographic states. AFU is not a promise of access: Class A closes again on lock, Class B depends on what is open, Keychain has its own classes, and an export still needs a legitimate path.

Preservation means recording that state, not testing it: the model, the iOS or iPadOS version if known, locked or unlocked, any known restart since the incident, and the legitimate access paths — the owner’s credential, a previously trusted computer, computer or iCloud backups, other synced devices. Don’t change any of them just to check. An existing authorized export or independent backup can be worth more than raw acquisition, because it already holds the data under credentials the owner controls.

Liquid, heat or a swollen battery change that order: whether such a device stays powered is for qualified handling to decide, not a universal “keep it on” or “switch it off” rule; the state table on the mobile preservation page records what each state puts at risk.

Automatic Restart can move a locked device back to BFU

Apple documents Automatic Restart in iOS 18.1, iPadOS 18.1 and later: if a device remains locked for a prolonged period, it restarts automatically, moving from AFU to BFU and purging sensitive security keys and transient data from memory. Apple says the mechanism uses the Secure Enclave to monitor unlock events, and gives no exact time. From iOS 18.4 and iPadOS 18.4, device management administrators can turn it on or off, and it is off by default on supervised devices.

A phone that is running is not evidence that its earlier unlock state survived — it may already have restarted, by this mechanism or another. Earlier versions should not be assumed to behave the same way. The mechanism is a reason to record the state promptly and plan an authorized export, not a timer to calculate or work around.

Forgotten passcode, failed board, damaged data and erase are different problems

  • Forgotten passcode. The hardware and key hierarchy are intact; the credential is missing. Apple ties the passcode to the UID, so it cannot be tested off the device (Passcodes and passwords). The realistic sources are independent copies: backups, iCloud data, other devices.
  • Failed board or access path. The key hierarchy may be intact, but the device cannot power, display or communicate; repairing the original board for an export keeps the dependency.
  • Damaged data. The keys work but a file system structure or an app database is damaged. That becomes a logical recovery problem on an exported copy, not a key problem.
  • Completed erase. Erase All Content and Settings or a remote wipe erases the effaceable key, which Apple states renders all files on that device cryptographically inaccessible. A reset is not a recovery step. What it destroys is the device’s own key material; whether a separate backup or cloud copy remains useful depends on that copy, not on the reset.
The one thing not to do

Don’t repeatedly guess a passcode. iOS imposes escalating delays after failed attempts, and with Erase Data turned on the device erases itself after 10 consecutive failures, or fewer if device management sets it. If the passcode is uncertain and the data matters, preserve the device’s current state and look for independent copies instead of testing guesses.

Checking what an export actually contains

A finished backup or export is an intermediate result. Check it against what was needed:

  • Needed datasets. The specific apps, conversations, date ranges and attachments, opened and checked — not a file count.
  • Decryptability on a copy. An encrypted backup opens with its backup password on a working copy, not only on the single original.
  • Export scope. Which method produced it (encrypted or unencrypted computer backup, iCloud, an app’s own export), and what that method covers.
  • What is not included. Non-migratory Keychain items, data an app keeps outside the backup or behind its own key, and content that exists only in a cloud service.

Photos that open do not show that the backup is complete, that app data is present, or that Keychain secrets came across. How to Validate Recovered Data covers what different checks can show, and the mobile preservation page what an export record should state.

Technical references: Apple Platform Security: Data Protection classes — key availability per class, Class B key agreement, Class D in Effaceable Storage · Apple Platform Security: Keybags for Data Protection — user/device, backup, escrow and iCloud Backup keybags · Apple Platform Security: Keychain data protection — item keys, accessibility classes, this-device-only items · Apple Platform Security: Protecting user data in the face of attack — Automatic Restart. Other Apple pages are cited inline; these describe Apple’s design for iPhone and iPad (some details only for A9 and later SoCs), Automatic Restart applies to iOS and iPadOS 18.1 and later, and Mac-specific behavior is not covered here.

Related: Android FBE, Keystore and Hardware-Bound Recovery · Mobile Device Recovery State and Board-Level Preservation · Mobile Device and Cloud Recovery Tools · Phone or Tablet Data Loss · LUKS Headers, Keyslots and Volume-Key Recovery