Package org.apache.harmony.security.asn1

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


     * Tests decoding/encoding integers to/from byte array
     */
    public void testDecode_Encode() throws IOException {

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

        // decode from byte array
        for (int i = 0; i < validTestcase.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) validTestcase[i][2]);
            assertTrue((validTestcase[i][0]).toString(), // message
                    Arrays.equals((byte[]) validTestcase[i][1], // expected
                            (byte[]) asn1.decode(in))); // returned
        }
       
        // decode from input stream
        for (int i = 0; i < validTestcase.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validTestcase[i][2]));
            assertTrue((validTestcase[i][0]).toString(), //message
                    Arrays.equals((byte[]) validTestcase[i][1], //expected
                            (byte[]) asn1.decode(in))); //returned
        }

        // encoding
        for (int i = 0; i < validTestcase.length; i++) {
            DerOutputStream out = new DerOutputStream(asn1, validTestcase[i][1]);
View Full Code Here


     * Tests decoding/encoding integers to/from byte array
     */
    public void testDecode_Encode() throws IOException {

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

        // decode from byte array
        for (int i = 0; i < validTestcase.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) validTestcase[i][2]);
            assertTrue((validTestcase[i][0]).toString(), // message
                    Arrays.equals((byte[]) validTestcase[i][1], // expected
                            (byte[]) asn1.decode(in))); // returned
        }
       
        // decode from input stream
        for (int i = 0; i < validTestcase.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validTestcase[i][2]));
            assertTrue((validTestcase[i][0]).toString(), //message
                    Arrays.equals((byte[]) validTestcase[i][1], //expected
                            (byte[]) asn1.decode(in))); //returned
        }

        // encoding
        for (int i = 0; i < validTestcase.length; i++) {
            DerOutputStream out = new DerOutputStream(asn1, validTestcase[i][1]);
View Full Code Here

    public PBKDF2Params(
        byte[]  salt,
        int     iterationCount)
    {
        this.octStr = new DEROctetString(salt);
        this.iterationCount = new ASN1Integer(iterationCount);
    }
View Full Code Here

        int     iterationCount,
        int     keyLength)
    {
        this(salt, iterationCount);

        this.keyLength = new ASN1Integer(keyLength);
    }
View Full Code Here

    public DHParameter(
        BigInteger  p,
        BigInteger  g,
        int         l)
    {
        this.p = new ASN1Integer(p);
        this.g = new ASN1Integer(g);

        if (l != 0)
        {
            this.l = new ASN1Integer(l);
        }
        else
        {
            this.l = null;
        }
View Full Code Here

    public CompressedData(
        AlgorithmIdentifier compressionAlgorithm,
        ContentInfo         encapContentInfo)
    {
        this.version = new ASN1Integer(0);
        this.compressionAlgorithm = compressionAlgorithm;
        this.encapContentInfo = encapContentInfo;
    }
View Full Code Here

        BigInteger maximum)
    {
        this.base = base;
        if (maximum != null)
        {
            this.maximum = new ASN1Integer(maximum);
        }
        if (minimum == null)
        {
            this.minimum = null;
        }
        else
        {
            this.minimum = new ASN1Integer(minimum);
        }
    }
View Full Code Here

     */
    public ASN1Primitive toASN1Primitive()
    {
        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(new ASN1Integer(version));                       // version
        v.add(new ASN1Integer(getModulus()));
        v.add(new ASN1Integer(getPublicExponent()));
        v.add(new ASN1Integer(getPrivateExponent()));
        v.add(new ASN1Integer(getPrime1()));
        v.add(new ASN1Integer(getPrime2()));
        v.add(new ASN1Integer(getExponent1()));
        v.add(new ASN1Integer(getExponent2()));
        v.add(new ASN1Integer(getCoefficient()));

        if (otherPrimeInfos != null)
        {
            v.add(otherPrimeInfos);
        }
View Full Code Here

    public RC2CBCParameter(
        int     parameterVersion,
        byte[]  iv)
    {
        this.version = new ASN1Integer(parameterVersion);
        this.iv = new DEROctetString(iv);
    }
View Full Code Here

    public DSAParameter(
        BigInteger  p,
        BigInteger  q,
        BigInteger  g)
    {
        this.p = new ASN1Integer(p);
        this.q = new ASN1Integer(q);
        this.g = new ASN1Integer(g);
    }
View Full Code Here

TOP

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

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.