summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/KeyStore.java
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2018-11-13 15:57:22 -0700
committerRob Barnes <robbarnes@google.com>2018-11-14 13:14:35 -0700
commitf1a678e0fedb23c53eb1890bd5a8bd8fc5438846 (patch)
tree6bd169841cc851673246f54439004f1736883275 /keystore/java/android/security/KeyStore.java
parent4a7a3934b606e5484524e190f67fe09e938613a2 (diff)
Added listUidsForAuthBoundKeys to KeyStore
listUidsForAuthBoundKeys was added to IKeyStoreService. This CL exposes this method in KeyStore for system apps. This method will be hidden for non system apps. Bug: b/112321280 Test: listUidsForAuthBoundKeys in IKeyStoreService has its own tests Test: This method cannot be tested directly from CTS Change-Id: Iac9e863079a1367ddb3a599bc3825baea96a1c31
Diffstat (limited to 'keystore/java/android/security/KeyStore.java')
-rw-r--r--keystore/java/android/security/KeyStore.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index 4e018833f1ff..1186ab4d7977 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -52,6 +52,7 @@ import java.math.BigInteger;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.InvalidKeyException;
+import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import sun.security.util.ObjectIdentifier;
@@ -292,6 +293,31 @@ public class KeyStore {
}
}
+ /**
+ * List uids of all keys that are auth bound to the current user.
+ * Only system is allowed to call this method.
+ */
+ @UnsupportedAppUsage
+ public int[] listUidsOfAuthBoundKeys() {
+ final int MAX_RESULT_SIZE = 100;
+ int[] uidsOut = new int[MAX_RESULT_SIZE];
+ try {
+ int rc = mBinder.listUidsOfAuthBoundKeys(uidsOut);
+ if (rc != NO_ERROR) {
+ Log.w(TAG, String.format("listUidsOfAuthBoundKeys failed with error code %d", rc));
+ return null;
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "Cannot connect to keystore", e);
+ return null;
+ } catch (android.os.ServiceSpecificException e) {
+ Log.w(TAG, "KeyStore exception", e);
+ return null;
+ }
+ // Remove any 0 entries
+ return Arrays.stream(uidsOut).filter(x -> x > 0).toArray();
+ }
+
public String[] list(String prefix) {
return list(prefix, UID_SELF);
}