blob: 0ac788ed86011e8e1e322ad98400c867caf1a8e5 [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
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 */
27interface 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 Chynaf5d0a62018-08-31 16:06:43 -070063 @callflow(next={"authenticate", "generateChallenge", "enumerate", "remove"})
Zachary Iqbal1f700742018-04-24 23:42:21 -070064 setActiveUser(int32_t userId, string storePath) generates (Status status);
65
66 /**
Kevin Chynaf5d0a62018-08-31 16:06:43 -070067 * Begins a secure transaction request, e.g. enrollment.
Zachary Iqbal1f700742018-04-24 23:42:21 -070068 *
69 * Generates a unique and cryptographically secure random token used to
Kevin Chynaf5d0a62018-08-31 16:06:43 -070070 * 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 Iqbal1f700742018-04-24 23:42:21 -070073 *
Kevin Chynaf5d0a62018-08-31 16:06:43 -070074 * generateChallenge() generates a challenge which must then be wrapped by the
Zachary Iqbal1f700742018-04-24 23:42:21 -070075 * 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 Chyn2acfd2a2018-09-20 18:42:09 -070081 * @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 Iqbal1f700742018-04-24 23:42:21 -070084 * @return result, with its "value" parameter representing a "challenge": a
85 * unique and cryptographically secure random token.
86 */
Kevin Chynaf5d0a62018-08-31 16:06:43 -070087 @callflow(next={"enroll", "revokeChallenge", "setRequireAttention"})
Kevin Chyn2acfd2a2018-09-20 18:42:09 -070088 generateChallenge(uint32_t challengeTimeoutSec)
89 generates (OptionalUint64 result);
Zachary Iqbal1f700742018-04-24 23:42:21 -070090
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 Chynaf5d0a62018-08-31 16:06:43 -0700102 * 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 Iqbal1f700742018-04-24 23:42:21 -0700106 *
107 * This method triggers the IBiometricsFaceClientCallback#onEnrollResult()
108 * method.
109 *
110 * @param hat A valid Hardware Authentication Token, generated as a result
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700111 * of a generateChallenge() challenge being wrapped by the gatekeeper
112 * after a sucessful strong authentication request.
Zachary Iqbal1f700742018-04-24 23:42:21 -0700113 * @param timeoutSec A timeout in seconds, after which this enrollment
114 * attempt is cancelled. Note that the client still needs to
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700115 * call revokeChallenge() to terminate the enrollment session.
Kevin Chyn57acf972018-08-31 15:10:03 -0700116 * @param requireAttention When set to true, requires user attention (e.g.
117 * eyes open and looking at the device) for enrollment to complete, as
118 * well as subsequent authentication. This is expected to be enabled by
119 * default to improve security and decrease falsing (unintentional face
120 * detection). This feature can be disabled at the user's request
121 * during enrollment, e.g. for accessibility reasons. When enabled,
122 * the FaceAcquiredInfo#POOR_GAZE message must be sent when the user's
123 * attention has not been established. The UI should inform the user
124 * to look at the device.
Zachary Iqbal1f700742018-04-24 23:42:21 -0700125 * @return status The status of this method call.
126 */
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700127 @callflow(next={"cancel", "enroll", "revokeChallenge", "remove"})
Kevin Chyn57acf972018-08-31 15:10:03 -0700128 enroll(vec<uint8_t> hat, uint32_t timeoutSec, bool requireAttention)
129 generates (Status status);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700130
131 /**
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700132 * Finishes the secure transaction by invalidating the challenge generated
133 * by generateChallenge().
Zachary Iqbal1f700742018-04-24 23:42:21 -0700134 *
135 * Clients must call this method once enrollment is complete, and the user's
136 * face template no longer needs to be updated.
137 *
138 * @return status The status of this method call.
139 */
140 @callflow(next={"authenticate", "setActiveUser", "enumerate", "remove"})
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700141 revokeChallenge() generates (Status status);
142
143 /**
144 * Requires that all subsequent authenticate calls to first have the
145 * user's attention. This method does not affect enroll, which has its
146 * own requireAttention parameter.
147 *
148 * Changes the state of previous enrollment setting. Because this may
149 * decrease security, the user must enter their password before this method
150 * is invoked (see @param HAT). The driver must verify the HAT before
151 * changing the requireAttention state.
152 * Note: In some cases it may not be possible to change the state of this
153 * flag without re-enrolling. For example, if the user didn't provide
154 * attention during the original enrollment. This flag reflects the same
155 * persistent state as the one passed to enroll().
156 *
157 * @param requireAttention When set to true, requires user attention for
158 * authentication to succeed.
159 * @param hat A valid Hardware Authentication Token, generated as a result
160 * of getChallenge().
161 * @return status The status of this method call.
162 */
163 setRequireAttention(bool requireAttention, vec<uint8_t> hat)
164 generates(Status status);
165
166 /**
167 * Retrieves the current requireAttention state.
168 *
169 * @return result, with its value parameter representing the current
170 * requireAttention state.
171 */
172 getRequireAttention(vec<uint8_t> hat) generates (OptionalBool result);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700173
174 /**
175 * Returns an identifier associated with the current face set.
176 *
177 * The authenticator ID must change whenever a new face is enrolled. The
178 * authenticator ID must not be changed when a face is deleted. The
179 * authenticator ID must be an entropy-encoded random number which all
180 * current templates are tied to. The authenticator ID must be immutable
181 * outside of an active enrollment window to prevent replay attacks.
182 *
183 * @return result, with its value parameter representing an
184 * "authenticatorId": an identifier associated to the user's current
185 * face enrollment.
186 */
187 @callflow(next={"authenticate"})
188 getAuthenticatorId() generates (OptionalUint64 result);
189
190 /**
191 * Cancels a pending enrollment or authentication request.
192 *
193 * @return status The status of this method call.
194 */
195 @callflow(next={"authenticate", "enroll", "enumerate", "remove",
196 "setActiveUser"})
197 cancel() generates (Status status);
198
199 /**
200 * Enumerates all face templates associated with the active user.
201 *
202 * The onEnumerate() callback method is invoked once for each face template
203 * found.
204 *
205 * @return status The status of this method call.
206 */
207 @callflow(next={"remove", "enroll", "authenticate", "setActiveUser"})
208 enumerate() generates (Status status);
209
210 /**
211 * Removes a face template or all face templates associated with the active
212 * user.
213 *
214 * This method triggers the IBiometricsFaceClientCallback#onRemoved() method.
215 *
216 * @param faceId The id correpsonding to the face to be removed; or 0 if all
217 * faces are to be removed.
218 * @return status The status of this method call.
219 */
220 @callflow(next={"enumerate", "authenticate", "cancel", "getAuthenticatorId",
221 "setActiveUser"})
222 remove(uint32_t faceId) generates (Status status);
223
224 /**
225 * Authenticates the active user.
226 *
227 * An optional operationId can be specified as a token from the transaction
Kevin Chynba9ec872018-09-28 16:37:45 -0700228 * being authorized. The hardware may enter a standby state during
229 * authentication, where the device is idle to conserve power while
230 * authenticating, e.g. after 3 seconds without finding a face. See
231 * IBiometricsFace#userActivity() for more info.
Zachary Iqbal1f700742018-04-24 23:42:21 -0700232 *
233 * @param operationId A non-zero operation id associated with a crypto
234 * object instance; or 0 if not being used.
235 * @return status The status of this method call.
236 */
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700237 @callflow(next={"cancel", "generateChallenge", "remove"})
Zachary Iqbal1f700742018-04-24 23:42:21 -0700238 authenticate(uint64_t operationId) generates (Status status);
Kevin Chynba9ec872018-09-28 16:37:45 -0700239
240 /**
241 * A hint to the HAL to continue looking for faces.
242 *
243 * This method should only be used when the HAL is in the authenticating
244 * or standby state. Using this method when the HAL is not in one of the
245 * mentioned states must return OPERATION_NOT_SUPPORTED. Calling this
246 * method while the HAL is already authenticating may extend the duration
247 * where it's looking for a face.
248 *
249 * @return status The status of this method call.
250 */
251 userActivity() generates (Status status);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700252};