Package org.bouncycastle.sasn1

Examples of org.bouncycastle.sasn1.Asn1OctetString


   
    public void testDerImplicitTaggedSequenceWriting()
        throws Exception
    {
       ByteArrayOutputStream bOut = new ByteArrayOutputStream();
       DerSequenceGenerator  seqGen = new DerSequenceGenerator(bOut, 1, false);
      
       seqGen.addObject(new Asn1Integer(BigInteger.valueOf(0)));
      
       seqGen.addObject(new Asn1ObjectIdentifier("1.1"));
      
       seqGen.close();

       assertTrue("implicit tag writing test failed.", Arrays.equals(implTagSeqData, bOut.toByteArray()));
    }
View Full Code Here


   
    public void testNestedExplicitTagDerWriting()
        throws Exception
    {
       ByteArrayOutputStream bOut = new ByteArrayOutputStream();
       DerSequenceGenerator  seqGen1 = new DerSequenceGenerator(bOut);
      
       seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
      
       seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
      
       DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream(), 1, true);
      
       seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
      
       seqGen2.close();
      
       seqGen1.close();

       assertTrue("nested explicit tagged DER writing test failed.", Arrays.equals(nestedSeqExpTagData, bOut.toByteArray()));
    }
View Full Code Here

   
    public void testNestedImplicitTagDerWriting()
        throws Exception
    {
       ByteArrayOutputStream bOut = new ByteArrayOutputStream();
       DerSequenceGenerator  seqGen1 = new DerSequenceGenerator(bOut);
      
       seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
      
       seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
      
       DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream(), 1, false);
      
       seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
      
       seqGen2.close();
      
       seqGen1.close();

       assertTrue("nested implicit tagged DER writing test failed.", Arrays.equals(nestedSeqImpTagData, bOut.toByteArray()));
    }
View Full Code Here

      
       seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
      
       seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
      
       DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream());
      
       seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
      
       seqGen2.close();
      
       seqGen1.close();

       assertTrue("nested BER/DER writing test failed.", Arrays.equals(berDerNestedSeqData, bOut.toByteArray()));
    }
View Full Code Here

        cGen.addObject(new Asn1Integer(0));
       
        //
        // AlgorithmIdentifier
        //
        DerSequenceGenerator algGen = new DerSequenceGenerator(cGen.getRawOutputStream());
       
        algGen.addObject(new Asn1ObjectIdentifier("1.2"));

        algGen.close();
       
        //
        // Encapsulated ContentInfo
        //
        BerSequenceGenerator eiGen = new BerSequenceGenerator(cGen.getRawOutputStream());
View Full Code Here

        //
        Asn1InputStream aIn = new Asn1InputStream(bOut.toByteArray());

        ContentInfoParser cp = new ContentInfoParser((Asn1Sequence)aIn.readObject());
       
        CompressedDataParser  comData = new CompressedDataParser((Asn1Sequence)cp.getContent(BerTag.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();

        Asn1OctetString bytes = (Asn1OctetString)content.getContent(BerTag.OCTET_STRING);

        InputStream in = bytes.getOctetStream();
        int         count = 0;
View Full Code Here

   
    private void parseEnveloped(byte[] data) throws IOException
    {
        Asn1InputStream aIn = new Asn1InputStream(data);
       
        ContentInfoParser cP = new ContentInfoParser((Asn1Sequence)aIn.readObject());
       
        EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE));
       
        eP.getRecipientInfos();
       
        EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();
       
View Full Code Here

        //
        // reading back
        //
        Asn1InputStream aIn = new Asn1InputStream(bOut.toByteArray());

        ContentInfoParser cp = new ContentInfoParser((Asn1Sequence)aIn.readObject());
       
        CompressedDataParser  comData = new CompressedDataParser((Asn1Sequence)cp.getContent(BerTag.SEQUENCE));
        ContentInfoParser     content = comData.getEncapContentInfo();

        Asn1OctetString bytes = (Asn1OctetString)content.getContent(BerTag.OCTET_STRING);

        InputStream in = bytes.getOctetStream();
        int         count = 0;
       
        while (in.read() >= 0)
View Full Code Here

       
        EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE));
       
        eP.getRecipientInfos();
       
        EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();
       
        Asn1OctetString content = (Asn1OctetString)ecP.getEncryptedContent(BerTag.OCTET_STRING);
       
        InputStream in = content.getOctetStream();
       
        while (in.read() >= 0)
        {
View Full Code Here

    {
        Asn1InputStream aIn = new Asn1InputStream(data);
       
        ContentInfoParser cP = new ContentInfoParser((Asn1Sequence)aIn.readObject());
       
        EnvelopedDataParser eP = new EnvelopedDataParser((Asn1Sequence)cP.getContent(BerTag.SEQUENCE));
       
        eP.getRecipientInfos();
       
        EncryptedContentInfoParser ecP = eP.getEncryptedContentInfo();
       
        Asn1OctetString content = (Asn1OctetString)ecP.getEncryptedContent(BerTag.OCTET_STRING);
       
        InputStream in = content.getOctetStream();
       
View Full Code Here

TOP

Related Classes of org.bouncycastle.sasn1.Asn1OctetString

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.