Package aQute.libg.asn1
Class BER
- java.lang.Object
-
- aQute.libg.asn1.BER
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.text.DateFormat
df
(package private) long
position
(package private) java.io.DataInputStream
xin
-
Fields inherited from interface aQute.libg.asn1.Types
APPLICATION, BIT_STRING, BMP_STRING, BOOLEAN, CHARACTER_STRING, CLASSES, CLASSMASK, CONSTRUCTED, CONTEXT, EMBEDDED_PDV, ENUMERATED, EOC, EXTERNAL, GENERAL_STRING, GENERALIZED_TIME, GRAPHIC_STRING, IA5STRING, INTEGER, NULL, NUMERIC_STRING, OBJECT_DESCRIPTOR, OBJECT_IDENTIFIER, OCTET_STRING, PRINTABLE_STRING, PRIVATE, REAL, RELATIVE_OID, SEQUENCE, SET, T61_STRING, TAGMASK, TAGS, UNIVERSAL, UNIVERSAL_STRING, UTCTIME, UTF8_STRING, VIDEOTEX_STRING, VISIBLE_STRING
-
-
Constructor Summary
Constructors Constructor Description BER(java.io.InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dump(java.io.PrintStream out)
(package private) void
dump(java.io.PrintStream out, int type, long length, java.lang.String indent)
(package private) int
getPayloadLength(PDU pdu)
private long
getPosition()
private void
putOid(java.io.OutputStream out, int i)
private int
read()
private int
readByte()
private void
readFully(byte[] data)
private long
readLength()
8.1.3.3 For the definite form, the length octets shall consist of one or more octets, and shall represent the number of octets in the contents octets using either the short form (see 8.1.3.4) or the long form (see 8.1.3.5) as a sender's option.(package private) java.lang.String
readOID(byte[] data)
(package private) int
size(long value)
(package private) long
toLong(byte[] data)
void
write(java.io.OutputStream out, PDU pdu)
(package private) void
writePayload(java.io.OutputStream out, PDU pdu)
-
-
-
Method Detail
-
dump
public void dump(java.io.PrintStream out) throws java.lang.Exception
- Throws:
java.lang.Exception
-
dump
void dump(java.io.PrintStream out, int type, long length, java.lang.String indent) throws java.lang.Exception
- Throws:
java.lang.Exception
-
toLong
long toLong(byte[] data)
-
readLength
private long readLength() throws java.io.IOException
8.1.3.3 For the definite form, the length octets shall consist of one or more octets, and shall represent the number of octets in the contents octets using either the short form (see 8.1.3.4) or the long form (see 8.1.3.5) as a sender's option. NOTE – The short form can only be used if the number of octets in the contents octets is less than or equal to 127. 8.1.3.4 In the short form, the length octets shall consist of a single octet in which bit 8 is zero and bits 7 to 1 encode the number of octets in the contents octets (which may be zero), as an unsigned binary integer with bit 7 as the most significant bit. EXAMPLE L = 38 can be encoded as 001001102 8.1.3.5 In the long form, the length octets shall consist of an initial octet and one or more subsequent octets. The initial octet shall be encoded as follows: a) bit 8 shall be one; b) bits 7 to 1 shall encode the number of subsequent octets in the length octets, as an unsigned binary integer with bit 7 as the most significant bit; c) the value 111111112 shall not be used. ISO/IEC 8825-1:2003 (E) NOTE 1 – This restriction is introduced for possible future extension. Bits 8 to 1 of the first subsequent octet, followed by bits 8 to 1 of the second subsequent octet, followed in turn by bits 8 to 1 of each further octet up to and including the last subsequent octet, shall be the encoding of an unsigned binary integer equal to the number of octets in the contents octets, with bit 8 of the first subsequent octet as the most significant bit. EXAMPLE L = 201 can be encoded as: 100000012 110010012 NOTE 2 – In the long form, it is a sender's option whether to use more length octets than the minimum necessary. 8.1.3.6 For the indefinite form, the length octets indicate that the contents octets are terminated by end-of-contents octets (see 8.1.5), and shall consist of a single octet. 8.1.3.6.1 The single octet shall have bit 8 set to one, and bits 7 to 1 set to zero. 8.1.3.6.2 If this form of length is used, then end-of-contents octets (see 8.1.5) shall be present in the encoding following the contents octets. 8.1.4 Contents octets The contents octets shall consist of zero, one or more octets, and shall encode the data value as specified in subsequent clauses. NOTE – The contents octets depend on the type of the data value; subsequent clauses follow the same sequence as the definition of types in ASN.1. 8.1.5 End-of-contents octets The end-of-contents octets shall be present if the length is encoded as specified in 8.1.3.6, otherwise they shall not be present. The end-of-contents octets shall consist of two zero octets. NOTE – The end-of-contents octets can be considered as the encoding of a value whose tag is universal class, whose form is primitive, whose number of the tag is zero, and whose contents are absent, thus: End-of-contents Length Contents 0016 0016 Absent- Throws:
java.io.IOException
-
readByte
private int readByte() throws java.io.IOException
- Throws:
java.io.IOException
-
readFully
private void readFully(byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
getPosition
private long getPosition()
-
read
private int read() throws java.io.IOException
- Throws:
java.io.IOException
-
readOID
java.lang.String readOID(byte[] data)
-
getPayloadLength
int getPayloadLength(PDU pdu) throws java.lang.Exception
- Throws:
java.lang.Exception
-
size
int size(long value)
-
write
public void write(java.io.OutputStream out, PDU pdu) throws java.lang.Exception
- Throws:
java.lang.Exception
-
writePayload
void writePayload(java.io.OutputStream out, PDU pdu) throws java.lang.Exception
- Throws:
java.lang.Exception
-
putOid
private void putOid(java.io.OutputStream out, int i) throws java.io.IOException
- Throws:
java.io.IOException
-
-