public class PINPadInterface
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ALGO_CHECK_VALUE_DEFAULT
ALGO_CHECK_VALUE type
|
static int |
ALGO_CHECK_VALUE_SE919 |
static int |
ALGORITH_3DES
3DES
|
static int |
ALGORITH_DES
DES
|
static int |
ALGORITH_SM4
SM4
|
static int |
KEY_TYPE_FIX
fix key type
|
static int |
KEY_TYPE_MASTER
master-session key type
|
static int |
KEY_TYPE_PUBLIC
public key type
|
static int |
KEY_TYPE_TDUKPT
tdukpt key type
|
static int |
KEY_TYPE_TDUKPT_2009
tdukpt 2009 key type
|
static int |
MAC_METHOD_ECB |
static int |
MAC_METHOD_ECB_FIRST |
static int |
MAC_METHOD_SE919 |
static int |
MAC_METHOD_X99 |
static int[] |
MASTER_KEY_ID
master keyID
|
static int |
PINPAD_ENCRYPT_STRING_MODE_CBC
MODE CBC
|
static int |
PINPAD_ENCRYPT_STRING_MODE_CFB
MODE CFB
|
static int |
PINPAD_ENCRYPT_STRING_MODE_EBC
MODE EBC
|
static int |
PINPAD_ENCRYPT_STRING_MODE_OFB
MODE OFB
|
static int[] |
USER_KEY_ID
user keyID
|
Constructor and Description |
---|
PINPadInterface() |
Modifier and Type | Method and Description |
---|---|
static int |
calculateMac(byte[] arryData,
int nDataLength,
int nMACFlag,
byte[] arryMACOutBuffer)
Calculate the MAC.
|
static int |
calculatePINBlock(byte[] arryASCIICardNumber,
int nCardNumberLength,
byte[] arryPinBlockBuffer,
int nTimeout_MS,
int nFlagSound)
Calculate the PIN block of the inputted PIN.
|
static int |
close()
Close the PINPad device.
|
static int |
encrypt(byte[] arryPlainText,
int nTextLength,
byte[] arryCipherTextBuffer)
Encrypt string.
|
static int |
encryptWithMode(byte[] arrayPlainText,
byte[] arrayCipherTextBuffer,
int nMode,
byte[] arrayIV,
int nIVLen)
encrypt string using user key
|
static int |
getHwserialno(byte[] buffer)
Get pinpad serial number.
|
static int |
getMacForSnk(byte[] p1,
byte[] p2,
byte[] p3) |
static int |
getMKCheckValue(int nMKID,
int nAlgo,
byte[] pCheckValueBuf,
int nCheckValueBufLen) |
static int |
getSerialNo(byte[] arrySerialNo)
get serial number
|
static int |
getSKCheckValue(int nMKID,
int nSKID,
int nAlgo,
byte[] pCheckValueBuf,
int nCheckValueBufLen) |
static int |
importDukptKey(int dukptKeyId,
int keyUsage,
byte[] snKey,
byte[] counter,
byte[] key)
permission:android.permission.CLOUDPOS_PIN_LOAD_KEY.
|
static int |
open()
Open the PINPad device.
|
static void |
pinpadCallback(byte[] data)
Call back method, called by driver.
|
static int |
selectKey(int nKeyType,
int nMasterKeyID,
int nUserKeyID,
int nAlgorith)
Select master key and user key before encryption operations.
|
static int |
setAllowBypassPinFlag(int flag)
Set bypass pin.permit click Enter key in PINPAD, bypass the pin.
|
static int |
setPinblockCallback()
set the callback, the callback method is pinpadCallback
|
static int |
setPinLength(int nLength,
int nFlag)
Set the max or min length of PIN.
|
static int |
setupCallbackHandler(PinPadCallbackHandler handler) |
static int |
showText(int nLineIndex,
byte[] arryText,
int nTextLength,
int nFlagSound)
Show text in the specified line.
|
static int |
updateCipherMasterKey(int nMasterKeyID,
byte[] arryCipherNewMasterKey,
int nCipherNewMasterKeyLength,
byte[] pCheckValue,
int nCheckValueLen)
Update master key, the master key must be ciphered by transport key.
|
static int |
updateCipherMasterKeyE(int nMasterKeyID,
byte[] arryCipherNewMasterKey,
int nCipherNewMasterKeyLength,
byte[] pCheckValue,
int nCheckValueLen,
int algoCheckValue)
Update master key, the master key must be ciphered by transport key, and use the selected algorithm of check .
|
static int |
updateMasterKey(int nMasterKeyID,
byte[] arrayOldKey,
int nOldKeyLength,
byte[] arrayNewKey,
int nNewKeyLength)
Update plain master key.
|
static int |
updateUserKey(int nMasterKeyID,
int nUserKeyID,
byte[] arryCipherNewUserKey,
int nCipherNewUserKeyLength)
Update the user key.
|
static int |
updateUserKeyWithCheck(int nMasterKeyID,
int nUserKeyID,
byte[] arryCipherNewUserKey,
int nCipherNewUserKeyLength,
int nUserKeyType,
byte[] checkValue,
int checkValueLength)
Update the user key with check value.
|
static int |
updateUserKeyWithCheckE(int nMasterKeyID,
int nUserKeyID,
byte[] arryCipherNewUserKey,
int nCipherNewUserKeyLength,
int nUserKeyType,
byte[] checkValue,
int checkValueLength,
int algoCheckValue)
Update the user key with check value.
|
public static final int ALGO_CHECK_VALUE_DEFAULT
public static final int ALGO_CHECK_VALUE_SE919
public static final int KEY_TYPE_TDUKPT
public static final int KEY_TYPE_MASTER
public static final int KEY_TYPE_PUBLIC
public static final int KEY_TYPE_FIX
public static final int KEY_TYPE_TDUKPT_2009
public static final int[] MASTER_KEY_ID
public static final int[] USER_KEY_ID
public static final int ALGORITH_3DES
public static final int ALGORITH_DES
public static final int ALGORITH_SM4
public static final int MAC_METHOD_X99
public static final int MAC_METHOD_ECB_FIRST
public static final int MAC_METHOD_SE919
public static final int MAC_METHOD_ECB
public static final int PINPAD_ENCRYPT_STRING_MODE_EBC
public static final int PINPAD_ENCRYPT_STRING_MODE_CBC
public static final int PINPAD_ENCRYPT_STRING_MODE_CFB
public static final int PINPAD_ENCRYPT_STRING_MODE_OFB
public static int open()
public static int close()
public static int showText(int nLineIndex, byte[] arryText, int nTextLength, int nFlagSound)
nLineIndex:
- Line No. to display, 0 or 1.arryText:
- Text to show, String.getBytes().nTextLength:
- Text length.nFlagSound:
- Not used.public static int selectKey(int nKeyType, int nMasterKeyID, int nUserKeyID, int nAlgorith)
nKeyType:
- 1 : TDUKPT, 2 : MASTER-SESSION PAIR, 5 : TDUKPT_2009.nMasterKeyID:
- Master key id, 0-9 when nKeyType is master-session; Master key id, 0,1,2when nKeyType is TDUKPT or TDUKPT_2009nUserKeyID:
- User key id, used when nKeyType is master-session.nAlgorith:
- 0,Not usedpublic static int setPinLength(int nLength, int nFlag)
nLength:
- PIN lengthnFlag:
- Flag, 0--min length 1--max lengthpublic static int encrypt(byte[] arryPlainText, int nTextLength, byte[] arryCipherTextBuffer)
arryPlainText:
- Plain text data buffer.nTextLength:
- Length of plain text data buffer.arryCipherTextBuffer:
- buffer for saving cipher text。public static int calculatePINBlock(byte[] arryASCIICardNumber, int nCardNumberLength, byte[] arryPinBlockBuffer, int nTimeout_MS, int nFlagSound)
arryASCIICardNumber:
- Card number in ASCII format.nCardNumberLength:
- Length of card number.arryPinBlockBuffer:
- buffer for saving PIN block。nTimeout_MS:
- Timeout waiting for user input in milliseconds. If it is less than 0, then wait forever.nFlagSound:
- Not used。public static int calculateMac(byte[] arryData, int nDataLength, int nMACFlag, byte[] arryMACOutBuffer)
arryData:
- data buffer.nDataLength:
- Length of data buffer.arryMACOutBuffer:
- buffer for saving mac result。public static int updateUserKey(int nMasterKeyID, int nUserKeyID, byte[] arryCipherNewUserKey, int nCipherNewUserKeyLength)
nMasterKeyID:
- Master key id.nUserKeyID:
- User key id.arryCipherNewUserKey:
- New user key in cipher text。nCipherNewUserKeyLength:
- Length of new user key。public static int updateCipherMasterKey(int nMasterKeyID, byte[] arryCipherNewMasterKey, int nCipherNewMasterKeyLength, byte[] pCheckValue, int nCheckValueLen)
nMasterKeyID:
- Master key id.arryCipherNewMasterKey:
- Ciphered master key.nCipherNewMasterKeyLength:
- Length of ciphered master key。pCheckValue:
- Check value。nCheckValueLen:
- Length of check value。public static int updateUserKeyWithCheck(int nMasterKeyID, int nUserKeyID, byte[] arryCipherNewUserKey, int nCipherNewUserKeyLength, int nUserKeyType, byte[] checkValue, int checkValueLength)
nMasterKeyID:
- Master key id.nUserKeyID:
- User key id.arryCipherNewUserKey:
- New user key in cipher text。nCipherNewUserKeyLength:
- Length of new user key。nUserKeyType:
- Key type. 0--PIN key;1--MAC key;2—Data key。checkValue:
- Check value of user key。checkValueLength:
- Length of check value, 4 bytes in general。public static int updateMasterKey(int nMasterKeyID, byte[] arrayOldKey, int nOldKeyLength, byte[] arrayNewKey, int nNewKeyLength)
nMasterKeyID:
- Master key id.arrayOldKey:
- Old plain master key.nOldKeyLength:
- Length of old key。arrayNewKey:
- New plain master key。nNewKeyLength:
- Length of new key。public static int updateUserKeyWithCheckE(int nMasterKeyID, int nUserKeyID, byte[] arryCipherNewUserKey, int nCipherNewUserKeyLength, int nUserKeyType, byte[] checkValue, int checkValueLength, int algoCheckValue)
nMasterKeyID:
- Master key id.nUserKeyID:
- User key id.arryCipherNewUserKey:
- New user key in cipher text。nCipherNewUserKeyLength:
- Length of new user key。nUserKeyType:
- Key type. 0--PIN key;1--MAC key;2—Data key。checkValue:
- Check value of user key。checkValueLength:
- Length of check value, 4 bytes in general。algoCheckValue:
- 0-- ALGO_CHECK_VALUE_DEFAULT;1-- ALGO_CHECK_VALUE_SE919(only for aisino).public static int updateCipherMasterKeyE(int nMasterKeyID, byte[] arryCipherNewMasterKey, int nCipherNewMasterKeyLength, byte[] pCheckValue, int nCheckValueLen, int algoCheckValue)
nMasterKeyID:
- Master key id.arryCipherNewMasterKey:
- Ciphered master key.nCipherNewMasterKeyLength:
- Length of ciphered master key。pCheckValue:
- Check value。nCheckValueLen:
- Length of check value。algoCheckValue:
- 0-- ALGO_CHECK_VALUE_DEFAULT;1-- ALGO_CHECK_VALUE_SE919(only for aisino).public static int getSerialNo(byte[] arrySerialNo)
arrySerialNo
- serial number buffer return value。public static int setPinblockCallback()
public static int setAllowBypassPinFlag(int flag)
flag:
- 1--bypass;0--can not bypass.public static int encryptWithMode(byte[] arrayPlainText, byte[] arrayCipherTextBuffer, int nMode, byte[] arrayIV, int nIVLen)
arrayPlainText:
- Plain textarrayCipherTextBuffer:
- buffer for saving cipher text, for dukpt encrypt, the buffer data structure is: cipher data + KSN + counter.nMode:
- PINPAD_ENCRYPT_STRING_MODE_EBC 0
PINPAD_ENCRYPT_STRING_MODE_CBC 1
PINPAD_ENCRYPT_STRING_MODE_CFB 2
PINPAD_ENCRYPT_STRING_MODE_OFB 3arrayIV:
- Initial vector, only for CBC, CFB, OFB modenIVLen:
- Length of IV, must be equal to block length according to the algorithmpublic static int getHwserialno(byte[] buffer)
buffer:
- data buffer for saving the serial number.public static int setupCallbackHandler(PinPadCallbackHandler handler)
public static void pinpadCallback(byte[] data)
data:
- callback data from the driver, data[0] is the count of *, data[1] is other parameterspublic static int importDukptKey(int dukptKeyId, int keyUsage, byte[] snKey, byte[] counter, byte[] key)
dukptKeyId
- : 0, 1, 2keyUsage
- 0 : SESSION_KEY_USAGE_pin,
1 : SESSION_KEY_USAGE_mac,
2 : SESSION_KEY_USAGE_data,snkey
- :8 bytecounter
- :4 bytekey
- :16bytepublic static int getMacForSnk(byte[] p1, byte[] p2, byte[] p3)
public static int getMKCheckValue(int nMKID, int nAlgo, byte[] pCheckValueBuf, int nCheckValueBufLen)
public static int getSKCheckValue(int nMKID, int nSKID, int nAlgo, byte[] pCheckValueBuf, int nCheckValueBufLen)