public class DerInputStream
extends java.lang.Object
Note that, like BER/1, DER streams are streams of explicitly tagged data values. Accordingly, this programming interface does not expose any variant of the java.io.InputStream interface, since that kind of input stream holds untagged data values and using that I/O model could prevent correct parsing of the DER data.
At this time, this class supports only a subset of the types of DER data encodings which are defined. That subset is sufficient for parsing most X.509 certificates.
| Modifier and Type | Field and Description |
|---|---|
byte |
tag
The DER tag of the value; one of the tag_ constants.
|
| Constructor and Description |
|---|
DerInputStream(byte[] data)
Create a DER input stream from a data buffer.
|
DerInputStream(byte[] data,
int offset,
int len)
Create a DER input stream from part of a data buffer.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of bytes available for reading.
|
java.math.BigInteger |
getBigInteger()
Get an integer from the input stream as a BigInteger object.
|
byte[] |
getBitString()
Get a bit string from the input stream.
|
java.lang.String |
getBMPString()
Read a string that was encoded as a BMPString DER value.
|
void |
getBytes(byte[] val)
Returns the asked number of bytes from the input stream.
|
DerValue |
getDerValue()
Get a single DER-encoded value from the input stream.
|
int |
getEnumerated()
Get an enumerated from the input stream.
|
java.lang.String |
getGeneralString()
Read a string that was encoded as a GeneralString DER value.
|
java.lang.String |
getIA5String()
Read a string that was encoded as a IA5tring DER value.
|
int |
getInteger()
Get an integer from the input stream as an integer.
|
void |
getNull()
Reads an encoded null value from the input stream.
|
byte[] |
getOctetString()
Returns an ASN.1 OCTET STRING from the input stream.
|
ObjectIdentifier |
getOID()
Reads an X.200 style Object Identifier from the stream.
|
java.math.BigInteger |
getPositiveBigInteger()
Returns an ASN.1 INTEGER value as a positive BigInteger.
|
java.lang.String |
getPrintableString()
Read a string that was encoded as a PrintableString DER value.
|
DerValue[] |
getSequence(int startLen)
Return a sequence of encoded entities.
|
DerValue[] |
getSet(int startLen)
Return a set of encoded entities.
|
DerValue[] |
getSet(int startLen,
boolean implicit)
Return a set of encoded entities.
|
java.lang.String |
getT61String()
Read a string that was encoded as a T61String DER value.
|
BitArray |
getUnalignedBitString()
Get a bit string from the input stream.
|
java.lang.String |
getUTF8String()
Read a string that was encoded as a UTF8String DER value.
|
void |
mark(int value)
Mark the current position in the buffer, so that
a later call to
reset will return here. |
int |
peekByte() |
protected DerValue[] |
readVector(int startLen) |
void |
reset()
Return to the position of the last
mark
call. |
DerInputStream |
subStream(int len,
boolean do_skip)
Creates a new DER input stream from part of this input stream.
|
byte[] |
toByteArray()
Return what has been written to this DerInputStream
as a byte array.
|
public DerInputStream(byte[] data)
throws java.io.IOException
data - the buffer from which to create the string (CONSUMED)java.io.IOExceptionpublic DerInputStream(byte[] data,
int offset,
int len)
throws java.io.IOException
data - the buffer from which to create the string (CONSUMED)offset - the first index of data which will
be read as DER input in the new streamlen - how long a chunk of the buffer to use,
starting at "offset"java.io.IOExceptionpublic DerInputStream subStream(int len, boolean do_skip) throws java.io.IOException
len - how long a chunk of the current input stream to use,
starting at the current position.do_skip - true if the existing data in the input stream should
be skipped. If this value is false, the next data read
on this stream and the newly created stream will be the
same.java.io.IOExceptionpublic byte[] toByteArray()
public int getInteger()
throws java.io.IOException
java.io.IOExceptionpublic java.math.BigInteger getBigInteger()
throws java.io.IOException
java.io.IOExceptionpublic java.math.BigInteger getPositiveBigInteger()
throws java.io.IOException
java.io.IOExceptionpublic int getEnumerated()
throws java.io.IOException
java.io.IOExceptionpublic byte[] getBitString()
throws java.io.IOException
java.io.IOExceptionpublic BitArray getUnalignedBitString() throws java.io.IOException
java.io.IOExceptionpublic byte[] getOctetString()
throws java.io.IOException
java.io.IOExceptionpublic void getBytes(byte[] val)
throws java.io.IOException
java.io.IOExceptionpublic void getNull()
throws java.io.IOException
java.io.IOExceptionpublic ObjectIdentifier getOID() throws java.io.IOException
java.io.IOExceptionpublic DerValue[] getSequence(int startLen) throws java.io.IOException
startLen - guess about how long the sequence will be
(used to initialize an auto-growing data structure)java.io.IOExceptionpublic DerValue[] getSet(int startLen) throws java.io.IOException
startLen - guess about how large the set will be
(used to initialize an auto-growing data structure)java.io.IOExceptionpublic DerValue[] getSet(int startLen, boolean implicit) throws java.io.IOException
startLen - guess about how large the set will be
(used to initialize an auto-growing data structure)implicit - if true tag is assumed implicit.java.io.IOExceptionprotected DerValue[] readVector(int startLen) throws java.io.IOException
java.io.IOExceptionpublic DerValue getDerValue() throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getUTF8String()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getPrintableString()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getT61String()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getIA5String()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getBMPString()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getGeneralString()
throws java.io.IOException
java.io.IOExceptionpublic int peekByte()
throws java.io.IOException
java.io.IOExceptionpublic void mark(int value)
reset will return here.public void reset()
mark
call. A mark is implicitly set at the beginning of
the stream when it is created.public int available()
Copyright © 2025. All rights reserved.