MobDojoStart learning free

iOS Internals · Locks & Encryption · Lesson 1 of 5

The Secure Enclave

Meet the vault inside your iPhone's chip that checks passcodes and guards keys.

11 min60 XPFree lab

A vault inside the chip

Inside the main chip of every recent iPhone sits a smaller, walled-off computer called the Secure Enclave. It's a separate processor with its own startup code, its own protected memory and its own encryption hardware. Apple built it so your most sensitive secrets stay safe even if the main processor, where iOS and your apps run, were ever taken over by an attacker.

Picture the main processor as a busy office and the Secure Enclave as a small vault room inside it. People in the office can pass a request through a slot in the door, such as "is this the right passcode?", and get a yes or no back. They can never walk in and read what's on the shelves.

Here's what the Secure Enclave handles:

The UID is the clever part. Your passcode is mixed with it to make the keys that protect your data. Apple calls this entangling the passcode with the UID. Because the UID never leaves the chip, Apple says your passcode can't be learned by sending guesses from anywhere other than that phone's own Secure Enclave.

So copying the storage chip onto a powerful computer doesn't help an attacker. Every guess has to go through that one phone, at the speed the phone allows. Apple tunes the key-making math so that each attempt takes about 80 milliseconds, even before any extra waiting is added. You'll see in the next task how that waiting grows.

Making guessing slow

A short passcode doesn't have that many combinations. A 6-digit passcode has a million. If a phone let someone try them as fast as possible, a patient attacker could get through a lot of them. So iOS adds a growing wait after wrong guesses, and Apple says the Secure Enclave enforces it, not iOS. That means a compromised iOS can't simply skip the wait.

Here's the delay Apple lists for the iPhone Lock Screen:

Two details make this harder to cheat. Typing the same wrong passcode again doesn't count as a new attempt, so a toddler hammering one number doesn't burn through your tries as fast. And restarting the phone during a delay doesn't cancel it. The timer starts over for that period.

Once an iPhone stops accepting guesses, the only way back in is to erase it. That's why a backup matters.

There's also an optional setting called Erase Data. You'll find it at the bottom of Settings, Face ID & Passcode (or Touch ID & Passcode). With it on, Apple says that after 10 wrong passcodes in a row, all content and settings are removed. Because everything on the phone is encrypted, erasing just means destroying the keys, which is fast and thorough.

Is Erase Data right for you? It's a strong choice if you worry about someone guessing your passcode. It's riskier if small children play with your phone, or if you don't have a recent backup. The delays alone already make guessing a 6-digit passcode take an extremely long time, and a longer passcode with letters helps even more.

Test yourself

Can you answer these?

  1. A thief copies the raw contents of a stolen iPhone's storage onto a fast computer, hoping to guess the passcode there much faster. Why doesn't this work?
  2. Your nephew has typed 8 different wrong passcodes on your iPhone and is waiting out the delay. If his next guess is also wrong, how many hours will the iPhone make him wait?

Answer them in the app to earn 60 XP.

Answer in the app