Package org.apache.harmony.security.asn1

Examples of org.apache.harmony.security.asn1.BerOutputStream


                            (byte[]) asn1.decode(in))); //returned
        }

        // encoding
        for (int i = 0; i < validTestcase.length; i++) {
            DerOutputStream out = new DerOutputStream(asn1, validTestcase[i][1]);
            assertTrue((validTestcase[i][0]).toString(), //message
                    Arrays.equals((byte[]) validTestcase[i][2], //expected
                            out.encoded));//returned
        }
    }
View Full Code Here


    //FIXME need testcase for decoding invalid encodings

    public void testEncode() throws IOException {

        for (int i = 0; i < testcases.length; i++) {
            DerOutputStream out = new DerOutputStream(choice, testcases[i][0]);
            assertTrue("Test case: " + i, Arrays.equals(
                    (byte[]) testcases[i][1], out.encoded));
        }
    }
View Full Code Here

                    utime.decode(in)); //decoded
        }

        // encoding date object
        for (int i = 0; i < validUTCTimes.length; i++) {
            DerOutputStream out = new DerOutputStream(utime,
                    validUTCTimes[i][2]);
            assertTrue("Encoding date for " + validUTCTimes[i][0], Arrays
                    .equals((byte[]) validUTCTimes[i][1], // expected
                            out.encoded)); //encoded
        }
View Full Code Here

                    gtime.decode(in)); //decoded
        }

        // encoding date object
        for (int i = 0; i < validGeneralizedTimes.length; i++) {
            DerOutputStream out = new DerOutputStream(gtime,
                    validGeneralizedTimes[i][2]);
            assertTrue("Encoding date for " + validGeneralizedTimes[i][0],
                    Arrays.equals((byte[]) validGeneralizedTimes[i][1], // expected
                            out.encoded)); //encoded
        }
View Full Code Here

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

            byte[] encoded = new DerOutputStream(ASN1Oid.getInstance(),
                    oid[i][1]).encoded;

            assertTrue("Failed to encode oid: " + oid[i][0], // error message
                    Arrays.equals((byte[]) oid[i][2], // expected encoding
                            encoded));
View Full Code Here

        // testing encoding
        for (int i = 0; i < oid.length; i++) {
            assertTrue("Failed to encode oid: " + oid[i][0], // error message
                    Arrays.equals((byte[]) oid[i][2], // expected encoding
                            new DerOutputStream(asn1, oid[i][0]).encoded));
        }
    }
View Full Code Here

        assertTrue(Arrays.equals(encoded, (byte[]) ASN1Any.getInstance()
                .decode(in)));
    }

    public void testEncode() throws IOException {
        DerOutputStream out = new DerOutputStream(ASN1Any.getInstance(),
                encoded);
        assertTrue("False", Arrays.equals(encoded, out.encoded));
    }
View Full Code Here

    //ASN.1 DER encoding
    private byte[] encoding;

    Oid(int[] data) {
        super();
        oid = new ObjectIdentifier(data);
    }
View Full Code Here

    }

    public Oid(byte[] data) throws GSSException {
        super();
        try {
            oid = new ObjectIdentifier((int[]) ASN1.decode(data));
        } catch (IOException e) {
            GSSException gsse = new GSSException(GSSException.FAILURE);
            gsse.initCause(e);
            throw gsse;
        }
View Full Code Here

        {
            asn1Out = new DEROutputStream(bOut);
        }
        else
        {
            asn1Out = new BEROutputStream(bOut);
        }

        asn1Out.writeObject(auth);

        byte[] pkg = bOut.toByteArray();

        ContentInfo mainInfo = new ContentInfo(data, new BEROctetString(pkg));

        //
        // create the mac
        //
        byte[] mSalt = new byte[20];
        int itCount = MIN_ITERATIONS;

        random.nextBytes(mSalt);

        byte[] data = ((ASN1OctetString)mainInfo.getContent()).getOctets();

        MacData mData;

        try
        {
            byte[] res = calculatePbeMac(id_SHA1, mSalt, itCount, password, false, data);

            AlgorithmIdentifier algId = new AlgorithmIdentifier(id_SHA1, DERNull.INSTANCE);
            DigestInfo dInfo = new DigestInfo(algId, res);

            mData = new MacData(dInfo, mSalt, itCount);
        }
        catch (Exception e)
        {
            throw new IOException("error constructing MAC: " + e.toString());
        }

        //
        // output the Pfx
        //
        Pfx pfx = new Pfx(mainInfo, mData);

        if (useDEREncoding)
        {
            asn1Out = new DEROutputStream(stream);
        }
        else
        {
            asn1Out = new BEROutputStream(stream);
        }

        asn1Out.writeObject(pfx);
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.security.asn1.BerOutputStream

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.