summaryrefslogtreecommitdiffstats
path: root/keystore/java
diff options
context:
space:
mode:
Diffstat (limited to 'keystore/java')
-rw-r--r--keystore/java/android/security/KeyChain.java24
-rw-r--r--keystore/java/android/security/KeyStore.java9
2 files changed, 33 insertions, 0 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index d7119fff..c99dff0 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -356,6 +356,30 @@ public final class KeyChain {
}
}
+ /**
+ * Returns {@code true} if the current device's {@code KeyChain} supports a
+ * specific {@code PrivateKey} type indicated by {@code algorithm} (e.g.,
+ * "RSA").
+ */
+ public static boolean isKeyAlgorithmSupported(String algorithm) {
+ return "RSA".equals(algorithm);
+ }
+
+ /**
+ * Returns {@code true} if the current device's {@code KeyChain} binds any
+ * {@code PrivateKey} of the given {@code algorithm} to the device once
+ * imported or generated. This can be used to tell if there is special
+ * hardware support that can be used to bind keys to the device in a way
+ * that makes it non-exportable.
+ */
+ public static boolean isBoundKeyAlgorithm(String algorithm) {
+ if (!isKeyAlgorithmSupported(algorithm)) {
+ return false;
+ }
+
+ return KeyStore.getInstance().isHardwareBacked();
+ }
+
private static X509Certificate toCertificate(byte[] bytes) {
if (bytes == null) {
throw new IllegalArgumentException("bytes == null");
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index 2037472..852f0bb 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -305,6 +305,15 @@ public class KeyStore {
}
}
+ public boolean clearUid(int uid) {
+ try {
+ return mBinder.clear_uid(uid) == NO_ERROR;
+ } catch (RemoteException e) {
+ Log.w(TAG, "Cannot connect to keystore", e);
+ return false;
+ }
+ }
+
public int getLastError() {
return mError;
}