Package org.bouncycastle.sasn1

Examples of org.bouncycastle.sasn1.BerOctetStringGenerator$BufferedBerOctetStream


    private static void pipeOctetString(
        ASN1OctetStringParser octs,
        OutputStream          output)
        throws IOException
    {
        BEROctetStringGenerator octGen = new BEROctetStringGenerator(output, 0, true);
        // TODO Allow specification of a specific fragment size?
        OutputStream outOctets = octGen.getOctetOutputStream();
        Streams.pipeAll(octs.getOctetStream(), outOctets);
        outOctets.close();
    }
View Full Code Here


        //
        BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());
       
        eiGen.addObject(new DERObjectIdentifier(contentOID));
       
        BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, true);
       
        return new CmsCompressedOutputStream(new DeflaterOutputStream(octGen.getOctetOutputStream()), sGen, cGen, eiGen);
    }
View Full Code Here

       
        OutputStream digStream;
       
        if (encapsulate)
        {
            BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, true);
           
            if (_bufferSize != 0)
            {
                digStream = octGen.getOctetOutputStream(new byte[_bufferSize]);
            }
            else
            {
                digStream = octGen.getOctetOutputStream();
            }

            if (dataOutputStream != null)
            {
                digStream = new TeeOutputStream(dataOutputStream, digStream);
View Full Code Here

            AlgorithmIdentifier encAlgId = getAlgorithmIdentifier(encryptionOID, params);
                       
            eiGen.getRawOutputStream().write(encAlgId.getEncoded());
           
            BEROctetStringGenerator octGen = new BEROctetStringGenerator(eiGen.getRawOutputStream(), 0, false);
           
            CipherOutputStream      cOut;
           
            if (_bufferSize != 0)
            {
                cOut = new CipherOutputStream(octGen.getOctetOutputStream(new byte[_bufferSize]), cipher);
            }
            else
            {
                cOut = new CipherOutputStream(octGen.getOctetOutputStream(), cipher);
            }

            return new CmsEnvelopedDataOutputStream(cOut, cGen, envGen, eiGen);
        }
        catch (InvalidKeyException e)
View Full Code Here

        String oid,
        byte[] enc)
        throws IOException
    {
        ByteArrayInputStream     bIn = new ByteArrayInputStream(enc);
        Asn1InputStream          aIn = new Asn1InputStream(bIn);

        Asn1ObjectIdentifier      o = new Asn1ObjectIdentifier(oid);
        Asn1ObjectIdentifier      encO = (Asn1ObjectIdentifier)aIn.readObject();
       
        if (!o.equals(encO))
        {
            fail("oid ID didn't match - got: " + o + " expected " + encO);
        }
View Full Code Here

        String  oid)
        throws IOException
    {
        Asn1ObjectIdentifier    o = new Asn1ObjectIdentifier(oid);
        ByteArrayInputStream    bIn = new ByteArrayInputStream(o.getEncoded());
        Asn1InputStream         aIn = new Asn1InputStream(bIn);
       
        o = (Asn1ObjectIdentifier)aIn.readObject();
       
        if (!o.toString().equals(oid))
        {
            fail("failed oid check for " + oid);
        }
View Full Code Here

    }
   
    public void testDerReading()
        throws Exception
    {
        Asn1InputStream aIn = new Asn1InputStream(seqData);
       
        Asn1Sequence    seq = (Asn1Sequence)aIn.readObject();
        Object          o = null;
        int             count = 0;
       
        assertNotNull("null sequence returned", seq);
       
View Full Code Here

    public void testNestedReading(
        byte[] data)
        throws Exception
    {
        Asn1InputStream aIn = new Asn1InputStream(data);
       
        Asn1Sequence    seq = (Asn1Sequence)aIn.readObject();
        Object          o = null;
        int             count = 0;
       
        assertNotNull("null sequence returned", seq);
       
View Full Code Here

    }
   
    public void testBerReading()
        throws Exception
    {
        Asn1InputStream aIn = new Asn1InputStream(berSeqData);
       
        Asn1Sequence    seq = (Asn1Sequence)aIn.readObject();
        Object          o = null;
        int             count = 0;
       
        assertNotNull("null sequence returned", seq);
       
View Full Code Here

    }
   
    public void testLongTag()
        throws IOException
    {
        Asn1InputStream aIn = new Asn1InputStream(longTagged);
       
        Asn1TaggedObject tagged = (Asn1TaggedObject)aIn.readObject();
       
        assertEquals(31, tagged.getTagNumber());
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle.sasn1.BerOctetStringGenerator$BufferedBerOctetStream

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.