|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectschemajic.encoder.ASN1Helper
public class ASN1Helper
Useful tools that help DER encoding values of ASN.1 types.
| Field Summary | |
|---|---|
static byte |
HIGH_BIT
Defines the "high bit" that is the sign extension bit for a 8-bit signed value. |
static byte |
TAG_CLASS
|
static byte |
TAG_PC
|
| Method Summary | |
|---|---|
int |
buildHeader(byte[] buf,
int startOffset,
int asnLength)
Encodes an ASN.1 header into the given byte buffer in support of the AsnEncoder interface. |
int |
buildLength(byte[] buf,
int startOffset,
int asnLength)
The buildLength() method is used to encode an
ASN.1 vlaue length into the specified byte buffer. |
int |
buildObjectId(byte[] buffer,
int startOffset,
int[] arcs)
The buildObjectId() method is used to encode an ASN.1 object id value into the specified byte buffer. |
int |
buildRelativeObjectId(byte[] buffer,
int startOffset,
int[] arcs)
The buildObjectId() method is used to encode an ASN.1 object id value into the specified byte buffer. |
int |
calcOidLengthInBytes(int[] arcs)
Calculates the length of a value of ASN.1 type OBJECT IDENTIFIER in octets. |
int |
calcRidLengthInBytes(int[] arcs)
Calculates the length of a value of ASN.1 type RELATIVE-OID in octets. |
int |
decode7BitEncodedInteger(java.io.InputStream buffer)
Given a tag class, pc and tag value, create an instance of the appropriate Tag subclass. |
protected void |
encodeLongTag(int tag,
java.io.OutputStream out)
A 'tag number' was > 30, and therefore must be encoded in multiple octets, each with 7 significant bits. |
protected void |
encodeShortTag(int tag,
java.io.OutputStream out)
A 'tag number' is < 31, and therefore it may be encoded in a single octet. |
static ASN1Helper |
getInstance()
Returns the current instance or a new instance of ASN1Helper |
int |
getIntegerLengthInBits(int i)
Returns the minimum number of octets required to hold the value of the specified integer. |
int |
getIntegerLengthInBytes(int i)
Returns the minimum number of octets required to hold the value of the specified integer. |
protected static void |
rotate(byte[] buf,
int begin,
int pivot,
int end)
Rotates a give buffer area marked by begin, pivot, and end. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte HIGH_BIT
public static final byte TAG_CLASS
public static final byte TAG_PC
| Method Detail |
|---|
public static ASN1Helper getInstance()
ASN1Helper
public int getIntegerLengthInBytes(int i)
public int getIntegerLengthInBits(int i)
Only suuports integers of 31 bits or less, as the
Java int type is signed.
i - a provided length
public int calcOidLengthInBytes(int[] arcs)
OBJECT IDENTIFIER in octets.
arcs - a series of OID arcs
public int calcRidLengthInBytes(int[] arcs)
RELATIVE-OID in octets.
arcs - a series of relative OID arcs
public int buildHeader(byte[] buf,
int startOffset,
int asnLength)
throws java.io.IOException
buildLength() method.
buf - an output buffer of encoded octets (bytes)startOffset - offset from the start of the buffer where the
method should start writing the encoded dataasnLength - length to be encoded
startOffset is subtracted from the
return value then the length of the encoded data
can be determined
java.io.IOException
public int buildLength(byte[] buf,
int startOffset,
int asnLength)
throws java.io.IOException
buildLength() method is used to encode an
ASN.1 vlaue length into the specified byte buffer. The method
is defined in the AsnEncoder interface.
buf - The output buffer of encoded bytes.startOffset - The offset from the start of the buffer where the
method should start writing the encoded data.asnLength - The length to be encoded.
startOffset is subtracted from the return value
then the length of the encoded data can be determined.
java.io.IOException
public int buildObjectId(byte[] buffer,
int startOffset,
int[] arcs)
throws java.io.IOException
buffer - The output buffer of encoded bytes.startOffset - The offset from the start of the buffer where the
method should start writing the encoded data.arcs - An array of integers to encode.
java.io.IOException
public int buildRelativeObjectId(byte[] buffer,
int startOffset,
int[] arcs)
throws java.io.IOException
buffer - The output buffer of encoded bytes.startOffset - The offset from the start of the buffer where the
method should start writing the encoded data.arcs - An array of integers to encode.
java.io.IOException - Thrown if an error occurs encoding
the datatype.
protected void encodeShortTag(int tag,
java.io.OutputStream out)
throws java.io.IOException
java.io.IOException
protected void encodeLongTag(int tag,
java.io.OutputStream out)
throws java.io.IOException
java.io.IOException
protected static void rotate(byte[] buf,
int begin,
int pivot,
int end)
throws java.lang.ArrayIndexOutOfBoundsException
buf - The buffer containing the data to rotatebegin - The start of the rotationpivot - The pivot point for the rotationend - The end of the rotational buffer
java.lang.ArrayIndexOutOfBoundsException - Thrown if an access exception occurs
public int decode7BitEncodedInteger(java.io.InputStream buffer)
throws DecodingException
DecodingException
|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||