Package org.bouncycastle.cms

Examples of org.bouncycastle.cms.CMSSignedDataParser


        sigOut.write(TEST_MESSAGE.getBytes());

        sigOut.close();

        CMSSignedDataParser     sp = new CMSSignedDataParser(bOut.toByteArray());

        CMSTypedStream stream = sp.getSignedContent();

        assertEquals("1.2.3.4", stream.getContentType());

        stream.drain();
View Full Code Here


   
        sigOut.write(TEST_MESSAGE.getBytes());
       
        sigOut.close();
       
        CMSSignedDataParser     sp = new CMSSignedDataParser(
                new CMSTypedStream(new ByteArrayInputStream(TEST_MESSAGE.getBytes())), bOut.toByteArray());
   
        sp.getSignedContent().drain();
       
        verifySignatures(sp);
    }
View Full Code Here

            sigOut.write(i & 0xff);
        }
       
        sigOut.close();
       
        CMSSignedDataParser     sp = new CMSSignedDataParser(bOut.toByteArray());

        sp.getSignedContent().drain();
       
        verifySignatures(sp);
       
        int unbufferedLength = bOut.toByteArray().length;
       
View Full Code Here

            sigOut.write(i & 0xff);
        }
       
        sigOut.close();
       
        CMSSignedDataParser     sp = new CMSSignedDataParser(bOut.toByteArray());
   
        sp.getSignedContent().drain();
       
        verifySignatures(sp);
       
        int unbufferedLength = bOut.toByteArray().length;
       
View Full Code Here

        sigOut.write(TEST_MESSAGE.getBytes());
       
        sigOut.close();
       
        CMSSignedDataParser     sp = new CMSSignedDataParser(bOut.toByteArray());

        sp.getSignedContent().drain();
       
        verifySignatures(sp);
       
        byte[] contentDigest = (byte[])gen.getGeneratedDigests().get(CMSSignedGenerator.DIGEST_SHA1);

        AttributeTable table = ((SignerInformation)sp.getSignerInfos().getSigners().iterator().next()).getSignedAttributes();
        Attribute hash = table.get(CMSAttributes.messageDigest);

        assertTrue(MessageDigest.isEqual(contentDigest, ((ASN1OctetString)hash.getAttrValues().getObjectAt(0)).getOctets()));

        //
        // try using existing signer
        //
        gen = new CMSSignedDataStreamGenerator();

        gen.addSigners(sp.getSignerInfos());
       
        gen.addCertificatesAndCRLs(sp.getCertificatesAndCRLs("Collection", "BC"));
       
        bOut.reset();
       
        sigOut = gen.open(bOut, true);
View Full Code Here

        sigOut.write(TEST_MESSAGE.getBytes());

        sigOut.close();

        CMSSignedDataParser     sp = new CMSSignedDataParser(bOut.toByteArray());

        sp.getSignedContent().drain();

        verifySignatures(sp);

        //
        // check attributes
        //
        SignerInformationStore  signers = sp.getSignerInfos();

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

        while (it.hasNext())
View Full Code Here

        sigOut.write(TEST_MESSAGE.getBytes());

        sigOut.close();

        CMSSignedDataParser     sp = new CMSSignedDataParser(bOut.toByteArray());

        sp.getSignedContent().drain();

        assertEquals(4, sp.getVersion());

        store = sp.getAttributeCertificates("Collection", "BC");

        Collection coll = store.getMatches(null);

        assertEquals(1, coll.size());
View Full Code Here

        sd = new CMSSignedData(new CMSProcessableByteArray(data), newOut.toByteArray());
        SignerInformation signer = (SignerInformation)sd.getSignerInfos().getSigners().iterator().next();

        assertEquals(signer.getDigestAlgOID(), CMSSignedDataStreamGenerator.DIGEST_SHA224);

        CMSSignedDataParser sp = new CMSSignedDataParser(new CMSTypedStream(new ByteArrayInputStream(data)), newOut.toByteArray());

        sp.getSignedContent().drain();

        verifySignatures(sp);
    }
View Full Code Here

        sd = new CMSSignedData(newOut.toByteArray());
        SignerInformation signer = (SignerInformation)sd.getSignerInfos().getSigners().iterator().next();

        assertEquals(signer.getDigestAlgOID(), CMSSignedDataStreamGenerator.DIGEST_SHA224);

        CMSSignedDataParser sp = new CMSSignedDataParser(newOut.toByteArray());

        sp.getSignedContent().drain();

        verifySignatures(sp);
    }
View Full Code Here

        ByteArrayInputStream original = new ByteArrayInputStream(bOut.toByteArray());
        ByteArrayOutputStream newOut = new ByteArrayOutputStream();

        CMSSignedDataParser.replaceCertificatesAndCRLs(original, certs, newOut);

        CMSSignedDataParser sp = new CMSSignedDataParser(new CMSTypedStream(new ByteArrayInputStream(data)), newOut.toByteArray());

        sp.getSignedContent().drain();

        verifySignatures(sp);
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle.cms.CMSSignedDataParser

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.