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 | */ |
| 63 | @callflow(next={"authenticate", "preEnroll", "enumerate", "remove"}) |
| 64 | setActiveUser(int32_t userId, string storePath) generates (Status status); |
| 65 | |
| 66 | /** |
| 67 | * Begins a pre-enrollment request. |
| 68 | * |
| 69 | * Generates a unique and cryptographically secure random token used to |
| 70 | * indicate the start of an enrollment transaction. preEnroll() and |
| 71 | * postEnroll() specify a pin/pattern/password cleared time window where |
| 72 | * enrollment is allowed. |
| 73 | * |
| 74 | * preEnroll() generates a challenge which must then be wrapped by the |
| 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 | * |
| 81 | * @return result, with its "value" parameter representing a "challenge": a |
| 82 | * unique and cryptographically secure random token. |
| 83 | */ |
| 84 | @callflow(next={"enroll", "postEnroll"}) |
| 85 | preEnroll() generates (OptionalUint64 result); |
| 86 | |
| 87 | /** |
| 88 | * Enrolls a user's face. |
| 89 | * |
| 90 | * Note that this interface permits implementations where multiple faces can |
| 91 | * be enrolled for a single user. However, allowing multiple faces to be |
| 92 | * enrolled can be a severe security vulnerability and hence, most |
| 93 | * implementations must ensure that only a single face be enrolled at a |
| 94 | * given time. Multi-enrollment must only be used where there is a clear |
| 95 | * necessity for a shared use case, e.g. TVs or cars. |
| 96 | * |
| 97 | * Note that the Hardware Authentication Token must still be valid after |
| 98 | * this call, and must be explicitly invalidated by a call to postEnroll(). |
| 99 | * This allows clients to immediately reattempt enrollment (for example, if |
| 100 | * a user wasn’t satisfied with their enrollment) without having to go |
| 101 | * through another strong authentication flow. |
| 102 | * |
| 103 | * This method triggers the IBiometricsFaceClientCallback#onEnrollResult() |
| 104 | * method. |
| 105 | * |
| 106 | * @param hat A valid Hardware Authentication Token, generated as a result |
| 107 | * of a preEnroll() challenge being wrapped by the gatekeeper after a |
| 108 | * sucessful strong authentication request. |
| 109 | * @param timeoutSec A timeout in seconds, after which this enrollment |
| 110 | * attempt is cancelled. Note that the client still needs to |
| 111 | * call postEnroll() to terminate the enrollment session. |
| 112 | * @return status The status of this method call. |
| 113 | */ |
| 114 | @callflow(next={"cancel", "enroll", "postEnroll", "remove"}) |
| 115 | enroll(vec<uint8_t> hat, uint32_t timeoutSec) generates (Status status); |
| 116 | |
| 117 | /** |
| 118 | * Finishes the enrollment session and invalidates the challenge generated |
| 119 | * by preEnroll(). |
| 120 | * |
| 121 | * Clients must call this method once enrollment is complete, and the user's |
| 122 | * face template no longer needs to be updated. |
| 123 | * |
| 124 | * @return status The status of this method call. |
| 125 | */ |
| 126 | @callflow(next={"authenticate", "setActiveUser", "enumerate", "remove"}) |
| 127 | postEnroll() generates (Status status); |
| 128 | |
| 129 | /** |
| 130 | * Returns an identifier associated with the current face set. |
| 131 | * |
| 132 | * The authenticator ID must change whenever a new face is enrolled. The |
| 133 | * authenticator ID must not be changed when a face is deleted. The |
| 134 | * authenticator ID must be an entropy-encoded random number which all |
| 135 | * current templates are tied to. The authenticator ID must be immutable |
| 136 | * outside of an active enrollment window to prevent replay attacks. |
| 137 | * |
| 138 | * @return result, with its value parameter representing an |
| 139 | * "authenticatorId": an identifier associated to the user's current |
| 140 | * face enrollment. |
| 141 | */ |
| 142 | @callflow(next={"authenticate"}) |
| 143 | getAuthenticatorId() generates (OptionalUint64 result); |
| 144 | |
| 145 | /** |
| 146 | * Cancels a pending enrollment or authentication request. |
| 147 | * |
| 148 | * @return status The status of this method call. |
| 149 | */ |
| 150 | @callflow(next={"authenticate", "enroll", "enumerate", "remove", |
| 151 | "setActiveUser"}) |
| 152 | cancel() generates (Status status); |
| 153 | |
| 154 | /** |
| 155 | * Enumerates all face templates associated with the active user. |
| 156 | * |
| 157 | * The onEnumerate() callback method is invoked once for each face template |
| 158 | * found. |
| 159 | * |
| 160 | * @return status The status of this method call. |
| 161 | */ |
| 162 | @callflow(next={"remove", "enroll", "authenticate", "setActiveUser"}) |
| 163 | enumerate() generates (Status status); |
| 164 | |
| 165 | /** |
| 166 | * Removes a face template or all face templates associated with the active |
| 167 | * user. |
| 168 | * |
| 169 | * This method triggers the IBiometricsFaceClientCallback#onRemoved() method. |
| 170 | * |
| 171 | * @param faceId The id correpsonding to the face to be removed; or 0 if all |
| 172 | * faces are to be removed. |
| 173 | * @return status The status of this method call. |
| 174 | */ |
| 175 | @callflow(next={"enumerate", "authenticate", "cancel", "getAuthenticatorId", |
| 176 | "setActiveUser"}) |
| 177 | remove(uint32_t faceId) generates (Status status); |
| 178 | |
| 179 | /** |
| 180 | * Authenticates the active user. |
| 181 | * |
| 182 | * An optional operationId can be specified as a token from the transaction |
| 183 | * being authorized. |
| 184 | * |
| 185 | * @param operationId A non-zero operation id associated with a crypto |
| 186 | * object instance; or 0 if not being used. |
| 187 | * @return status The status of this method call. |
| 188 | */ |
| 189 | @callflow(next={"cancel", "preEnroll", "remove"}) |
| 190 | authenticate(uint64_t operationId) generates (Status status); |
| 191 | }; |