summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/KeyChain.java
diff options
context:
space:
mode:
authorEran Messeri <eranm@google.com>2018-07-09 17:58:26 +0100
committerEran Messeri <eranm@google.com>2018-07-17 12:58:13 +0100
commit607a995691dcda1475042ddcd4e4cba708c791be (patch)
tree1d944e1c9c1b893e5bd8fd336114384075435d63 /keystore/java/android/security/KeyChain.java
parent309adbff03ea6e0dedd232375a9f0583a7a80049 (diff)
DPM: Propagate StrongBox-related exception
When the caller attempts to generate a key via DevicePolicyManager (using DevicePolicyManager.generateKeyPair), and specifies that StrongBox should be used, throw the right exception indicating StrongBox unavailability - the same one that is thrown if the same parameters were passed to the KeyStore's key generation method. This is achieved by catching the StrongBoxUnavailableException in KeyChain, returning an error code indicating this particular failure to the DevicePolicyManagerService, which then propagates it by throwing a service-specific exception with a value indicating StrongBox unavailability. The DevicePolicyManager then raises StrongBoxUnavailableException. Prior to this change the exception propagated from KeyChain would be a generic failure so the caller would simply get a null result. Bug: 110882855 Bug: 111183576 Bug: 111322478 Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.MixedDeviceOwnerTest#testKeyManagement Change-Id: I9abe3f449b48eb5a960fafbc15c59b9b4ce7a966
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r--keystore/java/android/security/KeyChain.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index 030fa60abfd3..78dbb6ae0df3 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -283,10 +283,16 @@ public final class KeyChain {
public static final int KEY_GEN_NO_KEYSTORE_PROVIDER = 5;
/**
+ * StrongBox unavailable when calling {@link #generateKeyPair}
+ * @hide
+ */
+ public static final int KEY_GEN_STRONGBOX_UNAVAILABLE = 6;
+
+ /**
* General failure while calling {@link #generateKeyPair}
* @hide
*/
- public static final int KEY_GEN_FAILURE = 6;
+ public static final int KEY_GEN_FAILURE = 7;
/**
* Successful call to {@link #attestKey}