Package org.bouncycastle.cms

Examples of org.bouncycastle.cms.SignerInformationStore


        //
        MessageDigest md = MessageDigest.getInstance("SHA1", "SUN");

        byte[]                  contentDigest = md.digest(TEST_MESSAGE.getBytes());
        CertStore               certStore = sp.getCertificatesAndCRLs("Collection", "SUN");
        SignerInformationStore  signers = sp.getSignerInfos();

        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
View Full Code Here


                                                "Collection", "BC");

        //
        // SignerInfo blocks which contain the signatures
        //
        SignerInformationStore  signers = s.getSignerInfos();

        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        //
        // check each signer
        //
View Full Code Here

                                                "Collection", "BC");

        //
        // SignerInfo blocks which contain the signatures
        //
        SignerInformationStore  signers = s.getSignerInfos();

        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        //
        // check each signer
        //
View Full Code Here

    private void verifySignatures(CMSSignedData s, byte[] contentDigest)
        throws Exception
    {
        CertStore               certStore = s.getCertificatesAndCRLs("Collection", "BC");
        SignerInformationStore  signers = s.getSignerInfos();
       
        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
View Full Code Here

       
        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())
View Full Code Here

        gen.addCertificatesAndCRLs(certsAndCrls);

        CMSSignedData s = gen.generate(msg, true, "BC");
        SignerInformation origSigner = (SignerInformation)s.getSignerInfos().getSigners().toArray()[0];
        SignerInformationStore counterSigners = gen.generateCounterSigners(origSigner, "BC");

        SignerInformation signer = SignerInformation.addCounterSigners(origSigner, counterSigners);

        SignerInformationStore signers = signer.getCounterSignatures();
        Iterator it = signers.getSigners().iterator();
        while (it.hasNext())
        {
            SignerInformation   cSigner = (SignerInformation)it.next();
            Collection          certCollection = certsAndCrls.getCertificates(cSigner.getSID());
View Full Code Here

       
        s = new CMSSignedData(ContentInfo.getInstance(aIn.readObject()));
   
        certsAndCrls = s.getCertificatesAndCRLs("Collection", "BC");
   
        SignerInformationStore  signers = s.getSignerInfos();
        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();
   
        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
            Collection          certCollection = certsAndCrls.getCertificates(signer.getSID());
   
            Iterator        certIt = certCollection.iterator();
            X509Certificate cert = (X509Certificate)certIt.next();
   
            assertEquals(true, signer.verify(cert, "BC"));
        }

        //
        // check for CRLs
        //
        Collection crls = certsAndCrls.getCRLs(null);

        assertEquals(1, crls.size());

        assertTrue(crls.contains(_signCrl));
       
        //
        // 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()));
   
        certsAndCrls = s.getCertificatesAndCRLs("Collection", "BC");
   
        signers = s.getSignerInfos();
        c = signers.getSigners();
        it = c.iterator();
   
        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
View Full Code Here

    {
        CMSSignedData s = new CMSSignedData(new CMSProcessableByteArray(disorderedMessage), disorderedSet);

        CertStore certs = s.getCertificatesAndCRLs("Collection", "BC");

        SignerInformationStore  signers = s.getSignerInfos();
        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
View Full Code Here

    private void verifySignatures(CMSSignedDataParser sp)
        throws Exception
    {
        CertStore               certs = sp.getCertificatesAndCRLs("Collection", "BC");
        SignerInformationStore  signers = sp.getSignerInfos();

        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
View Full Code Here

       
        assertEquals(true, Arrays.areEqual(_msgBytes, _resBytes));

        certs = s.getCertificatesAndCRLs("Collection", "BC");

        SignerInformationStore  signers = s.getSignerInfos();
        Collection              c = signers.getSigners();
        Iterator                it = c.iterator();

        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
View Full Code Here

TOP

Related Classes of org.bouncycastle.cms.SignerInformationStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.