Class DerUtils

java.lang.Object
io.airlift.security.der.DerUtils

public final class DerUtils extends Object
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 Details

  • Method Details

    • encodeSequence

      public static byte[] encodeSequence(byte[]... encodedValues)
      Encodes a sequence of encoded values.
    • decodeSequence

      public static List<byte[]> decodeSequence(byte[] sequence)
      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

      public static byte[] encodeInteger(BigInteger value)
      Encodes an integer.
    • encodeOctetString

      public static byte[] encodeOctetString(byte[] value)
      Encodes an octet string.
    • encodeUtcTime

      public static byte[] encodeUtcTime(String value)
      Encodes an octet string.
    • encodeUtcTime

      public static byte[] encodeUtcTime(Instant value)
      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

      public static byte[] encodeOid(String oid)
    • 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)