com.pax.dal

Interface ITypeA



  • public interface ITypeA
    TypeA。
    TypeA.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void beep(EBeepMode mode, int timeMs)
      蜂鸣器按参数指定的频率和持续时间发声。
      The buzzer sounds according to the frequency and duration specified by the parameters.
      byte[] calcDes(byte keyIndex, byte mode, byte[] dataIn)
      用指定的 DES 密钥对 Data 作 DES 或者 3DES 加密或解密运算。
      Use the specified DES key to perform DES or 3DES encryption or decryption operations on Data.
      byte[] calcExtDes(byte cipherFlag, byte[] dataIn)
      用指定的 DES 密钥对 Data 作 DES 或者 3DES 加密或解密运算。
      Use the specified DES key to perform DES or 3DES encryption or decryption operations on Data.
      byte[] calcSM2Data(byte cipherFlag, byte[] dataIn)
      使用 SM2 公钥加密数据或私钥解密数据。
      Use SM2 public key to encrypt data or private key to decrypt data.
      byte[] calcSM4Data(byte cipherFlag, byte[] dataIn)
      使用SM4 算法加解密数据。
      Use SM4 algorithm to encrypt and decrypt data.
      void cancelInputPin()
      用于在密码键盘处于密码输入状态时,POS 机取消密码输入。
      It is used to cancel the password input by the POS machine when the password keyboard is in the password input state.
      void changeBaudRate(byte bps)
      更改外置密码键盘通信波特率。
      Change the external PINPAD communication Baud rate.
      void clearKeyBuffer(byte mode)
      按键缓冲区。
      1.设置为清空按键缓冲区,则用户输入密码前会对按键缓冲区做一次清空(默认) 。
      2.设置为不清空按键缓冲区,则发送该命令后的按键缓冲不做清除,发送该命令前的按键缓冲区会做 一次清除。
      Key buffer.
      void clearScreen()
      清除密码键盘 LCD 屏幕上所有的显示内容。
      Clear all the contents displayed on the LCD screen of the password keyboard.
      void clearScreenByLine(byte lineNo)
      清除指定显示行。
      Clear the specified display line.
      byte[] cmdExchange(byte[] dataIn)
      与卡片进行APDU数据交互。将数据直接发送给卡片,并接收卡片的应答数据。
      APDU data exchange with the card.
      void connect()
      连接。
      Connect.
      void derivedTWK(byte derivedKeyIndex, byte srcKeyIndex, byte destKeyIndex, byte mode)
      发散密钥。
      用derivedKeyIndex指定的主密钥或工作密钥对 srcKeyIndex 指定的工作密钥进行 mode 方式的加密或解密后,将 结果存储在工作密钥区的 destKeyIndex 指定的位置。
      Diverge the key.
      PiccCardInfo detect(byte mode)
      按指定的模式搜寻PICC卡片,搜到卡片后,将其选中并激活。感应区内不允许多张卡存在。
      Search for PICC cards according to the specified mode.
      void disconnect()
      断开连接。
      Disconnect.
      byte[] EPS(byte option, byte[] dataIn)
      EPS 专用接口。
      EPS dedicated interface.
      void eraseDUKPTKey(byte appNo, byte keyIndex, byte mode)
      用于清除指定的部分或全部 DUKPT 密钥
      Used to clear some or all of the specified DUKPT key
      void eraseKey()
      清空所有秘钥。
      Clear all keys.
      byte[] extEPS(byte option, byte mode, byte[] dataIn)
      扩展的 EPS 专用接口。
      Extended EPS dedicated interface.
      SM2KeyPair genSM2Key(byte cipherFlag, byte[] dataIn)
      生成 SM2 公私钥对。
      Generate SM2 public and private key pair.
      DUKPTResult getDUKPTMac(byte appNo, byte groupIndex, byte mode, byte[] dataIn)
      对输入数据报文进行指定算法的验证码运算,并输出生成的 MAC 和当前密钥序号 KSN。
      Perform the verification code operation of the specified algorithm on the input data message, and output the generated MAC and the current key sequence number KSN.
      DUKPTResult getDUKPTPin(byte appNo, byte groupIndex, byte min, byte max, byte[] dataIn, byte mode, int timeoutMs)
      提示用户输入 PIN。待输入完毕后,依照所选标准生成和输出 PIN 密文块和当前密钥序号 KSN。
      为防止非法套取密钥,从上一次执行该命令到本次指令之间的间隔应不小于 30 秒(该值可能需要调整)。
      Prompt the user to enter a PIN.
      byte[] getExtMac(byte cipherFlag, byte[] dataIn)
      用指定的 MAC 密钥对 Data 作 MAC 加密运算。
      Use the specified MAC key to perform MAC encryption operations on Data.
      java.lang.String getInputAmount(byte min, byte max, byte pointMode, byte prompMode)
      输入金额。
      等待输入金额,小数点自动增加在固定位置,经过“确认”后,密码键盘将所显示的值返回给 POS 机。
      Enter the amount.
      java.lang.String getInputCipherString(byte min, byte max, byte mode)
      密码键盘输入字符串[密文交互]
      将按键值以明码或者“*”的形式在 LCD 第二行的右下角显示出来,经过“确认”后,密码键盘将按键值全部 返回给 POS 机。
      大陆版和越南版本密码键盘在收到该命令后,不在首行显示任何信息,如:“PLS INPUT PIN:”。密码键盘回应的数据包中的DATA域由TXK加密。
      Password keyboard input string [ciphertext interaction]
      The key value is displayed in the lower right corner of the second line of the LCD in the form of clear code or "*".
      java.lang.String getInputString(byte min, byte max, byte mode)
      密码键盘输入字符串。
      将按键值以明码或者“*”的形式在 LCD 第二行的右下角显示出来,经过“确认”后,密码键盘将按键值全部返回给 POS 机。
      密码键盘在收到该命令后,大陆版和越南版不在首行显示任何信息,如:“PLS INPUT PIN:”。香港版在首行显示任何信息,如:“PLS INPUT PIN:”。
      Password keyboard input character string.
      EKeyCode getKey()
      获取当前按键缓冲区(非 PIN 输入状态下)的按键值。
      Get the key value of the current key buffer (in non-PIN input state).
      byte[] getMac(byte macMode, byte keyIndex, byte algorithmMode, byte[] dataIn)
      用指定的 MAC 密钥对 Data 作 MAC 加密运算。
      当其最高位为 1 时,先用指定的工作密钥对 Data 前 8 字节进行一次 DES 或 3DES 解密,其结果覆盖 Data 前 8 字节,然后再按 Mode 指定的算法对最新的 Data 数据块进行相应 MAC 运算。
      Use the specified MAC key to perform MAC encryption operations on Data.
      byte[] getPinBlock(boolean isNewAccount, byte mode, byte keyIndex, byte min, byte max, byte[] data, int timeoutMs)
      用户输入密码。
      触发用户输入账户密码,在输入密码并按“确认”键后,密码键盘用POS机传下来的数据(卡号或 ISN), 根据 ANSI X9.8 标准或 ANSI X3.92 标准和 WKeyID 指定的 PIN 密钥对 PIN 进行加密。在输入密码时,用户能取消操作, POS 机一端通过发送操作取消命令也可中止密码输入。大陆版和越南版本密码键盘在收到该命令后,不在首行显示任何信息,如:“PLS INPUT PIN:”。 缺省的密码输入超时为 120 秒,但可由后述的相关超时设置命令重新设定。
      The user enters the password.
      byte[] getPinBlock(byte[] cipherByTXK, int timeoutMs)
      扩展获取 PINBLOCK [密文传输]。
      Extended access to PINBLOCK [ciphertext transmission].
      int getRecvTimeout()
      获取接收超时时间,默认20000ms。
      get receive timeout, default is 20000ms
      byte[] getSM3Hash(byte cipherFlag, byte[] dataIn)
      使用 SM3 算法计算杂凑值。
      The SM3 algorithm is used to calculate the hash value.
      byte[] getSM4Mac(byte cipherFlag, byte[] dataIn)
      使用 SM4 算法计算 MAC。
      Use SM4 algorithm to calculate MAC.
      byte[] getSM4PinBlock(byte cipherFlag, byte[] dataIn, int timeoutMs)
      提示用户输入 PIN,输入 PIN 之后按照指定 mode 生成 PINBlock,并使用 SM4 密钥加密。
      Prompt the user to enter the PIN.
      java.lang.String getSN()
      读取序列号。
      Read serial number.
      java.lang.String getTerminalInfo(byte item)
      获取密码键盘系统信息。
      Get password keyboard system information.
      byte[] getTXK(byte[] modulus, byte[] exponent)
      向密码键盘请求获取 TXK。
      该命令用于上位机从 PED 获取读取传输密钥。 传输密钥 TXK 固定为 16 字节。上位机临时产生一组模长 512bit 的 RSA 公私钥对,并将公钥传给 PED, PED 产生传输密钥 TXK,并保存在安全存储器中,然后用公钥加密后,将密文发给上位机。
      Request a TXK from the password keyboard.
      byte[] getTXKCheckValue()
      获取 TXK 校验值。
      该命令用于上位机检查 TXK 是否同步。
      密码键盘产生 8 字节随机数,并用 TXK 加密,把随机数和加密后的值,发给上位机。上位机可以由自身的 TXK 进行相关验证。
      Get TXK check value.
      java.lang.String getVersion()
      读取密码键盘版本号。
      Read the password keyboard version number.
      void initFelica(byte rate, byte pol)
      初始化 Felica 卡片。
      Initialize the Felica card.
      ApduRespInfo isoCommand(byte cid, ApduSendInfo sendInfo)
      在指定的通道上,向卡片发送 APDU 格式的数据,并接收响应。
      On the designated channel, send data in APDU format to the card and receive the response.
      void ledControl(byte ledIndex, byte control)
      4个LED灯的点亮和熄灭状态。。
      The on and off status of 4 LED lights.
      void m1Auth(EM1KeyType type, byte blkNo, byte[] pwd, byte[] serialNo)
      验证访问M1卡时读写相应块需要提交的 A 密码或 B 密码。
      Verify the A password or B password that needs to be submitted when reading and writing the corresponding block when accessing the M1 card.
      void m1Operate(EM1OperateType type, byte blkNo, byte[] blkValue, byte updateBlkNo)
      对 M1 卡的指定数据块 blkNo 进行充/减值/备份操作,将操作后的值更新到另一个指定的数据块 updateBlkNo。
      byte[] m1Read(byte blkNo)
      读取M1卡指定块的内容。共16字节。
      Read the contents of the specified block of the M1 card.
      void m1Write(byte blkNo, byte[] blkValue)
      向M1卡指定块写入指定的内容。共16字节。
      Write the specified content to the specified block of the M1 card.
      void piccClose()
      关闭非接模块,使该模块处于下电状态。
      Turn off the contactless module and make the module in the power-off state.
      void piccOpen()
      非接模块上电。
      Power on contactless module.
      void playVoice(byte type)
      按所选序号播放语音。必须支持语音芯片
      Play the voice according to the selected sequence number.
      PiccPara readParam()
      读取非接读卡器参数。 只有在piccOpen()函数之后,detect(byte)initFelica(byte, byte)之前调用才有效。
      Read the parameters of the contactless card reader.
      void recovery()
      恢复出厂设置。(蜂鸣器响一声,且键盘恢复出厂设置:输入 PIN 时按键发声,波特率 9600,8,E,1,按键时屏幕有背光。)
      Recovery.(The buzzer beeps once, and the keyboard is restored to factory settings: when the PIN is input, the key is sounded, the baud rate is 9600, 8, E, 1, and the screen has backlight when the key is pressed.)
      void remove(byte mode, byte cid)
      依据指定的模式,向卡片发送停机指令;或者发送停活指令;或者复位载波,并判断卡片是否已经移开感应区。
      According to the specified mode, send a stop instruction to the card; or send a deactivation instruction; or reset the carrier, and determine whether the card has moved out of the sensing area.
      void scanClose()
      关闭扫描模块。
      Close the scan module.
      void scanOpen()
      打开扫描模块。
      Open the scan module.
      java.lang.String scanRead()
      读取扫描数据。
      Read scan data.
      void setComm(IComm comm)
      设置通信IComm。
      Set the IComm.
      void setExtSN(java.lang.String extSN)
      向密码键盘写入扩展序列号。
      Write the extended serial number to the password keyboard.
      void setLCDBitmap(byte mode, byte[] data)
      更换 LCD 显示缺省位图。
      下载 LCD 显示位图,替代 LCD 缺省显示位图。
      缺省的显示位图为如下两行字符:
      WELCOME!
      PAX TECHNOLOGY
      Replace the LCD display default bitmap.
      void setLed(byte led, byte mode)
      控制射频卡指示灯点亮或熄灭。
      Control the radio frequency card indicator to turn on or off.
      void setParam(PiccPara para)
      设置非接读卡器参数。 只有在piccOpen()函数之后,detect(byte)initFelica(byte, byte)之前调用才有效。
      Set the parameters of the contactless card reader.
      void setPinTimeout(byte high, byte low)
      PIN 输入超时设置。
      PINPAD 每次开机后的缺省值是 120 秒(2 分钟)。
      设置的键盘超时值为:Time_High×256+Time_Low,单位为 10 毫秒(Timeout<655.36 秒)。当设置为0 时,其超时时间为 2 分钟。
      PIN input timeout setting.
      void setRecvTimeout(int timeoutMs)
      设置接收超时时间 ,默认20000ms。
      set receive timeout, default is 20000ms
      void setUartParam(UartParam uartParam)
      设置默认通信配置。
      Set the default UartParam.
      void setup(byte item, byte value)
      控制密码键盘的硬件状态。
      Control the hardware status of the password keyboard.
      void setupAndTest(byte item, byte value)
      设置及测试密码键盘。
      Set up and test the password keyboard.
      void setVolumeLevel(byte level)
      调节音量等级。必须支持语音芯片
      Adjust the volume level.
      void showChar(byte x, byte y, byte[] chars)
      显示英文字符。在指定位置显示 16x8 点阵的英文和字符,一行最多可以显示 15 个字符。在显示时,如果显示字符小于 15 但当前行显示不完(列号非 0),则把多余的数据切掉,返回码为 OK。
      Display English characters.
      void showDotMatrix(byte x, byte y, byte[] data)
      显示点阵。在指定 LCD 指定位置显示点阵。LCD 液晶显示共有两行,每一行分为上、下半行。在送点阵数据时,数据格式应该是: 上半行数据(长度为 n)+下半行数据(长度为 n)=点阵数据(长度为 2n) 显示数据的第 1 个字节对应 LCD 显示指定位置上半行的第 1 列,第 2 个字节对应上半行的第 2 列,…… 第 n+1 个字节对应 LCD 显示指定位置下半行的第 1 列,n+2 对应下半行的第 2 列,…… 点阵数据长度应小于等于 244。 在显示时,如果显示点阵数据长度<=244 但当前行显示不完(列号非 0),则把多余的数据切掉,返回码 为 OK。
      Display dot matrix.
      byte showMenuOrAmount(byte startNumber, byte endNumber, byte countLines, byte[] data)
      显示菜单或金额。
      显示一段内容并等待输入,并返回该值(ASCII 码)。
      当显示金额时,开始序号=0x3d(取消);结束序号=0x3e(确认)。可以按 POS 上(取消)退出。
      Display menu or amount.
      void showQRCode(byte[] content, short sizeLevel, byte type, byte correctionLevel, short x, short y)
      创建并显示二维码。
      Create and show a QR code.
      byte[] SM2Sign(byte cipherFlag, byte[] dataIn)
      使用 SM2 算法获得签名信息。
      Use SM2 algorithm to obtain signature information.
      void SM2Verify(byte cipherFlag, byte[] dataIn)
      使用 SM2 公钥验证签名。
      Use the SM2 public key to verify the signature.
      byte testKeyboard()
      测试键盘按键。
      测试时必须按屏幕指定的按键次序进行按键测试;
      命令执行后,且未完成测试前,如果超过 120 秒未按键,将超时退出。
      Test keyboard keys.
      void writeCipherKey(byte[] cipherKeyValue)
      密文传送主密钥或 DES 密钥。
      将 Key 存储在主密钥区或 DES 密钥区的指定(KeyID)位置。DATA 由 TXK 加密。
      The master key or DES key is transmitted in cipher text.
      void writePlainKey(byte keyIndex, byte mode, byte[] plainKeyValue)
      传送主密钥或 DES 密钥。
      按照 mode 方式将 Key 存储在主密钥区或 DES 密钥区的指定(KeyID)位置。
      Transfer the master key or DES key.
      void writeSM2Key(byte cipherFlag, byte[] dataIn)
      将SM2密钥存储在PED中。
      注意:SM2 密钥存储于 DES 密钥区域,KeyIndex指示的是 DES 密钥区的存储位置,以 8 字节为单位, 比如 SM2 私钥 32 字节,则占用 4 个存储位置。
      Store the SM2 key in the PED.
      void writeSM4Key(byte cipherFlag, byte[] dataIn)
      将 SM4 密钥存储在指定位置。
      void writeTIK(byte appNo, byte groupIndex, byte[] keyValue, byte[] ksn)
      用于重新初始化 DUKPT 密钥。
      Used to reinitialize the DUKPT key.
      void writeTWK(byte srcKeyIndex, byte destKeyIndex, byte mode, byte[] keyValue)
      写入工作密钥。
      通常用来写入 PIN-BLOCK 生成和 MAC 运算的密钥。用 srcKeyIndex 指定的主密钥对 keyValue 进行 mode 指定方式的加密或解密后,将结果存储在 keyIndex 指定的工作密钥区位置。如果 srcKeyIndex 为 0,则不对 keyValue 进行加密或解密,而直接将 keyValue 存储在工作密钥区的keyIndex 指定的位置。
      Write the work key.
    • Method Detail

      • setup

        void setup(byte item,
                   byte value)
            throws TypeAException
        控制密码键盘的硬件状态。
        Control the hardware status of the password keyboard.
        Parameters:
        item -
        • D0:0-按键无声 1-按键发声
        • D1:0-关闭语音提示 1-打开语音提示
        • D2:0-按键无声 1-按键立即发声
        • D3:红灯
        • D4:黄灯
        • D5:绿灯
        • D6:1-PINPAD 将发出“嘀”的一声
        • D7:0-关闭 LCD 背光 1-打开 LCD 背光
        D0 与 D2 的区别:D0 设置为 1 后只有输入 PIN 时按键才发声,D2 设置后无论何时按键都发声
        • D0: 0-key is silent 1-key is sounded
        • D1: 0-Turn off the voice prompt 1-Turn on the voice prompt
        • D2: 0-key is silent 1-key is sounded immediately
        • D3: Red light
        • D4: Yellow light
        • D5: Green light
        • D6: 1-PINPAD will make a beep
        • D7: 0-Turn off LCD backlight 1-Turn on LCD backlight
        The difference between D0 and D2: After D0 is set to 1, the key will sound only when the PIN is input, and whenever D2 is set, the key will sound whenever the key is pressed
        value -
        D0-D7:1-设置数据有效,0-设置数据无效
        D0-D7: 1-Set the data to be valid, 0-Set the data to be invalid
        Throws:
        TypeAException - TypeAException
      • getVersion

        java.lang.String getVersion()
                             throws TypeAException
        读取密码键盘版本号。
        Read the password keyboard version number.
        Returns:
        版本号,格式为“HvXXSvXX”。Hv代表硬件版本、XX为版本号,Sv 代表软件版本、XX 为版本号。
        Version number, the format is "HvXXSvXX". Hv represents the hardware version, XX is the version number, Sv represents the software version, and XX is the version number.
        Throws:
        TypeAException - TypeAException
      • setupAndTest

        void setupAndTest(byte item,
                          byte value)
                   throws TypeAException
        设置及测试密码键盘。
        Set up and test the password keyboard.
        Parameters:
        item -
        • 0x31:设置按键时蜂鸣器是否发声
        • 0x32:设置 LCD 背光或 LED 指示灯
        • 0x33:设置等待输入按键时的超时时间。
        • 0x3e:解锁
        • 0x3f:测试 PINPAD 内存。
        • 0x31: Set whether the buzzer sounds when the key is pressed
        • 0x32: Set LCD backlight or LED indicator
        • 0x33: Set the timeout time when waiting for the key input.
        • 0x3e: Unlock
        • 0x3f: Test PINPAD memory.
        value -
        • item=0x31 时,value=0 时,禁止蜂鸣器发声;value=1 时,可以发声。
        • item=0x32 时,value=0 时,背光或 LED 指示灯熄;value=1 时,亮。
        • item=0x33 时,value 为等待输入按键时的超时时间(秒)的 1/10。
        • item=0x3e 时,value=0x3e 时,解锁。
        • item=0x3f 时,内存测试。
        • When item=0x31, when value=0, the buzzer is forbidden to sound; when value=1, it can sound.
        • When item=0x32, when value=0, the backlight or LED indicator is off; when value=1, it is on.
        • When item=0x33, the value is 1/10 of the timeout time (seconds) while waiting for the key input.
        • When item=0x3e, value=0x3e, unlock.
        • When item=0x3f, memory test.
        Throws:
        TypeAException - TypeAException
      • getSN

        java.lang.String getSN()
                        throws TypeAException
        读取序列号。
        Read serial number.
        Returns:
        序列号。SN为10位数字的字符串
        Serial number.SN is a string of 10 digits
        Throws:
        TypeAException - TypeAException
      • beep

        void beep(EBeepMode mode,
                  int timeMs)
           throws TypeAException
        蜂鸣器按参数指定的频率和持续时间发声。
        The buzzer sounds according to the frequency and duration specified by the parameters.
        Parameters:
        mode - EBeepMode
        timeMs -
        持续时间,单位毫秒
        Duration in milliseconds
        Throws:
        TypeAException - TypeAException
      • ledControl

        void ledControl(byte ledIndex,
                        byte control)
                 throws TypeAException
        4个LED灯的点亮和熄灭状态。。
        The on and off status of 4 LED lights.
        Parameters:
        ledIndex -
        • BIT0:红灯
        • BIT1:绿灯
        • BIT2:黄灯
        • BIT3:蓝灯
        • BIT4-BIT7:保留
        • BIT0:red
        • BIT1:green
        • BIT2:yellow
        • BIT3:blue
        • BIT4-BIT7:reserved
        control -
        • 0:熄灭
        • 非 0: 点亮
        • 0: off
        • Non-zero: light up
        Throws:
        TypeAException - TypeAException
      • getTerminalInfo

        java.lang.String getTerminalInfo(byte item)
                                  throws TypeAException
        获取密码键盘系统信息。
        Get password keyboard system information.
        Parameters:
        item -
        • 0x01:终端名称
        • 0x02:终端配置信息
        • 0x03:序列号
        • 0x04:扩展序列号
        • 0x05:主板号
        • 0x06:扩展板号
        • 0x07:协议类型
        • 0x08:Boot 版本号
        • 0x09:Monitor 版本号
        • 0x0A:通讯方式
        • 0x0B:射频模块配置, “N”或“Y + 射频参数”
        • 0x0C:是否支持 NFC 功能
        • 0x0D:硬件国密配置信息,‘N’或‘Y+国密固件版本信息 xx.xx.xx’
        • 0x0E:识别支持语音芯片的型号
        对于终端配置信息项(0x02),返回格式是:PN:PN 号:配置文件:配置文件版本。例如: PN : SP20-121-9C0 : CONFIG_FILE_VER : V1.0,即每项之间用冒号隔开。并不是所有机型都能获取到有效的配置信息, 比如对于不使用配置文件的机型,由于无法获取相关信息,所以它的返回为 NULL: NULL: NULL: NULL。
        对于射频模块配置项(0x0B),在有配置文件的机型中,如果存在射频模块,则只返回 “Y”,射频参数需通过终端配置信息(0x02)所指明的配置文件来获取。
        • 0x01: terminal name
        • 0x02: terminal configuration information
        • 0x03: serial number
        • 0x04: extended serial number
        • 0x05: Motherboard number
        • 0x06: extension board number
        • 0x07: Protocol type
        • 0x08: Boot version number
        • 0x09: Monitor version number
        • 0x0A: Communication method
        • 0x0B: RF module configuration, "N" or "Y + RF parameters"
        • 0x0C: Whether to support NFC function
        • 0x0D: hardware national secret configuration information, ‘N’ or ‘Y+ national secret firmware version information xx.xx.xx’
        • 0x0E: Identify the model that supports the voice chip
        For the terminal configuration information item (0x02), the return format is: PN: PN number: configuration file: configuration file version. For example: PN: SP20-121-9C0: CONFIG_FILE_VER: V1.0, that is, each item is separated by a colon. Not all models can obtain valid configuration information. For example, for models that do not use configuration files, since the relevant information cannot be obtained, it returns NULL: NULL: NULL: NULL.
        For the radio frequency module configuration item (0x0B), in models with configuration files, if there is a radio frequency module, only "Y" is returned. The frequency parameters need to be obtained through the configuration file specified in the terminal configuration information (0x02).
        Returns:
        系统信息
        返回信息长度:
        0x00:发送数据错误(比如信息类别错误),命令没有返回数据;
        其它:密码键盘返回的有效数据长度。
        system message
        Return message length:
        0x00: Sending data error (for example, the information type is wrong), the command does not return data;
        Others: The length of the valid data returned by the password keyboard.
        Throws:
        TypeAException - TypeAException
      • setExtSN

        void setExtSN(java.lang.String extSN)
               throws TypeAException
        向密码键盘写入扩展序列号。
        Write the extended serial number to the password keyboard.
        Parameters:
        extSN -
        扩展序列号。长度小于31个字符,合法范围ASCII 0x21-0x7E。
        Extended serial number. The length is less than 31 characters, and the legal range is ASCII 0x21-0x7E.
        Throws:
        TypeAException - TypeAException
      • testKeyboard

        byte testKeyboard()
                   throws TypeAException
        测试键盘按键。
        测试时必须按屏幕指定的按键次序进行按键测试;
        命令执行后,且未完成测试前,如果超过 120 秒未按键,将超时退出。
        Test keyboard keys.
        During the test, you must perform the keystroke test according to the key sequence specified on the screen;
        After the command is executed and before the test is completed, if no key is pressed for more than 120 seconds, it will time out and exit.
        Returns:
        0x00: 所有按键均通过测试。
        其它: 未通过测试。该非 0 值表示未按指定次序完成测试的按键数
        0x00: All keys have passed the test.
        Other: Failed the test. The non-zero value indicates the number of keystrokes that did not complete the test in the specified order
        Throws:
        TypeAException - TypeAException
      • recovery

        void recovery()
               throws TypeAException
        恢复出厂设置。(蜂鸣器响一声,且键盘恢复出厂设置:输入 PIN 时按键发声,波特率 9600,8,E,1,按键时屏幕有背光。)
        Recovery.(The buzzer beeps once, and the keyboard is restored to factory settings: when the PIN is input, the key is sounded, the baud rate is 9600, 8, E, 1, and the screen has backlight when the key is pressed.)
        Throws:
        TypeAException - TypeAException
      • clearScreen

        void clearScreen()
                  throws TypeAException
        清除密码键盘 LCD 屏幕上所有的显示内容。
        Clear all the contents displayed on the LCD screen of the password keyboard.
        Throws:
        TypeAException - TypeAException
      • clearScreenByLine

        void clearScreenByLine(byte lineNo)
                        throws TypeAException
        清除指定显示行。
        Clear the specified display line.
        Parameters:
        lineNo -
        LCD 显示行号。每行均为 16 点高的行,0—第一行,1--第二行。
        Line number displayed on LCD. Each row is a 16-point high row, 0—the first row, and 1—the second row.
        Throws:
        TypeAException - TypeAException
      • showChar

        void showChar(byte x,
                      byte y,
                      byte[] chars)
               throws TypeAException
        显示英文字符。在指定位置显示 16x8 点阵的英文和字符,一行最多可以显示 15 个字符。在显示时,如果显示字符小于 15 但当前行显示不完(列号非 0),则把多余的数据切掉,返回码为 OK。
        Display English characters. Display 16x8 dot matrix English and characters at the specified position, up to 15 characters can be displayed on a line. When displaying, if the displayed character is less than 15 but the current line is not displayed completely (column number is not 0), the redundant data will be cut off, and the return code will be OK.
        Parameters:
        x -
        显示字符在 LCD 上的起始点阵列号(单位:点),0≤x≤114;
        Display the starting point array number of the character on the LCD (unit: point), 0≤x≤114;
        y -
        显示字符在 LCD 上的行号(单位:行)。每行均为 16 点高的行,0—第一行,1--第二行。
        Display the line number of the character on the LCD (unit: line). Each row is a 16-point high row, 0—the first row, and 1—the second row.
        chars -
        字符。
        Character.
        Throws:
        TypeAException - TypeAException
      • showDotMatrix

        void showDotMatrix(byte x,
                           byte y,
                           byte[] data)
                    throws TypeAException
        显示点阵。在指定 LCD 指定位置显示点阵。LCD 液晶显示共有两行,每一行分为上、下半行。在送点阵数据时,数据格式应该是: 上半行数据(长度为 n)+下半行数据(长度为 n)=点阵数据(长度为 2n) 显示数据的第 1 个字节对应 LCD 显示指定位置上半行的第 1 列,第 2 个字节对应上半行的第 2 列,…… 第 n+1 个字节对应 LCD 显示指定位置下半行的第 1 列,n+2 对应下半行的第 2 列,…… 点阵数据长度应小于等于 244。 在显示时,如果显示点阵数据长度<=244 但当前行显示不完(列号非 0),则把多余的数据切掉,返回码 为 OK。
        Display dot matrix. Display the dot matrix at the specified position on the specified LCD. The LCD liquid crystal display has two lines, and each line is divided into upper and lower half lines. When sending dot matrix data, the data format should be: upper half line data (length n) + lower half line data (length n) = dot matrix data (length 2n). The first byte of the display data corresponds to LCD Display the first column of the upper half row of the specified position, the second byte corresponds to the second column of the upper half row, ... the n+1th byte corresponds to the first column of the lower half row of the LCD display specified position, n+2 Corresponding to the second column of the lower half of the row,... the length of the dot matrix data should be less than or equal to 244. During display, if the length of the displayed dot matrix data is less than 244 but the current line is not displayed completely (column number is not 0), the redundant data will be cut off, and the return code will be OK.
        Parameters:
        x -
        显示点阵在 LCD 上的起始点阵列号(单位:点),0≤x<122;
        Display the starting point array number of the dot matrix on the LCD (unit: dot), 0≤x<122;
        y -
        显示点阵在 LCD 上的行号(单位:行)。每行均为 16 点高的行,0—第一行,1--第二行。
        Display the line number (unit: line) of the dot matrix on the LCD. Each row is a 16-point high row, 0—the first row, and 1—the second row.
        data -
        点阵数据。
        Dot matrix data.
        Throws:
        TypeAException - TypeAException
      • showMenuOrAmount

        byte showMenuOrAmount(byte startNumber,
                              byte endNumber,
                              byte countLines,
                              byte[] data)
                       throws TypeAException
        显示菜单或金额。
        显示一段内容并等待输入,并返回该值(ASCII 码)。
        当显示金额时,开始序号=0x3d(取消);结束序号=0x3e(确认)。可以按 POS 上(取消)退出。
        Display menu or amount.
        Display a piece of content and wait for input, and return the value (ASCII code).
        When the amount is displayed, the start serial number=0x3d (cancel); the end serial number=0x3e (confirm). You can press POS (Cancel) to exit.
        Parameters:
        startNumber -
        显示内容的开始序号;
        The starting sequence number of the displayed content;
        endNumber -
        显示内容的结束序号;
        The ending sequence number of the displayed content;
        countLines -
        显示内容的总行数;
        The total number of lines of the displayed content;
        data -
        为[行数][16BYTE]的数组。多页显示时用 F2,F3 翻页。
        It is an array of [number of rows] [16BYTE]. When multiple pages are displayed, use F2 and F3 to turn pages.
        Returns:
        返回的序号,在开始序号、结束序号之间
        The returned sequence number, between the start sequence number and the end sequence number
        Throws:
        TypeAException - TypeAException
      • setLCDBitmap

        void setLCDBitmap(byte mode,
                          byte[] data)
                   throws TypeAException
        更换 LCD 显示缺省位图。
        下载 LCD 显示位图,替代 LCD 缺省显示位图。
        缺省的显示位图为如下两行字符:
        WELCOME!
        PAX TECHNOLOGY
        Replace the LCD display default bitmap.
        Download the LCD display bitmap to replace the LCD default display bitmap.
        The default display bitmap is the following two lines of characters:
        >WELCOME!
        PAX TECHNOLOGY
        Parameters:
        mode -
        • mode = 1 替换位图 1(0 行显示的位图)
        • mode = 2 替换位图 2(1 行显示的位图)
        • mode = 0 恢复厂家缺省 LOG 图
        • mode = 1 Replace bitmap 1 (the bitmap displayed on line 0)
        • mode = 2 Replace bitmap 2 (bitmap displayed in 1 row)
        • mode = 0 Restore to factory default LOG chart
        data -
        位图数据的格式和显示点阵数据的格式一样。 上半行数据(n=122)+下半行数据(n=122)= 位图点阵数据(244)
        The format of bitmap data is the same as the format of displaying dot matrix data. Top half line data (n=122) + bottom half line data (n=122) = bitmap dot matrix data (244)
        Throws:
        TypeAException - TypeAException
      • getInputString

        java.lang.String getInputString(byte min,
                                        byte max,
                                        byte mode)
                                 throws TypeAException
        密码键盘输入字符串。
        将按键值以明码或者“*”的形式在 LCD 第二行的右下角显示出来,经过“确认”后,密码键盘将按键值全部返回给 POS 机。
        密码键盘在收到该命令后,大陆版和越南版不在首行显示任何信息,如:“PLS INPUT PIN:”。香港版在首行显示任何信息,如:“PLS INPUT PIN:”。
        Password keyboard input character string.
        The key value is displayed in the lower right corner of the second line of the LCD in the form of clear code or "*". After "confirmation", the password keyboard will return all the key values to the POS machine.
        After password keyboard received the order, the mainland version and Vietnam version will not display any information on the first line, such as: "PLS INPUT PIN:". The Hong Kong version displays any information on the first line, such as: "PLS INPUT PIN:".
        Parameters:
        min -
        字符串最小长度(为 0 时,按 ENTER 键返回,且输入长度 Len=0)
        The minimum length of the string (when it is 0, press ENTER to return, and enter the length Len=0)
        max -
        字符串最大长度(小于等于 40 字节)
        Maximum string length (less than or equal to 40 bytes)
        mode -
        0x00 显示明码;0x01 显示“*”号。
        0x00 displays plain code; 0x01 displays "*" sign.
        Returns:
        输入的字符串
        Input string
        Throws:
        TypeAException - TypeAException
      • getInputAmount

        java.lang.String getInputAmount(byte min,
                                        byte max,
                                        byte pointMode,
                                        byte prompMode)
                                 throws TypeAException
        输入金额。
        等待输入金额,小数点自动增加在固定位置,经过“确认”后,密码键盘将所显示的值返回给 POS 机。
        Enter the amount.
        Waiting for the amount to be entered, the decimal point is automatically added to the fixed position, after "confirmation", the password keyboard will return the displayed value to the POS machine.
        Parameters:
        min -
        字符串最小长度(为 0 时,按 ENTER 键返回,且输入长度 Len=0)
        The minimum length of the string (when it is 0, press ENTER to return, and enter the length Len=0)
        max -
        字符串最大长度(小于等于 16 字节)
        Maximum string length (less than or equal to 16 bytes)
        pointMode -
        小数点方式,
        • 0X00:小数点后有两位小数;
        • 0X01:小数点后有三位小数;
        • 0X02:无小数点(整数);
        • 0X03:小数点后有一位小数;
        Decimal point method,
        • 0X00: There are two decimal places after the decimal point;
        • 0X01: There are three decimal places after the decimal point;
        • 0X02: No decimal point (integer);
        • 0X03: There is one decimal place after the decimal point;
        prompMode -
        无意义
        Meaningless
        Returns:
        输入的金额字符串
        Entered amount string
        Throws:
        TypeAException - TypeAException
      • getInputCipherString

        java.lang.String getInputCipherString(byte min,
                                              byte max,
                                              byte mode)
                                       throws TypeAException
        密码键盘输入字符串[密文交互]
        将按键值以明码或者“*”的形式在 LCD 第二行的右下角显示出来,经过“确认”后,密码键盘将按键值全部 返回给 POS 机。
        大陆版和越南版本密码键盘在收到该命令后,不在首行显示任何信息,如:“PLS INPUT PIN:”。密码键盘回应的数据包中的DATA域由TXK加密。
        Password keyboard input string [ciphertext interaction]
        The key value is displayed in the lower right corner of the second line of the LCD in the form of clear code or "*". After "confirmation", the password keyboard will return all the key values to the POS machine.
        After receiving this command, the mainland version and Vietnam version of the password keyboard will not display any information on the first line, such as: "PLS INPUT PIN:". The DATA field in the data packet responded by the password keyboard is encrypted by TXK.
        Parameters:
        min -
        字符串最小长度(为 0 时,按 ENTER 键返回,且输入长度 Len=0)
        The minimum length of the string (when it is 0, press ENTER to return, and enter the length Len=0)
        max -
        字符串最大长度(小于等于 40 字节)
        Maximum string length (less than or equal to 40 bytes)
        mode -
        0x00: 显示明码;
        0x01: 显示“*”号。
        0x00: Display plain code;
        0x01: Display "*" sign.
        Returns:
        输入的字符串
        Input string
        Throws:
        TypeAException - TypeAException
      • clearKeyBuffer

        void clearKeyBuffer(byte mode)
                     throws TypeAException
        按键缓冲区。
        1.设置为清空按键缓冲区,则用户输入密码前会对按键缓冲区做一次清空(默认) 。
        2.设置为不清空按键缓冲区,则发送该命令后的按键缓冲不做清除,发送该命令前的按键缓冲区会做 一次清除。
        Key buffer.
        1. Set to clear the key buffer, then the key buffer will be cleared once before the user enters the password (default).
        2. If it is set to not clear the key buffer, the key buffer after sending this command will not be cleared, and the key buffer before sending this command will be cleared once.
        Parameters:
        mode -
        0:不清空按键缓冲区
        1:清空按键缓冲区
        0: Do not clear the key buffer
        1: Clear the key buffer
        Throws:
        TypeAException - TypeAException
      • writePlainKey

        void writePlainKey(byte keyIndex,
                           byte mode,
                           byte[] plainKeyValue)
                    throws TypeAException
        传送主密钥或 DES 密钥。
        按照 mode 方式将 Key 存储在主密钥区或 DES 密钥区的指定(KeyID)位置。
        Transfer the master key or DES key.
        Store the Key in the designated (KeyID) location of the master key area or DES key area according to mode.
        Parameters:
        keyIndex -
        最高位[bit7]来区分主密钥和 DES 密钥的索引,为 0 表示为主密钥索引,为 1 表示 DES 密钥索引。(使用时DES密钥索引最高位[bit7]为0)
        KeyID=0xxxxxxxb 主密钥区的密钥索引
        KeyID=1xxxxxxxb DES 密钥区的索引
        The most significant bit [bit7] distinguishes the index of the master key and the DES key, 0 means the master key index, and 1 means the DES key index.(The highest bit of the DES key index [bit7] is 0 when in use)
        KeyID=0xxxxxxxb The key index of the master key zone
        KeyID=1xxxxxxxb DES key area index
        mode -
        • mode=0x01 单 DES 密钥, len=10;
        • mode=0x03 3 倍 DES 密钥, len=18;
        • mode=0x07 3 倍 DES 密钥, len=26;
        • mode=0x01 single DES key, len=10;
        • mode=0x03 3 times the DES key, len=18;
        • mode=0x07 3 times the DES key, len=26;
        plainKeyValue -
        密钥值(8 字节或 16 字节或者 24 字节)。
        Key value (8 bytes or 16 bytes or 24 bytes).
        Throws:
        TypeAException - TypeAException
      • writeCipherKey

        void writeCipherKey(byte[] cipherKeyValue)
                     throws TypeAException
        密文传送主密钥或 DES 密钥。
        将 Key 存储在主密钥区或 DES 密钥区的指定(KeyID)位置。DATA 由 TXK 加密。
        The master key or DES key is transmitted in cipher text.
        Store the Key in the designated (KeyID) location of the master key area or DES key area. DATA is encrypted by TXK.
        Parameters:
        cipherKeyValue -
        由 TXK 加密。
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 keyIndex 1-100
        KeyID=0xxxxxxxb 主密钥区的密钥索引
        KeyID=1xxxxxxxb DES 密钥区的索引
        0x0001 1 keyLen 8、16 或 24,
        0x0002 N key key
        0x0002+N M Fill 填充字节,以上数据长度不被 8 字节整除时,填充至 8 字节整除的个数。
        Encrypted by TXK.
        Offset Length (byte) Variable name Description
        0x0000 1 keyIndex 1-100
        KeyID=0xxxxxxxb Key index of the master key area
        KeyID=1xxxxxxxb key index of DES key
        0x0001 1 keyLen 8、16 or 24,
        0x0002 N key key
        0x0002+N M Fill Filling bytes, when the above data length is not evenly divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes.
        Throws:
        TypeAException - TypeAException
      • writeTWK

        void writeTWK(byte srcKeyIndex,
                      byte destKeyIndex,
                      byte mode,
                      byte[] keyValue)
               throws TypeAException
        写入工作密钥。
        通常用来写入 PIN-BLOCK 生成和 MAC 运算的密钥。用 srcKeyIndex 指定的主密钥对 keyValue 进行 mode 指定方式的加密或解密后,将结果存储在 keyIndex 指定的工作密钥区位置。如果 srcKeyIndex 为 0,则不对 keyValue 进行加密或解密,而直接将 keyValue 存储在工作密钥区的keyIndex 指定的位置。
        Write the work key.
        It is usually used to write the key for PIN-BLOCK generation and MAC operation. Use the master key specified by srcKeyIndex to encrypt or decrypt keyValue in the mode specified by mode, and store the result in the working key area specified by keyIndex. If srcKeyIndex is 0, the keyValue is not encrypted or decrypted, and the keyValue is directly stored in the location specified by the keyIndex of the working key area.
        Parameters:
        srcKeyIndex -
        主密钥索引号,该密钥将用作生成工作密钥明文加/解密运算的密钥。
        The index number of the master key, which will be used as the key for the plaintext encryption/decryption operation to generate the working key.
        destKeyIndex -
        工作密钥索引号,传入的密钥值密文经过 mode 指定的运算后,生成明文,该明文将写入该索引号对应的密钥位置。当 srcKeyIndex 为 0 时,传入的密钥值为明文,无需运算;mode 的设置仅指示长度。
        Working key index number. After the passed-in key value ciphertext undergoes the operation specified by mode, a plaintext is generated, and the plaintext will be written into the key position corresponding to the index number. When srcKeyIndex is 0, the key value passed in is plain text, no operation is required; the setting of mode only indicates the length.
        mode -
        指示最终工作密钥明文的生成运算方式,取值共有 16 种,具体如下所示,
        • 0x01-- DES 加密
        • 0x81-- DES 解密
          srcdestKeyIndex 与 destKeyIndex 均为单 DES/ 8 字节密钥,Len=11。
        • 0x03-- 3DES 加密
        • 0x31-- 3DES 加密
        • 0x83-- 3DES 解密
        • 0xb1-- 3DES 解密
          srcdestKeyIndex 为 3DES/16 字节密钥,destKeyIndex 为单 DES/8 字节密钥,Len=11。
        • 0x07-- 3DES 加密
        • 0x87-- 3DES 解密
          srcdestKeyIndex 为 3DES/24 字节密钥,destKeyIndex 为单 DES/8 字节密钥,Len=11。
        • 0x33-- 3DES 加密
        • 0xb3-- 3DES 解密
          srcdestKeyIndex 与 destKeyIndex 均为 3DES/16 字节密钥,Len=19。
        • 0x71-- 3DES 加密
        • 0xf1-- 3DES 解密
          srcdestKeyIndex 为 3DES/24 字节密钥, destKeyIndex 为单 DES/8 字节密钥,Len=11。
        • 0x73-- 3DES 加密
        • 0xf3-- 3DES 解密
          srcdestKeyIndex 为 3DES/24 字节密钥, destKeyIndex 为 3DES-16 字节密钥,Len=19。
        • 0x77-- 3DES 加密
        • 0xf7-- 3DES 解密
          srcdestKeyIndex 与 destKeyIndex 均为 3DES/24 字节密钥,Len=27。
        Indicate the calculation method for generating the final working key plaintext. There are 16 values in total, as shown below.
        • 0x01-- DES encryption
        • 0x81-- DES decrypt
          Both srcdestKeyIndex and destKeyIndex are single DES/8-byte keys, Len=11.
        • 0x03-- 3DES encryption
        • 0x31-- 3DES encryption
        • 0x83-- 3DES decryption
        • 0xb1-- 3DES decryption
          srcdestKeyIndex is a 3DES/16 byte key, destKeyIndex is a single DES/8 byte key, Len=11.
        • 0x07-- 3DES encryption
        • 0x87-- 3DES decryption
          srcdestKeyIndex is a 3DES/24-byte key, destKeyIndex is a single DES/8-byte key, Len=11.
        • 0x33-- 3DES encryption
        • 0xb3-- 3DES decryption
          Both srcdestKeyIndex and destKeyIndex are 3DES/16 byte keys, Len=19.
        • 0x71-- 3DES encryption
        • 0xf1-- 3DES decrypt
          srcdestKeyIndex is a 3DES/24-byte key, destKeyIndex is a single DES/8-byte key, Len=11.
        • 0x73-- 3DES encryption
        • 0xf3-- 3DES decryption
          srcdestKeyIndex is a 3DES/24 byte key, destKeyIndex is a 3DES-16 byte key, Len=19.
        • 0x77-- 3DES encryption
        • 0xf7-- 3DES decryption
          Both srcdestKeyIndex and destKeyIndex are 3DES/24-byte keys, Len=27.
        keyValue -
        需写入的密钥值(8、16 或 24 字节, 由 mode 决定)。
        The key value to be written (8, 16 or 24 bytes, determined by mode).
        Throws:
        TypeAException - TypeAException
      • derivedTWK

        void derivedTWK(byte derivedKeyIndex,
                        byte srcKeyIndex,
                        byte destKeyIndex,
                        byte mode)
                 throws TypeAException
        发散密钥。
        用derivedKeyIndex指定的主密钥或工作密钥对 srcKeyIndex 指定的工作密钥进行 mode 方式的加密或解密后,将 结果存储在工作密钥区的 destKeyIndex 指定的位置。
        Diverge the key.
        After using the master key or working key specified by derivedKeyIndex to encrypt or decrypt the working key specified by srcKeyIndex in mode, the result is stored in the location specified by destKeyIndex in the working key area.
        Parameters:
        derivedKeyIndex -
        用来对 srcKeyIndex指定的工作密钥进行 mode 方式运算的主密钥或工作密钥索引。
        = 0xxxxxxxb 时,用主密钥来发散
        = 1xxxxxxxb 时,用工作密钥来发散。
        The master key or working key index used to perform mode operation on the working key specified by srcKeyIndex.
        = 0xxxxxxxb, use the master key to diverge
        = 1xxxxxxxb, use the working key to diverge.
        srcKeyIndex -
        需进行分散的工作密钥的索引。
        Index of the working key that needs to be diverged
        destKeyIndex -
        对 srcKeyIndex分散后的结果存储在工作密钥区的索引。
        The result of divergence of srcKeyIndex is stored in the index of the working key area.
        mode -
        指示最终工作密钥明文的生成运算方式,取值共有 16 种,具体如下所示,
        • 0x01-- DES 加密
        • 0x81-- DES 解密
          derivedKeyIndex 与 srcKeyIndex 均为单 DES/ 8 字节密钥,Len=11。
        • 0x03-- 3DES 加密
        • 0x31-- 3DES 加密
        • 0x83-- 3DES 解密
        • 0xb1-- 3DES 解密
          derivedKeyIndex 为 3DES/16 字节密钥,srcKeyIndex 为单 DES/8 字节密钥,Len=11。
        • 0x07-- 3DES 加密
        • 0x87-- 3DES 解密
          derivedKeyIndex 为 3DES/24 字节密钥,srcKeyIndex 为单 DES/8 字节密钥,Len=11。
        • 0x33-- 3DES 加密
        • 0xb3-- 3DES 解密
          derivedKeyIndex 与 srcKeyIndex 均为 3DES/16 字节密钥,Len=19。
        • 0x71-- 3DES 加密
        • 0xf1-- 3DES 解密
          derivedKeyIndex 为 3DES/24 字节密钥, srcKeyIndex 为单 DES/8 字节密钥,Len=11。
        • 0x73-- 3DES 加密
        • 0xf3-- 3DES 解密
          derivedKeyIndex 为 3DES/24 字节密钥, srcKeyIndex 为 3DES-16 字节密钥,Len=19。
        • 0x77-- 3DES 加密
        • 0xf7-- 3DES 解密
          derivedKeyIndex 与 srcKeyIndex 均为 3DES/24 字节密钥,Len=27。
        Indicate the calculation method for generating the final working key plaintext. There are 16 values in total, as shown below.
        • 0x01-- DES encryption
        • 0x81-- DES decrypt
          Both derivedKeyIndex and srcKeyIndex are single DES/8-byte keys, Len=11.
        • 0x03-- 3DES encryption
        • 0x31-- 3DES encryption
        • 0x83-- 3DES decryption
        • 0xb1-- 3DES decryption
          derivedKeyIndex is a 3DES/16 byte key, srcKeyIndex is a single DES/8 byte key, Len=11.
        • 0x07-- 3DES encryption
        • 0x87-- 3DES decryption
          derivedKeyIndex is a 3DES/24-byte key, srcKeyIndex is a single DES/8-byte key, Len=11.
        • 0x33-- 3DES encryption
        • 0xb3-- 3DES decryption
          Both derivedKeyIndex and srcKeyIndex are 3DES/16 byte keys, Len=19.
        • 0x71-- 3DES encryption
        • 0xf1-- 3DES decrypt
          derivedKeyIndex is a 3DES/24-byte key, srcKeyIndex is a single DES/8-byte key, Len=11.
        • 0x73-- 3DES encryption
        • 0xf3-- 3DES decryption
          derivedKeyIndex is a 3DES/24 byte key, srcKeyIndex is a 3DES-16 byte key, Len=19.
        • 0x77-- 3DES encryption
        • 0xf7-- 3DES decryption
          Both derivedKeyIndex and srcKeyIndex are 3DES/24-byte keys, Len=27.
        Throws:
        TypeAException - TypeAException
      • getTXK

        byte[] getTXK(byte[] modulus,
                      byte[] exponent)
               throws TypeAException
        向密码键盘请求获取 TXK。
        该命令用于上位机从 PED 获取读取传输密钥。 传输密钥 TXK 固定为 16 字节。上位机临时产生一组模长 512bit 的 RSA 公私钥对,并将公钥传给 PED, PED 产生传输密钥 TXK,并保存在安全存储器中,然后用公钥加密后,将密文发给上位机。
        Request a TXK from the password keyboard.
        This command is used by the host computer to obtain and read the exchange key from the PED. The exchange key TXK is fixed at 16 bytes. The host computer temporarily generates a set of RSA public-private key pairs with a modulus of 512 bits, and transmits the public key to the PED. The PED generates the exchange key TXK and saves it in the secure memory. After encrypting with the public key, the cipher text is sent to the host. machine.
        Parameters:
        modulus -
        公钥模
        Public key module.
        exponent -
        公钥指数,高字节在前。
        Public key index, high byte first.
        Returns:
        TXK,PED 产生的 16 字节随机数。
        TXK, 16-byte random number generated by PED.
        Throws:
        TypeAException - TypeAException
      • getTXKCheckValue

        byte[] getTXKCheckValue()
                         throws TypeAException
        获取 TXK 校验值。
        该命令用于上位机检查 TXK 是否同步。
        密码键盘产生 8 字节随机数,并用 TXK 加密,把随机数和加密后的值,发给上位机。上位机可以由自身的 TXK 进行相关验证。
        Get TXK check value.
        This command is used by the host computer to check whether the TXK is synchronized.
        The password keyboard generates an 8-byte random number and encrypts it with TXK, and sends the random number and the encrypted value to the upper computer. The upper computer can be verified by its own TXK.
        Returns:
        8字节随即数+8字节随机数密文(用TXK加密)。
        8-byte random number + 8-byte random number ciphertext (encrypted with TXK).
        Throws:
        TypeAException - TypeAException
      • getPinBlock

        byte[] getPinBlock(boolean isNewAccount,
                           byte mode,
                           byte keyIndex,
                           byte min,
                           byte max,
                           byte[] data,
                           int timeoutMs)
                    throws TypeAException
        用户输入密码。
        触发用户输入账户密码,在输入密码并按“确认”键后,密码键盘用POS机传下来的数据(卡号或 ISN), 根据 ANSI X9.8 标准或 ANSI X3.92 标准和 WKeyID 指定的 PIN 密钥对 PIN 进行加密。在输入密码时,用户能取消操作, POS 机一端通过发送操作取消命令也可中止密码输入。大陆版和越南版本密码键盘在收到该命令后,不在首行显示任何信息,如:“PLS INPUT PIN:”。 缺省的密码输入超时为 120 秒,但可由后述的相关超时设置命令重新设定。
        The user enters the password.
        Trigger the user to enter the account password. After entering the password and pressing the "confirm" key, the password keyboard uses the data (card number or ISN) transmitted from the POS machine, according to the ANSI X9.8 standard or the ANSI X3.92 standard and the PIN password specified by WKeyID The key encrypts the PIN. When entering the password, the user can cancel the operation, and the POS terminal can also stop the password input by sending the operation cancel command. After receiving this command, the mainland version and Vietnam version of the PIN keyboard will not display any information on the first line, such as: "PLS INPUT PIN:". The default password input timeout is 120 seconds, but it can be reset by the related timeout setting command described later.
        Parameters:
        isNewAccount -
        是否是新开户。
        True:新开户
        False:不是新开户
        Whether it is a new account.
        True: New account
        False: Not a new account
        mode -
        指定加密标准
        • 0x01:按照 ANSI X9.8 标准,PIN 输入时当最小长度不为 0 时,允许按"确认"退出
        • 0x31:16 字节密钥 DES 按照 ANSI X9.8 标准,PIN 输入时当最小长度不为 0 时,允许按"确认"退出
        • 0x71:24 字节密钥 DES 按照 ANSI X9.8 标准,PIN 输入时当最小长度不为 0 时,允许按"确认"退出
        • 0x04:按照 ANSI X9.8 标准,采用 3DES 加密方法
        • 0x02:des 按照 ANSI X3.92 标准
        • 0x32:16 字节密钥 DES 按照 ANSI X3.92 标准
        • 0x72:24 字节密钥 DES 按照 ANSI X3.92 标准
        Specify encryption standards
        • 0x01: According to ANSI X9.8 standard, when the minimum length of PIN input is not 0, it is allowed to press "OK" to exit
        • 0x31: 16-byte key DES According to the ANSI X9.8 standard, when the minimum length of PIN input is not 0, it is allowed to press "OK" to exit
        • 0x71: 24-byte key DES According to ANSI X9.8 standard, when the minimum length of PIN input is not 0, it is allowed to press "OK" to exit
        • 0x04: According to ANSI X9.8 standard, using 3DES encryption method
        • 0x02: des is in accordance with ANSI X3.92 standard
        • 0x32: 16-byte key DES according to ANSI X3.92 standard
        • 0x72: 24-byte key DES according to ANSI X3.92 standard
        keyIndex -
        工作密钥的索引。
        The index of the working key.
        min -
        允许输入的 PIN 的最小长度(大于等于 0, 为 0 时,按 ENTER 键返回,且输入 长度 Len=0,此时应答数据长度为 0,表示用户没有输入密码)。
        The minimum length of the allowed PIN (when greater than or equal to 0, when it is 0, press the ENTER key to return, and enter the length Len=0, at this time the response data length is 0, which means that the user did not enter a password).
        max -
        允许输入的 PIN 的最大长度(小于等于 14)。
        The maximum length of the PIN that can be entered (less than or equal to 14).
        data -
        按照ANSI X9.8 标准,16字节卡号。
        按照ANSI X3.92标准,6字节交易流水号ISN。
        According to ANSI X9.8 standard, 16-byte card number.
        According to ANSI X3.92 standard, 6-byte transaction serial number ISN.
        timeoutMs -
        超时时间。单位: 毫秒。
        Timeout. Unit: milliseconds.
        Returns:
        如果输入长度为0,则返回new byte[0]。
        如果输入长度不为0,则返回8字节的PinBlock。
        If the input length is 0, new byte[0] is returned.
        If the input length is not 0, an 8-byte PinBlock is returned.
        Throws:
        TypeAException - TypeAException
      • cancelInputPin

        void cancelInputPin()
                     throws TypeAException
        用于在密码键盘处于密码输入状态时,POS 机取消密码输入。
        It is used to cancel the password input by the POS machine when the password keyboard is in the password input state.
        Throws:
        TypeAException - TypeAException
      • setPinTimeout

        void setPinTimeout(byte high,
                           byte low)
                    throws TypeAException
        PIN 输入超时设置。
        PINPAD 每次开机后的缺省值是 120 秒(2 分钟)。
        设置的键盘超时值为:Time_High×256+Time_Low,单位为 10 毫秒(Timeout<655.36 秒)。当设置为0 时,其超时时间为 2 分钟。
        PIN input timeout setting.
        The default value of PINPAD after each power-on is 120 seconds (2 minutes).
        The set keyboard timeout value is: Time_High×256+Time_Low, the unit is 10 milliseconds (Timeout<655.36 seconds). When set to 0, the timeout period is 2 minutes..
        Parameters:
        high -
        设置的键盘超时值为:Time_High×256+Time_Low。
        The set keyboard timeout value is: Time_High×256+Time_Low.
        low -
        设置的键盘超时值为:Time_High×256+Time_Low。
        The set keyboard timeout value is: Time_High×256+Time_Low.
        Throws:
        TypeAException - TypeAException
      • getPinBlock

        byte[] getPinBlock(byte[] cipherByTXK,
                           int timeoutMs)
                    throws TypeAException
        扩展获取 PINBLOCK [密文传输]。
        Extended access to PINBLOCK [ciphertext transmission].
        Parameters:
        cipherByTXK -
        偏移位置 长度 byte 变量名称 意义
        0x0000 1 WKeyID 1-100
        0x0001 1 WKeyLen 8、16 或 24,指示 PINBLOCK 是用 DES/TDES 加密
        0x0002 1 mode 选择 PIN BLOCK 的格式,
        0x00 ISO9564 格式 0
        0x01 ISO9564 格式 1
        0x02 ISO9564 格式 3
        0x03 HK EPS 专用格式[详见附录]
        0x0003 1 InputMode 0x01:只输入一次,0x02:输入两次密码,两次输入一致后返回 PINBLOCK
        0x0004 1 Min PinPad 输入最小长度,>=0
        0x0005 1 Max PinPad 输入最大长度,<=14
        0x0006 1 DataInLen DataIn的长度
        0x0007 N DataIn 当 Mode=0x00 时DataIn 指向卡号移位后生成的 16 位主帐号。
        当 Mode=0x01 时输入参数为参与 PinBlock 的格式化,8 字节数据(根据 ISO9564 的规范,该数据可以是随机数、交易流水号或时间戳等)。
        当 Mode=0x02 时DataIn 指向卡号移位后生成的 16 位主帐号,DataIn+16 指向参与 PinBlock 格式化的 8 字节数据(根据 ISO9564 的规范,该数据可以是随机数、交易流水号或时间戳等,但是每个字节的高 4 位和低 4位,均必须在 0xA-0xF 之间,所以当 Mode 为 0x02时,底层将该 8 字节的数据做此检查,如果不满足要求将返回错误)。
        当 Mode=0x03 时为交易流水号 ISN [6 Bytes,ASCII 码]] [输入]。
        0x0007+N M Fill 填充字节,以上数据长度不被 8 字节整除时,填充至8 字节整除。
        Encrypted by TXK。
        Offset Length (byte) Variable name Description
        0x0000 1 WKeyID 1-100
        0x0001 1 WKeyLen 8, 16 or 24, indicating that PINBLOCK is encrypted with DES/TDES
        0x0002 1 mode Choose the format of PIN BLOCK,
        0x00 ISO9564 format 0
        0x01 ISO9564 format 1
        0x02 ISO9564 format 3
        0x03 HK EPS special format [see appendix for details]
        0x0003 1 InputMode 0x01: Enter the password only once, 0x02: Enter the password twice, and return to PINBLOCK after the two entries are consistent
        0x0004 1 Min PinPad input minimum length, >=0
        0x0005 1 Max PinPad input maximum length, <=14
        0x0006 1 DataInLen Length of DataIn
        0x0007 N DataIn When Mode=0x00, DataIn points to the 16-bit master account number generated after the card number is shifted.
        When Mode=0x01, the input parameter is to participate in the formatting of PinBlock, 8 bytes of data (according to the ISO9564 specification, the data can be random numbers, transaction serial numbers or timestamps, etc.).
        When Mode=0x02, DataIn points to the 16-bit main account number generated after the card number is shifted, and DataIn+16 points to 8-byte data that participates in PinBlock formatting (according to the ISO9564 specification, this data can be a random number, transaction serial number, or time stamp And so on, but the upper 4 bits and lower 4 bits of each byte must be between 0xA-0xF, so when Mode is 0x02, the bottom layer will do this check for the 8-byte data, and if it does not meet the requirements, it will return Mistake).
        When Mode=0x03, it is the transaction serial number ISN [6 Bytes, ASCII code]] [input].
        0x0007+N M Fill Filling byte, when the above data length is not divisible by 8 bytes, it is filled to 8 bytes.
        timeoutMs -
        超时时间。单位: 毫秒。
        Timeout. Unit: milliseconds.
        Returns:
        如果输入长度为0,则返回new byte[0]。
        如果输入长度不为0,则返回8字节的PinBlock。
        If the input length is 0, new byte[0] is returned.
        If the input length is not 0, an 8-byte PinBlock is returned.
        Throws:
        TypeAException - TypeAException
      • getMac

        byte[] getMac(byte macMode,
                      byte keyIndex,
                      byte algorithmMode,
                      byte[] dataIn)
               throws TypeAException
        用指定的 MAC 密钥对 Data 作 MAC 加密运算。
        当其最高位为 1 时,先用指定的工作密钥对 Data 前 8 字节进行一次 DES 或 3DES 解密,其结果覆盖 Data 前 8 字节,然后再按 Mode 指定的算法对最新的 Data 数据块进行相应 MAC 运算。
        Use the specified MAC key to perform MAC encryption operations on Data.
        When the highest bit is 1, use the specified working key to decrypt the first 8 bytes of Data with DES or 3DES, and the result will cover the first 8 bytes of Data, and then perform the latest Data block according to the algorithm specified by Mode Carry out the corresponding MAC operation.
        Parameters:
        macMode -
        MAC算法类型
        • 0x00-算法 1\3
        • 0x01-算法 2
        MAC algorithm type
        • 0x00-algorithm 1\3
        • 0x01-algorithm 2
        keyIndex -
        低 7 位是 MAC 工作密钥的索引。 当其最高位为 1 时,将在 Mode 指定的算法进行之前增加一次额外的解密运算
        The lower 7 bits are the index of the MAC working key. When the highest bit is 1, an additional decryption operation will be added before the algorithm specified by Mode is performed
        algorithmMode -
        • 0x01 DES 加密 算法 1\2
        • 0x03 3DES 加密[密钥为 16 字节] 算法 1\2
        • 0x07 3DES 加密[密钥为 24 字节] 算法 1\2
        • 0x13: 3DES 加密[密钥为 16 字节] 算法 3
        • 0x17: 3DES 加密[密钥为 24 字节] 算法 3
        dataIn -
        要进行 MAC 加密的数据。 WKeyID 最高位为 1 时,需至少 9 字节。
        Data to be MAC encrypted. When the most significant bit of WKeyID is 1, at least 9 bytes are required.
        Returns:
        计算得到的MAC
        Calculated MAC
        Throws:
        TypeAException - TypeAException
      • calcDes

        byte[] calcDes(byte keyIndex,
                       byte mode,
                       byte[] dataIn)
                throws TypeAException
        用指定的 DES 密钥对 Data 作 DES 或者 3DES 加密或解密运算。
        Use the specified DES key to perform DES or 3DES encryption or decryption operations on Data.
        Parameters:
        keyIndex -
        DES(3DES)密钥索引(DES 密钥区)
        DES (3DES) key index (DES key area)
        mode -
        • mode = 0x01 DES 加密
        • mode = 0x03 3DES 加密 (密钥为 16 字节)
        • mode = 0x81 DES 解密 (EPS 无此项)
        • mode = 0x83 3DES 解密 (EPS 无此项)
        • mode = 0x07 3DES 加密 [密钥为 24 字节]
        • mode = 0x87 3DES 解密 [密钥为 24 字节]
        • mode = 0x01 DES encryption
        • mode = 0x03 3DES encryption (the key is 16 bytes)
        • mode = 0x81 DES decryption (EPS does not have this option)
        • mode = 0x83 3DES decryption (EPS does not have this option)
        • mode = 0x07 3DES encryption [key is 24 bytes]
        • mode = 0x87 3DES decryption [key is 24 bytes]
        dataIn -
        要进行 DES(3DES)加密或解密的数据。(8 字节)
        The data to be encrypted or decrypted by DES (3DES). (8 bytes)
        Returns:
        运算结果
        Calculation result
        Throws:
        TypeAException - TypeAException
      • getExtMac

        byte[] getExtMac(byte cipherFlag,
                         byte[] dataIn)
                  throws TypeAException
        用指定的 MAC 密钥对 Data 作 MAC 加密运算。
        Use the specified MAC key to perform MAC encryption operations on Data.
        Parameters:
        cipherFlag -
        0x00:DATA 域是明文
        0x01: DATA 域,由传输密加密
        0x00: DATA field is plain text
        0x01: DATA field, encrypted by transmission secret
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 WKeyID 1-100
        0x0001 1 WKeyLen 8、16 或 24,指示 MAC 运算采用的是 DES 还是 TDES
        0x0002 1 Mode 0x00-算法 1
        0x01-算法 2
        0x02-算法 3
        0x0003 2 MAC_DATA_LEN MAC_DATA 长度,小于等于 1024,两字节, 高字节在前,低字节在后
        0x0005 N MAC_DATA 待计算 MAC 的数据
        0x0005+N M FILL 填充字节,DATA 域上述数据长度不被 8 字节整除时,填充至 8 字节整除
        Offset Length(byte) Variable name Description
        0x0000 1 WKeyID 1-100
        0x0001 1 WKeyLen 8, 16, or 24, indicating whether the MAC operation uses DES or TDES
        0x0002 1 Mode 0x00-algorithm 1
        0x01-algorithm 2
        0x02-algorithm 3
        0x0003 2 MAC_DATA_LEN MAC_DATA length, less than or equal to 1024, two bytes, high byte first, low byte last
        0x0005 N MAC_DATA Data to be calculated MAC
        0x0005+N M FILL Filling byte, when the above data length in DATA field is not divisible by 8 bytes, it is filled to 8 bytes.
        Returns:
        输出的MAC
        Output MAC
        Throws:
        TypeAException - TypeAException
      • calcExtDes

        byte[] calcExtDes(byte cipherFlag,
                          byte[] dataIn)
                   throws TypeAException
        用指定的 DES 密钥对 Data 作 DES 或者 3DES 加密或解密运算。
        Use the specified DES key to perform DES or 3DES encryption or decryption operations on Data.
        Parameters:
        cipherFlag -
        0x00:DATA_IN 与 acuIV 是明文
        0x01: DATA_IN 与 acuIV,由传输密钥加密
        0x00: DATA_IN and acuIV are plain text
        0x01: DATA_IN and acuIV, encrypted by the transmission key
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 DKeyID 1-100
        0x0001 1 DKeyLen 8、16 或 24,指示数据加解密是采用的是 DES 还 是 TDES
        0x0002 1 Mode
        • 0x00: ECB decryption
        • 0x01: ECB encryption
        • 0x02: CBC decryption
        • 0x03: CBC encryption
        • 0x04: OFB decryption
        • 0x05: OFB encryption
        0x0003 2 DATA_LEN DATA 长度,小于等于 1024,两字节,高 字节在前,低字节在后,8 字节整除。
        0x0005 N DATA_IN_IN 待加解密的数据
        0x0005+N 8 aucIV 初始向量,ECB 时不需要。
        Offset Length(byte) Variable name Description
        0x0000 1 DKeyID 1-100
        0x0001 1 DKeyLen 8, 16 or 24, indicating whether the data encryption and decryption use DES or TDES
        0x0002 1 Mode
        • 0x00: ECB decryption
        • 0x01: ECB encryption
        • 0x02: CBC decryption
        • 0x03: CBC encryption
        • 0x04: OFB decryption
        • 0x05: OFB encryption
        0x0003 2 DATA_LEN DATA length, less than or equal to 1024, two bytes, high byte first, low byte last, 8 bytes are divisible
        0x0005 N DATA_IN_IN DData to be encrypted and decrypted
        0x0005+N 8 aucIV Initial vector, not needed for ECB.
        Returns:
        运算结果
        Calculation result
        Throws:
        TypeAException - TypeAException
      • writeTIK

        void writeTIK(byte appNo,
                      byte groupIndex,
                      byte[] keyValue,
                      byte[] ksn)
               throws TypeAException
        用于重新初始化 DUKPT 密钥。
        Used to reinitialize the DUKPT key.
        Parameters:
        appNo -
        应用标志号,有效值 0-23
        Application mark number, valid value 0-23
        groupIndex -
        密钥标志号,有效值 1-10。
        Key mark number, valid value 1-10.
        keyValue -
        初始 PIN 输入设备密钥,16 字节,由 BDK 和 KSN 通过 DUKPT 密钥初始化 专用设备生成。
        初始 KSN,长度不足 10 字节时,会自动在左边填充 0xFF 至 10 字节。
        Initial KSN. when ksn is less than 10 bytes in length, 0xFF to 10 bytes will be automatically filled on the left.
        Throws:
        TypeAException - TypeAException
      • getDUKPTPin

        DUKPTResult getDUKPTPin(byte appNo,
                                byte groupIndex,
                                byte min,
                                byte max,
                                byte[] dataIn,
                                byte mode,
                                int timeoutMs)
                         throws TypeAException
        提示用户输入 PIN。待输入完毕后,依照所选标准生成和输出 PIN 密文块和当前密钥序号 KSN。
        为防止非法套取密钥,从上一次执行该命令到本次指令之间的间隔应不小于 30 秒(该值可能需要调整)。
        Prompt the user to enter a PIN. After the input is completed, the PIN ciphertext block and the current key sequence number KSN are generated and output according to the selected standard.
        In order to prevent illegal key acquisition, the interval from the last execution of this command to this command should be no less than 30 seconds (this value may need to be adjusted).
        Parameters:
        appNo -
        应用标志号,有效值 0-23
        Application mark number, valid value 0-23
        groupIndex -
        密钥标志号,有效值 1-10。
        Key mark number, valid value 1-10.
        min -
        允许输入 PIN 的最小长度,应不超过最大允许长度。
        The minimum length allowed to enter the PIN should not exceed the maximum allowed length.
        max -
        允许输入 PIN 的最大长度,应不超过 12。
        The maximum length of the PIN allowed to be entered should not exceed 12.
        dataIn -
        当mode = 0x00时,表示持卡人的卡号资料,该卡号应固定为 16 字节,并保证其尾部 12 字节为有效 数据。
        当mode = 0x01时,表示交易序号,该序号应固定为 6 字节,有效值 000000-999999。
        When mode = 0x00, it means the card number information of the cardholder. The card number should be fixed to 16 bytes, and the last 12 bytes should be guaranteed to be valid data.
        When mode = 0x01, it means the transaction serial number. The serial number should be fixed to 6 bytes and the effective value is 000000-999999.
        mode -
        0x00: 依照 ANSI X98 标准
        0x01: 依照 ANSI X3.92 标准
        0x00: According to ANSI X98 standard
        0x01: According to ANSI X3.92 standard
        timeoutMs -
        超时时间,单位:ms
        Timeout time(ms)
        Returns:
        DUKPTResult
        Throws:
        TypeAException - TypeAException
      • getDUKPTMac

        DUKPTResult getDUKPTMac(byte appNo,
                                byte groupIndex,
                                byte mode,
                                byte[] dataIn)
                         throws TypeAException
        对输入数据报文进行指定算法的验证码运算,并输出生成的 MAC 和当前密钥序号 KSN。
        Perform the verification code operation of the specified algorithm on the input data message, and output the generated MAC and the current key sequence number KSN.
        Parameters:
        appNo -
        应用标志号,有效值 0-23
        Application mark number, valid value 0-23
        groupIndex -
        密钥标志号,有效值 1-10。
        Key mark number, valid value 1-10.
        mode -
        指定 MAC 算法
        • 0x00: 依次连续进行 3DES/异或/3DES/异或/…/3DES 的运算
        • 0x01: 依次连续进行异或/异或/…/异或,最后进行一次 3DES 的运算
        • 0x02: 依次连续进行 DES/异或/DES/异或/…/3DES 的运算,注意最后一次为 3DES 运算
        Specify MAC algorithm
        • 0x00: Perform 3DES/XOR/3DES/XOR/.../3DES operations in sequence
        • 0x01: XOR/XOR/.../XOR is performed successively, and the 3DES operation is performed last
        • 0x02: DES/XOR/DES/XOR/.../3DES operations are successively performed in sequence, note that the last operation is 3DES operation
        dataIn -
        输入的数据报文,有效长度为1-250
        The input data message, the effective length is 1-250
        Returns:
        DUKPTResult
        Throws:
        TypeAException - TypeAException
      • eraseDUKPTKey

        void eraseDUKPTKey(byte appNo,
                           byte keyIndex,
                           byte mode)
                    throws TypeAException
        用于清除指定的部分或全部 DUKPT 密钥
        Used to clear some or all of the specified DUKPT key
        Parameters:
        appNo -
        应用标志号,有效值 0-23
        Application mark number, valid value 0-23
        keyIndex -
        密钥标志号,有效值 1-10。
        Key mark number, valid value 1-10.
        mode -
        指定清除方式:
        0—清除 AppNo 指定应用中所有 DUKPT 密钥
        1—清除 AppNo 指定应用中 KeyId 所对应的 DUKPT 密钥
        Specify the clearing method:
        0—Clear all DUKPT keys in AppNo specified application
        1—Clear the DUKPT key corresponding to the KeyId in the AppNo specified application
        Throws:
        TypeAException - TypeAException
      • writeSM4Key

        void writeSM4Key(byte cipherFlag,
                         byte[] dataIn)
                  throws TypeAException
        将 SM4 密钥存储在指定位置。
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 MKeyIndex 1-99 ,该密钥是密钥加解密密钥,当 KeyType 是主密钥时,KeyIndex 无效,Mode 必须为 0x00,即主密钥只能明文注入。
        0x0001 1 Mode 0x00:不作任何运算。
        0x01:解密运算。
        0x02:加密运算。
        0x0002 1 KeyType 0x00:主密钥。
        0x01:数据加解密密钥。
        0x02:PIN 加密密钥。
        0x03:MAC 计算密钥
        0x0003 1 KeyIndex 1-99,传入的密钥值密文经过 Mode 指定的运算后,生成明文,该明文将写该索引号对应的密钥位置。
        0x0004 1 KeyLen 固定取值 0x10。
        0x0005 16 Key 传入的密钥值。
        0x0006 N Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 MKeyIndex 1-99, the key is the key encryption and decryption key. When the KeyType is the master key, the KeyIndex is invalid and the Mode must be 0x00, that is, the master key can only be injected in plain text.
        0x0001 1 Mode 0x00: No operation is performed.
        0x01: Decryption operation.
        0x02: Encryption operation.
        0x0002 1 KeyType 0x00: Master key.
        0x01: Data encryption and decryption key.
        0x02: PIN encryption key.
        0x03: MAC calculation key.
        0x0003 1 KeyIndex 1 to 99, after the passed-in key value ciphertext undergoes the operation specified by Mode, a plaintext is generated, and the plaintext will be written with the key position corresponding to the index number.
        0x0004 1 KeyLen The fixed value is 0x10.
        0x0005 16 Key The key value.
        0x0006 N Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Throws:
        TypeAException - TypeAException
      • genSM2Key

        SM2KeyPair genSM2Key(byte cipherFlag,
                             byte[] dataIn)
                      throws TypeAException
        生成 SM2 公私钥对。
        Generate SM2 public and private key pair.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 2 PrvKeyLenBit 私钥位数,支持256bit。
        0x0002 N Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 PrvKeyLenBit The length of private key bits, supports 256bit.
        0x0002 N Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Returns:
        SM2KeyPair
        Throws:
        TypeAException - TypeAException
      • writeSM2Key

        void writeSM2Key(byte cipherFlag,
                         byte[] dataIn)
                  throws TypeAException
        将SM2密钥存储在PED中。
        注意:SM2 密钥存储于 DES 密钥区域,KeyIndex指示的是 DES 密钥区的存储位置,以 8 字节为单位, 比如 SM2 私钥 32 字节,则占用 4 个存储位置。
        Store the SM2 key in the PED.
        Note: The SM2 key is stored in the DES key area. KeyIndex indicates the storage location of the DES key area, in units of 8 bytes. For example, if the SM2 private key is 32 bytes, it occupies 4 storage locations.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 KeyType 0x00:SM2 私钥;
        0x01: SM2 公钥。
        0x0001 1 KeyIndex SM2 私钥: 1~97;
        SM2 公钥:1~93。
        0x0002 2 KeyLenBit SM2 私钥固定256bit;
        SM2 公钥固定512bit。
        0x0004 N Key 密钥。
        0x0004+N M Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 KeyType 0x00: SM2 private key.
        0x01: SM2 public key.
        0x0001 1 KeyIndex SM2 private key: 1~97;
        SM2 public key: 1~93.
        0x0002 2 KeyLenBit SM2 private key is fixed 256bit;
        The SM2 public key is fixed at 512 bits.
        0x0004 N Key The key value.
        0x0004+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Throws:
        TypeAException - TypeAException
      • getSM4PinBlock

        byte[] getSM4PinBlock(byte cipherFlag,
                              byte[] dataIn,
                              int timeoutMs)
                       throws TypeAException
        提示用户输入 PIN,输入 PIN 之后按照指定 mode 生成 PINBlock,并使用 SM4 密钥加密。
        Prompt the user to enter the PIN. After entering the PIN, a PINBlock is generated according to the specified mode and encrypted with the SM4 key.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 WKeyIndex 1~99。
        0x0001 1 WKeyLen 16。
        0x0002 1 Mode 0x00: 国密格式0。
        0x0003 1 InputMode 0x01: 只输入一次;
        0x02: 输入两次密码,两次输入一致后返回PINBlock。
        0x0004 1 Min 输入最小长度,大于等于0。
        0x0005 1 Max 输入最大长度,小于等于14。
        0x0006 1 DataInLen DataIn的长度。
        0x0007 N DataIn 卡号移位后生成的 16 位主帐号。
        0x0007+N M Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 WKeyIndex 1~99。
        0x0001 1 WKeyLen 16。
        0x0002 1 Mode 0x00: SM format 0.
        0x0003 1 InputMode 0x01: Enter only once;
        0x02: Enter the password twice, and return to PINBlock after the two entries are consistent.
        0x0004 1 Min Enter the minimum length, which is greater than or equal to 0.
        0x0005 1 Max Enter the maximum length, which is less than or equal to 14.
        0x0006 1 DataInLen The length of DataIn.
        0x0007 N DataIn The 16-digit master account number generated after the card number is shifted.
        0x0007+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        timeoutMs -
        超时时间。单位: 毫秒。
        Timeout. Unit: milliseconds.
        Returns:
        16字节的PINBlock。
        16-byte PINBlock.
        Throws:
        TypeAException - TypeAException
      • getSM4Mac

        byte[] getSM4Mac(byte cipherFlag,
                         byte[] dataIn)
                  throws TypeAException
        使用 SM4 算法计算 MAC。
        Use SM4 algorithm to calculate MAC.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 WKeyIndex 1~99。
        0x0001 1 WKeyLen 16。
        0x0002 1 Mode 0x00: 使用SM4 CBC 算法计算MAC 值,首先将初始向量与BLOCK1 进行异或,并用SM4算法使用TAK 对异或的结果进行加密, 然后获得的密文与BLOCK2 异或,用SM4 算法使用TAK 对结果加密,按顺序给出16 字节的加密果。结果为16 字节。
        0x01: SM3 HMAC, 结果为32字节。
        0x0003 2 MacDataLen MacData的长度。
        0x0005 N MacData 待计算Mac的数据。
        0x0005+N 16 IV 16字节初始化向量。
        0x0015+N M Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 WKeyIndex 1~99。
        0x0001 1 WKeyLen 16。
        0x0002 1 Mode 0x00: Use the SM4 CBC algorithm to calculate the MAC value. First, the initial vector and BLOCK1 are XORed, and the SM4 algorithm uses TAK to encrypt the XOR result, and then the obtained ciphertext is XORed with BLOCK2, and the SM4 algorithm uses TAK to encrypt the result. The 16-byte encryption result is given in sequence. The result is 16 bytes.
        0x01: SM3 HMAC, the result is 32 bytes.
        0x0003 2 MacDataLen The length of MacData.
        0x0005 N MacData The data of Mac to be calculated.
        0x0005+N 16 IV 16-byte initialization vector.
        0x0015+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Returns:
        Mac结果。
        Mac results.
        Throws:
        TypeAException - TypeAException
      • calcSM4Data

        byte[] calcSM4Data(byte cipherFlag,
                           byte[] dataIn)
                    throws TypeAException
        使用SM4 算法加解密数据。
        Use SM4 algorithm to encrypt and decrypt data.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 WKeyIndex 1~99。
        0x0001 1 WKeyLen 16。
        0x0002 1 Mode 0x00: ECB 解密;
        0x01: ECB 加密;
        0x02: CBC 解密;
        0x03: CBC 加密;
        0x0003 2 DataInLen DataIn的长度。
        0x0005 N DataIn 待加解密的数据。
        0x0005+N 16 IV 16字节初始化向量。ECB时不需要。
        0x0015+N M Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 WKeyIndex 1~99。
        0x0001 1 WKeyLen 16。
        0x0002 1 Mode 0x00: ECB decryption.;
        0x01: ECB encryption;
        0x02: CBC decryption;
        0x03: CBC encryption;
        0x0003 2 DataInLen The length of DataIn.
        0x0005 N DataIn Data to be encrypted and decrypted.
        0x0005+N 16 IV 16-byte initialization vector. Not required for ECB.
        0x0015+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Returns:
        加解密的结果。
        The result of encryption and decryption.
        Throws:
        TypeAException - TypeAException
      • SM2Sign

        byte[] SM2Sign(byte cipherFlag,
                       byte[] dataIn)
                throws TypeAException
        使用 SM2 算法获得签名信息。
        Use SM2 algorithm to obtain signature information.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 PubKeyIndex SM2公钥索引: 1~93。
        0x0001 1 PrvKeyIndex SM2私钥索引: 1~97。
        0x0002 2 PrvKeyLenBit 私钥位数。
        0x0004 2 UidLen Uid的长度。
        0x0006 N Uid 签名者 ID。
        0x0006+N 2 DataInLen DataIn长度。
        0x0008+N M DataIn 待签名的数据。
        0x0008+N+M M Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 PubKeyIndex SM2 public key index: 1~93。
        0x0001 1 PrvKeyIndex SM2 private key index: 1~97。
        0x0002 2 PrvKeyLenBit The number of bits of the private key.
        0x0004 2 UidLen The length of Uid.
        0x0006 N Uid Signer ID.
        0x0006+N 2 DataInLen The length of DataIn.
        0x0008+N M DataIn The data to be signed.
        0x0015+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Returns:
        64字节的签名数据。
        64 bytes of signature data.
        Throws:
        TypeAException - TypeAException
      • SM2Verify

        void SM2Verify(byte cipherFlag,
                       byte[] dataIn)
                throws TypeAException
        使用 SM2 公钥验证签名。
        Use the SM2 public key to verify the signature.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 PubKeyIndex SM2公钥索引: 1~93。
        0x0001 2 PubKeyLenBit 公钥位数。
        0x0003 2 UidLen Uid的长度。
        0x0005 N Uid 签名者 ID。
        0x0005+N 2 DataInLen DataIn长度。小于等于1024。
        0x0007+N M DataIn 待签名的数据。
        0x0007+N+M 64 Signature 签名值,固定为 64 字节。
        0x0047+N+M L Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 PubKeyIndex SM2 public key index: 1~93。
        0x0001 2 PubKeyLenBit The number of bits of the public key.
        0x0003 2 UidLen The length of Uid.
        0x0005 N Uid Signer ID.
        0x0005+N 2 DataInLen The length of DataIn.
        0x0007+N M DataIn The data to be signed.
        0x0007+N+M 64 Signature The signature value is fixed at 64 bytes.
        0x0047+N+M M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Throws:
        TypeAException - TypeAException
      • calcSM2Data

        byte[] calcSM2Data(byte cipherFlag,
                           byte[] dataIn)
                    throws TypeAException
        使用 SM2 公钥加密数据或私钥解密数据。
        Use SM2 public key to encrypt data or private key to decrypt data.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 KeyIndex SM2公钥索引: 1~93;
        SM2私钥索引: 1~97。
        0x0001 2 KeyLenBit SM2密钥位数。
        0x0003 1 Mode 0x00: 使用SM2私钥解密数据;
        0x01: 使用SM2公钥加密数据。
        0x0004 2 DataInLen DataIn长度。小于等于1024。
        0x0006 N DataIn 待加密或者解密的数据。
        0x0006+N L Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 KeyIndex SM2 public key index: 1~93;
        SM2 private key index: 1~97。
        0x0001 2 KeyLenBit SM2密钥位数。
        0x0003 1 Mode 0x00: Use SM2 private key to decrypt data;
        0x01: Use SM2 public key to encrypt data.
        0x0004 2 DataInLen DataIn length. Less than or equal to 1024.
        0x0006 N DataIn The data to be encrypted or decrypted.
        0x0006+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Returns:
        计算结果。数据长度:加密时为源数据长度加96字节; 解密时为源数据长度减96字节。
        Calculation results. Data length: When encrypting, the length of the source data plus 96 bytes; when decrypting, the length of the source data minus 96 bytes.
        Throws:
        TypeAException - TypeAException
      • getSM3Hash

        byte[] getSM3Hash(byte cipherFlag,
                          byte[] dataIn)
                   throws TypeAException
        使用 SM3 算法计算杂凑值。
        The SM3 algorithm is used to calculate the hash value.
        Parameters:
        cipherFlag -
        • 0x00: dataIn 是明文。
        • 0x01: dataIn 是由传输密钥(TXK)加密。
        • 0x00: dataIn is plain text.
        • 0x01: dataIn is encrypted by the exchange key(TXK).
        dataIn -
        偏移位置 长度(byte) 变量名称 意义
        0x0000 1 Mode 0x00: 目前只支持0x00;
        其他值保留。
        0x0001 2 DataInLen DataIn长度。小于等于1024。
        0x0003 N DataIn 待计算的数据。
        0x0003+N L Fill 加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。
        Offset Length(byte) Variable name Description
        0x0000 1 Mode 0x00: Currently only 0x00 is supported;
        Other values are reserved.
        0x0001 2 DataInLen DataIn length. Less than or equal to 1024.
        0x0003 N DataIn The data to be calculated.
        0x0003+N M Fill The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes, it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.
        Returns:
        Throws:
        TypeAException - TypeAException
      • playVoice

        void playVoice(byte type)
                throws TypeAException
        按所选序号播放语音。必须支持语音芯片
        Play the voice according to the selected sequence number. Must support voice chip
        Parameters:
        type -
        • 0x01: "请拍卡。
        • 0x02: "请重新拍卡"。
        • 0x03: "请输入密码"。
        • 0x04: "请输入信息"。
        • 0x05: "请重新输入"。
        • 0x06: "嘀"。
        • 0x07: "Please tap the card"。
        • 0x08: "Please re-tap the card"。
        • 0x09: "Please enter password"。
        • 0x0A: "Please input information"。
        • 0x0B: "Please re-input"。
        • 0x0C: 音效 1。
        • 0x0D: 音效 2。
        • 0x0E: 音效 3。
        • 0x0F: 音效 4。
        • 0x10: 音效 5。
        • 0x11: 音效 6。
        • 0x12: 音效 7。
        • 0x01: "请拍卡".
        • 0x02: "请重新拍卡".
        • 0x03: "请输入密码".
        • 0x04: "请输入信息".
        • 0x05: "请重新输入".
        • 0x06: "Beep".
        • 0x07: "Please tap the card".
        • 0x08: "Please re-tap the card".
        • 0x09: "Please enter password".
        • 0x0A: "Please input information".
        • 0x0B: "Please re-input".
        • 0x0C: Sound effect 1.
        • 0x0D: Sound effect 2.
        • 0x0E: Sound effect 3.
        • 0x0F: Sound effect 4.
        • 0x10: Sound effect 5.
        • 0x11: Sound effect 6.
        • 0x12: Sound effect 7.
        Throws:
        TypeAException - TypeAException
      • setVolumeLevel

        void setVolumeLevel(byte level)
                     throws TypeAException
        调节音量等级。必须支持语音芯片
        Adjust the volume level. Must support voice chip
        Parameters:
        level -
        范围为 0 至 7 档。 0 档对应静音。
        The range is from 0 to 7 level。Level 0 corresponds to mute.
        Throws:
        TypeAException - TypeAException
      • EPS

        byte[] EPS(byte option,
                   byte[] dataIn)
            throws TypeAException
        EPS 专用接口。
        EPS dedicated interface.
        Parameters:
        option -
        • 0x01: 下载初始 TMK,方式一。由 POS 产生临时 KEY,上传主机,取回密文 TMK1 和临时加密参考值,由临时 KEY 对密文 TMK1 解密,得 TMK, 明文 TMK 应符合奇校验;TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,加密后的结 果前四字节应与加密参考值相等,之后将明文 TMK 写入 WKeyID1 低 7 位所指定的工作密钥区位置。
        • 0x02: 更新 TMK 或 下载 TPK。用WKeyID1处的TMK对主机下传的新的密文解密,明文应符合奇校验,之后将明文结果写入WKeyID2 位置。 更新 TMK:主机下传新的密文 TMK2,用明文 TMK1 对 TMK2 解密,明文 TMK2 应符合奇校验, 之后将明文 TMK2 写入 WKeyID2 位置。 当 WKeyID1 与 WKeyID2 相等时,即覆盖明文 TMK1。 下载 TPK:主机下传新的密文 TPK,用 WKeyID1 处的 TMK 对其解密,明文 TPK 应符合奇校验,之后将明文 TPK 写入 WKeyID2 位置。
        • 0x03: 计算出输出 TAK 的密文。POS 送入 8 字节随机数(输出 TAK 的明文), 其应符合奇校验,用 MKeyID 处的 TMK 对其加密,返回其结果。
        • 0x04: 冲正时重算 PIN-BLOCK 和更新 TPK。POS 送入 8 bytes pin_block,新的 ISN,新的 TPK,原 TPK WKeyID2,TMK WKeyID1, PINPAD 用原 TPK 对 pin_block 按 X3.92 解密得到明文 PIN,再将新 TPK 用 TMK 解密,明文 TPK 应符合奇校验,新 TPK 替 换原 TPK, 之后用明文 TPK,ISN 对 PIN 按 X3.92 加密,返回新的 pin_block.
        • 0x05: 交换输入 TAK。用 WKeyID1 处的 TMK 对主机下传的新的密文解密得到输入 TAK,明文应符合奇校验,对输入的数据 以输入 TAK 为密钥做 MAC 运算, 其结果与输入的 MAC 运算值(ASCII)相等(前 4 bytes),之后将明文结果 TAK 写入 WKeyID2 位置。
        • 0x06: 校验 TMK。用原 TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,并返回结果。
        • 0x08: 下载初始 TMK,方式二。 由 POS 产生临时 KEY,上传主机,取回密文 TMK1 和临时加密参考值,由临时 KEY 对密文 TMK1 解密,得 TMK, 明文 TMK 应符合奇校验;TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,加密后的结果前四字节应与加密参考值相等;之后将明文 TMK 写入 MWKeyID1 低 7 位所指定的主密钥或工作密钥区域。MWKeyID1 最高位为 0 时,表示 TMK 存入主密钥区域,为 1 时表示 TMK 存入工作密钥区域。
        • 0x01: Download the initial TMK, method one. The POS generates a temporary KEY, uploads it to the host, retrieves the ciphertext TMK1 and the temporary encryption reference value, and decrypts the ciphertext TMK1 by the temporary KEY to obtain TMK,The plaintext TMK should meet odd parity; TMK encrypts "\x12\x34\x56\x78\x90\x12\x34\x56", the first four bytes of the encrypted result should be equal to the encryption reference value, and then write the plaintext TMK Enter the working key area location specified by the lower 7 bits of WKeyID1.
        • 0x02: Update TMK or download TPK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host. The plaintext should meet odd parity, and then write the plaintext result into the WKeyID2 location. Update TMK: The host downloads the new ciphertext TMK2, decrypts TMK2 with the plaintext TMK1, the plaintext TMK2 should meet odd parity, and then writes the plaintext TMK2 into the WKeyID2 location. When WKeyID1 and WKeyID2 are equal, the plaintext TMK1 is overwritten. Download TPK: The host downloads the new ciphertext TPK, decrypts it with the TMK at WKeyID1, the plaintext TPK should meet odd parity, and then writes the plaintext TPK into the WKeyID2 location.
        • 0x03: Calculate the ciphertext of the output TAK. POS sends an 8-byte random number (the plaintext of TAK output), which should meet odd parity, encrypt it with TMK at MKeyID, and return the result.
        • 0x04: Recalculate PIN-BLOCK and update TPK during timing. POS sends 8 bytes pin_block, new ISN, new TPK, original TPK WKeyID2, TMK WKeyID1, PINPAD uses the original TPK to decrypt the pin_block by X3.92 to obtain the plaintext PIN, and then decrypts the new TPK with TMK. The plaintext TPK should conform to the odd Verify, replace the original TPK with the new TPK, then use the plain text TPK and ISN to encrypt the PIN by X3.92, and return the new pin_block.
        • 0x05: Exchange input TAK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host to obtain the input TAK. The plaintext should meet odd parity. The input data is used to perform MAC operations with the input TAK as the key. The result is the same as the input MAC operation value (ASCII ) Are equal (the first 4 bytes), and then write the plaintext result TAK into the WKeyID2 position.
        • 0x06: Verify TMK. Use the original TMK to encrypt "\x12\x34\x56\x78\x90\x12\x34\x56" and return the result.
        • 0x08: Download the initial TMK, method two. The POS generates a temporary KEY, uploads it to the host, retrieves the ciphertext TMK1 and the temporary encryption reference value, and decrypts the ciphertext TMK1 by the temporary KEY to obtain TMK. The plaintext TMK should meet odd parity; TMK pairs "\x12\x34\x56\" x78\x90\x12\x34\x56" encryption, the first four bytes of the encrypted result should be equal to the encrypted reference value; then the plaintext TMK is written into the master key or work key area specified by the lower 7 bits of MWKeyID1. When the highest bit of MWKeyID1 is 0, it means that TMK is stored in the master key area; when it is 1, it means that TMK is stored in the working key area.
        dataIn -
        • 当option = 0x01时,dataIn = WKeyID1(1byte) + 临时 KEY(8bytes)+密文 TMK1(8bytes)+加密参考值(8bytes)。
        • 当option = 0x02时, dataIn = WKeyID1(1byte) + WKeyID2(1byte)+密文 TMK2(8bytes)。
        • 当option = 0x03时, dataIn = MKeyID(1byte) + 明文 Random(8bytes)。
        • 当option = 0x04时, dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes)。
        • 当option = 0x05时, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK 密文 (8bytes) + rsp_data(rsp_len) + rsp_MAC(8byte, 将 MAC 码的前 4 字节进行值串转换后传入,如 0x123456AB 转换为“123456AB”)。
        • 当option = 0x06时, dataIn = WKeyID1(1byte)。
        • 当option = 0x08时, dataIn = MWKeyID1(1byte) + 临时 KEY(8bytes) + 密文 TMK1(8bytes) + 加密参考值(8bytes)。
        • When option = 0x01, dataIn = WKeyID1(1byte) + temporary KEY(8bytes) + ciphertext TMK1(8bytes) + encrypted reference value (8bytes).
        • When option = 0x02, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + cipher text TMK2(8bytes).
        • When option = 0x03, dataIn = MKeyID(1byte) + plaintext Random(8bytes).
        • When option = 0x04, dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes).
        • When option = 0x05, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK ciphertext (8bytes) + rsp_data(rsp_len) + rsp_MAC(8byte, convert the first 4 bytes of the MAC code to the value string and then pass in, such as 0x123456AB converted to "123456AB").
        • When option = 0x06, dataIn = WKeyID1(1byte).
        • When option = 0x08, dataIn = MWKeyID1(1byte) + temporary KEY(8bytes) + ciphertext TMK1(8bytes) + encrypted reference value (8bytes).
        Returns:
        • 当option = 0x01时,无返回结果。
        • 当option = 0x02时, 无返回结果。
        • 当option = 0x03时, 随机数密文(8bytes)。
        • 当option = 0x04时, 新的 pin_block(8bytes)。
        • 当option = 0x05时, 无返回结果。
        • 当option = 0x06时, 加密结果(8byte)。
        • 当option = 0x08时, 无返回结果。
        • When option = 0x01, no result is returned.
        • When option = 0x02, no result is returned.
        • When option = 0x03, random number ciphertext (8bytes).
        • When option = 0x04, new pin_block(8bytes).
        • When option = 0x05, no result is returned.
        • When option = 0x06, the encryption result (8byte).
        • When option = 0x08, no result is returned.
        Throws:
        TypeAException - TypeAException
      • extEPS

        byte[] extEPS(byte option,
                      byte mode,
                      byte[] dataIn)
               throws TypeAException
        扩展的 EPS 专用接口。
        Extended EPS dedicated interface.
        Parameters:
        option -
        • 0x01: 下载初始 TMK,方式一。由 POS 产生临时 KEY,上传主机,取回密文 TMK1 和临时加密参考值,由临时 KEY 对密文 TMK1 解密,得 TMK, 明文 TMK 应符合奇校验;TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,加密后的结 果前四字节应与加密参考值相等,之后将明文 TMK 写入 WKeyID1 低 7 位所指定的工作密钥区位置。
        • 0x02: 更新 TMK 或 下载 TPK。用WKeyID1处的TMK对主机下传的新的密文解密,明文应符合奇校验,之后将明文结果写入WKeyID2 位置。 更新 TMK:主机下传新的密文 TMK2,用明文 TMK1 对 TMK2 解密,明文 TMK2 应符合奇校验, 之后将明文 TMK2 写入 WKeyID2 位置。 当 WKeyID1 与 WKeyID2 相等时,即覆盖明文 TMK1。 下载 TPK:主机下传新的密文 TPK,用 WKeyID1 处的 TMK 对其解密,明文 TPK 应符合奇校验,之后将明文 TPK 写入 WKeyID2 位置。
        • 0x03: 计算出输出 TAK 的密文。POS 送入 8 或者 16 或者 24 字节随机数(输出 TAK 的明文), 其应符合奇校验,用 MKeyID 处的 TMK 对其加密,返回其结果。
        • 0x04: 冲正时重算 PIN-BLOCK 和更新 TPK。POS 送入 8 bytes pin_block,新的 ISN,新的 TPK,原 TPK WKeyID2,TMK WKeyID1 PINPAD 用原 TPK 对 pin_block 按 X3.92 解密得到明文 PIN,再将新 TPK 用 TMK 解密,明文 TPK 应符合奇校验,新 TPK 替 换原 TPK, 之后用明文 TPK,ISN 对 PIN 按 X3.92 加密,返回新的 pin_block.
        • 0x05: 交换输入 TAK。用 WKeyID1 处的 TMK 对主机下传的新的密文解密得到输入 TAK,明文应符合奇校验,对输入的数据 以输入 TAK 为密钥做 MAC 运算, 其结果与输入的 MAC 运算值(ASCII)相等(前 4 bytes),之后将明文结果 TAK 写入 WKeyID2 位置。进行的 MAC 运算共有算法 1 和算法 2 两种,由 Mode 来指定。 MAC 算法 1: 若密钥为 8 字节,则依次连续进行 DES/异或/DES/异或/…/DES;若密钥为 16 字节或 24 字节,则依次连续进行 3DES/异或/3DES/异或/…/3DES 的运算。 MAC 算法 2:若密钥为 8 字节,则依次连续进行 DES/异或/DES/异或/…/DES 的运算;若密钥为 16 字节或 24 字节,则依次连续进行 DES/异或/DES/异或/…/3DES 的运算,注意最后一次为 3DES 运算。 如果密钥为 8 字节,则算法 1 和算法 2 是相同的。
        • 0x06: 校验 TMK。用原 TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,并返回结果。
        • 0x01: Download the initial TMK, method one. The POS generates a temporary KEY, uploads it to the host, retrieves the ciphertext TMK1 and the temporary encryption reference value, and decrypts the ciphertext TMK1 by the temporary KEY to obtain TMK,The plaintext TMK should meet odd parity; TMK encrypts "\x12\x34\x56\x78\x90\x12\x34\x56", the first four bytes of the encrypted result should be equal to the encryption reference value, and then write the plaintext TMK Enter the working key area location specified by the lower 7 bits of WkeyID
        • 0x02: Update TMK or download TPK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host. The plaintext should meet odd parity, and then write the plaintext result into the WKeyID2 location. Update TMK: The host downloads the new ciphertext TMK2, decrypts TMK2 with the plaintext TMK1, the plaintext TMK2 should meet odd parity, and then writes the plaintext TMK2 into the WKeyID2 location. When WKeyID1 and WKeyID2 are equal, the plaintext TMK1 is overwritten. Download TPK: The host downloads the new ciphertext TPK, decrypts it with the TMK at WKeyID1, the plaintext TPK should meet odd parity, and then writes the plaintext TPK into the WKeyID2 location.
        • 0x03: Calculate the ciphertext of the output TAK. POS sends an 8 or 16 or 24-byte random number (the plaintext of TAK output), which should meet odd parity, encrypt it with TMK at MKeyID, and return the result.
        • 0x04: Recalculate PIN-BLOCK and update TPK during timing. POS sends 8 bytes pin_block, new ISN, new TPK, original TPK WKeyID2, TMK WKeyID1, PINPAD uses the original TPK to decrypt the pin_block by X3.92 to obtain the plaintext PIN, and then decrypts the new TPK with TMK. The plaintext TPK should conform to the odd Verify, replace the original TPK with the new TPK, then use the plain text TPK and ISN to encrypt the PIN by X3.92, and return the new pin_block.There are two types of MAC operations: Algorithm 1 and Algorithm 2, which are specified by Mode. MAC algorithm 1: If the key is 8 bytes, DES/XOR/DES/XOR/.../DES will be performed successively; if the key is 16 bytes or 24 bytes, then 3DES/XOR will be successively performed /3DES/XOR/.../3DES operation. MAC algorithm 2: If the key is 8 bytes, the DES/XOR/DES/XOR/.../DES operations will be performed successively; if the key is 16 bytes or 24 bytes, the DES/ will be successively performed successively. XOR/DES/XOR/.../3DES operation, note that the last operation is 3DES operation. If the key is 8 bytes, then Algorithm 1 and Algorithm 2 are the same.
        • 0x05: Exchange input TAK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host to obtain the input TAK. The plaintext should meet odd parity. The input data is used to perform MAC operations with the input TAK as the key. The result is the same as the input MAC operation value (ASCII ) Are equal (the first 4 bytes), and then write the plaintext result TAK into the WKeyID2 position.
        • 0x06: Verify TMK. Use the original TMK to encrypt "\x12\x34\x56\x78\x90\x12\x34\x56" and return the result.
        mode -
        • 0x01: DES 加密方式。
        • 0x03: 3DES 加密方式。
        • 0x07: 3DES 加密方式。
        • 0x31: 3DES 加密方式。
        • 0x33: 3DES 加密方式。
        • 0x71: 3DES 加密方式。
        • 0x73: 3DES 加密方式。
        • 0x77: 3DES 加密方式。
        • 0x81: 8 字节 DES 密钥方式; DES 解密方式;
        • 0x83: 3DES 解密方式。
        • 0x87: 3DES 解密方式。
        • 0x89: DES 解密方式。
        • 0x8B: 3DES 解密方式。
        • 0x8F: 3DES 解密方式。
        • 0xB1: 3DES 解密方式。
        • 0xB3: 16 字节 3DES 密钥方式; 3DES 解密方式;
        • 0xB9: 3DES 解密方式。
        • 0xBB: 3DES 解密方式。
        • 0xF1: 3DES 解密方式。
        • 0xF3: 3DES 解密方式。
        • 0xF7: 24 字节 3DES 密钥方式; 3DES 解密方式;
        • 0xF9: 3DES 解密方式。
        • 0xFB: 3DES 解密方式。
        • 0xFF: 3DES 解密方式。
        • 0x01: DES encryption method.
        • 0x03: 3DES encryption method.
        • 0x07: 3DES encryption method.
        • 0x31: 3DES encryption method.
        • 0x33: 3DES encryption method.
        • 0x71: 3DES encryption method.
        • 0x73: 3DES encryption method.
        • 0x77: 3DES encryption method.
        • 0x81: 8-byte DES key mode; DES encryption method;
        • 0x83: 3DES decryption method.
        • 0x87: 3DES decryption method.
        • 0x89: DES decryption method.
        • 0x8B: 3DES decryption method.
        • 0x8F: 3DES decryption method.
        • 0xB1: 3DES decryption method.
        • 0xB3: 16-byte DES key mode; 3DES decryption method;
        • 0xB9: 3DES decryption method.
        • 0xBB: 3DES decryption method.
        • 0xF1: 3DES decryption method.
        • 0xF3: 3DES decryption method.
        • 0xF7: 24-byte DES key mode; 3DES decryption method;
        • 0xF9: 3DES decryption method.
        • 0xFB: 3DES decryption method.
        • 0xFF: 3DES decryption method.
        dataIn -
        • 当 option = 0x01 时,dataIn = WKeyID1(1byte) + 临时 KEY + 密文 TMK1 + 加密参考值(8bytes)。
          • 当mode = 0x81 时,临时 KEY 与 密文 TMK1 均为 8 字节 DES 密钥。
          • 当mode = 0xB3 时,临时 KEY 与 密文 TMK1 均为 16 字节 3DES 密钥。
          • 当mode = 0xF7 时,临时 KEY 与 密文 TMK1 均为 24 字节 3DES 密钥。
        • 当 option = 0x02 时,dataIn = WKeyID1(1byte) + WKeyID2(1byte) + 密文 TMK2。
          • 当 mode = 0x81 时,DES 解密方式,WKeyID1 密钥 8 字节,WKeyID2 密钥 8 字节 ,密文 TMK2 为 8 字节。
          • 当 mode = 0x83 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。
          • 当 mode = 0x87 时,3DES 解密方式,WKeyID1 密钥 24 字节, WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。
          • 当 mode = 0xB1 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。
          • 当 mode = 0xB3 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 16 字节,密文 TMK2 为 16 字节。
          • 当 mode = 0xF1 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。
          • 当 mode = 0xF3 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 16 字节,密文 TMK2 为 16 字节。
          • 当 mode = 0xF7 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 24 字节,密文 TMK2 为 24 字节。
        • 当 option = 0x03 时,dataIn = MKeyID(1byte) + 明文 Random。
          • 当 mode = 0x01 时,DES 加密方式,MKeyID 密钥 8 字节,Random 8 字节。
          • 当 mode = 0x03 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 8 字节。
          • 当 mode = 0x31 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 8 字节。
          • 当 mode = 0x07 时,3DES 加密方式,MKeyID 密钥 24 字节,Random 8 字节。
          • 当 mode = 0x71 时,3DES 加密方式,MKeyID 密钥 24 字节,Random 8 字节。
          • 当 mode = 0x33 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 16 字节。
          • 当 mode = 0x73 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 16 字节。
          • 当 mode = 0x77 时,3DES 加密方式,MKeyID 密钥 24 字节,Random 24 字节。
        • 当 option = 0x04 时,dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes)。
          • 当 mode = 0x81 时,DES 解密方式,WKeyID1 密钥 8 字节,WKeyID2 密钥 8 字节。
          • 当 mode = 0x83 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节。
          • 当 mode = 0x87 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 8 字节。
          • 当 mode = 0xB1 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节。
          • 当 mode = 0xF1 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 8 字节。
          • 当 mode = 0xB3 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 16 字节。
          • 当 mode = 0xF3 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 16 字节。
          • 当 mode = 0xF7 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 24 字节。
        • 当 option = 0x05 时,dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK 密文 + rsp_data(rsp_len) + rsp_MAC(8byte, 将 MAC 码的前 4 字节进行值串转换后传入,如 0x123456AB 转换为“123456AB”)。

            MAC算法1:

          • 当 mode = 0x81 时,DES 解密方式,WKeyID1 密钥 8 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0x83 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0xB1 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0x87 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0xF1 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0xB3 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 16 字节。
          • 当 mode = 0xF3 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 16 字节。
          • 当 mode = 0xF7 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 24 字节。
          • 当 mode = 0x89 时,DES 解密方式,WKeyID1 密钥 8 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0x8B 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0xB9 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0x8F 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • 当 mode = 0xF9 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。
          • MAC算法2:

          • 当 mode = 0xBB 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 16 字节。
          • 当 mode = 0xFB 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 16 字节。
          • 当 mode = 0xFF 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 24 字节。
        • 当 option = 0x06 时,dataIn = WKeyID1(1byte)。
          • 当 mode = 0x01 时,DES 加密方式,WKeyID1 密钥 8 字节。
          • 当 mode = 0x03 时,3DES 加密方式,WKeyID1 密钥 16 字节。
          • 当 mode = 0x07 时,3DES 加密方式,WKeyID1 密钥 24 字节。
        • When option = 0x01, dataIn = WKeyID1(1byte) + temporary KEY(8bytes) + ciphertext TMK1 + encrypted reference value (8bytes).
          • When mode = 0x81, both temporary KEY and ciphertext TMK1 are 8-byte DES keys.
          • When mode = 0xB3, both temporary KEY and ciphertext TMK1 are 16-byte 3DES keys.
          • When mode = 0xF7, both temporary KEY and ciphertext TMK1 are 24byte 3DES keys.
        • When option = 0x02, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + cipher text TMK2.
          • When mode = 0x81, DES decryption mode, WKeyID1 key is 8 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.
          • When mode = 0x83, 3DES decryption mode, WKeyID1 key is 16 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.
          • When mode = 0x87, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.
          • When mode = 0xB1, 3DES decryption mode, WKeyID1 key is 16 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.
          • When mode = 0xB3, 3DES decryption mode, WKeyID1 key is 16 bytes, WKeyID2 key is 16 bytes, and cipher text TMK2 is 16 bytes.
          • When mode = 0xF1, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.
          • When mode = 0xF3, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 16 bytes, and cipher text TMK2 is 16 bytes.
          • When mode = 0xF7, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 24 bytes, and cipher text TMK2 is 24 bytes.
        • When option = 0x03, dataIn = MKeyID(1byte) + plaintext Random.
          • When mode = 0x01, DES encryption mode, MKeyID key 8 bytes, Random 8 bytes.
          • When mode = 0x03, 3DES encryption mode, MKeyID key 16 bytes, Random 8 bytes.
          • When mode = 0x31, 3DES encryption mode, MKeyID key 16 bytes, Random 8 bytes.
          • When mode = 0x07, 3DES encryption mode, MKeyID key 24 bytes, Random 8 bytes.
          • When mode = 0x71, 3DES encryption mode, MKeyID key 24 bytes, Random 8 bytes.
          • When mode = 0x33, 3DES encryption mode, MKeyID key 16 bytes, Random 16 bytes.
          • When mode = 0x73, 3DES encryption mode, MKeyID key 16 bytes, Random 16 bytes.
          • When mode = 0x77, 3DES encryption mode, MKeyID key 24 bytes, Random 24 bytes.
        • When option = 0x04, dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes).
          • When mode = 0x81, DES decryption mode, WKeyID1 key 8 bytes, WKeyID2 key 8 bytes.
          • When mode = 0x83, 3DES decryption mode, WKeyID1 key 16 bytes, WKeyID2 key 8 bytes.
          • When mode = 0x87, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 8 bytes.
          • When mode = 0xB1, 3DES decryption mode, WKeyID1 key 16 bytes, WKeyID2 key 8 bytes.
          • When mode = 0xF1, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 8 bytes.
          • When mode = 0xB3, 3DES decryption mode, WKeyID1 key 16 bytes, WKeyID2 key 16 bytes.
          • When mode = 0xF3, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 16 bytes.
          • When mode = 0xF7, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 24 bytes.
        • When option = 0x05, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK ciphertext + rsp_data(rsp_len) + rsp_MAC(8byte, convert the first 4 bytes of the MAC code to the value string and then pass in, such as 0x123456AB converted to "123456AB").

            MAC algorithm 1:

          • When mode = 0x81, DES decryption mode, WKeyID1 key is 8 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0x83, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0xB1, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0x87, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0xF1, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0xB3, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 16 bytes.
          • When mode = 0xF3, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 16 bytes.
          • When mode = 0xF7, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 24 bytes.
          • When mode = 0x89, DES decryption mode, WKeyID1 key is 8 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0x8B, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0xB9, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0x8F, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • When mode = 0xF9, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.
          • MAC algorithm 2:

          • When mode = 0xBB, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 16 bytes.
          • When mode = 0xFB, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 16 bytes.
          • When mode = 0xFF, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 24 bytes.
        • When option = 0x06, dataIn = WKeyID1(1byte).
          • When mode = 0x01, DES encryption mode, WKeyID1 key is 8 bytes.
          • When mode = 0x03, 3DES encryption mode, WKeyID1 key is 16 bytes.
          • When mode = 0x07, 3DES encryption mode, WKeyID1 key is 24 bytes.
        Returns:
        • 当option = 0x01时,无返回结果。
        • 当option = 0x02时, 无返回结果。
        • 当option = 0x03时, 随机数密文(8bytes)。
        • 当option = 0x04时, 新的 pin_block(8bytes)。
        • 当option = 0x05时, 无返回结果。
        • 当option = 0x06时, 加密结果(8byte)。
        • When option = 0x01, no result is returned.
        • When option = 0x02, no result is returned.
        • When option = 0x03, random number ciphertext (8bytes).
        • When option = 0x04, new pin_block(8bytes).
        • When option = 0x05, no result is returned.
        • When option = 0x06, the encryption result (8byte).
        Throws:
        TypeAException - TypeAException
      • detect

        PiccCardInfo detect(byte mode)
                     throws TypeAException
        按指定的模式搜寻PICC卡片,搜到卡片后,将其选中并激活。感应区内不允许多张卡存在。
        Search for PICC cards according to the specified mode. After the card is found, select and activate it. Multiple cards are not allowed in the induction area.
        Parameters:
        mode -
        • 0x00: 搜寻 A 型卡和 B 型卡一次,此模式适用于需要增强多卡检测功能的场合。该模式是符合 ISO14443 规范的寻卡模式。
        • 0x01: 搜寻 A 型卡和 B 型卡一次,此模式为EMV寻卡模式,通常使用该模式。
        • 0x10: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in VAS App OR PaymentMode)。此模式用于 apply pay。
        • 0x11: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in VAS App AND PaymentMode)。此模式用于 apply pay。
        • 0x12: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in VAS App Only Mode)。此模式用于 apply pay。
        • 0x13: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in Payment Mode Only)。
        • 'a'或'A': 只搜寻 A 型卡一次。
        • 'b'或'B': 只搜寻 B 型卡一次。
        • 'm'或'M': 只搜寻 M1 卡一次。
        • 0x00: Search for type A card and type B card once. This mode is suitable for occasions that need to enhance the multi-card detection function. This mode is a card detection mode that conforms to the ISO14443 specification.
        • 0x01: Search for type A card and type B card once, this mode is EMV search card mode, usually use this mode.
        • 0x10: Search for Type A and Type B cards once, and send the VAS command (Terminal in VAS App OR Payment Mode). This mode is used for apply pay.
        • 0x11: Search for Type A and Type B cards once, and send the VAS command (Terminal in VAS App AND Payment Mode). This mode is used for apply pay.
        • 0x12: Search for Type A and Type B cards once, and send the VAS command (Terminal in VAS App Only Mode). This mode is used for apply pay.
        • 0x13: Search for Type A and Type B cards once, and send the VAS command (Terminal in Payment Mode Only).
        • 'a'or'A': Only search for Type A cards once.
        • 'b'or'B': Only search for type B cards once.
        • 'm'or'M': Only search for M1 card once.
        Returns:
        PiccCardInfo
        Throws:
        TypeAException - TypeAException
      • isoCommand

        ApduRespInfo isoCommand(byte cid,
                                ApduSendInfo sendInfo)
                         throws TypeAException
        在指定的通道上,向卡片发送 APDU 格式的数据,并接收响应。
        On the designated channel, send data in APDU format to the card and receive the response.
        Parameters:
        cid -
        用于指定卡片逻辑通道号;该通道号由PiccCardInfo.getCID() 获取,其取值范围 0-14,目前取值均为 0。
        Used to specify the card logical channel number; the channel number is obtained by PiccCardInfo.getCID(), and its value range is 0-14, and the current value is 0.
        sendInfo - ApduSendInfo
        Returns:
        ApduRespInfo
        Throws:
        TypeAException - TypeAException
      • remove

        void remove(byte mode,
                    byte cid)
             throws TypeAException
        依据指定的模式,向卡片发送停机指令;或者发送停活指令;或者复位载波,并判断卡片是否已经移开感应区。
        According to the specified mode, send a stop instruction to the card; or send a deactivation instruction; or reset the carrier, and determine whether the card has moved out of the sensing area.
        Parameters:
        mode -
        • 'h'或'H': 意为 HALT,仅向卡片发送停活指令后就退出。该过程不执行卡移开检测。
        • 'r'或'R': 意为 REMOVE,向卡片发送停活指令,并执行卡移开检测。
        • 'e'或'E': 符合 EMV 非接规范的移卡模式。复位载波,并执行卡移开检测。
        • 'h'or'H': It means HALT, and it will exit after sending a deactivation command to the card. This process does not perform card removal detection.
        • 'r'or'R': It means REMOVE, sending a deactivation command to the card and executing the card removal detection.
        • 'e'or'E': Shift card mode conforming to EMV contactless specification. Reset the carrier and perform card removal detection.
        cid -
        用于指定卡片逻辑通道号;该通道号由PiccCardInfo.getCID() 获取,其取值范围 0-14,目前取值均为 0。
        Used to specify the card logical channel number; the channel number is obtained by PiccCardInfo.getCID(), and its value range is 0-14, and the current value is 0.
        Throws:
        TypeAException - TypeAException
      • piccClose

        void piccClose()
                throws TypeAException
        关闭非接模块,使该模块处于下电状态。
        Turn off the contactless module and make the module in the power-off state.
        Throws:
        TypeAException - TypeAException
      • m1Auth

        void m1Auth(EM1KeyType type,
                    byte blkNo,
                    byte[] pwd,
                    byte[] serialNo)
             throws TypeAException
        验证访问M1卡时读写相应块需要提交的 A 密码或 B 密码。
        Verify the A password or B password that needs to be submitted when reading and writing the corresponding block when accessing the M1 card.
        Parameters:
        type - EM1KeyType
        blkNo -
        指定访问的块号。
        Specify the block number to be accessed.
        pwd -
        提交的密码。
        Password submitted.
        serialNo -
        卡片序列号。由PiccCardInfo.getSerialInfo()} 获取。
        Card serial number. Obtained by PiccCardInfo.getSerialInfo()}.
        Throws:
        TypeAException - TypeAException
      • m1Read

        byte[] m1Read(byte blkNo)
               throws TypeAException
        读取M1卡指定块的内容。共16字节。
        Read the contents of the specified block of the M1 card. A total of 16 bytes..
        Parameters:
        blkNo -
        指定访问的块号。
        Specify the block number to be accessed.
        Returns:
        块内数据。16字节。
        Data in the block. 16 bytes.
        Throws:
        TypeAException - TypeAException
      • m1Write

        void m1Write(byte blkNo,
                     byte[] blkValue)
              throws TypeAException
        向M1卡指定块写入指定的内容。共16字节。
        Write the specified content to the specified block of the M1 card. A total of 16 bytes.
        Parameters:
        blkNo -
        指定访问的块号。
        Specify the block number to be accessed.
        blkValue -
        要写入块中的数据。16字节。
        The data to be written in the block. 16 bytes.
        Throws:
        TypeAException - TypeAException
      • m1Operate

        void m1Operate(EM1OperateType type,
                       byte blkNo,
                       byte[] blkValue,
                       byte updateBlkNo)
                throws TypeAException
        对 M1 卡的指定数据块 blkNo 进行充/减值/备份操作,将操作后的值更新到另一个指定的数据块 updateBlkNo。
        Parameters:
        type - EM1OperateType
        blkNo -
        指定访问的块号。
        Specify the block number to be accessed.
        blkValue -
        待充值或减值的金额数。共4字节。M1卡通常都有两个钱包:主钱包和备用钱包。 为了在对主钱包进行操作时,可以从出现的异常错误中恢复, 主钱包的操作结果通常会写入备用钱包。
        The amount of money to be recharged or devalued. A total of 4 bytes. M1 cards usually have two wallets: the main wallet and the backup wallet. In order to recover from abnormal errors when operating on the main wallet, the operation result of the main wallet is usually written into the backup wallet.
        updateBlkNo -
        指定操作结果最终写入到的块号。
        Specify the block number to which the operation result is finally written.
        Throws:
        TypeAException - TypeAException
      • setLed

        void setLed(byte led,
                    byte mode)
             throws TypeAException
        控制射频卡指示灯点亮或熄灭。
        Control the radio frequency card indicator to turn on or off.
        Parameters:
        led -
        • bit0: 红灯。
        • bit1: 绿灯。
        • bit2: 黄灯
        • bit3: 蓝灯。
        • bit4-7: 保留。
        • bit0: Red.
        • bit1: Green.
        • bit2: Yellow.
        • bit3: Blue.
        • bit4-7: Reserve.
        mode -
        • 0x00:熄灭。
        • 0x01:点亮。
        • 0x00:Turn off.
        • 0x01:Turn on.
        Throws:
        TypeAException - TypeAException
      • initFelica

        void initFelica(byte rate,
                        byte pol)
                 throws TypeAException
        初始化 Felica 卡片。
        Initialize the Felica card.
        Parameters:
        rate -
        与卡片交互的传输速率。
        • 0x00: 212Kbps。
        • 0x01: 424Kbps。
        The transfer rate of interaction with the card.
        • 0x00: 212Kbps.
        • 0x01: 424Kbps.
        pol -
        FeliCa卡调制方式。
        • 0x00: 正向调制输出。
        • 0x01: 反向调制输出。
        FeliCa card modulation method.
        • 0x00: Forward modulation output.
        • 0x01: Reverse modulation output.
        Throws:
        TypeAException - TypeAException
      • cmdExchange

        byte[] cmdExchange(byte[] dataIn)
                    throws TypeAException
        与卡片进行APDU数据交互。将数据直接发送给卡片,并接收卡片的应答数据。
        APDU data exchange with the card. Send the data directly to the card and receive the response data from the card.
        Parameters:
        dataIn -
        待发送的命令数据。
        The command data to be sent.
        Returns:
        接收到的卡片数据。
        The received card data.
        Throws:
        TypeAException - TypeAException
      • changeBaudRate

        void changeBaudRate(byte bps)
                     throws TypeAException
        更改外置密码键盘通信波特率。
        Change the external PINPAD communication Baud rate.
        Parameters:
        bps -
        波特率。
        • 0x00: 9600,8,E,1
        • 0x01: 115200,8,N,1
        Baud rate.
        • 0x00: 9600,8,E,1
        • 0x01: 115200,8,N,1
        Throws:
        TypeAException - TypeAException
      • showQRCode

        void showQRCode(byte[] content,
                        short sizeLevel,
                        byte type,
                        byte correctionLevel,
                        short x,
                        short y)
                 throws TypeAException
        创建并显示二维码。
        Create and show a QR code.
        Parameters:
        content -
        二维码内容。最大不超过255字节。
        QR code content. The maximum is not more than 255 bytes.
        sizeLevel -
        最小可是别的模块大小。取值(2, 4, 8)。
        The smallest but other module size. Take the value (2, 4, 8).
        type -
        二维码类型。0x00: QR; 0x01: GM。
        QR code type. 0x00: QR; 0x01: GM.
        correctionLevel -
        纠错能力级别。取值0~4。当type为0x00时有效。
        The level of error correction capability. The value ranges from 0 to 4. It is valid when type is 0x00.
        x -
        横坐标。
        The abscissa.
        y -
        纵坐标。
        The ordinate.
        Throws:
        TypeAException - TypeAException
      • getRecvTimeout

        int getRecvTimeout()
        获取接收超时时间,默认20000ms。
        get receive timeout, default is 20000ms
        Returns:
        接收超时,单位ms
        receive timeout, in ms
      • setRecvTimeout

        void setRecvTimeout(int timeoutMs)
        设置接收超时时间 ,默认20000ms。
        set receive timeout, default is 20000ms
        Parameters:
        timeoutMs -
        接收超时,单位ms
        receive timeout, in ms