Package com.maverick.crypto.asn1

Examples of com.maverick.crypto.asn1.DERInputStream


                // 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


                        new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };

        ASN1NamedBitList decoder = new ASN1NamedBitList();

        for (int i = 0; i < testcaseBoolean.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) testcaseBoolean[i][1]);

            assertTrue("Testcase: " + i, Arrays.equals(
                    (boolean[]) testcaseBoolean[i][0], (boolean[]) decoder
                            .decode(in)));
View Full Code Here

                        new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };

        ASN1NamedBitList decoder = new ASN1NamedBitList(8);

        for (int i = 0; i < testcaseBoolean.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) testcaseBoolean[i][1]);

            assertTrue("Testcase: " + i, Arrays.equals(
                    (boolean[]) testcaseBoolean[i][0], (boolean[]) decoder
                            .decode(in)));
View Full Code Here

    }

    public void testDecode_Valid() throws IOException {

        for (int i = 0; i < taggedType.length; i++) {
            DerInputStream in = new DerInputStream((byte[]) taggedType[i][1]);
            assertEquals("Test case: " + i, taggedType[i][0],
                    ((ASN1Type) taggedType[i][2]).decode(in));
        }
    }
View Full Code Here

    {
  super("X.509");
  try {
      if ( encoding.equals( "PkiPath" ) )
      {
    DERInputStream derInStream = new DERInputStream(inStream);
    DERObject derObject = derInStream.readObject();
    if ( derObject == null || ! ( derObject instanceof ASN1Sequence ) )
    {
        throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath" );
    }
    Enumeration enumx = ((ASN1Sequence)derObject).getObjects();
View Full Code Here

    private DERObject getEncodedX509Certificate( X509Certificate cert )
  throws CertificateEncodingException
    {
  try {
      ByteArrayInputStream inStream = new ByteArrayInputStream( cert.getEncoded() );
      DERInputStream derInStream = new DERInputStream( inStream );
      return derInStream.readObject();
  } catch ( IOException ex ) {
      throw new CertificateEncodingException( "IOException caught while encoding certificate\n" + ex.toString() );
  }
    }
View Full Code Here

            && (data[2] == 0x02 || data[2] == 0x03))
        {
            try
            {
                ByteArrayInputStream    bIn = new ByteArrayInputStream(data);
                DERInputStream          dIn = new DERInputStream(bIn);

                key = (ASN1OctetString)dIn.readObject();
            }
            catch (IOException ex)
            {
                throw new IllegalArgumentException("error recovering public key");
            }
View Full Code Here

    private DigestInfo derDecode(
        byte[]  encoding)
        throws IOException
    {
        ByteArrayInputStream    bIn = new ByteArrayInputStream(encoding);
        DERInputStream          dIn = new DERInputStream(bIn);

        return new DigestInfo((ASN1Sequence)dIn.readObject());
    }
View Full Code Here

     static PublicKey createPublicKeyFromDERStream(
            InputStream         in)
            throws IOException
        {
            return createPublicKeyFromPublicKeyInfo(
                    new SubjectPublicKeyInfo((ASN1Sequence)(new DERInputStream(in).readObject())));
        }
View Full Code Here

    static PrivateKey createPrivateKeyFromDERStream(
            InputStream         in)
            throws IOException
        {
            return createPrivateKeyFromPrivateKeyInfo(
                    new PrivateKeyInfo((ASN1Sequence)(new DERInputStream(in).readObject())));
        }
View Full Code Here

TOP

Related Classes of com.maverick.crypto.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.