s = new CMSSignedData(ContentInfo.getInstance(aIn.readObject()));
certs = s.getCertificatesAndCRLs("Collection", "BC");
SignerInformationStore signers = s.getSignerInfos();
assertEquals(2, signers.size());
Collection c = signers.getSigners();
Iterator it = c.iterator();
SignerId sid = null;
while (it.hasNext())
{
SignerInformation signer = (SignerInformation)it.next();
Collection certCollection = certs.getCertificates(signer.getSID());
Iterator certIt = certCollection.iterator();
X509Certificate cert = (X509Certificate)certIt.next();
sid = signer.getSID();
assertEquals(true, signer.verify(cert, "BC"));
//
// check content digest
//
byte[] contentDigest = (byte[])gen.getGeneratedDigests().get(signer.getDigestAlgOID());
AttributeTable table = signer.getSignedAttributes();
Attribute hash = table.get(CMSAttributes.messageDigest);
assertTrue(MessageDigest.isEqual(contentDigest, ((ASN1OctetString)hash.getAttrValues().getObjectAt(0)).getOctets()));
}
c = signers.getSigners(sid);
assertEquals(2, c.size());
//
// try using existing signer
//
gen = new CMSSignedDataGenerator();
gen.addSigners(s.getSignerInfos());
gen.addCertificatesAndCRLs(s.getCertificatesAndCRLs("Collection", "BC"));
s = gen.generate(msg, true, "BC");
bIn = new ByteArrayInputStream(s.getEncoded());
aIn = new ASN1InputStream(bIn);
s = new CMSSignedData(ContentInfo.getInstance(aIn.readObject()));
certs = s.getCertificatesAndCRLs("Collection", "BC");
signers = s.getSignerInfos();
c = signers.getSigners();
it = c.iterator();
assertEquals(2, c.size());
while (it.hasNext())