1 /*
2  * Copyright (C) 2015 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.service.gatekeeper;
18 
19 import android.service.gatekeeper.GateKeeperResponse;
20 
21 /**
22  * Interface for communication with GateKeeper, the
23  * secure password storage daemon.
24  *
25  * This must be kept manually in sync with system/core/gatekeeperd
26  * until AIDL can generate both C++ and Java bindings.
27  *
28  * @hide
29  */
30 @SensitiveData
31 interface IGateKeeperService {
32     /**
33      * Enrolls a password, returning the handle to the enrollment to be stored locally.
34      * @param userId The Android user ID associated to this enrollment
35      * @param currentPasswordHandle The previously enrolled handle, or null if none
36      * @param currentPassword The previously enrolled plaintext password, or null if none.
37      *                        If provided, must verify against the currentPasswordHandle.
38      * @param desiredPassword The new desired password, for which a handle will be returned
39      *                        upon success.
40      * @return an EnrollResponse or null on failure
41      */
enroll(int userId, in @nullable byte[] currentPasswordHandle, in @nullable byte[] currentPassword, in byte[] desiredPassword)42     GateKeeperResponse enroll(int userId, in @nullable byte[] currentPasswordHandle,
43             in @nullable byte[] currentPassword, in byte[] desiredPassword);
44 
45     /**
46      * Verifies an enrolled handle against a provided, plaintext blob.
47      * @param userId The Android user ID associated to this enrollment
48      * @param enrolledPasswordHandle The handle against which the provided password will be
49      *                               verified.
50      * @param The plaintext blob to verify against enrolledPassword.
51      * @return a VerifyResponse, or null on failure.
52      */
verify(int userId, in byte[] enrolledPasswordHandle, in byte[] providedPassword)53     GateKeeperResponse verify(int userId, in byte[] enrolledPasswordHandle, in byte[] providedPassword);
54 
55     /**
56      * Verifies an enrolled handle against a provided, plaintext blob.
57      * @param userId The Android user ID associated to this enrollment
58      * @param challenge a challenge to authenticate agaisnt the device credential. If successful
59      *                  authentication occurs, this value will be written to the returned
60      *                  authentication attestation.
61      * @param enrolledPasswordHandle The handle against which the provided password will be
62      *                               verified.
63      * @param The plaintext blob to verify against enrolledPassword.
64      * @return a VerifyResponse with an attestation, or null on failure.
65      */
verifyChallenge(int userId, long challenge, in byte[] enrolledPasswordHandle, in byte[] providedPassword)66     GateKeeperResponse verifyChallenge(int userId, long challenge, in byte[] enrolledPasswordHandle,
67             in byte[] providedPassword);
68 
69     /**
70      * Retrieves the secure identifier for the user with the provided Android ID,
71      * or 0 if none is found.
72      * @param userId the Android user id
73      */
getSecureUserId(int userId)74     long getSecureUserId(int userId);
75 
76     /**
77      * Clears secure user id associated with the provided Android ID.
78      * Must be called when password is set to NONE.
79      * @param userId the Android user id.
80      */
clearSecureUserId(int userId)81     void clearSecureUserId(int userId);
82 
83     /**
84      * Notifies gatekeeper that device setup has been completed and any potentially still existing
85      * state from before a factory reset can be cleaned up (if it has not been already).
86      */
reportDeviceSetupComplete()87     void reportDeviceSetupComplete();
88 }
89