summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-09-21 20:36:39 -0400
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-09-21 20:36:39 -0400
commit6a93483621c8393a57b50dca1dadaeb48dcb6e38 (patch)
tree6eb68fecf0590cdf8c674cb6b0805808cf6ee9c5 /security
parentbb0d360e281a26b3aa65bf9d7b616e1ef2519220 (diff)
parent5777f56ef4522e39ff9e41e967c399642fc6c6b4 (diff)
downloadlibcore-6a93483621c8393a57b50dca1dadaeb48dcb6e38.zip
libcore-6a93483621c8393a57b50dca1dadaeb48dcb6e38.tar.gz
libcore-6a93483621c8393a57b50dca1dadaeb48dcb6e38.tar.bz2
Merge change 26055 into eclair
* changes: Replaced an O(N) algorithm with an O(1) algorithm. This shaves off 2/3 of the server cert checking time or ~200ms on Sapphire. This is in preparation for tripling the number of certs in an upcoming change.
Diffstat (limited to 'security')
-rw-r--r--security/src/main/java/org/bouncycastle/jce/provider/IndexedPKIXParameters.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/security/src/main/java/org/bouncycastle/jce/provider/IndexedPKIXParameters.java b/security/src/main/java/org/bouncycastle/jce/provider/IndexedPKIXParameters.java
index e8e834a..03679e2 100644
--- a/security/src/main/java/org/bouncycastle/jce/provider/IndexedPKIXParameters.java
+++ b/security/src/main/java/org/bouncycastle/jce/provider/IndexedPKIXParameters.java
@@ -109,7 +109,7 @@ public class IndexedPKIXParameters extends PKIXParameters {
if (anchor != null) {
return anchor;
}
- } catch (Exception e) {
+ } catch (Exception e) {
Logger.getLogger(IndexedPKIXParameters.class.getName()).log(
Level.WARNING, "Error encoding cert.", e);
}
@@ -125,6 +125,21 @@ public class IndexedPKIXParameters extends PKIXParameters {
}
/**
+ * Returns true if the given certificate is found in the trusted key
+ * store.
+ */
+ public boolean isDirectlyTrusted(X509Certificate cert) {
+ try {
+ Bytes encoded = new Bytes(cert.getEncoded());
+ return encodings.containsKey(encoded);
+ } catch (Exception e) {
+ Logger.getLogger(IndexedPKIXParameters.class.getName()).log(
+ Level.WARNING, "Error encoding cert.", e);
+ return false;
+ }
+ }
+
+ /**
* Wraps a byte[] and adds equals() and hashCode() support.
*/
static class Bytes {