diff options
author | Kenny Root <kroot@google.com> | 2014-04-30 16:55:20 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-04-30 16:55:20 +0000 |
commit | 9cd5caece4cf5d64898e9241c79194c0a9f52d24 (patch) | |
tree | b2563eaa6b305886478940cdc18c62f1b8ebfc26 /luni/src/main/java/org | |
parent | 531968cf367586f38167ced0415f89fe330ee75f (diff) | |
parent | 8c9ea6916a5bb232fe1bfd6d61194196685fe81c (diff) | |
download | libcore-9cd5caece4cf5d64898e9241c79194c0a9f52d24.zip libcore-9cd5caece4cf5d64898e9241c79194c0a9f52d24.tar.gz libcore-9cd5caece4cf5d64898e9241c79194c0a9f52d24.tar.bz2 |
am 8c9ea691: Revert "Add API to check certificate chain signatures"
* commit '8c9ea6916a5bb232fe1bfd6d61194196685fe81c':
Revert "Add API to check certificate chain signatures"
Diffstat (limited to 'luni/src/main/java/org')
-rw-r--r-- | luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java b/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java index 4b03937..f6efb8a 100644 --- a/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java +++ b/luni/src/main/java/org/apache/harmony/security/utils/JarUtils.java @@ -52,27 +52,18 @@ public class JarUtils { new int[] {1, 2, 840, 113549, 1, 9, 4}; /** - * @see #verifySignature(InputStream, InputStream, boolean) - */ - public static Certificate[] verifySignature(InputStream signature, InputStream signatureBlock) - throws IOException, GeneralSecurityException { - return verifySignature(signature, signatureBlock, false); - } - - /** * This method handle all the work with PKCS7, ASN1 encoding, signature verifying, * and certification path building. * See also PKCS #7: Cryptographic Message Syntax Standard: * http://www.ietf.org/rfc/rfc2315.txt * @param signature - the input stream of signature file to be verified * @param signatureBlock - the input stream of corresponding signature block file - * @param chainCheck - whether to validate certificate chain signatures * @return array of certificates used to verify the signature file * @throws IOException - if some errors occurs during reading from the stream * @throws GeneralSecurityException - if signature verification process fails */ public static Certificate[] verifySignature(InputStream signature, InputStream - signatureBlock, boolean chainCheck) throws IOException, GeneralSecurityException { + signatureBlock) throws IOException, GeneralSecurityException { BerInputStream bis = new BerInputStream(signatureBlock); ContentInfo info = (ContentInfo)ContentInfo.ASN1.decode(bis); @@ -180,11 +171,10 @@ public class JarUtils { throw new SecurityException("Incorrect signature"); } - return createChain(certs[issuerSertIndex], certs, chainCheck); + return createChain(certs[issuerSertIndex], certs); } - private static X509Certificate[] createChain(X509Certificate signer, - X509Certificate[] candidates, boolean chainCheck) { + private static X509Certificate[] createChain(X509Certificate signer, X509Certificate[] candidates) { LinkedList chain = new LinkedList(); chain.add(0, signer); @@ -194,16 +184,13 @@ public class JarUtils { } Principal issuer = signer.getIssuerDN(); - X509Certificate issuerCert = null; - X509Certificate subjectCert = signer; + X509Certificate issuerCert; int count = 1; while (true) { - X509Certificate newIssuerCert = findCert(issuer, candidates, subjectCert, chainCheck); - if (newIssuerCert == null) { + issuerCert = findCert(issuer, candidates); + if( issuerCert == null) { break; } - subjectCert = issuerCert; - issuerCert = newIssuerCert; chain.add(issuerCert); count++; if (issuerCert.getSubjectDN().equals(issuerCert.getIssuerDN())) { @@ -214,17 +201,9 @@ public class JarUtils { return (X509Certificate[])chain.toArray(new X509Certificate[count]); } - private static X509Certificate findCert(Principal issuer, X509Certificate[] candidates, - X509Certificate subjectCert, boolean chainCheck) { + private static X509Certificate findCert(Principal issuer, X509Certificate[] candidates) { for (int i = 0; i < candidates.length; i++) { if (issuer.equals(candidates[i].getSubjectDN())) { - if (chainCheck) { - try { - subjectCert.verify(candidates[i].getPublicKey()); - } catch (Exception e) { - continue; - } - } return candidates[i]; } } |