Class Asn1

java.lang.Object
com.codename1.backend.security.pki.Asn1

public final class Asn1 extends Object

The DER this package reads and writes: a reader over definite-length encodings and the handful of writers the formats here need.

BER's indefinite lengths are refused. X.509, PKCS#10 and the PKCS#12 files OpenSSL and the JDK write are DER; a file that is not is reported as such rather than half read.

It is public for formats this package does not cover -- a CMS SignedData structure, an Apple receipt, an attestation extension -- so they are read with the same bounds checks rather than by hand.

Asn1.Reader outer = new Asn1.Reader(der).open(Asn1.SEQUENCE);
String type = outer.oid();
byte[] content = outer.open(Asn1.explicit(0)).raw(Asn1.SEQUENCE);
  • Field Details

  • Method Details

    • explicit

      public static int explicit(int n)
      The context-specific constructed tag [n].
    • implicit

      public static int implicit(int n)
      The context-specific primitive tag [n].
    • tlv

      public static byte[] tlv(int tag, byte[]... parts)
    • sequence

      public static byte[] sequence(byte[]... parts)
    • set

      public static byte[] set(byte[]... parts)
    • octets

      public static byte[] octets(byte[] value)
    • bitString

      public static byte[] bitString(byte[] value)
    • nullValue

      public static byte[] nullValue()
    • integer

      public static byte[] integer(long value)
      A non-negative INTEGER.
    • unsignedInteger

      public static byte[] unsignedInteger(byte[] magnitude)
      An INTEGER from an unsigned magnitude.
    • oid

      public static byte[] oid(String dotted)
    • utf8String

      public static byte[] utf8String(String value)
    • ia5String

      public static byte[] ia5String(String value)
    • printableString

      public static byte[] printableString(String value)
    • oidString

      public static String oidString(byte[] value) throws IOException
      Throws:
      IOException