Class Tag

java.lang.Object
io.fusionauth.der.Tag

public class Tag extends Object
This object models a ASN.1 DER Tag.
Author:
Daniel DeGroff
  • Field Details

    • BitString

      public static final int BitString
      Bit String Tag
      See Also:
    • Integer

      public static final int Integer
      Integer Tag
      See Also:
    • Null

      public static final int Null
      Null Tag
      See Also:
    • ObjectIdentifier

      public static final int ObjectIdentifier
      Object Identifier Tag
      See Also:
    • OctetString

      public static final int OctetString
      Octet String Tag
      See Also:
    • PrintableString

      public static final int PrintableString
      PrintableString Tag

      19 decimal, 0x13 hex

      See Also:
    • Sequence

      public static final int Sequence
      Sequence Tag

      16 decimal, 0x10 hex, 0b00010000 binary

      Because the Sequence tag is always in a constructed form (not primitive), the tag will present as 0x30 because the 6th bit is a 1 indicating a constructed form. So the raw sequence of 0b00010000 becomes 0b00110000 which is 48 decimal.
      See Also:
    • Set

      public static final int Set
      Set and Set of

      17 decimal, 0x11 hex

      See Also:
    • UTCTime

      public static final int UTCTime
      UTCTime Tag

      23 decimal, 0x17 hex

      See Also:
    • primitive

      public final boolean primitive
      True if this Tag is primitive. False if this Tag is constructed.
    • rawByte

      public final byte rawByte
      The raw byte read from the DER encoded array. This byte includes the class, form and tag number.
    • tagClass

      public final TagClass tagClass
      The class of this tag read from bits 8 and 7 of the raw byte.
    • value

      public final int value
      The tag value in decimal. This value will only represent the decimal value of bits 5 to 1.

      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.

  • Constructor Details

    • Tag

      public Tag(int value)
      Construct a new tag from the tag byte in the DER byte array. The following depicts the layout of the tag byte.
         ---------------------------------------------------------
         |  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
       
      Parameters:
      value - the tag value from the DER byte array
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • getName

      public String getName()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • is

      public boolean is(int tag)
      Parameters:
      tag - a tag
      Returns:
      true if this tag has the same value as requested
    • isConstructed

      public boolean isConstructed()
    • isPrimitive

      public boolean isPrimitive()
    • toString

      public String toString()
      Overrides:
      toString in class Object