Class 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.
    • Method Detail

      • 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.
      • encodeOctetString

        public static byte[] encodeOctetString​(byte[] 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)