public final class DerUtils extends Object
Modifier and Type | Field and Description |
---|---|
static byte |
INTEGER_TAG
DER tag for integer values.
|
static byte |
SEQUENCE_TAG
DER tag for sequence values.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
encodeEcdsaSignature(byte[] signature)
Minimal DER encoder for the format expected by the SunEC signature provider.
|
static int |
readLength(ByteBuffer buffer)
Reads a DER-encoded length field from the given byte buffer.
|
static void |
readUnsignedInteger(ByteBuffer input,
byte[] output,
int offset,
int length)
Reads an unsigned integer value into the given byte array.
|
static void |
writeInteger(ByteBuffer buffer,
byte[] data)
Writes an integer value in DER format to the given buffer.
|
static void |
writeLength(ByteBuffer output,
int length)
Writes a length field to the output.
|
public static final byte INTEGER_TAG
public static final byte SEQUENCE_TAG
public static void readUnsignedInteger(ByteBuffer input, byte[] output, int offset, int length)
length
bytes (leaving untouched any unused leading bytes).input
- the input DER-encoded byte buffer.output
- the output byte array.offset
- the offset into the byte array to start writing the integer value.length
- the maximum length of the byte value (excluding any leading sign byte).BufferOverflowException
- if the integer does not fit in the given output buffer slice.public static void writeInteger(ByteBuffer buffer, byte[] data)
buffer
- the buffer to write the value todata
- the integer value (in big-endian format) to writepublic static int readLength(ByteBuffer buffer)
buffer
- the buffer to read a length field from.public static void writeLength(ByteBuffer output, int length)
output
- the output buffer.length
- the length to write.public static byte[] encodeEcdsaSignature(byte[] signature)
signature
- raw signatureCopyright © 2010-2018, ForgeRock All Rights Reserved.