[DO NOT MERGE] Rollup changes from R related to CertInstaller and KeyChain
This change includes the following commits that are related to CertInstaller and KeyChain: 7a5c8fe4afd KeyChain: Unify manual and programmatic key installation flows a894225c7da Added functionality to select type of certificate to be installed from the Settings app a9131939a35 Add KeyChain.KEY_ALIAS_SELECTION_DENIED constant. 485be505f19 Fix KeyChain.KEY_ALIAS_SELECTION_DENIED Bug: 161347472 Test: builds & manual testing Change-Id: I560bade479b41a5b88f81ea6dfdecba689c2f4ad
This commit is contained in:
@@ -41088,6 +41088,7 @@ package android.security {
|
||||
field public static final String EXTRA_KEY_ALIAS = "android.security.extra.KEY_ALIAS";
|
||||
field public static final String EXTRA_NAME = "name";
|
||||
field public static final String EXTRA_PKCS12 = "PKCS12";
|
||||
field public static final String KEY_ALIAS_SELECTION_DENIED = "android:alias-selection-denied";
|
||||
}
|
||||
|
||||
public interface KeyChainAliasCallback {
|
||||
|
||||
@@ -63,6 +63,10 @@ public class DelegatedAdminReceiver extends BroadcastReceiver {
|
||||
* Allows this receiver to select the alias for a private key and certificate pair for
|
||||
* authentication. If this method returns null, the default {@link android.app.Activity} will
|
||||
* be shown that lets the user pick a private key and certificate pair.
|
||||
* If this method returns {@link KeyChain#KEY_ALIAS_SELECTION_DENIED},
|
||||
* the default {@link android.app.Activity} will not be shown and the user will not be allowed
|
||||
* to pick anything. And the app, that called {@link KeyChain#choosePrivateKeyAlias}, will
|
||||
* receive {@code null} back.
|
||||
*
|
||||
* <p> This callback is only applicable if the delegated app has
|
||||
* {@link DevicePolicyManager#DELEGATION_CERT_SELECTION} capability. Additionally, it must
|
||||
|
||||
@@ -791,6 +791,10 @@ public class DeviceAdminReceiver extends BroadcastReceiver {
|
||||
* Allows this receiver to select the alias for a private key and certificate pair for
|
||||
* authentication. If this method returns null, the default {@link android.app.Activity} will be
|
||||
* shown that lets the user pick a private key and certificate pair.
|
||||
* If this method returns {@link KeyChain#KEY_ALIAS_SELECTION_DENIED},
|
||||
* the default {@link android.app.Activity} will not be shown and the user will not be allowed
|
||||
* to pick anything. And the app, that called {@link KeyChain#choosePrivateKeyAlias}, will
|
||||
* receive {@code null} back.
|
||||
*
|
||||
* @param context The running context as per {@link #onReceive}.
|
||||
* @param intent The received intent as per {@link #onReceive}.
|
||||
|
||||
@@ -2422,6 +2422,11 @@ enum PageId {
|
||||
// OS: Q
|
||||
SETTINGS_GESTURE_TAP = 1751;
|
||||
|
||||
// OPEN: Settings > Security & screen lock -> Encryption & credentials > Install a certificate
|
||||
// CATEGORY: SETTINGS
|
||||
// OS: R
|
||||
INSTALL_CERTIFICATE_FROM_STORAGE = 1803;
|
||||
|
||||
// OPEN: Settings > Developer Options > Platform Compat
|
||||
// CATEGORY: SETTINGS
|
||||
// OS: R
|
||||
|
||||
@@ -74,6 +74,15 @@ public class Credentials {
|
||||
/** Key containing suffix of lockdown VPN profile. */
|
||||
public static final String LOCKDOWN_VPN = "LOCKDOWN_VPN";
|
||||
|
||||
/** Name of CA certificate usage. */
|
||||
public static final String CERTIFICATE_USAGE_CA = "ca";
|
||||
|
||||
/** Name of User certificate usage. */
|
||||
public static final String CERTIFICATE_USAGE_USER = "user";
|
||||
|
||||
/** Name of WIFI certificate usage. */
|
||||
public static final String CERTIFICATE_USAGE_WIFI = "wifi";
|
||||
|
||||
/** Data type for public keys. */
|
||||
public static final String EXTRA_PUBLIC_KEY = "KEY";
|
||||
|
||||
@@ -94,30 +103,25 @@ public class Credentials {
|
||||
public static final String EXTRA_INSTALL_AS_UID = "install_as_uid";
|
||||
|
||||
/**
|
||||
* Intent extra: name for the user's private key.
|
||||
* Intent extra: type of the certificate to install
|
||||
*/
|
||||
public static final String EXTRA_USER_PRIVATE_KEY_NAME = "user_private_key_name";
|
||||
public static final String EXTRA_CERTIFICATE_USAGE = "certificate_install_usage";
|
||||
|
||||
/**
|
||||
* Intent extra: name for the user's key pair.
|
||||
*/
|
||||
public static final String EXTRA_USER_KEY_ALIAS = "user_key_pair_name";
|
||||
|
||||
/**
|
||||
* Intent extra: data for the user's private key in PEM-encoded PKCS#8.
|
||||
*/
|
||||
public static final String EXTRA_USER_PRIVATE_KEY_DATA = "user_private_key_data";
|
||||
|
||||
/**
|
||||
* Intent extra: name for the user's certificate.
|
||||
*/
|
||||
public static final String EXTRA_USER_CERTIFICATE_NAME = "user_certificate_name";
|
||||
|
||||
/**
|
||||
* Intent extra: data for the user's certificate in PEM-encoded X.509.
|
||||
*/
|
||||
public static final String EXTRA_USER_CERTIFICATE_DATA = "user_certificate_data";
|
||||
|
||||
/**
|
||||
* Intent extra: name for CA certificate chain
|
||||
*/
|
||||
public static final String EXTRA_CA_CERTIFICATES_NAME = "ca_certificates_name";
|
||||
|
||||
/**
|
||||
* Intent extra: data for CA certificate chain in PEM-encoded X.509.
|
||||
*/
|
||||
|
||||
@@ -43,7 +43,8 @@ interface IKeyChainService {
|
||||
String installCaCertificate(in byte[] caCertificate);
|
||||
|
||||
// APIs used by DevicePolicyManager
|
||||
boolean installKeyPair(in byte[] privateKey, in byte[] userCert, in byte[] certChain, String alias);
|
||||
boolean installKeyPair(
|
||||
in byte[] privateKey, in byte[] userCert, in byte[] certChain, String alias, int uid);
|
||||
boolean removeKeyPair(String alias);
|
||||
|
||||
// APIs used by Settings
|
||||
|
||||
@@ -342,6 +342,16 @@ public final class KeyChain {
|
||||
*/
|
||||
public static final int KEY_ATTESTATION_FAILURE = 4;
|
||||
|
||||
/**
|
||||
* Used by DPC or delegated app in
|
||||
* {@link android.app.admin.DeviceAdminReceiver#onChoosePrivateKeyAlias} or
|
||||
* {@link android.app.admin.DelegatedAdminReceiver#onChoosePrivateKeyAlias} to identify that
|
||||
* the requesting app is not granted access to any key, and nor will the user be able to grant
|
||||
* access manually.
|
||||
*/
|
||||
public static final String KEY_ALIAS_SELECTION_DENIED =
|
||||
"android:alias-selection-denied";
|
||||
|
||||
/**
|
||||
* Returns an {@code Intent} that can be used for credential
|
||||
* installation. The intent may be used without any extras, in
|
||||
|
||||
@@ -40944,6 +40944,7 @@ package android.security {
|
||||
field public static final String EXTRA_KEY_ALIAS = "android.security.extra.KEY_ALIAS";
|
||||
field public static final String EXTRA_NAME = "name";
|
||||
field public static final String EXTRA_PKCS12 = "PKCS12";
|
||||
field public static final String KEY_ALIAS_SELECTION_DENIED = "android:alias-selection-denied";
|
||||
}
|
||||
|
||||
public interface KeyChainAliasCallback {
|
||||
|
||||
@@ -5672,7 +5672,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
KeyChain.bindAsUser(mContext, UserHandle.getUserHandleForUid(callingUid));
|
||||
try {
|
||||
IKeyChainService keyChain = keyChainConnection.getService();
|
||||
if (!keyChain.installKeyPair(privKey, cert, chain, alias)) {
|
||||
if (!keyChain.installKeyPair(privKey, cert, chain, alias, KeyStore.UID_SELF)) {
|
||||
return false;
|
||||
}
|
||||
if (requestAccess) {
|
||||
|
||||
Reference in New Issue
Block a user