AsnInputStream extends InputStream { public byte[] readIndefinite() throws AsnException, IOException { int startPos = this.pos; this.advanceIndefiniteLength(); byte[] res = new byte[this.pos - startPos - 2]; System.arraycopy(this.buffer, this.start + startPos, res, 0, this.pos - startPos - 2); return res; } AsnInputStream( byte[] buf );  AsnInputStream( byte[] buf, int tagClass, boolean isPrimitive, int tag ); protected  AsnInputStream( AsnInputStream buf, int start, int length ); @Deprecated  AsnInputStream(InputStream in); int position(); void position( int newPosition ); @Override int available(); void advance(int byteCount); @Override long skip(long n); @Override boolean markSupported(); @Override int read(); @Override int read(byte[] b, int off, int len); @Override int read(byte[] b); int readTag(); int getTagClass(); int getTag(); boolean isTagPrimitive(); int readLength(); AsnInputStream readSequenceStream(); byte[] readSequence(); AsnInputStream readSequenceStreamData(int length); byte[] readSequenceData(int length); AsnInputStream readSequenceIndefinite(); byte[] readIndefinite(); void advanceElement(); void advanceElementData(int length); boolean readBoolean(); boolean readBooleanData(int length); long readInteger(); long readIntegerData(int length); double readReal(); double readRealData(int length); BitSetStrictLength readBitString(); BitSetStrictLength readBitStringData(int length); @Deprecated void readBitString(BitSet bitSet); @Deprecated void readBitStringData(BitSet bitSet, int length); @Deprecated void readBitStringData(BitSet bitSet, int length, boolean isTagPrimitive); byte[] readOctetString(); @Deprecated void readOctetString(OutputStream outputStream); byte[] readOctetStringData(int length); @Deprecated void readOctetStringData(OutputStream outputStream, int length); @Deprecated void readOctetStringData(OutputStream outputStream, int length, boolean isTagPrimitive); void readNull(); void readNullData(int length); long[] readObjectIdentifier(); long[] readObjectIdentifierData(int length); String readIA5String(); String readIA5StringData(int length); String readUTF8String(); String readUTF8StringData(int length); String readGraphicString(); String readGraphicStringData(int length); @Override String toString();  }
@Test public void testReadIndefinite() throws Exception { byte[] data = new byte[] { (byte)0x80, (byte)0x80, 0x09, (byte)0x96, 0x02, 0x24, (byte)0x80, 0x03, 0x00, (byte)0x80, 0x00, (byte)0xf2, (byte)0x81, 0x07, (byte)0x91, 0x13, 0x26, (byte)0x98, (byte)0x86, 0x03, (byte)0xf0, 0x00, 0x00 }; AsnInputStream asnIs = new AsnInputStream(data); int length = asnIs.readLength(); assertTrue(Tag.Indefinite_Length == length); byte[] indefiniteData = asnIs.readIndefinite(); assertTrue(20 == indefiniteData.length); asnIs = new AsnInputStream(data); AsnInputStream asnIs2 = asnIs.readSequenceStream(); assertTrue(20 == asnIs2.available()); asnIs = new AsnInputStream(data); byte[] bfRes = asnIs.readSequence(); assertTrue(20 == bfRes.length); }