gnu.crypto.der

Class DERReader

public final class DERReader extends Object implements DER

This class decodes DER sequences into Java objects. The methods of this class do not have knowledge of higher-levels of structure in the DER stream -- such as ASN.1 constructions -- and it is therefore up to the calling application to determine if the data are structured properly by inspecting the DERValue that is returned.

Author: Casey Marshall (rsdio@metastatic.org)

Constructor Summary
DERReader(byte[] in)
Create a new DER reader from a byte array.
DERReader(byte[] in, int off, int len)
DERReader(InputStream in)
Create a new DER readed from an input stream.
Method Summary
static DERValueread(byte[] encoded)
Convenience method for reading a single primitive value from the given byte array.
DERValueread()
Decode a single value from the input stream, returning it in a new DERValue.
voidskip(int bytes)

Constructor Detail

DERReader

public DERReader(byte[] in)
Create a new DER reader from a byte array.

Parameters: in The encoded bytes.

DERReader

public DERReader(byte[] in, int off, int len)

DERReader

public DERReader(InputStream in)
Create a new DER readed from an input stream.

Parameters: in The encoded bytes.

Method Detail

read

public static DERValue read(byte[] encoded)
Convenience method for reading a single primitive value from the given byte array.

Parameters: encoded The encoded bytes.

Throws: IOException If the bytes do not represent an encoded object.

read

public DERValue read()
Decode a single value from the input stream, returning it in a new DERValue. By "single value" we mean any single type in its entirety -- including constructed types such as SEQUENCE and all the values they contain. Usually it is sufficient to call this method once to parse and return the top-level structure, then to inspect the returned value for the proper contents.

Returns: The parsed DER structure.

Throws: IOException If an error occurs reading from the input stream. DEREncodingException If the input does not represent a valid DER stream.

skip

public void skip(int bytes)
Copyright © 2001, 2002, 2003 Free Software Foundation, Inc. All Rights Reserved.