Class KeySerialNumber
java.lang.Object
org.jpos.security.KeySerialNumber
- All Implemented Interfaces:
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
Refer to ANSI X9.24 for more information about DUKPT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionKeySerialNumber(byte[] ksn) Constructs a key serial number object from its binary representation.KeySerialNumber(String baseKeyID, String deviceID, String transactionCounter) Constructs a key serial number object -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(PrintStream p, String indent) dumps Key Serial NumberReturns the base key ID as a hexadecimal string padded with leading zeros to a length of 10 characters.byte[]Returns the base key ID as an array of bytes.byte[]getBytes()Constructs a 10-byte Key Serial Number (KSN) array using the base key ID, device ID, and transaction counter.Returns the device ID as a hexadecimal string padded with leading zeros to a length of 6 characters.byte[]Returns the deviceID as an array of bytes.Returns the transaction counter as a hexadecimal string padded with leading zeros to a length of 6 characters.byte[]Returns the transaction counter as an array of bytes.toString()
-
Constructor Details
-
KeySerialNumber
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
Constructs a key serial number object from its binary representation.- Parameters:
ksn- binary representation of the KSN.
-
-
Method Details
-
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
Returns the base key ID as an array of bytes.- Returns:
- a 5 bytes array representing the base key ID.
-
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
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
Returns the transaction counter as an array of bytes. -
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
dumps Key Serial Number -
toString
-