Class KeySerialNumber

java.lang.Object
org.jpos.security.KeySerialNumber
All Implemented Interfaces:
Serializable, Loggeable

public class KeySerialNumber extends Object implements Serializable, Loggeable
Key Serial Number (also called Key Name in the ANSI X9.24). Needed for deriving the Transaction Key when DUKPT (Derived Unique Key Per Transaction) method is used.
Refer to ANSI X9.24 for more information about DUKPT
See Also:
  • Constructor Details

    • KeySerialNumber

      public KeySerialNumber(String baseKeyID, String deviceID, String transactionCounter)
      Constructs a key serial number object
      Parameters:
      baseKeyID - a HexString representing the BaseKeyID (also called KeySet ID)
      deviceID - a HexString representing the Device ID (also called TRSM ID)
      transactionCounter - a HexString representing the transaction counter
    • KeySerialNumber

      public KeySerialNumber(byte[] ksn)
      Constructs a key serial number object from its binary representation.
      Parameters:
      ksn - binary representation of the KSN.
  • Method Details

    • getBaseKeyID

      public String getBaseKeyID()
      Returns the base key ID as a hexadecimal string padded with leading zeros to a length of 10 characters.
      Returns:
      a String representing the base key ID.
    • getBaseKeyIDBytes

      public byte[] getBaseKeyIDBytes()
      Returns the base key ID as an array of bytes.
      Returns:
      a 5 bytes array representing the base key ID.
    • getDeviceID

      public String getDeviceID()
      Returns the device ID as a hexadecimal string padded with leading zeros to a length of 6 characters.
      Returns:
      a String representing the device ID.
    • getDeviceIDBytes

      public byte[] getDeviceIDBytes()
      Returns the deviceID as an array of bytes.
    • getTransactionCounter

      Returns the transaction counter as a hexadecimal string padded with leading zeros to a length of 6 characters.
      Returns:
      a String representing the transaction counter.
    • getTransactionCounterBytes

      public byte[] getTransactionCounterBytes()
      Returns the transaction counter as an array of bytes.
    • getBytes

      public byte[] getBytes()
      Constructs a 10-byte Key Serial Number (KSN) array using the base key ID, device ID, and transaction counter. The method first extracts the last 5 bytes from the base key ID and device ID (shifted and combined with the transaction counter), and then combines them into a single ByteBuffer of size 10.
      Returns:
      A byte array containing the 10-byte Key Serial Number.
    • dump

      public void dump(PrintStream p, String indent)
      dumps Key Serial Number
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - a PrintStream usually supplied by Logger
      indent - indention string, usually suppiled by Logger
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object