diff options
author | Sergio Giro <sgiro@google.com> | 2015-04-21 23:20:25 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-21 23:20:25 +0000 |
commit | 7f729f07947047c1ceaad8a78febacd1269a62b3 (patch) | |
tree | 35d98bf60cbe7a6487bd0014728eb263e89004bb /bcpkix/src/main/java/org/bouncycastle/cms | |
parent | bf9fc13901d0666be69118222a1eb0161202af5f (diff) | |
parent | fb93a7697b35e8a059d93e3d1776bc307981fc0e (diff) | |
download | android_external_bouncycastle-7f729f07947047c1ceaad8a78febacd1269a62b3.tar.gz android_external_bouncycastle-7f729f07947047c1ceaad8a78febacd1269a62b3.tar.bz2 android_external_bouncycastle-7f729f07947047c1ceaad8a78febacd1269a62b3.zip |
am fb93a769: Merge "bouncycastle: upgrade to version 1.52"
* commit 'fb93a7697b35e8a059d93e3d1776bc307981fc0e':
bouncycastle: upgrade to version 1.52
Diffstat (limited to 'bcpkix/src/main/java/org/bouncycastle/cms')
4 files changed, 73 insertions, 15 deletions
diff --git a/bcpkix/src/main/java/org/bouncycastle/cms/CMSSignedData.java b/bcpkix/src/main/java/org/bouncycastle/cms/CMSSignedData.java index ec4da91..5ef95ee 100644 --- a/bcpkix/src/main/java/org/bouncycastle/cms/CMSSignedData.java +++ b/bcpkix/src/main/java/org/bouncycastle/cms/CMSSignedData.java @@ -23,6 +23,7 @@ import org.bouncycastle.asn1.cms.SignerInfo; import org.bouncycastle.operator.DefaultSignatureAlgorithmIdentifierFinder; import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.SignatureAlgorithmIdentifierFinder; +import org.bouncycastle.util.Encodable; import org.bouncycastle.util.Store; /** @@ -54,6 +55,7 @@ import org.bouncycastle.util.Store; * </pre> */ public class CMSSignedData + implements Encodable { private static final CMSSignedHelper HELPER = CMSSignedHelper.INSTANCE; @@ -347,7 +349,7 @@ public class CMSSignedData // { // return verifySignatures(verifierProvider, false); // } - // + // // /** // * Verify all the SignerInformation objects and optionally their associated counter signatures attached // * to this CMS SignedData object. @@ -361,30 +363,27 @@ public class CMSSignedData // throws CMSException // { // Collection signers = this.getSignerInfos().getSigners(); - // + // // for (Iterator it = signers.iterator(); it.hasNext();) // { // SignerInformation signer = (SignerInformation)it.next(); - // + // // try // { // SignerInformationVerifier verifier = verifierProvider.get(signer.getSID()); - // + // // if (!signer.verify(verifier)) // { // return false; // } - // + // // if (!ignoreCounterSignatures) // { // Collection counterSigners = signer.getCounterSignatures().getSigners(); - // + // // for (Iterator cIt = counterSigners.iterator(); cIt.hasNext();) // { - // SignerInformation counterSigner = (SignerInformation)cIt.next(); - // SignerInformationVerifier counterVerifier = verifierProvider.get(signer.getSID()); - // - // if (!counterSigner.verify(counterVerifier)) + // if (!verifyCounterSignature((SignerInformation)cIt.next(), verifierProvider)) // { // return false; // } @@ -396,7 +395,29 @@ public class CMSSignedData // throw new CMSException("failure in verifier provider: " + e.getMessage(), e); // } // } - // + // + // return true; + // } + // + // private boolean verifyCounterSignature(SignerInformation counterSigner, SignerInformationVerifierProvider verifierProvider) + // throws OperatorCreationException, CMSException + // { + // SignerInformationVerifier counterVerifier = verifierProvider.get(counterSigner.getSID()); + // + // if (!counterSigner.verify(counterVerifier)) + // { + // return false; + // } + // + // Collection counterSigners = counterSigner.getCounterSignatures().getSigners(); + // for (Iterator cIt = counterSigners.iterator(); cIt.hasNext();) + // { + // if (!verifyCounterSignature((SignerInformation)cIt.next(), verifierProvider)) + // { + // return false; + // } + // } + // // return true; // } // END android-removed diff --git a/bcpkix/src/main/java/org/bouncycastle/cms/DefaultCMSSignatureAlgorithmNameGenerator.java b/bcpkix/src/main/java/org/bouncycastle/cms/DefaultCMSSignatureAlgorithmNameGenerator.java index f69772d..d454fa6 100644 --- a/bcpkix/src/main/java/org/bouncycastle/cms/DefaultCMSSignatureAlgorithmNameGenerator.java +++ b/bcpkix/src/main/java/org/bouncycastle/cms/DefaultCMSSignatureAlgorithmNameGenerator.java @@ -52,6 +52,11 @@ public class DefaultCMSSignatureAlgorithmNameGenerator addEntries(PKCSObjectIdentifiers.sha256WithRSAEncryption, "SHA256", "RSA"); addEntries(PKCSObjectIdentifiers.sha384WithRSAEncryption, "SHA384", "RSA"); addEntries(PKCSObjectIdentifiers.sha512WithRSAEncryption, "SHA512", "RSA"); + + addEntries(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd128, "RIPEMD128", "RSA"); + addEntries(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd160, "RIPEMD160", "RSA"); + addEntries(TeleTrusTObjectIdentifiers.rsaSignatureWithripemd256, "RIPEMD256", "RSA"); + addEntries(X9ObjectIdentifiers.ecdsa_with_SHA1, "SHA1", "ECDSA"); addEntries(X9ObjectIdentifiers.ecdsa_with_SHA224, "SHA224", "ECDSA"); addEntries(X9ObjectIdentifiers.ecdsa_with_SHA256, "SHA256", "ECDSA"); diff --git a/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformation.java b/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformation.java index 7e178d6..081d121 100644 --- a/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformation.java +++ b/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformation.java @@ -302,7 +302,7 @@ public class SignerInformation { if (signedAttributeSet != null) { - return signedAttributeSet.getEncoded(); + return signedAttributeSet.getEncoded(ASN1Encoding.DER); } return null; diff --git a/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformationStore.java b/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformationStore.java index b65ab5e..79ec0a0 100644 --- a/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformationStore.java +++ b/bcpkix/src/main/java/org/bouncycastle/cms/SignerInformationStore.java @@ -7,13 +7,37 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.bouncycastle.util.Iterable; + public class SignerInformationStore + implements Iterable<SignerInformation> { private List all = new ArrayList(); private Map table = new HashMap(); + /** + * Create a store containing a single SignerInformation object. + * + * @param signerInfo the signer information to contain. + */ + public SignerInformationStore( + SignerInformation signerInfo) + { + this.all = new ArrayList(1); + this.all.add(signerInfo); + + SignerId sid = signerInfo.getSID(); + + table.put(sid, all); + } + + /** + * Create a store containing a collection of SignerInformation objects. + * + * @param signerInfos a collection signer information objects to contain. + */ public SignerInformationStore( - Collection signerInfos) + Collection<SignerInformation> signerInfos) { Iterator it = signerInfos.iterator(); @@ -65,7 +89,7 @@ public class SignerInformationStore * * @return a collection of signers. */ - public Collection getSigners() + public Collection<SignerInformation> getSigners() { return new ArrayList(all); } @@ -76,7 +100,7 @@ public class SignerInformationStore * @param selector a signer id to select against. * @return a collection of SignerInformation objects. */ - public Collection getSigners( + public Collection<SignerInformation> getSigners( SignerId selector) { if (selector.getIssuer() != null && selector.getSubjectKeyIdentifier() != null) @@ -106,4 +130,12 @@ public class SignerInformationStore return list == null ? new ArrayList() : new ArrayList(list); } } + + /** + * Support method for Iterable where available. + */ + public Iterator<SignerInformation> iterator() + { + return getSigners().iterator(); + } } |