Top Description Fields Constructors Methods
org.apache.sshd.common.util.io.der

public Class DERParser

extends FilterInputStream
Class Inheritance
Imports
java.io.ByteArrayInputStream, .FilterInputStream, .IOException, .InputStream, .StreamCorruptedException, java.math.BigInteger, java.util.Arrays, org.apache.sshd.common.util.GenericUtils, .NumberUtils, org.apache.sshd.common.util.buffer.BufferUtils

A bare minimum DER parser - just enough to be able to decode signatures and private keys
Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final byte[]
public static final int
MAX_DER_VALUE_LENGTH

Maximum size of data allowed by readLength() - it is a bit arbitrary since one can encode 32-bit length data, but it is good enough for the keys

Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
DERParser(byte... bytes)

public
DERParser(byte[] bytes, int offset, int len)

public

Method Summary

Modifier and TypeMethod and Description
public BigInteger
public int

Returns:

The length as integer
readLength
()

Decode the length of the field.

public ASN1Object
Inherited from java.io.FilterInputStream:
availableclosemarkmarkSupportedreadreadreadresetskip

Field Detail

lenBytesback to summary
private final byte[] lenBytes
MAX_DER_VALUE_LENGTHback to summary
public static final int MAX_DER_VALUE_LENGTH

Maximum size of data allowed by readLength() - it is a bit arbitrary since one can encode 32-bit length data, but it is good enough for the keys

Constructor Detail

DERParserback to summary
public DERParser(byte... bytes)
DERParserback to summary
public DERParser(byte[] bytes, int offset, int len)
DERParserback to summary
public DERParser(InputStream s)

Method Detail

readBigIntegerback to summary
public BigInteger readBigInteger() throws IOException
readLengthback to summary
public int readLength() throws IOException

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:int

The length as integer

Exceptions
IOException:
If invalid format found
readObjectback to summary
public ASN1Object readObject() throws IOException