blob: cd368faddb1d9beeebdd165ccad9f4e042d9e658 [file] [log] [blame]
Zachary Iqbal1f700742018-04-24 23:42:21 -07001/*
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
17package android.hardware.biometrics.face@1.0;
18
19import IBiometricsFaceClientCallback;
20
Zachary Iqbal1f700742018-04-24 23:42:21 -070021/**
22 * The HAL interface for biometric face authentication.
23 */
24interface 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 Chyn25fe23f2019-03-04 15:35:40 -080056 * 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 Iqbal1f700742018-04-24 23:42:21 -070060 * @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 Chynaf5d0a62018-08-31 16:06:43 -070064 @callflow(next={"authenticate", "generateChallenge", "enumerate", "remove"})
Zachary Iqbal1f700742018-04-24 23:42:21 -070065 setActiveUser(int32_t userId, string storePath) generates (Status status);
66
67 /**
Kevin Chyn25fe23f2019-03-04 15:35:40 -080068 * Begins a secure transaction request, e.g. enroll() or resetLockout().
Zachary Iqbal1f700742018-04-24 23:42:21 -070069 *
70 * Generates a unique and cryptographically secure random token used to
Kevin Chynaf5d0a62018-08-31 16:06:43 -070071 * indicate the start of a secure transaction. generateChallenge() and
Kevin Chyn25fe23f2019-03-04 15:35:40 -080072 * 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 Iqbal1f700742018-04-24 23:42:21 -070075 *
Kevin Chyn25fe23f2019-03-04 15:35:40 -080076 * generateChallenge() generates a challenge which must then be wrapped by
Zachary Iqbal1f700742018-04-24 23:42:21 -070077 * gatekeeper after verifying a successful strong authentication attempt,
78 * which generates a Hardware Authentication Token. The challenge prevents
Kevin Chyn25fe23f2019-03-04 15:35:40 -080079 * 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 Iqbal1f700742018-04-24 23:42:21 -070084 *
Kevin Chyn2acfd2a2018-09-20 18:42:09 -070085 * @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 Iqbal1f700742018-04-24 23:42:21 -070088 * @return result, with its "value" parameter representing a "challenge": a
89 * unique and cryptographically secure random token.
90 */
Kevin Chyn25fe23f2019-03-04 15:35:40 -080091 @callflow(next={"enroll", "revokeChallenge", "setFeature"})
Kevin Chyn2acfd2a2018-09-20 18:42:09 -070092 generateChallenge(uint32_t challengeTimeoutSec)
93 generates (OptionalUint64 result);
Zachary Iqbal1f700742018-04-24 23:42:21 -070094
95 /**
96 * Enrolls a user's face.
97 *
Kevin Chyn25fe23f2019-03-04 15:35:40 -080098 * 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 Iqbal1f700742018-04-24 23:42:21 -0700107 *
108 * This method triggers the IBiometricsFaceClientCallback#onEnrollResult()
109 * method.
110 *
111 * @param hat A valid Hardware Authentication Token, generated as a result
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700112 * of a generateChallenge() challenge being wrapped by the gatekeeper
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800113 * 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 Chyna009f892018-12-06 21:29:36 -0800120 * @param disabledFeatures A list of features to be disabled during
121 * enrollment. Note that all features are enabled by default.
Zachary Iqbal1f700742018-04-24 23:42:21 -0700122 * @return status The status of this method call.
123 */
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700124 @callflow(next={"cancel", "enroll", "revokeChallenge", "remove"})
Kevin Chyna009f892018-12-06 21:29:36 -0800125 enroll(vec<uint8_t> hat, uint32_t timeoutSec, vec<Feature> disabledFeatures)
Kevin Chyn57acf972018-08-31 15:10:03 -0700126 generates (Status status);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700127
128 /**
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700129 * Finishes the secure transaction by invalidating the challenge generated
130 * by generateChallenge().
Zachary Iqbal1f700742018-04-24 23:42:21 -0700131 *
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800132 * Clients must call this method once the secure transaction (e.g. enroll
133 * or setFeature) is completed. See generateChallenge().
Zachary Iqbal1f700742018-04-24 23:42:21 -0700134 *
135 * @return status The status of this method call.
136 */
137 @callflow(next={"authenticate", "setActiveUser", "enumerate", "remove"})
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700138 revokeChallenge() generates (Status status);
139
140 /**
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700141 * 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 Chyn25fe23f2019-03-04 15:35:40 -0800144 * 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 Chynaf5d0a62018-08-31 16:06:43 -0700148 * 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 Chyn25fe23f2019-03-04 15:35:40 -0800153 * 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 Chyna009f892018-12-06 21:29:36 -0800158 * @param feature The feature to be enabled or disabled.
159 * @param enabled True to enable the feature, false to disable.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700160 * @param hat A valid Hardware Authentication Token, generated as a result
161 * of getChallenge().
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800162 * @param faceId the ID of the enrollment returned by enroll() for the
163 * feature to update.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700164 * @return status The status of this method call.
165 */
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800166 setFeature(Feature feature, bool enabled, vec<uint8_t> hat, uint32_t faceId)
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700167 generates(Status status);
168
169 /**
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800170 * Retrieves the current state of the feature. If the faceId is invalid,
171 * the implementation must return ILLEGAL_ARGUMENT.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700172 *
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800173 * @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 Chynaf5d0a62018-08-31 16:06:43 -0700176 */
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800177 getFeature(Feature feature, uint32_t faceId) generates (OptionalBool result);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700178
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 Chyn25fe23f2019-03-04 15:35:40 -0800196 * Cancels the current enroll, authenticate, remove, or enumerate operation.
Zachary Iqbal1f700742018-04-24 23:42:21 -0700197 *
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 Chynba9ec872018-09-28 16:37:45 -0700233 * 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 Iqbal1f700742018-04-24 23:42:21 -0700237 *
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 Chynaf5d0a62018-08-31 16:06:43 -0700242 @callflow(next={"cancel", "generateChallenge", "remove"})
Zachary Iqbal1f700742018-04-24 23:42:21 -0700243 authenticate(uint64_t operationId) generates (Status status);
Kevin Chynba9ec872018-09-28 16:37:45 -0700244
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 Chyn16d891d2018-12-14 16:19:38 -0800257
258 /**
259 * Reset lockout for the current user.
260 *
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800261 * 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 Chyn16d891d2018-12-14 16:19:38 -0800265 * @param hat A valid Hardware Authentication Token, generated when the
Kevin Chyn25fe23f2019-03-04 15:35:40 -0800266 * user authenticates with PIN/pattern/pass. When the Hardware
Kevin Chyn1c164452019-02-13 10:16:52 -0800267 * 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 Chyn16d891d2018-12-14 16:19:38 -0800270 */
Kevin Chyn1c164452019-02-13 10:16:52 -0800271 resetLockout(vec<uint8_t> hat) generates (Status status);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700272};