Note
This class only substitute indefinite length octets to definite length octets. It does not update the contents even if they are not DER.
This assumes that the basic data structure is "tag, length, value" triplet. In the case where the length is "indefinite", terminating end-of-contents bytes are expected.
| Modifier and Type | Field and Description |
|---|---|
| private byte[] | |
| private int | |
| private int | |
| private int | |
| private static final int | |
| private static final int | |
| private final ArrayList | |
| private byte[] | |
| private int | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv byte[] | Returns: the byte array containing the definite length DER encoding, or null if there is not enough data.the byte array holding the indefinite
length encoding. indefData)Converts an indefinite length DER encoded byte array to a definite length DER encoding. |
| public static byte[] | Returns: a DER byte arraythe input stream with tag and lenByte already read in, byte the tag to remember tag)Read the input stream into a DER byte array. |
| private byte[] | |
| private int | |
| private static boolean | |
| pack-priv static boolean | Returns: true if the byte is of Indefinite form otherwise returns false.the length byte from a DER encoded
object. lengthByte)Checks whether the given length byte is of the form Indefinite. |
| pack-priv static boolean | |
| private int | Returns: a) the length of definite length data next b) -1, if it is a definite length data next but the length octets is not complete to determine the actual length c) 0, if it is an indefinite length. Also, append the current position to thendefsList vector.Parse the length octets started at |
| private void | |
| private void | |
| private void | |
| private void | writeTag()
Write the tag and if it is an end-of-contents tag then skip the tag and its 1 byte length of zero. |
| private void |
| data | back to summary |
|---|---|
| private byte[] data | |
| dataPos | back to summary |
|---|---|
| private int dataPos | |
| dataSize | back to summary |
|---|---|
| private int dataSize | |
| index | back to summary |
|---|---|
| private int index | |
| LEN_LONG | back to summary |
|---|---|
| private static final int LEN_LONG | |
| LEN_MASK | back to summary |
|---|---|
| private static final int LEN_MASK | |
| ndefsList | back to summary |
|---|---|
| private final ArrayList<Object> ndefsList | |
| newData | back to summary |
|---|---|
| private byte[] newData | |
| newDataPos | back to summary |
|---|---|
| private int newDataPos | |
| numOfTotalLenBytes | back to summary |
|---|---|
| private int numOfTotalLenBytes | |
| unresolved | back to summary |
|---|---|
| private int unresolved | |
| DerIndefLenConverter | back to summary |
|---|---|
| private DerIndefLenConverter() | |
| convertBytes | back to summary |
|---|---|
| pack-priv byte[] convertBytes(byte[] indefData) throws IOException Converts an indefinite length DER encoded byte array to a definite length DER encoding.
| |
| convertStream | back to summary |
|---|---|
| public static byte[] convertStream(InputStream in, byte tag) throws IOException Read the input stream into a DER byte array. If an indef len BER is not resolved this method will try to read more data until EOF is reached. This may block.
| |
| getLengthBytes | back to summary |
|---|---|
| private byte[] getLengthBytes(int curLen) | |
| getNumOfLenBytes | back to summary |
|---|---|
| private int getNumOfLenBytes(int len) | |
| isEOC | back to summary |
|---|---|
| private static boolean isEOC(byte[] data, int pos) | |
| isIndefinite | back to summary |
|---|---|
| pack-priv static boolean isIndefinite(int lengthByte) Checks whether the given length byte is of the form Indefinite.
| |
| isLongForm | back to summary |
|---|---|
| pack-priv static boolean isLongForm(int lengthByte) | |
| parseLength | back to summary |
|---|---|
| private int parseLength() throws IOException Parse the length octets started at
| |
| parseTag | back to summary |
|---|---|
| private void parseTag() throws IOException Consumes the tag at
If it is EOC then replace the matching start position (i.e. the previous
| |
| writeLength | back to summary |
|---|---|
| private void writeLength(int curLen) | |
| writeLengthAndValue | back to summary |
|---|---|
| private void writeLengthAndValue() throws IOException Write the length and value.
If it was definite length, just re-write the length and copy the value.
If it was an indefinite length, copy the precalculated definite octets
from | |
| writeTag | back to summary |
|---|---|
| private void writeTag() Write the tag and if it is an end-of-contents tag then skip the tag and its 1 byte length of zero. | |
| writeValue | back to summary |
|---|---|
| private void writeValue(int curLen) Write the value; | |