Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
| 17 | package android.hardware.biometrics.face@1.0; |
| 18 | |
| 19 | import IBiometricsFaceClientCallback; |
| 20 | |
| 21 | // TODO(b/78538290): Update comments with state machine transitions when ready. |
| 22 | // TODO(b/78537981): Update comments with callback interaction contract. |
| 23 | // TODO(b/79496983): Update comments with status returns fully enumerated. |
| 24 | /** |
| 25 | * The HAL interface for biometric face authentication. |
| 26 | */ |
| 27 | interface IBiometricsFace { |
| 28 | |
| 29 | /** |
| 30 | * Sets the current client callback. |
| 31 | * |
| 32 | * Registers a user function that must receive notifications from the HAL. |
| 33 | * There is usually only one client (FaceService). This call must block |
| 34 | * if the HAL state machine is in busy state until the HAL leaves the |
| 35 | * busy state. |
| 36 | * |
| 37 | * All callback methods pass a deviceId to differentiate callback |
| 38 | * invocations in the case where multiple sensors exist. |
| 39 | * |
| 40 | * @param clientCallback The client defined callback to register. |
| 41 | * @return result, with its "value" parameter representing a "deviceId", |
| 42 | * which must be unique for a given sensor. |
| 43 | */ |
| 44 | @callflow(next={"setActiveUser"}) |
| 45 | @entry |
| 46 | setCallback(IBiometricsFaceClientCallback clientCallback) |
| 47 | generates (OptionalUint64 result); |
| 48 | |
| 49 | /** |
| 50 | * Sets the active user, which all subsequent HAL operations are applied to. |
| 51 | * |
| 52 | * HAL service implementors must ensure that operations are restricted to |
| 53 | * the given user. Clients must not call any part of this interface, except |
| 54 | * for setCallback(), without first having set an active user. The |
| 55 | * implementation is responsible for cancelling the current operation and |
| 56 | * returning to the idle state. Calling this method with the same userId |
| 57 | * should have no effect on the state machine. |
| 58 | * |
| 59 | * @param userId A non-negative user identifier that must be unique and |
| 60 | * persistent for a given user. |
| 61 | * @param storePath filesystem path to the template storage directory. |
| 62 | */ |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 63 | @callflow(next={"authenticate", "generateChallenge", "enumerate", "remove"}) |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 64 | setActiveUser(int32_t userId, string storePath) generates (Status status); |
| 65 | |
| 66 | /** |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 67 | * Begins a secure transaction request, e.g. enrollment. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 68 | * |
| 69 | * Generates a unique and cryptographically secure random token used to |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 70 | * indicate the start of a secure transaction. generateChallenge() and |
| 71 | * revokeChallenge() specify a pin/pattern/password cleared time window where |
| 72 | * the secure transaction is allowed. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 73 | * |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 74 | * generateChallenge() generates a challenge which must then be wrapped by the |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 75 | * gatekeeper after verifying a successful strong authentication attempt, |
| 76 | * which generates a Hardware Authentication Token. The challenge prevents |
| 77 | * spoofing and replay attacks and ensures that we only update a user’s face |
| 78 | * template if the operation was preceded by some kind of strong credential |
| 79 | * confirmation (e.g. device password). |
| 80 | * |
Kevin Chyn | 2acfd2a | 2018-09-20 18:42:09 -0700 | [diff] [blame] | 81 | * @param challengeTimeoutSec A timeout in seconds, after which the driver |
| 82 | * must invalidate the challenge. This is to prevent bugs or crashes in |
| 83 | * the system from leaving a challenge enabled indefinitely. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 84 | * @return result, with its "value" parameter representing a "challenge": a |
| 85 | * unique and cryptographically secure random token. |
| 86 | */ |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 87 | @callflow(next={"enroll", "revokeChallenge", "setFeatureDisabled"}) |
Kevin Chyn | 2acfd2a | 2018-09-20 18:42:09 -0700 | [diff] [blame] | 88 | generateChallenge(uint32_t challengeTimeoutSec) |
| 89 | generates (OptionalUint64 result); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Enrolls a user's face. |
| 93 | * |
| 94 | * Note that this interface permits implementations where multiple faces can |
| 95 | * be enrolled for a single user. However, allowing multiple faces to be |
| 96 | * enrolled can be a severe security vulnerability and hence, most |
| 97 | * implementations must ensure that only a single face be enrolled at a |
| 98 | * given time. Multi-enrollment must only be used where there is a clear |
| 99 | * necessity for a shared use case, e.g. TVs or cars. |
| 100 | * |
| 101 | * Note that the Hardware Authentication Token must still be valid after |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 102 | * this call, and must be explicitly invalidated by a call to |
| 103 | * revokeChallenge(). This allows clients to immediately reattempt |
| 104 | * enrollment (for example, if a user wasn’t satisfied with their enrollment) |
| 105 | * without having to go through another strong authentication flow. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 106 | * |
| 107 | * This method triggers the IBiometricsFaceClientCallback#onEnrollResult() |
| 108 | * method. |
| 109 | * |
| 110 | * @param hat A valid Hardware Authentication Token, generated as a result |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 111 | * of a generateChallenge() challenge being wrapped by the gatekeeper |
| 112 | * after a sucessful strong authentication request. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 113 | * @param timeoutSec A timeout in seconds, after which this enrollment |
| 114 | * attempt is cancelled. Note that the client still needs to |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 115 | * call revokeChallenge() to terminate the enrollment session. |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 116 | * @param disabledFeatures A list of features to be disabled during |
| 117 | * enrollment. Note that all features are enabled by default. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 118 | * @return status The status of this method call. |
| 119 | */ |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 120 | @callflow(next={"cancel", "enroll", "revokeChallenge", "remove"}) |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 121 | enroll(vec<uint8_t> hat, uint32_t timeoutSec, vec<Feature> disabledFeatures) |
Kevin Chyn | 57acf97 | 2018-08-31 15:10:03 -0700 | [diff] [blame] | 122 | generates (Status status); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 125 | * Finishes the secure transaction by invalidating the challenge generated |
| 126 | * by generateChallenge(). |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 127 | * |
| 128 | * Clients must call this method once enrollment is complete, and the user's |
| 129 | * face template no longer needs to be updated. |
| 130 | * |
| 131 | * @return status The status of this method call. |
| 132 | */ |
| 133 | @callflow(next={"authenticate", "setActiveUser", "enumerate", "remove"}) |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 134 | revokeChallenge() generates (Status status); |
| 135 | |
| 136 | /** |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 137 | * Requires all subsequent enroll/authenticate calls to use the feature. |
| 138 | * This method does not affect enroll, which has its own feature list. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 139 | * |
| 140 | * Changes the state of previous enrollment setting. Because this may |
| 141 | * decrease security, the user must enter their password before this method |
| 142 | * is invoked (see @param HAT). The driver must verify the HAT before |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 143 | * changing any feature state. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 144 | * Note: In some cases it may not be possible to change the state of this |
| 145 | * flag without re-enrolling. For example, if the user didn't provide |
| 146 | * attention during the original enrollment. This flag reflects the same |
| 147 | * persistent state as the one passed to enroll(). |
| 148 | * |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 149 | * @param feature The feature to be enabled or disabled. |
| 150 | * @param enabled True to enable the feature, false to disable. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 151 | * @param hat A valid Hardware Authentication Token, generated as a result |
| 152 | * of getChallenge(). |
| 153 | * @return status The status of this method call. |
| 154 | */ |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 155 | setFeature(Feature feature, bool enabled, vec<uint8_t> hat) |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 156 | generates(Status status); |
| 157 | |
| 158 | /** |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 159 | * Retrieves the current state of the feature. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 160 | * |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 161 | * @return enabled True if the feature is enabled, false if disabled. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 162 | */ |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 163 | getFeature(Feature feature) generates (bool enabled); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Returns an identifier associated with the current face set. |
| 167 | * |
| 168 | * The authenticator ID must change whenever a new face is enrolled. The |
| 169 | * authenticator ID must not be changed when a face is deleted. The |
| 170 | * authenticator ID must be an entropy-encoded random number which all |
| 171 | * current templates are tied to. The authenticator ID must be immutable |
| 172 | * outside of an active enrollment window to prevent replay attacks. |
| 173 | * |
| 174 | * @return result, with its value parameter representing an |
| 175 | * "authenticatorId": an identifier associated to the user's current |
| 176 | * face enrollment. |
| 177 | */ |
| 178 | @callflow(next={"authenticate"}) |
| 179 | getAuthenticatorId() generates (OptionalUint64 result); |
| 180 | |
| 181 | /** |
| 182 | * Cancels a pending enrollment or authentication request. |
| 183 | * |
| 184 | * @return status The status of this method call. |
| 185 | */ |
| 186 | @callflow(next={"authenticate", "enroll", "enumerate", "remove", |
| 187 | "setActiveUser"}) |
| 188 | cancel() generates (Status status); |
| 189 | |
| 190 | /** |
| 191 | * Enumerates all face templates associated with the active user. |
| 192 | * |
| 193 | * The onEnumerate() callback method is invoked once for each face template |
| 194 | * found. |
| 195 | * |
| 196 | * @return status The status of this method call. |
| 197 | */ |
| 198 | @callflow(next={"remove", "enroll", "authenticate", "setActiveUser"}) |
| 199 | enumerate() generates (Status status); |
| 200 | |
| 201 | /** |
| 202 | * Removes a face template or all face templates associated with the active |
| 203 | * user. |
| 204 | * |
| 205 | * This method triggers the IBiometricsFaceClientCallback#onRemoved() method. |
| 206 | * |
| 207 | * @param faceId The id correpsonding to the face to be removed; or 0 if all |
| 208 | * faces are to be removed. |
| 209 | * @return status The status of this method call. |
| 210 | */ |
| 211 | @callflow(next={"enumerate", "authenticate", "cancel", "getAuthenticatorId", |
| 212 | "setActiveUser"}) |
| 213 | remove(uint32_t faceId) generates (Status status); |
| 214 | |
| 215 | /** |
| 216 | * Authenticates the active user. |
| 217 | * |
| 218 | * An optional operationId can be specified as a token from the transaction |
Kevin Chyn | ba9ec87 | 2018-09-28 16:37:45 -0700 | [diff] [blame] | 219 | * being authorized. The hardware may enter a standby state during |
| 220 | * authentication, where the device is idle to conserve power while |
| 221 | * authenticating, e.g. after 3 seconds without finding a face. See |
| 222 | * IBiometricsFace#userActivity() for more info. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 223 | * |
| 224 | * @param operationId A non-zero operation id associated with a crypto |
| 225 | * object instance; or 0 if not being used. |
| 226 | * @return status The status of this method call. |
| 227 | */ |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 228 | @callflow(next={"cancel", "generateChallenge", "remove"}) |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 229 | authenticate(uint64_t operationId) generates (Status status); |
Kevin Chyn | ba9ec87 | 2018-09-28 16:37:45 -0700 | [diff] [blame] | 230 | |
| 231 | /** |
| 232 | * A hint to the HAL to continue looking for faces. |
| 233 | * |
| 234 | * This method should only be used when the HAL is in the authenticating |
| 235 | * or standby state. Using this method when the HAL is not in one of the |
| 236 | * mentioned states must return OPERATION_NOT_SUPPORTED. Calling this |
| 237 | * method while the HAL is already authenticating may extend the duration |
| 238 | * where it's looking for a face. |
| 239 | * |
| 240 | * @return status The status of this method call. |
| 241 | */ |
| 242 | userActivity() generates (Status status); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 243 | }; |