Danielle Roberts | 8bb806d | 2015-11-05 17:47:03 -0800 | [diff] [blame] | 1 | page.title=Hardware-backed Keystore |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 2 | @jd:body |
| 3 | |
| 4 | <!-- |
| 5 | Copyright 2015 The Android Open Source Project |
| 6 | |
| 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | you may not use this file except in compliance with the License. |
| 9 | You may obtain a copy of the License at |
| 10 | |
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | |
| 13 | Unless required by applicable law or agreed to in writing, software |
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | See the License for the specific language governing permissions and |
| 17 | limitations under the License. |
| 18 | --> |
| 19 | <div id="qv-wrapper"> |
| 20 | <div id="qv"> |
| 21 | <h2>In this document</h2> |
| 22 | <ol id="auto-toc"> |
| 23 | </ol> |
| 24 | </div> |
| 25 | </div> |
| 26 | |
| 27 | <p>The availability of a trusted execution environment in a system on a chip (SoC) |
| 28 | offers an opportunity for Android devices to provide hardware-backed, strong |
| 29 | security services to the Android OS, to platform services, and even to |
| 30 | third-party apps.</p> |
| 31 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 32 | <p>Keystore has been <a href="features.html">significantly enhanced</a> in |
| 33 | Android 6.0 with the addition of symmetric cryptographic primitives, AES and |
| 34 | HMAC, and the addition of an access control system for hardware-backed |
| 35 | keys. Access controls are specified during key generation and enforced for the |
| 36 | lifetime of the key. Keys can be restricted to be usable only after the user has |
| 37 | authenticated, and only for specified purposes or with specified cryptographic |
| 38 | parameters. For more information, please see the <a |
| 39 | href="implementer-ref.html">Implementer's Reference</a>.</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 40 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 41 | <p>Before Android 6.0, Android already had a simple, hardware-backed crypto |
| 42 | services API, provided by versions 0.2 and 0.3 of the Keymaster Hardware |
| 43 | Abstraction Layer (HAL). Keystore provided digital signing and verification |
| 44 | operations, plus generation and import of asymmetric signing key pairs. This is |
| 45 | already implemented on many devices, but there are many security goals that |
| 46 | cannot easily be achieved with only a signature API. Keystore in Android 6.0 |
| 47 | extends the Keystore API to provide a broader range of capabilities.</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 48 | |
| 49 | <h2 id=goals>Goals</h2> |
| 50 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 51 | <p>The goal of the Android 6.0 Keystore API and the underlying Keymaster 1.0 HAL |
| 52 | is to provide a basic but adequate set of cryptographic primitives to allow the |
| 53 | implementation of protocols using access-controlled, hardware-backed keys.</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 54 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 55 | <p>In addition to expanding the range of cryptographic primitives, Keystore in |
| 56 | Android 6.0 adds the following:</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 57 | |
| 58 | <ul> |
| 59 | <li>A usage control scheme to allow key usage to be limited, to mitigate the risk |
| 60 | of security compromise due to misuse of keys |
| 61 | <li>An access control scheme to enable restriction of keys to specified users, |
| 62 | clients, and a defined time range |
| 63 | </ul> |
| 64 | |
| 65 | <h2 id=architecture>Architecture</h2> |
| 66 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 67 | <p>The Keymaster HAL is an OEM-provided, dynamically-loadable library used by the |
| 68 | Keystore service to provide hardware-backed cryptographic services. HAL |
| 69 | implementations must not perform any sensitive operations in user space, or even |
| 70 | in kernel space. Sensitive operations are delegated to a secure processor |
| 71 | reached through some kernel interface. The resulting architecture looks |
| 72 | like the following:</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 73 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 74 | <div align="center"> |
| 75 | <img src="../images/access-to-keymaster.png" alt="Access to Keymaster" id="figure1" /> |
| 76 | </div> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 77 | <p class="img-caption"><strong>Figure 1.</strong> Access to Keymaster</p> |
| 78 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 79 | <p>Within an Android device, the "client" of the Keymaster HAL consists of |
| 80 | multiple layers (e.g. app, framework, Keystore daemon), but that can be ignored |
| 81 | for the purposes of this document. This means that the described Keymaster HAL |
| 82 | API is low-level, used by platform-internal components, and not exposed to app |
| 83 | developers. The higher-level API, for API level 23, is described on the <a |
| 84 | href="http://developer.android.com/reference/java/security/KeyStore.html">Android |
| 85 | Developer site</a>.</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 86 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 87 | <p>The purpose of the Keymaster HAL is not to implement the security-sensitive |
| 88 | algorithms but only to marshal and unmarshal requests to the secure world. The |
| 89 | wire format is implementation-defined.</p> |
Bert McMeen | daa1137 | 2015-09-17 16:35:18 -0700 | [diff] [blame] | 90 | |
| 91 | <h2 id=compatibility_with_previous_versions>Compatibility with previous versions</h2> |
| 92 | |
Shawn Willden | 453bcca | 2015-12-01 09:39:18 -0700 | [diff] [blame^] | 93 | <p>The Keymaster v1.0 HAL is completely incompatible with the |
| 94 | previously-released HALs, e.g. Keymaster v0.2 and v0.3. To facilitate |
| 95 | interoperability on pre-Marshmallow devices that launched with the older |
| 96 | Keymaster HALs, Keystore provides an adapter that implements the 1.0 HAL with |
| 97 | calls to the existing hardware library. The result cannot provide the full range |
| 98 | of functionality in the 1.0 HAL. In particular, it will only support RSA and |
| 99 | ECDSA algorithms, and all of the key authorization enforcement will be performed |
| 100 | by the adapter, in the non-secure world.</p> |