blob: 1456abe0383bb8b692593a0d8cb7ff1b526e0d7a [file] [log] [blame]
Shawn Willden94ad8912019-09-09 02:13:58 -06001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.keymaster@4.1;
18
19import @4.0::ErrorCode;
20import @4.0::HardwareAuthToken;
21import @4.0::IKeymasterDevice;
22import @4.0::KeyParameter;
23import @4.0::KeyPurpose;
24import @4.0::OperationHandle;
Shawn Willdenf3d74172020-01-08 10:26:40 -070025import @4.0::VerificationToken;
26
Shawn Willden94ad8912019-09-09 02:13:58 -060027import IOperation;
28
29/**
30 * @4.1::IKeymasterDevice is a minor extension to @4.0::IKeymasterDevice. It adds support for
31 *
32 * - Partial hardware enforcment of UNLOCKED_DEVICE_REQUIRED keys;
33 * - Device-unique attestaion;
34 * - Early boot only keys;
35 * - Better cleanup of operations when clients die without completing or aborting them.
Shawn Willdenf3d74172020-01-08 10:26:40 -070036 *
37 * @4.1::IKeymasterDevice::attestKey() must produce attestations with keymasterVersion 41. An
38 * oversight in the original numbering left no room for minor versions, so starting with 4.1 the
39 * versions will be numbered as major_version * 10 + minor version. The addition of new attestable
40 * tags changes the attestation format again, slightly, so the attestationVersion must be 4.
Shawn Willden94ad8912019-09-09 02:13:58 -060041 */
42interface IKeymasterDevice extends @4.0::IKeymasterDevice {
43 /**
44 * Called by client to notify the IKeymasterDevice that the device is now locked, and keys with
45 * the UNLOCKED_DEVICE_REQUIRED tag should no longer be usable. When this function is called,
46 * the IKeymasterDevice should note the current timestamp, and attempts to use
47 * UNLOCKED_DEVICE_REQUIRED keys must be rejected with Error::DEVICE_LOCKED until an
48 * authentication token with a later timestamp is presented. If the `passwordOnly' argument is
49 * set to true the sufficiently-recent authentication token must indicate that the user
50 * authenticated with a password, not a biometric.
51 *
Shawn Willdenf3d74172020-01-08 10:26:40 -070052 * Note that the IKeymasterDevice UNLOCKED_DEVICE_REQUIRED semantics are slightly different from
53 * the UNLOCKED_DEVICE_REQUIRED semantics enforced by keystore. Keystore handles device locking
54 * on a per-user basis. Because auth tokens do not contain an Android user ID, it's not
55 * possible to replicate the keystore enformcement logic in IKeymasterDevice. So from the
56 * IKeymasterDevice perspective, any user unlock unlocks all UNLOCKED_DEVICE_REQUIRED keys.
57 * Keystore will continue enforcing the per-user device locking.
58 *
Shawn Willden94ad8912019-09-09 02:13:58 -060059 * @param passwordOnly specifies whether the device must be unlocked with a password, rather
60 * than a biometric, before UNLOCKED_DEVICE_REQUIRED keys can be used.
Shawn Willdenf3d74172020-01-08 10:26:40 -070061 *
62 * @param verificationToken is used by StrongBox implementations of IKeymasterDevice. It
63 * provides the StrongBox IKeymasterDevice with a fresh, MACed timestamp which it can use as the
64 * device-lock time, for future comparison against auth tokens when operations using
65 * UNLOCKED_DEVICE_REQUIRED keys are attempted. Unless the auth token timestamp is newer than
66 * the timestamp in the verificationToken, the device is still considered to be locked.
67 * Crucially, if a StrongBox IKeymasterDevice receives a deviceLocked() call with a verification
68 * token timestamp that is less than the timestamp in the last deviceLocked() call, it must
69 * ignore the new timestamp. TEE IKeymasterDevice implementations will receive an empty
70 * verificationToken (zero values and empty vectors) and should use their own clock as the
71 * device-lock time.
Shawn Willden94ad8912019-09-09 02:13:58 -060072 */
Shawn Willdenf3d74172020-01-08 10:26:40 -070073 deviceLocked(bool passwordOnly, VerificationToken verificationToken) generates (ErrorCode error);
Shawn Willden94ad8912019-09-09 02:13:58 -060074
75 /**
76 * Called by client to notify the IKeymasterDevice that the device has left the early boot
77 * state, and that keys with the EARLY_BOOT_ONLY tag may no longer be used. All attempts to use
78 * an EARLY_BOOT_ONLY key after this method is called must fail with Error::INVALID_KEY_BLOB.
79 */
80 earlyBootEnded() generates (ErrorCode error);
81
82 /**
83 * Begins a cryptographic operation. beginOp() is a variation on begin(). beginOp() has
84 * identical functionality to begin, but instead of an OperationHandle it returns an IOperation
85 * object. An IKeymasterDevice HAL service must call linkToDeath() on the Operation before
86 * returning it, and the provided hidl_death_recipient, if called, must abort() the operation.
87 * This is to ensure that in the event a client crashes while an operation is in progress, the
88 * operation slot is freed and available for use by other clients.
89 *
90 * @4.1::IKeymasterDevices must implement both beginOp() and begin().
91 */
92 beginOp(KeyPurpose purpose, vec<uint8_t> keyBlob, vec<KeyParameter> inParams,
93 HardwareAuthToken authToken)
94 generates (ErrorCode error, vec<KeyParameter> outParam, IOperation operation);
95};