xref: /aosp_15_r20/hardware/interfaces/security/README.md (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1*4d7e907cSAndroid Build Coastguard Worker# Security-Related HALs
2*4d7e907cSAndroid Build Coastguard Worker
3*4d7e907cSAndroid Build Coastguard WorkerThe `security/` subdirectory holds various security-related HALs.  (The final two sections of this
4*4d7e907cSAndroid Build Coastguard Workerdocument also describe security-related HALs that are in other places under `hardware/interfaces/`.)
5*4d7e907cSAndroid Build Coastguard Worker
6*4d7e907cSAndroid Build Coastguard WorkerThe most significant HAL is KeyMint (**`IKeyMintDevice`** in the
7*4d7e907cSAndroid Build Coastguard Worker`hardware/interfaces/security/keymint/` directory), which allows access to cryptographic
8*4d7e907cSAndroid Build Coastguard Workerfunctionality where the key material is restricted to a secure environment.  This functionality is
9*4d7e907cSAndroid Build Coastguard Workerused by Android system services, and is also made available to apps via Android Keystore.
10*4d7e907cSAndroid Build Coastguard Worker
11*4d7e907cSAndroid Build Coastguard WorkerA KeyMint implementation (or an implementation of its predecessor, Keymaster) that runs in an
12*4d7e907cSAndroid Build Coastguard Workerisolated execution environment (e.g. ARM TrustZone) is required for most Android devices; see [CDD
13*4d7e907cSAndroid Build Coastguard Worker9.11](https://source.android.com/docs/compatibility/13/android-13-cdd#911_keys_and_credentials).
14*4d7e907cSAndroid Build Coastguard Worker
15*4d7e907cSAndroid Build Coastguard WorkerA device may optionally also support a second KeyMint instance, running in a dedicated secure
16*4d7e907cSAndroid Build Coastguard Workerprocessor; this is known as StrongBox ([CDD
17*4d7e907cSAndroid Build Coastguard Worker9.11.2](https://source.android.com/docs/compatibility/13/android-13-cdd#9112_strongbox)).
18*4d7e907cSAndroid Build Coastguard Worker
19*4d7e907cSAndroid Build Coastguard WorkerTwo specific features of KeyMint are worth highlighting, as they have an impact on the other
20*4d7e907cSAndroid Build Coastguard Workersecurity-related HALs:
21*4d7e907cSAndroid Build Coastguard Worker
22*4d7e907cSAndroid Build Coastguard Worker- KeyMint supports keys that can only be used when the operation is authenticated by the user,
23*4d7e907cSAndroid Build Coastguard Worker  either by their lock screen knowledge factor (LSKF, e.g. PIN or pattern) or by a strong biometric
24*4d7e907cSAndroid Build Coastguard Worker  (e.g. fingerprint).
25*4d7e907cSAndroid Build Coastguard Worker- KeyMint supports *attestation* of public keys: when an asymmetric keypair is created, the secure
26*4d7e907cSAndroid Build Coastguard Worker  environment produces a chain of signed certificates:
27*4d7e907cSAndroid Build Coastguard Worker  - starting from a trusted root certificate
28*4d7e907cSAndroid Build Coastguard Worker  - terminating in a leaf certificate that holds the public key; this leaf certificate may also
29*4d7e907cSAndroid Build Coastguard Worker    describe the state of the device and the policies attached to the key.
30*4d7e907cSAndroid Build Coastguard Worker
31*4d7e907cSAndroid Build Coastguard Worker## Authentication Verification
32*4d7e907cSAndroid Build Coastguard Worker
33*4d7e907cSAndroid Build Coastguard WorkerUser authentication must also take place in a secure environment (see the final section below), but
34*4d7e907cSAndroid Build Coastguard Workerthe results of that authentication are communicated to KeyMint via Android.  As such, the
35*4d7e907cSAndroid Build Coastguard Workerauthentication result (a *hardware auth token*) is signed with a per-boot shared HMAC key known only
36*4d7e907cSAndroid Build Coastguard Workerto the secure components, so that it's authenticity can be verified.
37*4d7e907cSAndroid Build Coastguard Worker
38*4d7e907cSAndroid Build Coastguard WorkerIf an authenticator, for example GateKeeper (described by the **`IGatekeeper`** HAL in
39*4d7e907cSAndroid Build Coastguard Worker`hardware/interfaces/gatekeeper/`), is co-located in the same secure environment as KeyMint, it can
40*4d7e907cSAndroid Build Coastguard Workeruse a local, vendor-specific, method to communicate the shared HMAC key.
41*4d7e907cSAndroid Build Coastguard Worker
42*4d7e907cSAndroid Build Coastguard WorkerHowever, if the authenticator is in a different environment than the KeyMint instance then a local
43*4d7e907cSAndroid Build Coastguard Workercommunication mechanism may not be possible.  For example, a StrongBox KeyMint instance running in a
44*4d7e907cSAndroid Build Coastguard Workerseparate secure processor may not have a communication channel with a TEE on the main processor.
45*4d7e907cSAndroid Build Coastguard Worker
46*4d7e907cSAndroid Build Coastguard WorkerTo allow for this, the **`ISharedSecret`** HAL (in `hardware/interfaces/security/sharedsecret`)
47*4d7e907cSAndroid Build Coastguard Workerdescribes an N-party shared key agreement protocol for per-boot derivation of the shared HMAC key,
48*4d7e907cSAndroid Build Coastguard Workerbased on a pre-provisioned shared secret.  This HAL can be implemented by any security component
49*4d7e907cSAndroid Build Coastguard Worker– whether KeyMint instance or authenticator – that needs access to the shared HMAC key.
50*4d7e907cSAndroid Build Coastguard Worker
51*4d7e907cSAndroid Build Coastguard WorkerUser authentication operations are also timestamped, but a StrongBox KeyMint instance may not have
52*4d7e907cSAndroid Build Coastguard Workeraccess to a secure time source that is aligned with the authenticator's time source.
53*4d7e907cSAndroid Build Coastguard Worker
54*4d7e907cSAndroid Build Coastguard WorkerTo allow for this, the **`ISecureClock`** HAL (in `hardware/interfaces/secureclock`) describes a
55*4d7e907cSAndroid Build Coastguard Workerchallenge-based timestamp authentication protocol.  This HAL is optional; it need only be
56*4d7e907cSAndroid Build Coastguard Workerimplemented if there is a KeyMint instance without a secure source of time.
57*4d7e907cSAndroid Build Coastguard Worker
58*4d7e907cSAndroid Build Coastguard Worker## Attestation Key Provisioning
59*4d7e907cSAndroid Build Coastguard Worker
60*4d7e907cSAndroid Build Coastguard WorkerAs noted above, key generation may also generate an attestation certificate chain, which requires
61*4d7e907cSAndroid Build Coastguard Workerthat the secure environment have access to a signing key which in turn chains back to the Google
62*4d7e907cSAndroid Build Coastguard Workerroot.
63*4d7e907cSAndroid Build Coastguard Worker
64*4d7e907cSAndroid Build Coastguard WorkerHistorically these signing keys were created by Google and provided to vendors for installation in
65*4d7e907cSAndroid Build Coastguard Workerbatches of devices (to prevent their use as unique device identifiers).  However, this mechanism had
66*4d7e907cSAndroid Build Coastguard Workersignificant disadvantages, as it required secure handling of key material and only allowed for
67*4d7e907cSAndroid Build Coastguard Workercoarse-grained revocation.
68*4d7e907cSAndroid Build Coastguard Worker
69*4d7e907cSAndroid Build Coastguard WorkerThe remote key provisioning HAL (**`IRemotelyProvisionedComponent`** in
70*4d7e907cSAndroid Build Coastguard Worker`hardware/interfaces/security/rkp/`) provides a mechanism whereby signing certificates for
71*4d7e907cSAndroid Build Coastguard Workerattestation can be retrieved at runtime from Google servers based on pre-registered device identity
72*4d7e907cSAndroid Build Coastguard Workerinformation.  This mechanism is used to provision certificates for KeyMint's signing keys, but is
73*4d7e907cSAndroid Build Coastguard Workernot restricted to that purpose; it can also be used in other scenarios where keys need to be
74*4d7e907cSAndroid Build Coastguard Workerprovisioned (for example, for [Widevine](https://developers.google.com/widevine/drm/overview)).
75*4d7e907cSAndroid Build Coastguard Worker
76*4d7e907cSAndroid Build Coastguard Worker## Keymaster
77*4d7e907cSAndroid Build Coastguard Worker
78*4d7e907cSAndroid Build Coastguard WorkerThe Keymaster HAL (**`IKeymasterDevice`** in `hardware/interfaces/keymaster/`) is the historical
79*4d7e907cSAndroid Build Coastguard Workerancestor of many of the HALs here (and may still be present on older devices).  Its functionality is
80*4d7e907cSAndroid Build Coastguard Workereffectively the union of the following current HALs:
81*4d7e907cSAndroid Build Coastguard Worker
82*4d7e907cSAndroid Build Coastguard Worker- **`IKeyMintDevice`**
83*4d7e907cSAndroid Build Coastguard Worker- **`ISharedSecret`**
84*4d7e907cSAndroid Build Coastguard Worker- **`ISecureClock`**
85*4d7e907cSAndroid Build Coastguard Worker
86*4d7e907cSAndroid Build Coastguard Worker## Related Authentication HALs
87*4d7e907cSAndroid Build Coastguard Worker
88*4d7e907cSAndroid Build Coastguard WorkerAuthentication of users needs to happen in a secure environment, using vendor-specific
89*4d7e907cSAndroid Build Coastguard Workerfunctionality, and so involves the use of one of the following HALs (all of which are outside the
90*4d7e907cSAndroid Build Coastguard Worker`security/` subdirectory).
91*4d7e907cSAndroid Build Coastguard Worker
92*4d7e907cSAndroid Build Coastguard Worker- The **`IGatekeeper`** HAL (in `hardware/interfaces/gatekeeper/`) provides user authentication
93*4d7e907cSAndroid Build Coastguard Worker  functionality based on the user's lock-screen knowledge factor (LSKF), including throttling
94*4d7e907cSAndroid Build Coastguard Worker  behaviour to prevent attacks.  Authentication tokens produced by this HAL are consumed by KeyMint,
95*4d7e907cSAndroid Build Coastguard Worker  validated using the shared HMAC key described above.
96*4d7e907cSAndroid Build Coastguard Worker  - The optional **`IWeaver`** HAL (in `hardware/interfaces/weaver`) improves the security of LSKF
97*4d7e907cSAndroid Build Coastguard Worker    authentication by converting the user's LSKF into a *synthetic password* via hashing and
98*4d7e907cSAndroid Build Coastguard Worker    stretching. This is required to be implemented on a separate secure element, which prevents
99*4d7e907cSAndroid Build Coastguard Worker    offline attacks on Gatekeeper storage. Note that Weaver does not directly interact with KeyMint;
100*4d7e907cSAndroid Build Coastguard Worker    the synthetic password is fed into Gatekeeper in place of the plain user password, and then
101*4d7e907cSAndroid Build Coastguard Worker    Gatekeeper interacts with KeyMint as normal.
102*4d7e907cSAndroid Build Coastguard Worker- The **`IFingerprint`** and **`IFace`** HAL definitions (under `hardware/interfaces/biometrics/`)
103*4d7e907cSAndroid Build Coastguard Worker  allow access to biometric authentication functionality that is implemented in a secure
104*4d7e907cSAndroid Build Coastguard Worker  environment.  Authentication tokens produced by these HALs are consumed by KeyMint, validated
105*4d7e907cSAndroid Build Coastguard Worker  using the shared HMAC key described above.
106*4d7e907cSAndroid Build Coastguard Worker- The optional **`IConfirmationUI`** HAL (in `hardware/interfaces/confirmationui`) supports
107*4d7e907cSAndroid Build Coastguard Worker  functionality where the user confirms that they have seen a specific message in a secure manner.
108*4d7e907cSAndroid Build Coastguard Worker  Confirmation tokens produced by this HAL are consumed by KeyMint, validated using the shared HMAC
109*4d7e907cSAndroid Build Coastguard Worker  key described above.
110