Class DERParser
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.sshd.common.util.io.der.DERParser
- All Implemented Interfaces:
Closeable
,AutoCloseable
A bare minimum DER parser - just enough to be able to decode signatures and private keys
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
static final int
Maximum size of data allowed byreadLength()
- it is a bit arbitrary since one can encode 32-bit length data, but it is good enough for the keysFields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Decode the length of the field.Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skip
-
Field Details
-
MAX_DER_VALUE_LENGTH
public static final int MAX_DER_VALUE_LENGTHMaximum size of data allowed byreadLength()
- it is a bit arbitrary since one can encode 32-bit length data, but it is good enough for the keys- See Also:
-
lenBytes
private final byte[] lenBytes
-
-
Constructor Details
-
DERParser
public DERParser(byte... bytes) -
DERParser
public DERParser(byte[] bytes, int offset, int len) -
DERParser
-
-
Method Details
-
readLength
Decode the length of the field. Can only support length encoding up to 4 octets. In BER/DER encoding, length can be encoded in 2 forms:-
Short form - One octet. Bit 8 has value "0" and bits 7-1 give the length.
-
Long form - Two to 127 octets (only 4 is supported here). Bit 8 of first octet has value "1" and bits 7-1 give the number of additional length octets. Second and following octets give the length, base 256, most significant digit first.
- Returns:
- The length as integer
- Throws:
IOException
- If invalid format found
-
-
readObject
- Throws:
IOException
-
readBigInteger
- Throws:
IOException
-