Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class Asn1
- Object
- Asn1
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);
Nested types
class Asn1.Reader | Reads one level of a DER structure. |
Fields
Methods
Inherited methods
Field details
BOOLEAN
public static final int BOOLEAN = 1INTEGER
public static final int INTEGER = 2BIT_STRING
public static final int BIT_STRING = 3OCTET_STRING
public static final int OCTET_STRING = 4NULL
public static final int NULL = 5OID
public static final int OID = 6UTF8_STRING
public static final int UTF8_STRING = 12PRINTABLE_STRING
public static final int PRINTABLE_STRING = 19T61_STRING
public static final int T61_STRING = 20IA5_STRING
public static final int IA5_STRING = 22UTC_TIME
public static final int UTC_TIME = 23GENERALIZED_TIME
public static final int GENERALIZED_TIME = 24UNIVERSAL_STRING
public static final int UNIVERSAL_STRING = 28BMP_STRING
public static final int BMP_STRING = 30SEQUENCE
public static final int SEQUENCE = 48SET
public static final int SET = 49Method 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