summaryrefslogtreecommitdiffstats
path: root/keystore/java/android/security/KeyChain.java
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-04-01 15:10:22 -0700
committerKenny Root <kroot@google.com>2013-04-02 10:34:24 -0700
commitbf556ac636a39c1d0fe5451a921b88400dd1c695 (patch)
tree46595e9d1072d3611adb6b30fa10741696a2831b /keystore/java/android/security/KeyChain.java
parent53de5c296a579e9012d152f8a25c08f6f6091b3b (diff)
downloadframeworks_base-bf556ac636a39c1d0fe5451a921b88400dd1c695.zip
frameworks_base-bf556ac636a39c1d0fe5451a921b88400dd1c695.tar.gz
frameworks_base-bf556ac636a39c1d0fe5451a921b88400dd1c695.tar.bz2
Add API to query KeyChain algorithm support
Bug: 7095660 Change-Id: Ia87caaa33bc01b032130811833f0a3c4f75b62d4
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r--keystore/java/android/security/KeyChain.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index d7119fff..e077257 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 isKeyTypeSupported(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 isBoundKeyType(String algorithm) {
+ if (!isKeyTypeSupported(algorithm)) {
+ return false;
+ }
+
+ return KeyStore.getInstance().isHardwareBacked();
+ }
+
private static X509Certificate toCertificate(byte[] bytes) {
if (bytes == null) {
throw new IllegalArgumentException("bytes == null");