Class Uid

java.lang.Object
dev.hloth.zgztransport.Uid

public final class Uid extends Object
The UID of block 0, four or seven bytes, together with the chip whose SAK and ATQA sit beside it. The length belongs to the block rather than to the chip: a 4K card comes with either.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    The bytes of this UID.
    The chip this UID was read beside.
    static Uid
    decode(byte[] block)
    Decodes block 0 by trying the two layouts a block 0 comes in, the seven byte one first, and reading the chip off the SAK and the ATQA each of them puts after the UID.
    boolean
    equals(Object other)
     
    int
     
    static Uid
    of(byte[] bytes, Chip chip)
    The UID those bytes hold, on the chip it was read from.
    The UID as upper case hex, the form dump tools print.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • of

      public static Uid of(byte[] bytes, Chip chip)
      The UID those bytes hold, on the chip it was read from.
      Parameters:
      bytes - the UID bytes, four or seven of them, which are copied
      chip - the chip the card is built on
      Returns:
      the UID
      Throws:
      CardFormatException - if the UID is neither four nor seven bytes long
      NullPointerException - if the chip is null
    • decode

      public static Uid decode(byte[] block)
      Decodes block 0 by trying the two layouts a block 0 comes in, the seven byte one first, and reading the chip off the SAK and the ATQA each of them puts after the UID. A seven byte UID can hold a known SAK in byte 5 by chance, so the BCC and the ATQA position are what tell the two apart.
      Parameters:
      block - the sixteen bytes
      Returns:
      the UID and the chip it was read beside
      Throws:
      CardFormatException - if the block is not sixteen bytes, or neither layout holds a known SAK and ATQA with a matching BCC
    • bytes

      public byte[] bytes()
      The bytes of this UID.
      Returns:
      a copy of them
    • chip

      public Chip chip()
      The chip this UID was read beside.
      Returns:
      the chip
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      The UID as upper case hex, the form dump tools print.
      Overrides:
      toString in class Object
      Returns:
      the printed UID