diff options
author | Rob Barnes <robbarnes@google.com> | 2018-11-15 09:47:39 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-11-15 09:47:39 -0800 |
commit | 3090f045a71815082db64f40b1358d62f2a9eadd (patch) | |
tree | a9de0c6b03f3983728c83cdaaa0b5ba880284b07 /keystore/java/android/security/KeyStore.java | |
parent | 2db64c2f55f12b7cd40cc0749286a029b6f9eec5 (diff) | |
parent | 73e964019414fc2dad66d8c980d29dc3929fe18c (diff) |
Merge "Added listUidsForAuthBoundKeys to KeyStore"
am: 73e9640194
Change-Id: I3cbe9d446994348639c2dbdfd47e26cd5b4528b1
Diffstat (limited to 'keystore/java/android/security/KeyStore.java')
-rw-r--r-- | keystore/java/android/security/KeyStore.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java index 2d214a787a88..40570c1083b3 100644 --- a/keystore/java/android/security/KeyStore.java +++ b/keystore/java/android/security/KeyStore.java @@ -54,6 +54,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 java.util.concurrent.CompletableFuture; @@ -296,6 +297,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); } |