summaryrefslogtreecommitdiffstats
path: root/keystore/java
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-09-05 13:03:16 -0700
committerKenny Root <kroot@google.com>2013-09-05 13:27:00 -0700
commitb91773bce1126d28a93f73fbef18f3a79245f24e (patch)
treea7ab82da0330b4f4249c219dbea9efd17a2b7953 /keystore/java
parentd2676f9bd93c333ae2c7f3ca284d0fef5a7e146b (diff)
downloadframeworks_base-b91773bce1126d28a93f73fbef18f3a79245f24e.zip
frameworks_base-b91773bce1126d28a93f73fbef18f3a79245f24e.tar.gz
frameworks_base-b91773bce1126d28a93f73fbef18f3a79245f24e.tar.bz2
Add argument to binder call to check key types
Before there was only one key type supported, so we didn't need to query a key type. Now there is DSA, EC, and RSA, so there needs to be another argument. Bug: 10600582 Change-Id: I9fe9e46b9ec9cfb2f1246179b2c396216b2c1fdb
Diffstat (limited to 'keystore/java')
-rw-r--r--keystore/java/android/security/KeyChain.java6
-rw-r--r--keystore/java/android/security/KeyStore.java9
2 files changed, 12 insertions, 3 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index 9ea325a..8ad973d 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -34,6 +34,7 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.List;
+import java.util.Locale;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -364,7 +365,8 @@ public final class KeyChain {
* "RSA").
*/
public static boolean isKeyAlgorithmSupported(String algorithm) {
- return "RSA".equals(algorithm);
+ final String algUpper = algorithm.toUpperCase(Locale.US);
+ return "DSA".equals(algUpper) || "EC".equals(algUpper) || "RSA".equals(algUpper);
}
/**
@@ -379,7 +381,7 @@ public final class KeyChain {
return false;
}
- return KeyStore.getInstance().isHardwareBacked();
+ return KeyStore.getInstance().isHardwareBacked(algorithm);
}
private static X509Certificate toCertificate(byte[] bytes) {
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index 9babb94..6ac49ee 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -22,6 +22,8 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
+import java.util.Locale;
+
/**
* @hide This should not be made public in its present form because it
* assumes that private and secret key bytes are available and would
@@ -306,9 +308,14 @@ public class KeyStore {
}
}
+ // TODO remove this when it's removed from Settings
public boolean isHardwareBacked() {
+ return isHardwareBacked("RSA");
+ }
+
+ public boolean isHardwareBacked(String keyType) {
try {
- return mBinder.is_hardware_backed() == NO_ERROR;
+ return mBinder.is_hardware_backed(keyType.toUpperCase(Locale.US)) == NO_ERROR;
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return false;