blob: ee67497ae3295a96f2f8508cc85d932476eb940d [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 Chyna009f892018-12-06 21:29:36 -080087 @callflow(next={"enroll", "revokeChallenge", "setFeatureDisabled"})
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 Chyna009f892018-12-06 21:29:36 -0800116 * @param disabledFeatures A list of features to be disabled during
117 * enrollment. Note that all features are enabled by default.
Zachary Iqbal1f700742018-04-24 23:42:21 -0700118 * @return status The status of this method call.
119 */
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700120 @callflow(next={"cancel", "enroll", "revokeChallenge", "remove"})
Kevin Chyna009f892018-12-06 21:29:36 -0800121 enroll(vec<uint8_t> hat, uint32_t timeoutSec, vec<Feature> disabledFeatures)
Kevin Chyn57acf972018-08-31 15:10:03 -0700122 generates (Status status);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700123
124 /**
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700125 * Finishes the secure transaction by invalidating the challenge generated
126 * by generateChallenge().
Zachary Iqbal1f700742018-04-24 23:42:21 -0700127 *
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 Chynaf5d0a62018-08-31 16:06:43 -0700134 revokeChallenge() generates (Status status);
135
136 /**
Kevin Chyna009f892018-12-06 21:29:36 -0800137 * Requires all subsequent enroll/authenticate calls to use the feature.
138 * This method does not affect enroll, which has its own feature list.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700139 *
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 Chyna009f892018-12-06 21:29:36 -0800143 * changing any feature state.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700144 * 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 Chyna009f892018-12-06 21:29:36 -0800149 * @param feature The feature to be enabled or disabled.
150 * @param enabled True to enable the feature, false to disable.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700151 * @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 Chyna009f892018-12-06 21:29:36 -0800155 setFeature(Feature feature, bool enabled, vec<uint8_t> hat)
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700156 generates(Status status);
157
158 /**
Kevin Chyna009f892018-12-06 21:29:36 -0800159 * Retrieves the current state of the feature.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700160 *
Kevin Chyna009f892018-12-06 21:29:36 -0800161 * @return enabled True if the feature is enabled, false if disabled.
Kevin Chynaf5d0a62018-08-31 16:06:43 -0700162 */
Kevin Chyna009f892018-12-06 21:29:36 -0800163 getFeature(Feature feature) generates (bool enabled);
Zachary Iqbal1f700742018-04-24 23:42:21 -0700164
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 Chynba9ec872018-09-28 16:37:45 -0700219 * 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 Iqbal1f700742018-04-24 23:42:21 -0700223 *
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 Chynaf5d0a62018-08-31 16:06:43 -0700228 @callflow(next={"cancel", "generateChallenge", "remove"})
Zachary Iqbal1f700742018-04-24 23:42:21 -0700229 authenticate(uint64_t operationId) generates (Status status);
Kevin Chynba9ec872018-09-28 16:37:45 -0700230
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 Iqbal1f700742018-04-24 23:42:21 -0700243};