diff options
author | Kenny Root <kroot@google.com> | 2013-04-01 15:10:22 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2013-04-02 10:34:24 -0700 |
commit | bf556ac636a39c1d0fe5451a921b88400dd1c695 (patch) | |
tree | 46595e9d1072d3611adb6b30fa10741696a2831b /keystore/java | |
parent | 53de5c296a579e9012d152f8a25c08f6f6091b3b (diff) | |
download | frameworks_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')
-rw-r--r-- | keystore/java/android/security/KeyChain.java | 24 |
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"); |