Package org.gudy.bouncycastle.asn1
Class ASN1InputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.gudy.bouncycastle.asn1.ASN1InputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,DERTags
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
FieldsModifier and TypeFieldDescriptionprivate static final DERObject
(package private) boolean
(package private) int
Fields inherited from class java.io.FilterInputStream
in
Fields inherited from interface org.gudy.bouncycastle.asn1.DERTags
APPLICATION, BIT_STRING, BMP_STRING, BOOLEAN, CONSTRUCTED, ENUMERATED, EXTERNAL, GENERAL_STRING, GENERALIZED_TIME, GRAPHIC_STRING, IA5_STRING, INTEGER, NULL, NUMERIC_STRING, OBJECT_IDENTIFIER, OCTET_STRING, PRINTABLE_STRING, SEQUENCE, SEQUENCE_OF, SET, SET_OF, T61_STRING, TAGGED, UNIVERSAL_STRING, UTC_TIME, UTF8_STRING, VIDEOTEX_STRING, VISIBLE_STRING
-
Constructor Summary
ConstructorsConstructorDescriptionASN1InputStream
(byte[] input) Create an ASN1InputStream based on the input byte array.ASN1InputStream
(InputStream input, int limit) Create an ASN1InputStream where no DER object will be longer than limit. -
Method Summary
Modifier and TypeMethodDescriptionprivate BERConstructedOctetString
buildConstructedOctetString
(DERObject sentinel) private BERConstructedOctetString
buildDerConstructedOctetString
(int length) private ASN1EncodableVector
buildDerEncodableVector
(int length) private ASN1EncodableVector
buildEncodableVector
(DERObject sentinel) protected DERObject
buildObject
(int tag, int tagNo, int length) build an object given its tag and the number of bytes to construct it from.private byte[]
readDefiniteLengthFully
(int length) protected void
readFully
(byte[] bytes) private byte[]
read a string of bytes representing an indefinite length object.protected int
private int
readTagNumber
(int tag) Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
END_OF_STREAM
-
eofFound
boolean eofFound -
limit
int limit
-
-
Constructor Details
-
ASN1InputStream
-
ASN1InputStream
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
- array containing ASN.1 encoded data.
-
ASN1InputStream
Create an ASN1InputStream where no DER object will be longer than limit.- Parameters:
input
- stream containing ASN.1 encoded data.limit
- maximum size of a DER encoded object.
-
-
Method Details
-
readLength
- Throws:
IOException
-
readFully
- Throws:
IOException
-
buildObject
build an object given its tag and the number of bytes to construct it from.- Throws:
IOException
-
readDefiniteLengthFully
- Throws:
IOException
-
readIndefiniteLengthFully
read a string of bytes representing an indefinite length object.- Throws:
IOException
-
buildConstructedOctetString
private BERConstructedOctetString buildConstructedOctetString(DERObject sentinel) throws IOException - Throws:
IOException
-
buildDerConstructedOctetString
- Throws:
IOException
-
buildEncodableVector
- Throws:
IOException
-
buildDerEncodableVector
- Throws:
IOException
-
readObject
- Throws:
IOException
-
readTagNumber
- Throws:
IOException
-