AOSP Foundations
4 min read

Platform Keys & Release Keys

Understand the critical difference between generic AOSP test keys and the custom release keys required for commercial devices.

You just built Android using the standard compilation command. The system boots successfully on your test device. You might assume this fresh build possesses enough security for a commercial product. That assumption leads to immediate disaster. The default compilation process relies on four generic cryptographic identities called test keys. These keys sit freely available in the public Google Git repository.

Warning: Never ship a production device using the default test keys. Doing so grants instant root access to anyone who knows where to look.

Shipping a device with these public keys resembles installing a bank vault and publishing the combination in the owner manual. A malicious actor simply downloads the platform key from the Android source tree. They write a malicious application and sign it with that public identity. When they push the application to your device, the operating system verifies the signature. Because the signature perfectly matches the system framework, Android grants the malware unrestricted system privileges. To stop attackers from exploiting the public keys, we must generate our own unique cryptographic locks.

Generating the Manufacturer's Release Keys

To protect the operating system, a manufacturer creates private cryptographic identities known as release keys. These custom RSA key pairs replace the generic public test keys. The Android source tree includes a specific utility named make_key for this exact purpose. You invoke this script to generate a .pk8 private key and an .x509.pem public certificate.

# Generate a secure RSA release key pair
development/tools/make_key releasekey '/C=US/ST=California/L=Mountain View/O=Google/OU=Android/CN=Android'

Running this command creates a unique cryptographic identity for your specific hardware. The output files form the foundation of your device security model.

Tip: Store your generated private keys on hardware security modules or offline servers. If an attacker breaches your build environment, they cannot steal keys that reside physically disconnected from the network.

Once you possess highly guarded private keys stored on a secure server, a new problem emerges. You need to sign the compiled operating system. Physical separation prevents the standard build server from accessing those offline keys.

The Two-Step Signing Architecture

Building Android requires constant compilation on internet-connected servers. You cannot place your private release keys on these vulnerable machines. This security requirement forces a mandatory two-step signing architecture. The build server acts like a factory assembling a vehicle with temporary parts. A completely separate secure server acts as the final inspection facility where engineers apply the permanent certification seal.

The following flowchart illustrates the separation between the insecure build environment and the offline secure signing environment. This visual representation helps clarify how the physical boundary protects the private keys from network breaches.

Inside the factory, the build server generates a massive archive containing every compiled component. The secure server receives this archive and runs the signing script to produce the final secure image.

The sign_target_files_apks script handles the complex transition between these two states. It opens the massive archive and strips out every insecure public signature. Our tool then aggressively re-signs every application and binary using your private release keys. Securing the factory applications protects the device at launch. We must also guarantee that future software updates remain equally secure.

Securing Over-The-Air Updates

Cryptographic identities secure the initial factory installation. They also authenticate any future system modifications. When a device downloads an over-the-air update package, it must verify the sender. The Android recovery environment inspects the package before allowing the installation. This verification prevents attackers from pushing malicious operating system replacements over compromised networks.

The following sequence diagram shows the recovery environment verifying an incoming update package. Tracing this flow helps explain how the device relies on a pre-installed public key to authenticate the file.

Upon receiving the file, the Android operating system hands the downloaded package to the recovery environment. The recovery system checks the cryptographic signature and either proceeds with the installation or aborts the process entirely.

Common Mistake: Failing to embed the matching public key into the recovery partition causes all legitimate system updates to fail verification.

Your device treats the update like a letter with a wax seal. If the package signature fails to match the public certificate embedded in the recovery partition, the system destroys the file. By securing both the installed applications and the incoming update packages, we successfully lock down the running operating system. We know the software is authentic. Now we must ask how the device trusts the hardware boot process before the operating system even loads.