Top Description Fields Constructors Methods
org.bouncycastle.asn1

public Class ASN1InputStream

extends FilterInputStream
implements BERTags
Class Inheritance
All Implemented Interfaces
org.bouncycastle.asn1.BERTags
Imports
java.io.ByteArrayInputStream, .EOFException, .FilterInputStream, .IOException, .InputStream, org.bouncycastle.util.io.Streams

A general purpose ASN.1 decoder - note: this class differs from the others in that it returns null after it has read the last object in the stream. If an ASN.1 NULL is encountered a DER/BER Null object is returned.

Field Summary

Modifier and TypeField and Description
private final boolean
private final int
private final byte[][]
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
public
ASN1InputStream(byte[]
array containing ASN.1 encoded data.
input
)

Create an ASN1InputStream based on the input byte array.

public
ASN1InputStream(byte[]
array containing ASN.1 encoded data.
input
,
boolean
true if parsing inside constructed objects can be delayed.
lazyEvaluate
)

Create an ASN1InputStream based on the input byte array.

public
ASN1InputStream(InputStream
stream containing ASN.1 encoded data.
input
,
int
maximum size of a DER encoded object.
limit
)

Create an ASN1InputStream where no DER object will be longer than limit.

public
ASN1InputStream(InputStream
stream containing ASN.1 encoded data.
input
,
boolean
true if parsing inside constructed objects can be delayed.
lazyEvaluate
)

Create an ASN1InputStream where no DER object will be longer than limit, and constructed objects such as sequences will be parsed lazily.

public
ASN1InputStream(InputStream
stream containing ASN.1 encoded data.
input
,
int
maximum size of a DER encoded object.
limit
,
boolean
true if parsing inside constructed objects can be delayed.
lazyEvaluate
)

Create an ASN1InputStream where no DER object will be longer than limit, and constructed objects such as sequences will be parsed lazily.

Method Summary

Modifier and TypeMethod and Description
pack-priv ASN1EncodableVector
pack-priv ASN1EncodableVector
protected ASN1Primitive

Returns:

the resulting primitive.
buildObject
(int
the full tag details.
tag
,
int
the tagNo defined.
tagNo
,
int
the length of the object.
length
)

build an object given its tag and the number of bytes to construct it from.

pack-priv static ASN1Primitive
createPrimitiveDERObject(int tagNo, DefiniteLengthInputStream defIn, byte[][] tmpBuffers)

private static char[]
private static byte[]
getBuffer(DefiniteLengthInputStream defIn, byte[][] tmpBuffers)

pack-priv int
protected void
readFully(byte[] bytes)

protected int
pack-priv static int
readLength(InputStream s, int limit)

public ASN1Primitive
pack-priv static int
Inherited from java.io.FilterInputStream:
availableclosemarkmarkSupportedreadreadreadresetskip

Field Detail

lazyEvaluateback to summary
private final boolean lazyEvaluate
limitback to summary
private final int limit
tmpBuffersback to summary
private final byte[][] tmpBuffers

Constructor Detail

ASN1InputStreamback to summary
public ASN1InputStream(InputStream is)
ASN1InputStreamback to summary
public ASN1InputStream(byte[] input)

Create an ASN1InputStream based on the input byte array. The length of DER objects in the stream is automatically limited to the length of the input array.

Parameters
input:byte[]

array containing ASN.1 encoded data.

ASN1InputStreamback to summary
public ASN1InputStream(byte[] input, boolean lazyEvaluate)

Create an ASN1InputStream based on the input byte array. The length of DER objects in the stream is automatically limited to the length of the input array.

Parameters
input:byte[]

array containing ASN.1 encoded data.

lazyEvaluate:boolean

true if parsing inside constructed objects can be delayed.

ASN1InputStreamback to summary
public ASN1InputStream(InputStream input, int limit)

Create an ASN1InputStream where no DER object will be longer than limit.

Parameters
input:InputStream

stream containing ASN.1 encoded data.

limit:int

maximum size of a DER encoded object.

ASN1InputStreamback to summary
public ASN1InputStream(InputStream input, boolean lazyEvaluate)

Create an ASN1InputStream where no DER object will be longer than limit, and constructed objects such as sequences will be parsed lazily.

Parameters
input:InputStream

stream containing ASN.1 encoded data.

lazyEvaluate:boolean

true if parsing inside constructed objects can be delayed.

ASN1InputStreamback to summary
public ASN1InputStream(InputStream input, int limit, boolean lazyEvaluate)

Create an ASN1InputStream where no DER object will be longer than limit, and constructed objects such as sequences will be parsed lazily.

Parameters
input:InputStream

stream containing ASN.1 encoded data.

limit:int

maximum size of a DER encoded object.

lazyEvaluate:boolean

true if parsing inside constructed objects can be delayed.

Method Detail

buildDEREncodableVectorback to summary
pack-priv ASN1EncodableVector buildDEREncodableVector(DefiniteLengthInputStream dIn) throws IOException
buildEncodableVectorback to summary
pack-priv ASN1EncodableVector buildEncodableVector() throws IOException
buildObjectback to summary
protected ASN1Primitive buildObject(int tag, int tagNo, int length) throws IOException

build an object given its tag and the number of bytes to construct it from.

Parameters
tag:int

the full tag details.

tagNo:int

the tagNo defined.

length:int

the length of the object.

Returns:ASN1Primitive

the resulting primitive.

Exceptions
IOException:
on processing exception.
createPrimitiveDERObjectback to summary
pack-priv static ASN1Primitive createPrimitiveDERObject(int tagNo, DefiniteLengthInputStream defIn, byte[][] tmpBuffers) throws IOException
getBMPCharBufferback to summary
private static char[] getBMPCharBuffer(DefiniteLengthInputStream defIn) throws IOException
getBufferback to summary
private static byte[] getBuffer(DefiniteLengthInputStream defIn, byte[][] tmpBuffers) throws IOException
getLimitback to summary
pack-priv int getLimit()
readFullyback to summary
protected void readFully(byte[] bytes) throws IOException
readLengthback to summary
protected int readLength() throws IOException
readLengthback to summary
pack-priv static int readLength(InputStream s, int limit) throws IOException
readObjectback to summary
public ASN1Primitive readObject() throws IOException
readTagNumberback to summary
pack-priv static int readTagNumber(InputStream s, int tag) throws IOException