Class EncryptedPIN

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

public class EncryptedPIN extends Object implements Serializable, Loggeable

The PIN (Personal Identification Number), is used to authenticate card holders. A user enters his/her PIN on the pin-pad (also called pin entry device) of a terminal (whether ATM or POS). The terminal forms the PIN Block, which is a mix of the PIN and the account number.
In a typical environment, the PIN Block (not the PIN) gets encrypted and sent to the acquirer. This Encrypted PIN Block is the typical content of the PIN Data ISO Field (Field 52). This class represents an encrypted PIN, no matter by whom it is encrypted. Typically a PIN is encrypted under one of these three:
1- Under a terminal PIN key (like TPK or DUKPT)
2- Under an Interchange PIN key (like ZPK)
3- Under the the security module itself (i.e. under LMK)
This class knows nothing about, who encrypted it.

This class represents an encrypted PIN using:
1- The PIN Block (encrypted)
2- The account number (the 12 right-most digits of the account number excluding the check digit)
3- The PIN Block Format

The PIN Block Format specifies how the clear pin (as entered by the card holder) and the account number get mixed to form the PIN Block.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    EncryptedPIN(byte[] pinBlock, byte pinBlockFormat, String accountNumber)
    Constructs an EncryptedPIN from raw PIN block bytes.
    EncryptedPIN(byte[] pinBlock, byte pinBlockFormat, String accountNumber, boolean extract)
    Constructs an EncryptedPIN from raw PIN block bytes, optionally extracting the account number part.
    EncryptedPIN(String pinBlockHexString, byte pinBlockFormat, String accountNumber)
    Constructs an EncryptedPIN from a hex-encoded PIN block string.
    EncryptedPIN(String pinBlockHexString, byte pinBlockFormat, String accountNumber, boolean extract)
    Constructs an EncryptedPIN from a hex-encoded PIN block string, optionally extracting the account number part.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dump(PrintStream p, String indent)
    dumps PIN basic information
    static String
    This method extracts the 12 right-most digits of the account number, execluding the check digit.
    Returns the extracted account number part.
    byte[]
    Returns the encrypted PIN block bytes.
    byte
    Returns the PIN block format identifier.
    void
    setAccountNumber(String extractedAccountNumber)
    Sets the 12 right-most digits of the account number excluding the check digit
    void
    setPINBlock(byte[] pinBlock)
    Sets the encrypted PIN block bytes.
    void
    setPINBlockFormat(byte pinBlockFormat)
    Sets the PIN block format identifier.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface Loggeable

    dump
    Modifier and Type
    Method
    Description
    default void
    Dumps a representation of this object using the specified renderer type.
  • Constructor Details

    • EncryptedPIN

      public EncryptedPIN()
      Default constructor. Creates an empty EncryptedPIN.
    • EncryptedPIN

      public EncryptedPIN(byte[] pinBlock, byte pinBlockFormat, String accountNumber)
      Constructs an EncryptedPIN from raw PIN block bytes.
      Parameters:
      pinBlock - the encrypted PIN block bytes
      pinBlockFormat - the PIN block format identifier
      accountNumber - account number, including BIN and the check digit
    • EncryptedPIN

      public EncryptedPIN(byte[] pinBlock, byte pinBlockFormat, String accountNumber, boolean extract)
      Constructs an EncryptedPIN from raw PIN block bytes, optionally extracting the account number part.
      Parameters:
      pinBlock - the encrypted PIN block bytes
      pinBlockFormat - the PIN block format identifier
      accountNumber - if extract is false then account number, including BIN and the check digit; if extract is true then 12 right-most digits of the account number, excluding the check digit
      extract - true to extract 12 right-most digits off the account number
    • EncryptedPIN

      public EncryptedPIN(String pinBlockHexString, byte pinBlockFormat, String accountNumber)
      Constructs an EncryptedPIN from a hex-encoded PIN block string.
      Parameters:
      pinBlockHexString - the PIN block represented as a hex string instead of a byte[]
      pinBlockFormat - the PIN block format identifier
      accountNumber - account number, including BIN and the check digit
    • EncryptedPIN

      public EncryptedPIN(String pinBlockHexString, byte pinBlockFormat, String accountNumber, boolean extract)
      Constructs an EncryptedPIN from a hex-encoded PIN block string, optionally extracting the account number part.
      Parameters:
      pinBlockHexString - the PIN block represented as a hex string instead of a byte[]
      pinBlockFormat - the PIN block format identifier
      accountNumber - if extract is false then account number, including BIN and the check digit; if extract is true then 12 right-most digits of the account number, excluding the check digit
      extract - true to extract 12 right-most digits off the account number
  • Method Details

    • dump

      public void dump(PrintStream p, String indent)
      dumps PIN basic information
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - a PrintStream usually supplied by Logger
      indent - indention string, usually suppiled by Logger
      See Also:
    • setPINBlock

      public void setPINBlock(byte[] pinBlock)
      Sets the encrypted PIN block bytes.
      Parameters:
      pinBlock - the encrypted PIN block bytes
    • getPINBlock

      public byte[] getPINBlock()
      Returns the encrypted PIN block bytes.
      Returns:
      the encrypted PIN block bytes
    • setPINBlockFormat

      public void setPINBlockFormat(byte pinBlockFormat)
      Sets the PIN block format identifier.
      Parameters:
      pinBlockFormat - the PIN block format identifier
    • getPINBlockFormat

      public byte getPINBlockFormat()
      Returns the PIN block format identifier.
      Returns:
      the PIN block format identifier
    • setAccountNumber

      public void setAccountNumber(String extractedAccountNumber)
      Sets the 12 right-most digits of the account number excluding the check digit
      Parameters:
      extractedAccountNumber - 12 right-most digits of the account number, excluding the check digit.
    • getAccountNumber

      Returns the extracted account number part.
      Returns:
      the 12 right-most digits of the account number, excluding the check digit
    • extractAccountNumberPart

      public static String extractAccountNumberPart(String accountNumber)
      This method extracts the 12 right-most digits of the account number, execluding the check digit.
      Parameters:
      accountNumber - (PAN) consists of the BIN (Bank Identification Number), accountNumber and a check digit.
      Returns:
      the 12 right-most digits of the account number, execluding the check digit. In case if account number length is lower that 12 proper count of 0 digts is added on the left side for align to 12