Class Asn1
java.lang.Object
com.codename1.backend.security.pki.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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classReads one level of a DER structure. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]bitString(byte[] value) static intexplicit(int n) The context-specific constructed tag[n].static byte[]static intimplicit(int n) The context-specific primitive tag[n].static byte[]integer(long value) A non-negative INTEGER.static byte[]static byte[]octets(byte[] value) static byte[]static StringoidString(byte[] value) static byte[]printableString(String value) static byte[]sequence(byte[]... parts) static byte[]set(byte[]... parts) static byte[]tlv(int tag, byte[]... parts) static byte[]unsignedInteger(byte[] magnitude) An INTEGER from an unsigned magnitude.static byte[]utf8String(String value)
-
Field Details
-
BOOLEAN
public static final int BOOLEAN- See Also:
-
INTEGER
public static final int INTEGER- See Also:
-
BIT_STRING
public static final int BIT_STRING- See Also:
-
OCTET_STRING
public static final int OCTET_STRING- See Also:
-
NULL
public static final int NULL- See Also:
-
OID
public static final int OID- See Also:
-
UTF8_STRING
public static final int UTF8_STRING- See Also:
-
PRINTABLE_STRING
public static final int PRINTABLE_STRING- See Also:
-
T61_STRING
public static final int T61_STRING- See Also:
-
IA5_STRING
public static final int IA5_STRING- See Also:
-
UTC_TIME
public static final int UTC_TIME- See Also:
-
GENERALIZED_TIME
public static final int GENERALIZED_TIME- See Also:
-
UNIVERSAL_STRING
public static final int UNIVERSAL_STRING- See Also:
-
BMP_STRING
public static final int BMP_STRING- See Also:
-
SEQUENCE
public static final int SEQUENCE- See Also:
-
SET
public static final int SET- See Also:
-
-
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
-
utf8String
-
ia5String
-
printableString
-
oidString
- Throws:
IOException
-