Package org.bouncycastle.asn1

Examples of org.bouncycastle.asn1.DERInputStream


        ASN1Oid asn1 = ASN1Oid.getInstance();

        // testing decoding
        for (int i = 0; i < oid.length; i++) {

            int[] decoded = (int[]) asn1.decode(new DerInputStream(
                    (byte[]) oid[i][2]));

            assertTrue("Failed to decode oid: " + oid[i][0], // error message
                    Arrays.equals((int[]) oid[i][1], // expected array
                            decoded));
View Full Code Here


        //FIXME new byte[] { 0x06, 0x02, (byte) 0x80, (byte) 0x01 }
        };

        for (int i = 0; i < invalid.length; i++) {
            try {
                DerInputStream in = new DerInputStream(invalid[i]);
                ASN1Oid.getInstance().decode(in);
                fail("No expected ASN1Exception for:" + i);
            } catch (ASN1Exception e) {
            }
        }
View Full Code Here

       
        // testing decoding
        for (int i = 0; i < oid.length; i++) {
            assertEquals("Failed to decode oid: " + oid[i][0], // error message
                    oid[i][0], // expected string
                    asn1.decode(new DerInputStream((byte[]) oid[i][2])));
        }

        // testing encoding
        for (int i = 0; i < oid.length; i++) {
            assertTrue("Failed to encode oid: " + oid[i][0], // error message
View Full Code Here

    }

    private static byte[] encoded = new byte[] { 0x01, 0x03, 0x11, 0x13, 0x15 };

    public void testDecode() throws IOException {
        DerInputStream in = new DerInputStream(encoded);
        assertTrue(Arrays.equals(encoded, (byte[]) ASN1Any.getInstance()
                .decode(in)));
    }
View Full Code Here

        // oid decoder/encoder for testing
        ASN1Boolean asn1 = ASN1Boolean.getInstance();

        // decoding false
        DerInputStream in = new DerInputStream(eFalse);
        assertEquals("Decoding false value", Boolean.FALSE, asn1.decode(in));

        // decoding true
        in = new DerInputStream(eTrue);
        assertEquals("Decoding true value", Boolean.TRUE, asn1.decode(in));

        // encoding false
        DerOutputStream out = new DerOutputStream(asn1, Boolean.FALSE);
        assertTrue("Encoding false value", Arrays.equals(eFalse, out.encoded));
View Full Code Here

                // wrong content: content is not 0x01 or 0xFF
                new byte[] { 0x01, 0x01, 0x33 } };

        for (int i = 0; i < invalid.length; i++) {
            try {
                DerInputStream in = new DerInputStream(invalid[i]);
                ASN1Boolean.getInstance().decode(in);
                fail("No expected ASN1Exception for: " + i);
            } catch (ASN1Exception e) {
            }
        }
View Full Code Here

    public void testDecode_Valid() throws IOException {

        for (int i = 0; i < testcases.length; i++) {
            try {
                DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
                assertEquals("Test case: " + i, testcases[i][0], sequenceOf
                        .decode(in));
            } catch (ASN1Exception e) {
                fail("Test case: " + i + "\n" + e.getMessage());
            }
View Full Code Here

                        "Method getDecodedObject MUST not be invoked");
            }
        };

        for (int i = 0; i < testcases.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) testcases[i][1]);
            in.setVerify();
            seqVerify.decode(in);
        }
    }
View Full Code Here

        // decoder/encoder for testing
        ASN1BitString asn1 = ASN1BitString.getInstance();

        // decode from byte array
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validBitstring[i][1]);

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
                    decoded.bytes));
        }

        // decode from input stream
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validBitstring[i][1]));

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);
View Full Code Here

                // wrong content: constructed encoding
                new byte[] { 0x23, 0x03, 0x03, 0x01, 0x00 } };

        for (int i = 0; i < invalid.length; i++) {
            try {
                DerInputStream in = new DerInputStream(invalid[i]);
                ASN1BitString.getInstance().decode(in);
                fail("No expected ASN1Exception for: " + i);
            } catch (ASN1Exception e) {
            }
        }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.DERInputStream

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.