Encryption & Hardware

Secure Enclaves and Trusted Execution Environments, Explained

May 12, 2026 8 min read Haven Team

When your phone encrypts a message, the private key used in that operation doesn't pass through ordinary application memory where malware or a compromised OS could read it. It lives — and stays — in a hardware-isolated execution environment designed to be opaque even to the operating system. Here's what that actually means.


Cryptographic keys are only as secure as the environment they're kept in. A private key stored in regular process memory is accessible to anything else that can read that memory — an exploited vulnerability in the app, a privileged OS process, or kernel-level malware. If the key can be exfiltrated, all the mathematics that make it secure become irrelevant.

Trusted Execution Environments (TEEs) solve this by carving out a hardware-enforced compartment where code and data can be processed in isolation from the main operating system. The isolation is enforced by the processor, not by software — which means that even a fully compromised OS cannot read what happens inside the TEE during normal operation.

The Key Variants: TEE, Secure Enclave, and TPM

These terms are related but refer to distinct architectures with different capabilities and threat models.

Technology Implementation Primary Use Can Run Arbitrary Code
ARM TrustZone TEE CPU architecture feature (all modern ARM SoCs) Isolated execution for trusted apps, DRM, biometrics Yes — runs a separate OS (OP-TEE, Kinibi, etc.)
Apple Secure Enclave Dedicated co-processor (iPhone 5s+, T2/M chips on Mac) Key storage, biometric auth, Face/Touch ID Limited — runs Apple-signed firmware only
Google Titan M Dedicated security chip (Pixel 3+) Verified boot, key storage, Strongbox Keymaster Limited — fixed-function with verified firmware
Intel SGX CPU instruction set extension (Intel Core, Xeon) Confidential computing, sealed storage Yes — runs enclaved user-space code
TPM 2.0 Separate chip or firmware (nearly all modern PCs) Platform attestation, disk encryption keys, measured boot No — fixed functionality only

How ARM TrustZone Works

ARM TrustZone divides the processor into two worlds: the Normal World, where the main OS (Android, Linux) runs, and the Secure World, which runs a separate trusted OS. The processor enforces this boundary in hardware — Normal World code cannot read Secure World memory or register state, and cannot directly call Secure World code except through defined entry points.

Transitions between worlds happen through a mechanism called the Secure Monitor Call (SMC). When your Android app needs to perform a biometric check, it calls through the OS into the Secure World, where the biometric matching happens in isolation. The result (pass/fail) comes back; the biometric template data never leaves the Secure World.

The Secure World runs its own operating system — OP-TEE is a common open-source implementation; OEM-specific implementations (ARM's Kinibi, Qualcomm's QTEE, MediaTek's MTEE) run on commercial devices. Trusted Applications (TAs) run within this secure OS and can be isolated from each other. Key material generated by a TA is accessible only to that TA; other TAs and the Normal World cannot read it.

Android Keystore and Hardware-Backed Keys

When an Android app creates a key with KeyPairGenerator using setIsStrongBoxBacked(true) or the system determines StrongBox is available, the key is generated and stored inside the secure hardware — either the Titan M chip (Pixel) or a TrustZone Trusted Application. The key material never appears in regular memory. Cryptographic operations (sign, decrypt) are sent to the secure element; the result comes back, but the key stays isolated. Apps that request hardware-backed keys get this protection transparently.

Apple's Secure Enclave

Apple's Secure Enclave Processor (SEP) is a separate ARM-based processor with its own boot ROM, encrypted memory, and dedicated AES engine. It's architecturally isolated from the Application Processor — the chip your apps run on. It first appeared in the iPhone 5s (2013) and is now present in all Apple devices including the M-series Macs via the T2 chip or integrated into the SoC.

The SEP is responsible for:

A critical property of the UID key: it's burned into the silicon at manufacturing, known only to the SEP, and cannot be exported or read by any software — including Apple's own. This is why Apple's Secure Enclave is a meaningful defense against forensic extraction even for well-resourced adversaries. Without the UID key, the data partition keys cannot be derived, regardless of how much computational power you bring to bear.

TPM: Platform Attestation and Disk Encryption

The Trusted Platform Module is narrower in scope than a full TEE. A TPM does not run arbitrary code; it provides a specific set of cryptographic functions:

This is how BitLocker (Windows) and LUKS (Linux with TPM2 support) can unlock the disk automatically at boot without requiring a password — the disk encryption key is sealed to the expected PCR measurements. If the bootloader or firmware has been tampered with, the PCR values change, the seal fails, and the key is not released. This is the Secure Boot integration story: TPM + Secure Boot together create a chain of trust from firmware through bootloader through OS.

What TEEs Cannot Protect Against

Understanding the limits of hardware-based isolation is as important as understanding the protections.

Side-channel attacks. Intel SGX, despite strong architectural isolation, was successfully attacked via the Foreshadow/L1TF vulnerability (2018), which exploited speculative execution to read SGX enclave memory from outside the enclave. Spectre and Meltdown variants continued to challenge SGX's isolation guarantees. Hardware manufacturers have largely mitigated these with microcode updates, but the attack class remains active research territory. TEEs provide strong isolation against software attacks; they provide weaker isolation against processor-level side channels.

Physical attacks with sufficient access and resources. Extracting keys from a Secure Enclave with physical access to the chip requires electron microscopes, focused ion beams, and deep expertise — it's outside the capability of all but the most well-resourced laboratories. But it's not impossible, and for extremely high-value targets, it's been demonstrated in research contexts.

The software around the enclave. If an attacker can compromise the Normal World OS sufficiently, they can sometimes influence what gets sent to the Secure World — not read keys, but potentially manipulate the requests that use them. Defense in depth at the application layer still matters.

Vulnerable TEE firmware. OEM-specific TEE implementations have had their share of vulnerabilities. Samsung's TrustZone implementation (Kinibi) has had documented vulnerabilities that allowed privilege escalation into the Secure World in older firmware versions. Hardware isolation is only as strong as the trusted software running inside it.

What "Hardware-Backed" Really Means for Messaging Apps

When a messaging app claims "hardware-backed key storage," it means the private keys used for end-to-end encryption are generated and stored within the device's secure element, using the platform's keystore API (Android Keystore on Android, Keychain backed by the Secure Enclave on iOS). Cryptographic operations happen inside the secure hardware; the key material is never exposed to the app process.

This means that even if an attacker achieves full compromise of the app process — through a memory corruption vulnerability or a malicious library — they cannot extract the private keys. They can ask the secure element to sign or decrypt things, but only while the app is running and only within the platform's access control policies (which can include biometric authentication requirements).

It's a meaningful layer of protection that doesn't require the user to understand any of the underlying hardware architecture. The protection is real; its limits are real too. The stack from silicon to application is long, and security is only as strong as its weakest point. Hardware isolation strengthens one link in that chain significantly — it doesn't make the chain unbreakable.

Your encryption keys stay on your device

Haven derives your encryption keys locally from your passphrase — they never leave your device, and they're never transmitted to our servers in any form.

Get Started →