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 | |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 21 | /** |
| 22 | * The HAL interface for biometric face authentication. |
| 23 | */ |
| 24 | interface IBiometricsFace { |
| 25 | |
| 26 | /** |
| 27 | * Sets the current client callback. |
| 28 | * |
| 29 | * Registers a user function that must receive notifications from the HAL. |
| 30 | * There is usually only one client (FaceService). This call must block |
| 31 | * if the HAL state machine is in busy state until the HAL leaves the |
| 32 | * busy state. |
| 33 | * |
| 34 | * All callback methods pass a deviceId to differentiate callback |
| 35 | * invocations in the case where multiple sensors exist. |
| 36 | * |
| 37 | * @param clientCallback The client defined callback to register. |
| 38 | * @return result, with its "value" parameter representing a "deviceId", |
| 39 | * which must be unique for a given sensor. |
| 40 | */ |
| 41 | @callflow(next={"setActiveUser"}) |
| 42 | @entry |
| 43 | setCallback(IBiometricsFaceClientCallback clientCallback) |
| 44 | generates (OptionalUint64 result); |
| 45 | |
| 46 | /** |
| 47 | * Sets the active user, which all subsequent HAL operations are applied to. |
| 48 | * |
| 49 | * HAL service implementors must ensure that operations are restricted to |
| 50 | * the given user. Clients must not call any part of this interface, except |
| 51 | * for setCallback(), without first having set an active user. The |
| 52 | * implementation is responsible for cancelling the current operation and |
| 53 | * returning to the idle state. Calling this method with the same userId |
| 54 | * should have no effect on the state machine. |
| 55 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 56 | * Note that onLockoutChanged() MUST be invoked by the implementation in |
| 57 | * response to a user change in order to update the framework with the |
| 58 | * timeout of the new user (or 0 if the user is not locked out). |
| 59 | * |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 60 | * @param userId A non-negative user identifier that must be unique and |
| 61 | * persistent for a given user. |
| 62 | * @param storePath filesystem path to the template storage directory. |
| 63 | */ |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 64 | @callflow(next={"authenticate", "generateChallenge", "enumerate", "remove"}) |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 65 | setActiveUser(int32_t userId, string storePath) generates (Status status); |
| 66 | |
| 67 | /** |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 68 | * Begins a secure transaction request, e.g. enroll() or resetLockout(). |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 69 | * |
| 70 | * Generates a unique and cryptographically secure random token used to |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 71 | * indicate the start of a secure transaction. generateChallenge() and |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 72 | * revokeChallenge() specify a window where the resulting HAT that is |
| 73 | * generated in response to checking the user's PIN/pattern/password |
| 74 | * can be used to verify/perform a secure transaction. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 75 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 76 | * generateChallenge() generates a challenge which must then be wrapped by |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 77 | * gatekeeper after verifying a successful strong authentication attempt, |
| 78 | * which generates a Hardware Authentication Token. The challenge prevents |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 79 | * spoofing and replay attacks and ensures that only a transaction backed |
| 80 | * by a user authentication (PIN/pattern/password) can proceed. |
| 81 | * |
| 82 | * The implementation should be tolerant of revokeChallenge() being invoked |
| 83 | * after timeout has expired. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 84 | * |
Kevin Chyn | 2acfd2a | 2018-09-20 18:42:09 -0700 | [diff] [blame] | 85 | * @param challengeTimeoutSec A timeout in seconds, after which the driver |
| 86 | * must invalidate the challenge. This is to prevent bugs or crashes in |
| 87 | * the system from leaving a challenge enabled indefinitely. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 88 | * @return result, with its "value" parameter representing a "challenge": a |
| 89 | * unique and cryptographically secure random token. |
| 90 | */ |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 91 | @callflow(next={"enroll", "revokeChallenge", "setFeature"}) |
Kevin Chyn | 2acfd2a | 2018-09-20 18:42:09 -0700 | [diff] [blame] | 92 | generateChallenge(uint32_t challengeTimeoutSec) |
| 93 | generates (OptionalUint64 result); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Enrolls a user's face. |
| 97 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 98 | * Note that the Hardware Authentication Token must be valid for the |
| 99 | * duration of enrollment and thus should be explicitly invalidated by a |
| 100 | * call to revokeChallenge() when enrollment is complete, to reduce the |
| 101 | * window of opportunity to re-use the challenge and HAT. For example, |
| 102 | * Settings calls generateChallenge() once to allow the user to enroll one |
| 103 | * or more faces or toggle secure settings without having to re-enter the |
| 104 | * PIN/pattern/password. Once the user completes the operation, Settings |
| 105 | * invokes revokeChallenge() to close the transaction. If the HAT is expired, |
| 106 | * the implementation must invoke onError with UNABLE_TO_PROCESS. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 107 | * |
| 108 | * This method triggers the IBiometricsFaceClientCallback#onEnrollResult() |
| 109 | * method. |
| 110 | * |
| 111 | * @param hat A valid Hardware Authentication Token, generated as a result |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 112 | * of a generateChallenge() challenge being wrapped by the gatekeeper |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 113 | * after a successful strong authentication request. |
| 114 | * @param timeoutSec A timeout in seconds, after which this enroll |
| 115 | * attempt is cancelled. Note that the framework can continue |
| 116 | * enrollment by calling this again with a valid HAT. This timeout is |
| 117 | * expected to be used to limit power usage if the device becomes idle |
| 118 | * during enrollment. The implementation is expected to send |
| 119 | * ERROR_TIMEOUT if this happens. |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 120 | * @param disabledFeatures A list of features to be disabled during |
| 121 | * enrollment. Note that all features are enabled by default. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 122 | * @return status The status of this method call. |
| 123 | */ |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 124 | @callflow(next={"cancel", "enroll", "revokeChallenge", "remove"}) |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 125 | enroll(vec<uint8_t> hat, uint32_t timeoutSec, vec<Feature> disabledFeatures) |
Kevin Chyn | 57acf97 | 2018-08-31 15:10:03 -0700 | [diff] [blame] | 126 | generates (Status status); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 127 | |
| 128 | /** |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 129 | * Finishes the secure transaction by invalidating the challenge generated |
| 130 | * by generateChallenge(). |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 131 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 132 | * Clients must call this method once the secure transaction (e.g. enroll |
| 133 | * or setFeature) is completed. See generateChallenge(). |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 134 | * |
| 135 | * @return status The status of this method call. |
| 136 | */ |
| 137 | @callflow(next={"authenticate", "setActiveUser", "enumerate", "remove"}) |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 138 | revokeChallenge() generates (Status status); |
| 139 | |
| 140 | /** |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 141 | * Changes the state of previous enrollment setting. Because this may |
| 142 | * decrease security, the user must enter their password before this method |
| 143 | * is invoked (see @param HAT). The driver must verify the HAT before |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 144 | * changing any feature state. This method must return ILLEGAL_ARGUMENT if |
| 145 | * the HAT or faceId is invalid. This must only be invoked after |
| 146 | * setActiveUser() is called. |
| 147 | * |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 148 | * Note: In some cases it may not be possible to change the state of this |
| 149 | * flag without re-enrolling. For example, if the user didn't provide |
| 150 | * attention during the original enrollment. This flag reflects the same |
| 151 | * persistent state as the one passed to enroll(). |
| 152 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 153 | * Note: This call may block for a short amount of time (few hundred |
| 154 | * milliseconds). Clients are expected to invoke this asynchronously if it |
| 155 | * takes much longer than the above limit. Also note that the result is |
| 156 | * returned solely through Status (and not onError). |
| 157 | * |
Kevin Chyn | a009f89 | 2018-12-06 21:29:36 -0800 | [diff] [blame] | 158 | * @param feature The feature to be enabled or disabled. |
| 159 | * @param enabled True to enable the feature, false to disable. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 160 | * @param hat A valid Hardware Authentication Token, generated as a result |
| 161 | * of getChallenge(). |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 162 | * @param faceId the ID of the enrollment returned by enroll() for the |
| 163 | * feature to update. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 164 | * @return status The status of this method call. |
| 165 | */ |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 166 | setFeature(Feature feature, bool enabled, vec<uint8_t> hat, uint32_t faceId) |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 167 | generates(Status status); |
| 168 | |
| 169 | /** |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 170 | * Retrieves the current state of the feature. If the faceId is invalid, |
| 171 | * the implementation must return ILLEGAL_ARGUMENT. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 172 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 173 | * @param faceId the ID of the enrollment returned by enroll(). |
| 174 | * @return result with the value set to true if the feature is enabled, |
| 175 | * false if disabled. |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 176 | */ |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 177 | getFeature(Feature feature, uint32_t faceId) generates (OptionalBool result); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 178 | |
| 179 | /** |
| 180 | * Returns an identifier associated with the current face set. |
| 181 | * |
| 182 | * The authenticator ID must change whenever a new face is enrolled. The |
| 183 | * authenticator ID must not be changed when a face is deleted. The |
| 184 | * authenticator ID must be an entropy-encoded random number which all |
| 185 | * current templates are tied to. The authenticator ID must be immutable |
| 186 | * outside of an active enrollment window to prevent replay attacks. |
| 187 | * |
| 188 | * @return result, with its value parameter representing an |
| 189 | * "authenticatorId": an identifier associated to the user's current |
| 190 | * face enrollment. |
| 191 | */ |
| 192 | @callflow(next={"authenticate"}) |
| 193 | getAuthenticatorId() generates (OptionalUint64 result); |
| 194 | |
| 195 | /** |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 196 | * Cancels the current enroll, authenticate, remove, or enumerate operation. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 197 | * |
| 198 | * @return status The status of this method call. |
| 199 | */ |
| 200 | @callflow(next={"authenticate", "enroll", "enumerate", "remove", |
| 201 | "setActiveUser"}) |
| 202 | cancel() generates (Status status); |
| 203 | |
| 204 | /** |
| 205 | * Enumerates all face templates associated with the active user. |
| 206 | * |
| 207 | * The onEnumerate() callback method is invoked once for each face template |
| 208 | * found. |
| 209 | * |
| 210 | * @return status The status of this method call. |
| 211 | */ |
| 212 | @callflow(next={"remove", "enroll", "authenticate", "setActiveUser"}) |
| 213 | enumerate() generates (Status status); |
| 214 | |
| 215 | /** |
| 216 | * Removes a face template or all face templates associated with the active |
| 217 | * user. |
| 218 | * |
| 219 | * This method triggers the IBiometricsFaceClientCallback#onRemoved() method. |
| 220 | * |
| 221 | * @param faceId The id correpsonding to the face to be removed; or 0 if all |
| 222 | * faces are to be removed. |
| 223 | * @return status The status of this method call. |
| 224 | */ |
| 225 | @callflow(next={"enumerate", "authenticate", "cancel", "getAuthenticatorId", |
| 226 | "setActiveUser"}) |
| 227 | remove(uint32_t faceId) generates (Status status); |
| 228 | |
| 229 | /** |
| 230 | * Authenticates the active user. |
| 231 | * |
| 232 | * An optional operationId can be specified as a token from the transaction |
Kevin Chyn | ba9ec87 | 2018-09-28 16:37:45 -0700 | [diff] [blame] | 233 | * being authorized. The hardware may enter a standby state during |
| 234 | * authentication, where the device is idle to conserve power while |
| 235 | * authenticating, e.g. after 3 seconds without finding a face. See |
| 236 | * IBiometricsFace#userActivity() for more info. |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 237 | * |
| 238 | * @param operationId A non-zero operation id associated with a crypto |
| 239 | * object instance; or 0 if not being used. |
| 240 | * @return status The status of this method call. |
| 241 | */ |
Kevin Chyn | af5d0a6 | 2018-08-31 16:06:43 -0700 | [diff] [blame] | 242 | @callflow(next={"cancel", "generateChallenge", "remove"}) |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 243 | authenticate(uint64_t operationId) generates (Status status); |
Kevin Chyn | ba9ec87 | 2018-09-28 16:37:45 -0700 | [diff] [blame] | 244 | |
| 245 | /** |
| 246 | * A hint to the HAL to continue looking for faces. |
| 247 | * |
| 248 | * This method should only be used when the HAL is in the authenticating |
| 249 | * or standby state. Using this method when the HAL is not in one of the |
| 250 | * mentioned states must return OPERATION_NOT_SUPPORTED. Calling this |
| 251 | * method while the HAL is already authenticating may extend the duration |
| 252 | * where it's looking for a face. |
| 253 | * |
| 254 | * @return status The status of this method call. |
| 255 | */ |
| 256 | userActivity() generates (Status status); |
Kevin Chyn | 16d891d | 2018-12-14 16:19:38 -0800 | [diff] [blame] | 257 | |
| 258 | /** |
| 259 | * Reset lockout for the current user. |
| 260 | * |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 261 | * Note: This call may block for a short amount of time (few hundred |
| 262 | * milliseconds). Clients are expected to invoke this asynchronously if it |
| 263 | * takes much longer than the above limit. |
| 264 | * |
Kevin Chyn | 16d891d | 2018-12-14 16:19:38 -0800 | [diff] [blame] | 265 | * @param hat A valid Hardware Authentication Token, generated when the |
Kevin Chyn | 25fe23f | 2019-03-04 15:35:40 -0800 | [diff] [blame] | 266 | * user authenticates with PIN/pattern/pass. When the Hardware |
Kevin Chyn | 1c16445 | 2019-02-13 10:16:52 -0800 | [diff] [blame] | 267 | * Authentication Token is verified, lockout must be reset and |
| 268 | * onLockoutChanged must be called with duration 0. |
| 269 | * @return status The status of this method call. |
Kevin Chyn | 16d891d | 2018-12-14 16:19:38 -0800 | [diff] [blame] | 270 | */ |
Kevin Chyn | 1c16445 | 2019-02-13 10:16:52 -0800 | [diff] [blame] | 271 | resetLockout(vec<uint8_t> hat) generates (Status status); |
Zachary Iqbal | 1f70074 | 2018-04-24 23:42:21 -0700 | [diff] [blame] | 272 | }; |