Package io.airlift.security.der
Class DerUtils
java.lang.Object
io.airlift.security.der.DerUtils
ASN.1 DER encoder methods necessary to process PEM files and to write a certificate signing request.
NOTE: this API is only present for the two mentioned use cases, and is subject to change without warning.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic List<byte[]>decodeSequence(byte[] sequence) Decodes a sequence of encoded values.static byte[]decodeSequenceOptionalElement(byte[] element) Decodes a optional element of a sequence.static byte[]encodeBitString(int padBits, byte[] value) Encodes a bit string padded with the specified number of bits.static byte[]Encodes an integer.static byte[]encodeContextSpecificSequence(int tag, byte[]... encodedValues) static byte[]encodeContextSpecificTag(int tag, byte[] body) static byte[]encodeInteger(long value) Encodes an integer.static byte[]encodeInteger(BigInteger value) Encodes an integer.static byte[]encodeLength(int length) Encodes the length of a DER value.static byte[]static byte[]encodeOctetString(byte[] value) Encodes an octet string.static byte[]static byte[]encodeSequence(byte[]... encodedValues) Encodes a sequence of encoded values.static byte[]encodeTag(int tag, byte[] body) static byte[]encodeUtcTime(String value) Encodes an octet string.static byte[]encodeUtcTime(Instant value) Encodes an octet string.
-
Field Details
-
SEQUENCE_TAG
public static final int SEQUENCE_TAG- See Also:
-
BOOLEAN_TAG
public static final int BOOLEAN_TAG- See Also:
-
INTEGER_TAG
public static final int INTEGER_TAG- See Also:
-
BIT_STRING_TAG
public static final int BIT_STRING_TAG- See Also:
-
OCTET_STRING_TAG
public static final int OCTET_STRING_TAG- See Also:
-
NULL_TAG
public static final int NULL_TAG- See Also:
-
OBJECT_IDENTIFIER_TAG
public static final int OBJECT_IDENTIFIER_TAG- See Also:
-
UTC_TIME_TAG
public static final int UTC_TIME_TAG- See Also:
-
-
Method Details
-
encodeSequence
public static byte[] encodeSequence(byte[]... encodedValues) Encodes a sequence of encoded values. -
decodeSequence
Decodes a sequence of encoded values. -
decodeSequenceOptionalElement
public static byte[] decodeSequenceOptionalElement(byte[] element) Decodes a optional element of a sequence. -
encodeBitString
public static byte[] encodeBitString(int padBits, byte[] value) Encodes a bit string padded with the specified number of bits. The encoding is a byte containing the padBits followed by the value bytes. -
encodeBooleanTrue
public static byte[] encodeBooleanTrue()Encodes an integer. -
encodeInteger
public static byte[] encodeInteger(long value) Encodes an integer. -
encodeInteger
Encodes an integer. -
encodeOctetString
public static byte[] encodeOctetString(byte[] value) Encodes an octet string. -
encodeUtcTime
Encodes an octet string. -
encodeUtcTime
Encodes an octet string. -
encodeLength
public static byte[] encodeLength(int length) Encodes the length of a DER value. The encoding of a 7bit value is simply the value. Values needing more than 7bits are encoded as a lead byte with the high bit set and containing the number of value bytes. Then the following bytes encode the length using the least number of bytes possible. -
encodeOid
-
encodeNull
public static byte[] encodeNull() -
encodeTag
public static byte[] encodeTag(int tag, byte[] body) -
encodeContextSpecificTag
public static byte[] encodeContextSpecificTag(int tag, byte[] body) -
encodeContextSpecificSequence
public static byte[] encodeContextSpecificSequence(int tag, byte[]... encodedValues)
-