Continuing on the previous post
Reading Length in ASN.1
private int readLength(DataInputStream inputStream)
{
byte[] bytes = readBytes(inputStream, 1);
BitIterator iterator = new BitIterator(bytes);
String mostSignificant = iterator.getBits(1);
String value = iterator.getBits(7);
int length = Integer.parseInt(value, 2);
if (!mostSignificant.equals("0"))
{
bytes = readBytes(inputStream, length);
value = byteArraytoHex(bytes);
length = Integer.parseInt(value, 16);
}
System.out.println("Length of the record " + length);
return length;
}
No comments:
Post a Comment