public class Tag extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BitString
Bit String Tag
|
static int |
Integer
Integer Tag
|
static int |
Null
Null Tag
|
static int |
ObjectIdentifier
Object Identifier Tag
|
static int |
OctetString
Octet String Tag
|
boolean |
primitive
True if this Tag is primitive.
|
static int |
PrintableString
PrintableString Tag
|
byte |
rawByte
The raw byte read from the DER encoded array.
|
static int |
Sequence
Sequence Tag
|
static int |
Set
Set and Set of
|
TagClass |
tagClass
The class of this tag read from bits 8 and 7 of the raw byte.
|
static int |
UTCTime
UTCTime Tag
|
int |
value
The tag value in decimal.
|
Constructor and Description |
---|
Tag(int value)
Construct a new tag from the tag byte in the DER byte array.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
String |
getName() |
int |
hashCode() |
boolean |
is(int tag) |
boolean |
isConstructed() |
boolean |
isPrimitive() |
String |
toString() |
public static final int BitString
public static final int Integer
public static final int Null
public static final int ObjectIdentifier
public static final int OctetString
public static final int PrintableString
19 decimal, 0x13 hex
public static final int Sequence
16 decimal, 0x10 hex, 0b00010000 binary
Because the Sequence tag is always in a constructed form (not primitive), the tag will present as0x30
because
the 6th bit is a 1
indicating a constructed form. So the raw sequence of 0b00010000
becomes
0b00110000
which is 48
decimal.public static final int Set
17 decimal, 0x11 hex
public static final int UTCTime
23 decimal, 0x17 hex
public final boolean primitive
public final byte rawByte
public final TagClass tagClass
public final int value
For example, if this is a sequence tag, this value will be 16
and you should expect primitive
to be false. If you want the raw byte which will be 48
or 0x30
you can read rawByte
.
public Tag(int value)
--------------------------------------------------------- | b8 | b7 | b6 | b5 | b4 | b3 | b2 | b1 | --------------------------------------------------------- |______| | |___________________________| | | | | |-- [0] Primitive | | |-- [1] Constructed | | Tag Number (value) | Class |--------------------------- |-- 0 0 Universal |-- 0 1 Application |-- 1 0 Context Specific |-- 1 1 Private
value
- the tag value from the DER byte arraypublic String getName()
public boolean is(int tag)
tag
- a tagpublic boolean isConstructed()
public boolean isPrimitive()
Copyright © 2021. All rights reserved.