summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcashman <dcashman@google.com>2015-05-29 14:47:23 -0700
committerdcashman <dcashman@google.com>2015-06-10 13:32:42 -0700
commit1616f30b0ca1221c7f60a6ae4e90562340c549a9 (patch)
tree5758ad5f737f44a4b65930fcfed477b736947ecb
parent59d6d943d86ef0e3f5ba2f03758b0d40a82639e9 (diff)
downloadframeworks_base-1616f30b0ca1221c7f60a6ae4e90562340c549a9.zip
frameworks_base-1616f30b0ca1221c7f60a6ae4e90562340c549a9.tar.gz
frameworks_base-1616f30b0ca1221c7f60a6ae4e90562340c549a9.tar.bz2
Add keyset support for ECDSA public keys.
Bug: 21363613 Change-Id: If9eafc725dec4800276251722a7456382dfe207d
-rw-r--r--core/java/android/content/pm/PackageParser.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 83b0140..5d96f1a 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -4019,7 +4019,7 @@ public class PackageParser {
public static final PublicKey parsePublicKey(final String encodedPublicKey) {
if (encodedPublicKey == null) {
- Slog.i(TAG, "Could not parse null public key");
+ Slog.w(TAG, "Could not parse null public key");
return null;
}
@@ -4028,7 +4028,7 @@ public class PackageParser {
final byte[] encoded = Base64.decode(encodedPublicKey, Base64.DEFAULT);
keySpec = new X509EncodedKeySpec(encoded);
} catch (IllegalArgumentException e) {
- Slog.i(TAG, "Could not parse verifier public key; invalid Base64");
+ Slog.w(TAG, "Could not parse verifier public key; invalid Base64");
return null;
}
@@ -4037,23 +4037,32 @@ public class PackageParser {
final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
return keyFactory.generatePublic(keySpec);
} catch (NoSuchAlgorithmException e) {
- Log.wtf(TAG, "Could not parse public key because RSA isn't included in build");
- return null;
+ Slog.wtf(TAG, "Could not parse public key: RSA KeyFactory not included in build");
} catch (InvalidKeySpecException e) {
// Not a RSA public key.
}
+ /* Now try it as a ECDSA key. */
+ try {
+ final KeyFactory keyFactory = KeyFactory.getInstance("EC");
+ return keyFactory.generatePublic(keySpec);
+ } catch (NoSuchAlgorithmException e) {
+ Slog.wtf(TAG, "Could not parse public key: EC KeyFactory not included in build");
+ } catch (InvalidKeySpecException e) {
+ // Not a ECDSA public key.
+ }
+
/* Now try it as a DSA key. */
try {
final KeyFactory keyFactory = KeyFactory.getInstance("DSA");
return keyFactory.generatePublic(keySpec);
} catch (NoSuchAlgorithmException e) {
- Log.wtf(TAG, "Could not parse public key because DSA isn't included in build");
- return null;
+ Slog.wtf(TAG, "Could not parse public key: DSA KeyFactory not included in build");
} catch (InvalidKeySpecException e) {
// Not a DSA public key.
}
+ /* Not a supported key type */
return null;
}