summaryrefslogtreecommitdiffstats
path: root/keystore/java/android/security/KeyChain.java
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2011-06-07 13:45:33 -0700
committerBrian Carlstrom <bdc@google.com>2011-06-07 15:33:09 -0700
commit9d7faa91be6661eccf73494f1ab96ae9a28d42d7 (patch)
tree85bf8aec36f40536a4e6dbf2cd25ea59239ab956 /keystore/java/android/security/KeyChain.java
parenta4a48a484fe862787cf2fbe1314deab8ac375951 (diff)
downloadframeworks_base-9d7faa91be6661eccf73494f1ab96ae9a28d42d7.zip
frameworks_base-9d7faa91be6661eccf73494f1ab96ae9a28d42d7.tar.gz
frameworks_base-9d7faa91be6661eccf73494f1ab96ae9a28d42d7.tar.bz2
Change KeyChain to assume PEM encoded keystore entries
Summary: - Changed KeyChain to assume PEM encoded keystore entries - Moved convertToPem from CertInstaller for reuse with other Credentials helpers - Added convertFromPem for use decoding keystore entries Change-Id: I340168b88aefa458d01e81324824e2e08b1d7c4e
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r--keystore/java/android/security/KeyChain.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java
index ec820cf..ba784ed 100644
--- a/keystore/java/android/security/KeyChain.java
+++ b/keystore/java/android/security/KeyChain.java
@@ -34,6 +34,7 @@ import java.io.ByteArrayInputStream;
import java.io.Closeable;
import java.io.IOException;
import java.security.KeyFactory;
+import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.cert.Certificate;
@@ -185,11 +186,9 @@ public final class KeyChain {
throw new IllegalArgumentException("bytes == null");
}
try {
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
- return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(bytes));
- } catch (NoSuchAlgorithmException e) {
- throw new AssertionError(e);
- } catch (InvalidKeySpecException e) {
+ KeyPair keyPair = (KeyPair) Credentials.convertFromPem(bytes).get(0);
+ return keyPair.getPrivate();
+ } catch (IOException e) {
throw new AssertionError(e);
}
}