public class ASN1Header
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Form |
CONSTRUCTED |
static Form |
PRIMITIVE |
Constructor and Description |
---|
ASN1Header(java.io.InputStream istream)
Gets info about the next item in the DER stream, consuming the
identifier and length octets.
|
ASN1Header(Tag tag,
Form form,
long contentLength)
This constructor is to be called when we are constructing an ASN1Value
rather than decoding it.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
encode() |
void |
encode(java.io.OutputStream ostream) |
long |
getContentLength()
Returns -1 for indefinite length encoding.
|
Form |
getForm()
Returns the Form, PRIMITIVE or CONSTRUCTED.
|
Tag |
getTag() |
long |
getTotalLength()
Returns the length of the header plus the length of the contents;
the total length of the DER encoding of an ASN1 value.
|
boolean |
isEOC()
Returns
true if this is a BER end-of-contents marker. |
static ASN1Header |
lookAhead(java.io.InputStream derStream)
Returns information about the next item in the stream, but does not
consume any octets.
|
static byte[] |
unsignedBigIntToByteArray(java.math.BigInteger bi)
Converts an unsigned BigInteger to a minimal-length byte array.
|
void |
validate(Tag expectedTag)
Verifies that this head has the given tag.
|
void |
validate(Tag expectedTag,
Form expectedForm)
Verifies that this header has the given tag and form.
|
public static final Form PRIMITIVE
public static final Form CONSTRUCTED
public ASN1Header(java.io.InputStream istream) throws InvalidBERException, java.io.IOException
InvalidBERException
java.io.IOException
public long getTotalLength()
public Tag getTag()
public long getContentLength()
public Form getForm()
public static ASN1Header lookAhead(java.io.InputStream derStream) throws java.io.IOException, InvalidBERException
java.io.IOException
- If the input stream does not support look ahead.InvalidBERException
public void encode(java.io.OutputStream ostream) throws java.io.IOException
java.io.IOException
public byte[] encode()
public static byte[] unsignedBigIntToByteArray(java.math.BigInteger bi)
public void validate(Tag expectedTag, Form expectedForm) throws InvalidBERException
InvalidBERException
- If the header's tag or form
differ from those passed in.public void validate(Tag expectedTag) throws InvalidBERException
InvalidBERException
- If the header's tag differs from that
passed in.public boolean isEOC()
true
if this is a BER end-of-contents marker.