1 /*
2  * Copyright (C) 2011 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 package com.android.keychain.tests.support;
17 
18 import android.accounts.Account;
19 import android.security.keystore.ParcelableKeyGenParameterSpec;
20 
21 /**
22  * Service that runs as the system user for the use of the
23  * KeyChainServiceTest which needs to run as a regular app user, but
24  * needs to automate some steps only permissable to the system
25  * user. In particular, revokeAppPermission and grantAppPermission
26  * must be run within the system_server itself. In a real application,
27  * the user is prompted to perform these steps via the
28  * com.android.credentials.UNLOCK Intent and
29  * KeyChainActivity.
30  *
31  * @hide
32  */
33 interface IKeyChainServiceTestSupport {
keystoreReset()34     boolean keystoreReset();
keystoreSetPassword(String password)35     boolean keystoreSetPassword(String password);
keystorePut(String key, in byte[] value)36     boolean keystorePut(String key, in byte[] value);
keystoreImportKey(String key, in byte[] value)37     boolean keystoreImportKey(String key, in byte[] value);
revokeAppPermission(int uid, String alias)38     void revokeAppPermission(int uid, String alias);
grantAppPermission(int uid, String alias)39     void grantAppPermission(int uid, String alias);
installKeyPair(in byte[] privateKey, in byte[] userCert, in byte[] certChain, String alias)40     boolean installKeyPair(in byte[] privateKey, in byte[] userCert, in byte[] certChain, String alias);
removeKeyPair(String alias)41     boolean removeKeyPair(String alias);
setUserSelectable(String alias, boolean isUserSelectable)42     void setUserSelectable(String alias, boolean isUserSelectable);
generateKeyPair(in String algorithm, in ParcelableKeyGenParameterSpec spec)43     int generateKeyPair(in String algorithm, in ParcelableKeyGenParameterSpec spec);
attestKey(in String alias, in byte[] challenge, in int[] idAttestationFlags)44     int attestKey(in String alias, in byte[] challenge, in int[] idAttestationFlags);
setKeyPairCertificate(String alias, in byte[] userCert, in byte[] certChain)45     boolean setKeyPairCertificate(String alias, in byte[] userCert, in byte[] certChain);
46 }
47