iOS Security: How Apple Protects Data on iOS Devices – Part 1

Apple has invested a lot of resources into making the iPhone and iPad secure. Here I discuss some of the techniques that Apple uses to secure information stored on iOS devices.

Guiding principles

In an effort to provide a system that is both secure and easy to use Apple follows these principles.

  • Hide complexity from user
  • Send and receive the minimum required information about users
  • If possible make data hard to decrypt by 3rd parties including themself

Apple takes security seriously

Apple uses state of the art cryptography to make sure that data is safe from malicious users. The following are just of some the features used:

  • Symmetric Encryption
  • Asymmetric (Public Key) Encryption
  • Key Wrapping
  • Cryptographic Hashing
  • Digital Signatures
  • Digital Certificates
  • Effaceable Storage

Before going into the iOS specific features it’s important to go over the fundamental security technology used.

Apple uses tried and true cryptographic techniques to keep your data safe.  In this section we’ll go over some of those techniques. Encryption is the conversion of electronic data into another form, called ciphertext, which cannot be easily understood by anyone except authorized parties. Most of the techniques that Apple uses address encrypting and decrypting of data.

Symmetric encryption

Symmetric key encryption describes a class of algorithms that encrypts and decrypts data using a passphrase or number called the key. Symmetric-key encryption uses the same key to encrypt plaintext and decrypt the ciphertext.  This key is also referred to as the shared secret. Since both parties need to have access to the secret key, an issue with symmetric encryption is how transmit the key without it being intercepted.

Asymmetric key encryption

Also known as public-key cryptography, assymmetric key encryption describes a class of algorithms using a a public and private key pair, to encrypt and decrypt. The public key can be used to decrypt data that was encrypted by the private key, and vice-versa.

This solves the key transmission problem with symmetric encryption because the private is never transmitted, only the public key.  Once someone has the public key they can be sent data that has been encrypted using the private key.  One disadvantage of asymmetric encryption algorithms is that they are much slower than symmetric encryption algorithm. Often both symmetric and asymmetric algorithms are used together to compensate for their weaknesses.

The Diffie-Hellman key exchange method is a good example of using symmetric and asymmetric keys together.  When two parties open a secure communication channel they start off using Public key encryption only long enough to agree upon a symmetric session (ephemeral) key, which will be used to encrypt further communication.  Since the communication is encrypted with an ephemeral key, disclosure of the private asymmetric key will not allow decrypting of old messages.

Cryptographic hashes

A cryptographic hash is a number created from a message that is practically impossible to reverse engineer back into the original message.  They are commonly used for password validation, evidence tampering (or lack thereof), and message signing. A cryptographic hash function may generate the same hash value (collision) for different messages; it’s practically impossible to create a message that hashes to a specific number.  SHA-1 and SHA-2 are very popular hash functions.  These hashes are often used to create a fingerprint for a document.

Digital signatures

Digital signatures are used to validate the authenticity of a digital message, ensuring that it was created by a known sender, and to ensure that the sender cannot deny sending the message (non-repudiation). Here’s an example of howdigital signatures work:

  • Party A wants to send a message to Party B
  • Party B wants to be sure the message is from Party A
  • Party B already has Party A’s public key
  • Party A creates a message and calculates it’s SHA-2 hash to create a message digest.
  • Party A signs the message by attaching the SHA-2 hash of the message encrypted with his private key, then sends it to Party B
  • When Party B receives the message he decrypts the message digest with Party A’s public key to get the SHA-2 hash.
  • Party B calculates the SHA-2 hash and compares it to the hash in the message digest.
  • If the calculated SHA-2 hash matches the one from the message digest then Party B can be assured that the message came from Party A and was not altered.

Digital certificates

Digital Certificates are documents used to show ownership of a public key. They contain information about the public key’s owner like their name, organization name, email, physical address, public key, etc.  The certificate is typically signed by a certificate authority that vouches for that the owner of the public key is who they say they are.  Certificates can also be signed by the public key owner, in this case they are called self signed certificates.

Key wrapping

Key wrapping is a technique for encrypting cryptographic keys.  This technique is used heavily by Apple to allow multiple layers for encryption. It is often use with encrypted file systems where the storage device can be stolen.  The key for the file system is encrypted (wrapped) with an ephemeral key that  is never stored on disk.  In iOS this ephemeral key is created with a combination of the UID and the passcode and stored in RAM.

Effaceable Storage

The storage system on iOS devices uses a type of flash memory, which have a lifetime defined by maximum number of write cycles . The circuitry for these drives use a technique called wear leveling to prolong the life of the storage system.  Wear leveling spreads writes over the entire drive to distribute wear evenly across the device, this makes it harder to erase blocks of data.  When wear leveling is used, a logical block of data is written to two different physical blocks, which can leave traces of old data in random blocks on the device over time. iOS has a region of storage called effaceable storage that bypasses wear leveling so that data can be erased completely without any traces left in random storage blocks. iOS devices store encryption keys in this region.

Secure enclave

The Secure Enclave is a co-processor on Apple’s A7 and A8 CPUs that stores ephemeral keys and processes Touch ID image data. Touch ID is an iOS 8 feature that lets users sign into 3rd party apps by fingerprint scan. The keys and fingerprint data are stored in the Secure Enclave and not directly accessible by the rest of the system.  The system can ask the Secure Enclave to decrypt something but it never sees the actual key.

The keys to the kingdom

Devices running iOS use a collection of keys to protect and validate information: stored, transmitted, and received.  They are the unique identifier (UID), group ID (GID), Apple Root Public Key, and class keys.

Device specific ID’s

Each iOS device has a UID and a GID, which are AES-256 bit keys. The UID is specific to the device, the GID is based on the product family.  These keys are kept in the Secure Enclave and are not known by anyone, even Apple. iOS uses these ID’s to encrypt data in a manner specific to the device.

Apple’s Public Key

The boot ROM contains Apple Root CA public key so it can verify information sent from Apple. Software downloaded from Apple is signed with their private key and the signature can be verified using their public key.

Data Protection Classes

Classes are used to indicate when data from the file system and keychain are accessible. There is an encryption key associated with each class. These keys along with the device passcode allow data to be encrypted in a way that is specific to each device.

In a follow to this post I will discuss how Apple:

  • validates the device software
  • Application isolation
  • protects data while it’s on the device
  • uses the Keychain

and more. Check out this reading list for more information on some of the topics I’ve discussed here:

Please share your thoughts on iOS security measures in the comments section below.


  1. acersupportt says:

    The integrated and secure software and hardware that are the platform for iPhone, iPad, and iPod touch. Encryption and data protection: The architecture and design that protects user data if the device is lost or stolen, or if an unauthorized person attempts to use or modify it.

Leave a Comment