Class Tlv

java.lang.Object
com.yubico.yubikit.core.util.Tlv

public class Tlv extends Object
Tag, length, Value structure that helps to parse APDU response data. This class handles BER-TLV encoded data with determinate length.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tlv(int tag, byte[] value)
    Creates a new Tlv given a tag and a value.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the Tlv as a BER-TLV encoded byte array.
    int
    Returns the length of the value.
    int
    Returns the tag.
    byte[]
    returns the value.
    static Tlv
    parse(byte[] data)
    Parse a Tlv from a BER-TLV encoded byte array.
    static Tlv
    parse(byte[] data, int offset, int length)
    Parse a Tlv from a BER-TLV encoded byte array.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Tlv

      public Tlv(int tag, @Nullable byte[] value)
      Creates a new Tlv given a tag and a value.
  • Method Details

    • getTag

      public int getTag()
      Returns the tag.
    • getValue

      public byte[] getValue()
      returns the value.
    • getLength

      public int getLength()
      Returns the length of the value.
    • getBytes

      public byte[] getBytes()
      Returns the Tlv as a BER-TLV encoded byte array.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parse

      public static Tlv parse(byte[] data, int offset, int length)
      Parse a Tlv from a BER-TLV encoded byte array.
      Parameters:
      data - a byte array containing the TLV encoded data.
      offset - the offset in data where the TLV data begins.
      length - the length of the TLV encoded data.
      Returns:
      The parsed Tlv
    • parse

      public static Tlv parse(byte[] data)
      Parse a Tlv from a BER-TLV encoded byte array.
      Parameters:
      data - a byte array containing the TLV encoded data (and nothing more).
      Returns:
      The parsed Tlv