001/*
002 * ===========================================================================================
003 * = COPYRIGHT
004 *          PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION
005 *   This software is supplied under the terms of a license agreement or nondisclosure
006 *   agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or
007 *   disclosed except in accordance with the terms in that agreement.
008 *     Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved.
009 * Description: // Detail description about the function of this module,
010 *             // interfaces with the other modules, and dependencies.
011 * Revision History:
012 * Date                         Author                        Action
013 * 2017/04/01                   PAX                     Create/Add/Modify/Delete
014 * ===========================================================================================
015 */
016package com.pax.dal;
017
018import com.pax.dal.entity.ApduRespInfo;
019import com.pax.dal.entity.ApduSendInfo;
020import com.pax.dal.entity.DUKPTResult;
021import com.pax.dal.entity.EBeepMode;
022import com.pax.dal.entity.EKeyCode;
023import com.pax.dal.entity.EM1KeyType;
024import com.pax.dal.entity.EM1OperateType;
025import com.pax.dal.entity.PiccCardInfo;
026import com.pax.dal.entity.PiccPara;
027import com.pax.dal.entity.SM2KeyPair;
028import com.pax.dal.entity.UartParam;
029import com.pax.dal.exceptions.TypeAException;
030
031/**
032 * <div class="zh">TypeA。</div> <div class="en">TypeA.</div>
033 */
034public interface ITypeA {
035    /**
036     * <div class="zh">设置默认通信配置。</div> <div class="en">Set the default UartParam.</div>
037     *
038     * @param uartParam {@link UartParam}
039     * @throws TypeAException TypeAException
040     */
041    void setUartParam(UartParam uartParam) throws TypeAException;
042
043    /**
044     * <div class="zh">设置通信IComm。</div> <div class="en">Set the IComm.</div>
045     *
046     * @param comm {@link IComm}
047     * @throws TypeAException TypeAException
048     */
049    void setComm(IComm comm) throws TypeAException;
050
051    /**
052     * <div class="zh">连接。</div> <div class="en">Connect.</div>
053     *
054     * @throws TypeAException TypeAException
055     */
056    void connect() throws TypeAException;
057
058    /**
059     * <div class="zh">断开连接。</div> <div class="en">Disconnect.</div>
060     *
061     * @throws TypeAException TypeAException
062     */
063    void disconnect() throws TypeAException;
064
065
066    /**
067     * <div class="zh">控制密码键盘的硬件状态。</div> <div class="en">Control the hardware status of the password keyboard.</div>
068     * @param item <div class="zh">
069     *             <ul>
070     *              <li>D0:0-按键无声 1-按键发声</li>
071     *              <li>D1:0-关闭语音提示 1-打开语音提示</li>
072     *              <li>D2:0-按键无声 1-按键立即发声</li>
073     *              <li>D3:红灯</li>
074     *              <li>D4:黄灯</li>
075     *              <li>D5:绿灯</li>
076     *              <li>D6:1-PINPAD 将发出“嘀”的一声</li>
077     *              <li>D7:0-关闭 LCD 背光 1-打开 LCD 背光</li>
078     *             </ul>
079     *             D0 与 D2 的区别:D0 设置为 1 后只有输入 PIN 时按键才发声,D2 设置后无论何时按键都发声</div>
080     *             <div class="en">
081     *             <ul></li>
082     *              <li> D0: 0-key is silent 1-key is sounded</li>
083     *              <li>D1: 0-Turn off the voice prompt 1-Turn on the voice prompt</li>
084     *              <li>D2: 0-key is silent 1-key is sounded immediately</li>
085     *              <li>D3: Red light</li>
086     *              <li>D4: Yellow light</li>
087     *              <li>D5: Green light</li>
088     *              <li>D6: 1-PINPAD will make a beep</li>
089     *              <li>D7: 0-Turn off LCD backlight 1-Turn on LCD backlight</li>
090     *             </ul>
091     *             The difference between D0 and D2: After D0 is set to 1, the key will sound only when the PIN is input,
092     *             and whenever D2 is set, the key will sound whenever the key is pressed</div>
093     * @param value <div class="zh">D0-D7:1-设置数据有效,0-设置数据无效</div>
094     *              <div class="zh">D0-D7: 1-Set the data to be valid, 0-Set the data to be invalid</div>
095     *
096     * @throws TypeAException TypeAException
097     */
098    void setup(byte item, byte value) throws TypeAException;
099
100    /**
101     * <div class="zh">读取密码键盘版本号。</div> <div class="en">Read the password keyboard version number.</div>
102     *
103     * @return <div class="zh">版本号,格式为“HvXXSvXX”。Hv代表硬件版本、XX为版本号,Sv 代表软件版本、XX 为版本号。</div>
104     *         <div class="en">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.</div>
105     * @throws TypeAException TypeAException
106     */
107    String getVersion() throws TypeAException;
108
109    /**
110     * <div class="zh">设置及测试密码键盘。</div> <div class="en">Set up and test the password keyboard.</div>
111     *
112     * @param item <div class="zh">
113     *             <ul><li>0x31:设置按键时蜂鸣器是否发声</li>
114     *              <li>0x32:设置 LCD 背光或 LED 指示灯</li>
115     *              <li>0x33:设置等待输入按键时的超时时间。</li>
116     *              <li>0x3e:解锁</li>
117     *              <li>0x3f:测试 PINPAD 内存。</li></ul></div>
118     *             <div class="en">
119     *              <ul><li>0x31: Set whether the buzzer sounds when the key is pressed</li>
120     *              <li>0x32: Set LCD backlight or LED indicator</li>
121     *              <li>0x33: Set the timeout time when waiting for the key input.</li>
122     *              <li>0x3e: Unlock</li>
123     *              <li>0x3f: Test PINPAD memory.</li>
124     *             </li></ul></div>
125     * @param value <div class="zh">
126     *              <ul><li>item=0x31 时,value=0 时,禁止蜂鸣器发声;value=1 时,可以发声。</li>
127     *               <li>item=0x32 时,value=0 时,背光或 LED 指示灯熄;value=1 时,亮。</li>
128     *               <li>item=0x33 时,value 为等待输入按键时的超时时间(秒)的 1/10。</li>
129     *               <li>item=0x3e 时,value=0x3e 时,解锁。</li>
130     *               <li>item=0x3f 时,内存测试。</li></ul></div>
131     *              <div class="zh">
132     *              <ul><li>When item=0x31, when value=0, the buzzer is forbidden to sound; when value=1, it can sound.</li>
133     *               <li>When item=0x32, when value=0, the backlight or LED indicator is off; when value=1, it is on.</li>
134     *               <li>When item=0x33, the value is 1/10 of the timeout time (seconds) while waiting for the key input.</li>
135     *               <li>When item=0x3e, value=0x3e, unlock.</li>
136     *               <li>When item=0x3f, memory test.</li></ul></div>
137     * @throws TypeAException TypeAException
138     */
139    void setupAndTest(byte item, byte value) throws TypeAException;
140
141    /**
142     * <div class="zh">读取序列号。</div> <div class="en">Read serial number.</div>
143     *
144     * @return <div class="zh">序列号。SN为10位数字的字符串</div> <div class="en">Serial number.SN is a string of 10 digits</div>
145     * @throws TypeAException TypeAException
146     */
147    String getSN() throws TypeAException;
148
149    /**
150     * <div class="zh">蜂鸣器按参数指定的频率和持续时间发声。</div> <div class="en">The buzzer sounds according to the frequency and duration specified by the parameters.</div>
151     *
152     * @param mode {@link EBeepMode}
153     * @param timeMs <div class="zh">持续时间,单位毫秒</div> <div class="en">Duration in milliseconds</div>
154     * @throws TypeAException TypeAException
155     */
156    void beep(EBeepMode mode, int timeMs) throws TypeAException;
157    /**
158     * <div class="zh">4个LED灯的点亮和熄灭状态。。</div> <div class="en">The on and off status of 4 LED lights.</div>
159     *
160     * @param ledIndex <div class="en"><ul>
161     *                   <li>BIT0:红灯 </li>
162     *                   <li>BIT1:绿灯 </li>
163     *                   <li>BIT2:黄灯 </li>
164     *                   <li>BIT3:蓝灯</li>
165     *                   <li>BIT4-BIT7:保留</li>
166     *                 </ul></div>
167     *                 <div class="en"><ul>
168     *                   <li>BIT0:red </li>
169     *                   <li>BIT1:green </li>
170     *                   <li>BIT2:yellow </li>
171     *                   <li>BIT3:blue</li>
172     *                   <li>BIT4-BIT7:reserved</li>
173     *                 </ul></div>
174     * @param control <div class="zh">
175     *                <ul>
176     *                 <li>0:熄灭</li>
177     *                 <li>非 0: 点亮</li></ul></div>
178     *                <div class="en">
179     *                <ul>
180     *                 <li>0: off</li>
181     *                 <li>Non-zero: light up</li></ul></div>
182     * @throws TypeAException TypeAException
183     */
184    void ledControl(byte ledIndex, byte control) throws TypeAException;
185    /**
186     * <div class="zh">获取密码键盘系统信息。</div> <div class="en">Get password keyboard system information.</div>
187     *
188     * @param item <div class="zh">
189     *             <ul>
190     *               <li>0x01:终端名称</li>
191     *               <li>0x02:终端配置信息</li>
192     *               <li>0x03:序列号</li>
193     *               <li>0x04:扩展序列号</li>
194     *               <li>0x05:主板号</li>
195     *               <li>0x06:扩展板号</li>
196     *               <li>0x07:协议类型</li>
197     *               <li>0x08:Boot 版本号</li>
198     *               <li>0x09:Monitor 版本号</li>
199     *               <li>0x0A:通讯方式</li>
200     *               <li>0x0B:射频模块配置, “N”或“Y + 射频参数”</li>
201     *               <li>0x0C:是否支持 NFC 功能</li>
202     *               <li>0x0D:硬件国密配置信息,‘N’或‘Y+国密固件版本信息 xx.xx.xx’</li>
203     *               <li>0x0E:识别支持语音芯片的型号</li></ul>
204     *             对于终端配置信息项(0x02),返回格式是:PN:PN 号:配置文件:配置文件版本。例如:
205     *             PN : SP20-121-9C0 : CONFIG_FILE_VER : V1.0,即每项之间用冒号隔开。并不是所有机型都能获取到有效的配置信息,
206     *             比如对于不使用配置文件的机型,由于无法获取相关信息,所以它的返回为 NULL: NULL: NULL: NULL。<br/>
207     *             对于射频模块配置项(0x0B),在有配置文件的机型中,如果存在射频模块,则只返回 “Y”,射频参数需通过终端配置信息(0x02)所指明的配置文件来获取。</div>
208     *             <div class="en">
209     *             <ul>
210     *               <li>0x01: terminal name</li>
211     *               <li>0x02: terminal configuration information</li>
212     *               <li>0x03: serial number</li>
213     *               <li>0x04: extended serial number</li>
214     *               <li>0x05: Motherboard number</li>
215     *               <li>0x06: extension board number</li>
216     *               <li>0x07: Protocol type</li>
217     *               <li>0x08: Boot version number</li>
218     *               <li>0x09: Monitor version number</li>
219     *               <li>0x0A: Communication method</li>
220     *               <li>0x0B: RF module configuration, "N" or "Y + RF parameters"</li>
221     *               <li>0x0C: Whether to support NFC function</li>
222     *               <li>0x0D: hardware national secret configuration information, ‘N’ or ‘Y+ national secret firmware version information xx.xx.xx’</li>
223     *               <li>0x0E: Identify the model that supports the voice chip</li></ul>
224     *             For the terminal configuration information item (0x02), the return format is: PN: PN number: configuration file: configuration file version.
225     *             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
226     *             information. For example, for models that do not use configuration files, since the relevant information cannot be obtained, it returns NULL: NULL: NULL: NULL.<br/>
227     *             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
228     *             parameters need to be obtained through the configuration file specified in the terminal configuration information (0x02).</div>
229     *
230     * @return <div class="zh">系统信息
231     *          <br>返回信息长度:
232     *          <br>0x00:发送数据错误(比如信息类别错误),命令没有返回数据;
233     *          <br>其它:密码键盘返回的有效数据长度。</div>
234     *         <div class="en">system message
235     *          <br>Return message length:
236     *          <br>0x00: Sending data error (for example, the information type is wrong), the command does not return data;
237     *          <br>Others: The length of the valid data returned by the password keyboard.</div>
238     * @throws TypeAException TypeAException
239     */
240    String getTerminalInfo(byte item) throws TypeAException;
241    /**
242     * <div class="zh">向密码键盘写入扩展序列号。</div> <div class="en">Write the extended serial number to the password keyboard.</div>
243     *
244     * @param extSN <div class="zh">扩展序列号。长度小于31个字符,合法范围ASCII 0x21-0x7E。</div>
245     *              <div class="en">Extended serial number. The length is less than 31 characters, and the legal range is ASCII 0x21-0x7E.</div>
246     * @throws TypeAException TypeAException
247     */
248    void setExtSN(String extSN) throws TypeAException;
249    /**
250     * <div class="zh">测试键盘按键。
251     *                  <br/>测试时必须按屏幕指定的按键次序进行按键测试;
252     *                  <br/>命令执行后,且未完成测试前,如果超过 120 秒未按键,将超时退出。</div>
253     * <div class="en">Test keyboard keys.
254     *                  <br/>During the test, you must perform the keystroke test according to the key sequence specified on the screen;
255     *                  <br/>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.</div>
256     *
257     * @return <div class="zh">0x00: 所有按键均通过测试。
258     *                     <br>其它: 未通过测试。该非 0 值表示未按指定次序完成测试的按键数</div>
259     *         <div class="en">0x00: All keys have passed the test.
260     *                     <br>Other: Failed the test. The non-zero value indicates the number of keystrokes that did not complete the test in the specified order</div>
261     * @throws TypeAException TypeAException
262     */
263    byte testKeyboard() throws TypeAException;
264    /**
265     * <div class="zh">恢复出厂设置。(蜂鸣器响一声,且键盘恢复出厂设置:输入 PIN 时按键发声,波特率 9600,8,E,1,按键时屏幕有背光。)</div>
266     * <div class="en">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.)</div>
267     *
268     * @throws TypeAException TypeAException
269     */
270    void recovery() throws TypeAException;
271    /**
272     * <div class="zh">清除密码键盘 LCD 屏幕上所有的显示内容。</div> <div class="en">Clear all the contents displayed on the LCD screen of the password keyboard.</div>
273     *
274     * @throws TypeAException TypeAException
275     */
276    void clearScreen() throws TypeAException;
277    /**
278     * <div class="zh">清除指定显示行。</div> <div class="en">Clear the specified display line.</div>
279     *
280     * @param lineNo <div class="zh">LCD 显示行号。每行均为 16 点高的行,0—第一行,1--第二行。</div>
281     *               <div class="en">Line number displayed on LCD. Each row is a 16-point high row, 0—the first row, and 1—the second row.</div>
282     * @throws TypeAException TypeAException
283     */
284    void clearScreenByLine(byte lineNo) throws TypeAException;
285    /**
286     * <div class="zh">显示英文字符。在指定位置显示 16x8 点阵的英文和字符,一行最多可以显示 15 个字符。在显示时,如果显示字符小于 15 但当前行显示不完(列号非 0),则把多余的数据切掉,返回码为 OK。</div>
287     * <div class="en">Display English characters. Display 16x8 dot matrix English and characters at the specified position, up to 15 characters can be displayed on a line.
288     *                 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
289     *                 data will be cut off, and the return code will be OK.</div>
290     *
291     * @param x <div class="zh">显示字符在 LCD 上的起始点阵列号(单位:点),0≤x≤114;</div>
292     *          <div class="en">Display the starting point array number of the character on the LCD (unit: point), 0≤x≤114;</div>
293     *
294     * @param y <div class="zh">显示字符在 LCD 上的行号(单位:行)。每行均为 16 点高的行,0—第一行,1--第二行。</div>
295     *          <div class="en">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.</div>
296     *
297     * @param chars <div class="zh">字符。</div>
298     *              <div class="en">Character.</div>
299     *
300     * @throws TypeAException TypeAException
301     */
302    void showChar(byte x, byte y, byte[] chars) throws TypeAException;
303    /**
304     * <div class="zh">显示点阵。在指定 LCD 指定位置显示点阵。LCD 液晶显示共有两行,每一行分为上、下半行。在送点阵数据时,数据格式应该是:
305     *                 上半行数据(长度为 n)+下半行数据(长度为 n)=点阵数据(长度为 2n)
306     *                 显示数据的第 1 个字节对应 LCD 显示指定位置上半行的第 1 列,第 2 个字节对应上半行的第 2 列,……
307     *                 第 n+1 个字节对应 LCD 显示指定位置下半行的第 1 列,n+2 对应下半行的第 2 列,……
308     *                 点阵数据长度应小于等于 244。
309     *                 在显示时,如果显示点阵数据长度<=244 但当前行显示不完(列号非 0),则把多余的数据切掉,返回码
310     *                 为 OK。</div>
311     * <div class="en">Display dot matrix. Display the dot matrix at the specified position on the specified LCD.
312     *                 The LCD liquid crystal display has two lines, and each line is divided into upper and lower half lines.
313     *                 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).
314     *                 The first byte of the display data corresponds to LCD Display the first column of the upper half row of the specified position,
315     *                 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,
316     *                 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,
317     *                 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.</div>
318     *
319     * @param x <div class="zh">显示点阵在 LCD 上的起始点阵列号(单位:点),0≤x<122;</div>
320     *          <div class="en">Display the starting point array number of the dot matrix on the LCD (unit: dot), 0≤x<122;</div>
321     *
322     * @param y <div class="zh">显示点阵在 LCD 上的行号(单位:行)。每行均为 16 点高的行,0—第一行,1--第二行。</div>
323     *          <div class="en">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.</div>
324     *
325     * @param data <div class="zh">点阵数据。</div>
326     *             <div class="en">Dot matrix data.</div>
327     *
328     * @throws TypeAException TypeAException
329     */
330    void showDotMatrix(byte x, byte y, byte[] data) throws TypeAException;
331    /**
332     * <div class="zh">显示菜单或金额。
333     * <br>显示一段内容并等待输入,并返回该值(ASCII 码)。
334     * <br>当显示金额时,开始序号=0x3d(取消);结束序号=0x3e(确认)。可以按 POS 上(取消)退出。
335     * </div> <div class="en">Display menu or amount.
336     * <br>Display a piece of content and wait for input, and return the value (ASCII code).
337     * <br>When the amount is displayed, the start serial number=0x3d (cancel); the end serial number=0x3e (confirm). You can press POS (Cancel) to exit.</div>
338     *
339     * @param startNumber <div class="zh">显示内容的开始序号;</div>
340     *                    <div class="en">The starting sequence number of the displayed content;</div>
341     *
342     * @param endNumber <div class="zh">显示内容的结束序号;</div>
343     *                  <div class="en">The ending sequence number of the displayed content;</div>
344     *
345     * @param countLines <div class="zh">显示内容的总行数;</div>
346     *                   <div class="en">The total number of lines of the displayed content;</div>
347     *
348     * @param data <div class="zh">为[行数][16BYTE]的数组。多页显示时用 F2,F3 翻页。</div>
349     *             <div class="en">It is an array of [number of rows] [16BYTE]. When multiple pages are displayed, use F2 and F3 to turn pages.</div>
350     *
351     * @return <div class="zh">返回的序号,在开始序号、结束序号之间</div>
352     *         <div class="en">The returned sequence number, between the start sequence number and the end sequence number</div>
353     * @throws TypeAException TypeAException
354     */
355    byte showMenuOrAmount(byte startNumber, byte endNumber, byte countLines, byte[] data) throws TypeAException;
356    /**
357     * <div class="zh">更换 LCD 显示缺省位图。
358     * <br>下载 LCD 显示位图,替代 LCD 缺省显示位图。
359     * <br>缺省的显示位图为如下两行字符:
360     * <br>WELCOME!
361     * <br>PAX TECHNOLOGY
362     * </div> <div class="en">Replace the LCD display default bitmap.
363     * <br>Download the LCD display bitmap to replace the LCD default display bitmap.
364     * <br>The default display bitmap is the following two lines of characters:
365     * <br>>WELCOME!
366     * <br>PAX TECHNOLOGY</div>
367     *
368     * @param mode <div class="zh">
369     *             <ul><li>mode = 1 替换位图 1(0 行显示的位图)</li>
370     *              <li>mode = 2 替换位图 2(1 行显示的位图)</li>
371     *              <li>mode = 0 恢复厂家缺省 LOG 图</li></ul></div>
372     *             <div class="en">
373     *             <ul><li>mode = 1 Replace bitmap 1 (the bitmap displayed on line 0)</li>
374     *              <li>mode = 2 Replace bitmap 2 (bitmap displayed in 1 row)</li>
375     *              <li>mode = 0 Restore to factory default LOG chart</li></ul></div>
376     *
377     * @param data <div class="zh">位图数据的格式和显示点阵数据的格式一样。
378     * 上半行数据(n=122)+下半行数据(n=122)= 位图点阵数据(244)</div>
379     *             <div class="en">The format of bitmap data is the same as the format of displaying dot matrix data.
380     * Top half line data (n=122) + bottom half line data (n=122) = bitmap dot matrix data (244)</div>
381     *
382     * @throws TypeAException TypeAException
383     */
384    void setLCDBitmap(byte mode, byte[] data) throws TypeAException;
385    /**
386     * <div class="zh">密码键盘输入字符串。
387     * <br>将按键值以明码或者“*”的形式在 LCD 第二行的右下角显示出来,经过“确认”后,密码键盘将按键值全部返回给 POS 机。
388     * <br>密码键盘在收到该命令后,大陆版和越南版不在首行显示任何信息,如:“PLS INPUT PIN:”。香港版在首行显示任何信息,如:“PLS INPUT PIN:”。</div>
389     * <div class="en">Password keyboard input character string.
390     * <br>The key value is displayed in the lower right corner of the second line of the LCD in the form of clear code or "*".
391     * After "confirmation", the password keyboard will return all the key values to the POS machine.
392     * <br>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:".
393     * The Hong Kong version displays any information on the first line, such as: "PLS INPUT PIN:".</div>
394     *
395     * @param min <div class="zh">字符串最小长度(为 0 时,按 ENTER 键返回,且输入长度 Len=0)</div>
396     *            <div class="en">The minimum length of the string (when it is 0, press ENTER to return, and enter the length Len=0)</div>
397     *
398     * @param max <div class="zh">字符串最大长度(小于等于 40 字节)</div>
399     *            <div class="en">Maximum string length (less than or equal to 40 bytes)</div>
400     *
401     * @param mode <div class="zh">0x00 显示明码;0x01 显示“*”号。</div>
402     *             <div class="en">0x00 displays plain code; 0x01 displays "*" sign.</div>
403     *
404     * @return <div class="zh">输入的字符串</div>
405     *         <div class="en">Input string</div>
406     * @throws TypeAException TypeAException
407     */
408    String getInputString(byte min, byte max, byte mode) throws TypeAException;
409    /**
410     * <div class="zh">输入金额。
411     * <br>等待输入金额,小数点自动增加在固定位置,经过“确认”后,密码键盘将所显示的值返回给 POS 机。</div>
412     * <div class="en">Enter the amount.
413     * <br>Waiting for the amount to be entered, the decimal point is automatically added to the fixed position,
414     * after "confirmation", the password keyboard will return the displayed value to the POS machine.</div>
415     *
416     * @param min <div class="zh">字符串最小长度(为 0 时,按 ENTER 键返回,且输入长度 Len=0)</div>
417     *            <div class="en">The minimum length of the string (when it is 0, press ENTER to return, and enter the length Len=0)</div>
418     *
419     * @param max <div class="zh">字符串最大长度(小于等于 16 字节)</div>
420     *            <div class="en">Maximum string length (less than or equal to 16 bytes)</div>
421     *
422     * @param pointMode <div class="zh">小数点方式,
423     *                  <ul><li>0X00:小数点后有两位小数;</li>
424     *                   <li>0X01:小数点后有三位小数;</li>
425     *                   <li>0X02:无小数点(整数);</li>
426     *                   <li>0X03:小数点后有一位小数;</li></ul></div>
427     *                  <div class="en">Decimal point method,
428     *                  <ul><li>0X00: There are two decimal places after the decimal point;</li>
429     *                   <li>0X01: There are three decimal places after the decimal point;</li>
430     *                   <li>0X02: No decimal point (integer);</li>
431     *                   <li>0X03: There is one decimal place after the decimal point;</li></ul></div>
432     *
433     * @param prompMode <div class="zh">无意义</div>
434     *                  <div class="en">Meaningless</div>
435     *
436     * @return <div class="zh">输入的金额字符串</div>
437     *         <div class="en">Entered amount string</div>
438     * @throws TypeAException TypeAException
439     */
440    String getInputAmount(byte min, byte max, byte pointMode, byte prompMode) throws TypeAException;
441    /**
442     * <div class="zh">密码键盘输入字符串[密文交互]
443     * <br>将按键值以明码或者“*”的形式在 LCD 第二行的右下角显示出来,经过“确认”后,密码键盘将按键值全部 返回给 POS 机。
444     * <br>大陆版和越南版本密码键盘在收到该命令后,不在首行显示任何信息,如:“PLS INPUT PIN:”。密码键盘回应的数据包中的DATA域由TXK加密。</div>
445     * <div class="en">Password keyboard input string [ciphertext interaction]
446     * <br>The key value is displayed in the lower right corner of the second line of the LCD in the form of clear code or "*".
447     * After "confirmation", the password keyboard will return all the key values to the POS machine.
448     * <br>After receiving this command, the mainland version and Vietnam version of the password keyboard will not display any information on the first line,
449     * such as: "PLS INPUT PIN:". The DATA field in the data packet responded by the password keyboard is encrypted by TXK.</div>
450     *
451     * @param min <div class="zh">字符串最小长度(为 0 时,按 ENTER 键返回,且输入长度 Len=0)</div>
452     *            <div class="en">The minimum length of the string (when it is 0, press ENTER to return, and enter the length Len=0)</div>
453     *
454     * @param max <div class="zh">字符串最大长度(小于等于 40 字节)</div>
455     *            <div class="en">Maximum string length (less than or equal to 40 bytes)</div>
456     *
457     * @param mode <div class="zh">0x00: 显示明码;
458     *                            <br>0x01: 显示“*”号。</div>
459     *             <div class="en">0x00: Display plain code;
460     *                            <br>0x01: Display "*" sign.</div>
461     *
462     * @return  <div class="zh">输入的字符串</div>
463     *          <div class=“en">Input string</div>
464     * @throws TypeAException TypeAException
465     */
466    String getInputCipherString(byte min, byte max, byte mode) throws TypeAException;
467    /**
468     * <div class="zh">按键缓冲区。
469     * <br>1.设置为清空按键缓冲区,则用户输入密码前会对按键缓冲区做一次清空(默认) 。
470     * <br>2.设置为不清空按键缓冲区,则发送该命令后的按键缓冲不做清除,发送该命令前的按键缓冲区会做 一次清除。</div>
471     * <div class="en">Key buffer.
472     * <br>1. Set to clear the key buffer, then the key buffer will be cleared once before the user enters the password (default).
473     * <br>2. If it is set to not clear the key buffer, the key buffer after sending this command will not be cleared,
474     *        and the key buffer before sending this command will be cleared once.</div>
475     *
476     * @param mode <div class="zh">0:不清空按键缓冲区
477     *                           <br>1:清空按键缓冲区</div>
478     *             <div class="en">0: Do not clear the key buffer
479     *                            <br> 1: Clear the key buffer</div>
480     * @throws TypeAException TypeAException
481     */
482    void clearKeyBuffer(byte mode) throws TypeAException;
483    /**
484     * <div class="zh">获取当前按键缓冲区(非 PIN 输入状态下)的按键值。</div>
485     * <div class="en">Get the key value of the current key buffer (in non-PIN input state).</div>
486     *
487     * @return {@link EKeyCode}
488     * @throws TypeAException TypeAException
489     */
490    EKeyCode getKey() throws TypeAException;
491    /**
492     * <div class="zh">传送主密钥或 DES 密钥。
493     * <br>按照 mode 方式将 Key 存储在主密钥区或 DES 密钥区的指定(KeyID)位置。</div>
494     * <div class="en">Transfer the master key or DES key.
495     * <br>Store the Key in the designated (KeyID) location of the master key area or DES key area according to mode.</div>
496     *
497     * @param keyIndex <div class="zh">最高位[bit7]来区分主密钥和 DES 密钥的索引,为 0 表示为主密钥索引,为 1 表示 DES 密钥索引。(使用时DES密钥索引最高位[bit7]为0)
498     *                  <br>KeyID=0xxxxxxxb 主密钥区的密钥索引
499     *                  <br>KeyID=1xxxxxxxb DES 密钥区的索引</div>
500     *                 <div class="en">The most significant bit [bit7] distinguishes the index of the master key and the DES key, 0 means the master key index,
501     *                 and 1 means the DES key index.(The highest bit of the DES key index [bit7] is 0 when in use)
502     *                  <br>KeyID=0xxxxxxxb The key index of the master key zone
503     *                  <br>KeyID=1xxxxxxxb DES key area index</div>
504     *
505     * @param mode <div class="zh">
506     *             <ul><li>mode=0x01 单 DES 密钥, len=10;</li>
507     *              <li>mode=0x03 3 倍 DES 密钥, len=18;</li>
508     *              <li>mode=0x07 3 倍 DES 密钥, len=26;</li></ul></div>
509     *             <div class="en">
510     *              <ul><li>mode=0x01 single DES key, len=10;</li>
511     *               <li>mode=0x03 3 times the DES key, len=18;</li>
512     *               <li>mode=0x07 3 times the DES key, len=26;</li></ul></div>
513     *
514     * @param plainKeyValue <div class="zh">密钥值(8 字节或 16 字节或者 24 字节)。</div>
515     *                      <div class="en">Key value (8 bytes or 16 bytes or 24 bytes).</div>
516     * @throws TypeAException TypeAException
517     */
518    void writePlainKey(byte keyIndex, byte mode, byte[] plainKeyValue) throws TypeAException;
519    /**
520     * <div class="zh">密文传送主密钥或 DES 密钥。
521     * <br>将 Key 存储在主密钥区或 DES 密钥区的指定(KeyID)位置。DATA 由 TXK 加密。</div>
522     * <div class="en">The master key or DES key is transmitted in cipher text.
523     * <br>Store the Key in the designated (KeyID) location of the master key area or DES key area. DATA is encrypted by TXK.</div>
524     *
525     * @param cipherKeyValue <div class="zh">由 TXK 加密。
526     *                       <table border="1">
527     *                   <tr>
528     *                    <th>偏移位置</th>
529     *                    <th>长度(byte)</th>
530     *                    <th>变量名称</th>
531     *                    <th>意义</th>
532     *                   </tr>
533     *                   <tr>
534     *                       <td>0x0000</td>
535     *                       <td>1</td>
536     *                       <td>keyIndex</td>
537     *                       <td>1-100
538     *                           <br>KeyID=0xxxxxxxb 主密钥区的密钥索引
539     *                           <br>KeyID=1xxxxxxxb DES 密钥区的索引</td>
540     *                   </tr>
541     *                   <tr>
542     *                       <td>0x0001</td>
543     *                       <td>1</td>
544     *                       <td>keyLen</td>
545     *                       <td>8、16 或 24,</td>
546     *                   </tr>
547     *                   <tr>
548     *                       <td>0x0002</td>
549     *                       <td>N</td>
550     *                       <td>key</td>
551     *                       <td>key</td>
552     *                   </tr>
553     *                   <tr>
554     *                       <td>0x0002+N</td>
555     *                       <td>M</td>
556     *                       <td>Fill</td>
557     *                       <td>填充字节,以上数据长度不被 8 字节整除时,填充至 8 字节整除的个数。</td>
558     *                   </tr>
559     *
560     *                      </table></div>
561     *                       <div class="en">Encrypted by TXK.
562     *                            <table border="1">
563     *                        <tr>
564     *                         <th>Offset</th>
565     *                         <th>Length (byte)</th>
566     *                         <th>Variable name</th>
567     *                         <th>Description</th>
568     *                        </tr>
569     *                        <tr>
570     *                            <td>0x0000</td>
571     *                            <td>1</td>
572     *                            <td>keyIndex</td>
573     *                            <td>1-100
574     *                                <br>KeyID=0xxxxxxxb Key index of the master key area
575     *                                <br>KeyID=1xxxxxxxb key index of DES key</td>
576     *                        </tr>
577     *                        <tr>
578     *                            <td>0x0001</td>
579     *                            <td>1</td>
580     *                            <td>keyLen</td>
581     *                            <td>8、16 or 24,</td>
582     *                        </tr>
583     *                        <tr>
584     *                            <td>0x0002</td>
585     *                            <td>N</td>
586     *                            <td>key</td>
587     *                            <td>key</td>
588     *                        </tr>
589     *                        <tr>
590     *                            <td>0x0002+N</td>
591     *                            <td>M</td>
592     *                            <td>Fill</td>
593     *                            <td>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.</td>
594     *                        </tr>
595     *
596     *                           </table></div>
597     * @throws TypeAException TypeAException
598     */
599    void writeCipherKey(byte[] cipherKeyValue) throws TypeAException;
600    /**
601     * <div class="zh">写入工作密钥。
602     * <br>通常用来写入 PIN-BLOCK 生成和 MAC 运算的密钥。用 srcKeyIndex 指定的主密钥对 keyValue 进行 mode 指定方式的加密或解密后,将结果存储在 keyIndex 指定的工作密钥区位置。如果 srcKeyIndex 为 0,则不对 keyValue 进行加密或解密,而直接将 keyValue 存储在工作密钥区的keyIndex 指定的位置。</div>
603     * <div class="en">Write the work key.
604     * <br>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.</div>
605     *
606     * @param srcKeyIndex <div class="zh">主密钥索引号,该密钥将用作生成工作密钥明文加/解密运算的密钥。</div>
607     *                    <div class="en">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.</div>
608     *
609     * @param destKeyIndex <div class="zh">工作密钥索引号,传入的密钥值密文经过 mode 指定的运算后,生成明文,该明文将写入该索引号对应的密钥位置。当 srcKeyIndex 为 0 时,传入的密钥值为明文,无需运算;mode 的设置仅指示长度。</div>
610     *                     <div class="en">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.</div>
611     *
612     * @param mode <div class="zh">指示最终工作密钥明文的生成运算方式,取值共有 16 种,具体如下所示,
613     *             <ul>
614     *             <li>0x01-- DES 加密</li>
615     *             <li>0x81-- DES 解密
616     *             <br>srcdestKeyIndex 与 destKeyIndex 均为单 DES/ 8 字节密钥,Len=11。</li>
617     *             <li>0x03-- 3DES 加密</li>
618     *             <li>0x31-- 3DES 加密</li>
619     *             <li>0x83-- 3DES 解密</li>
620     *             <li>0xb1-- 3DES 解密
621     *             <br>srcdestKeyIndex 为 3DES/16 字节密钥,destKeyIndex 为单 DES/8 字节密钥,Len=11。</li>
622     *             <li>0x07-- 3DES 加密</li>
623     *             <li>0x87-- 3DES 解密
624     *             <br>srcdestKeyIndex 为 3DES/24 字节密钥,destKeyIndex 为单 DES/8 字节密钥,Len=11。</li>
625     *             <li>0x33-- 3DES 加密</li>
626     *             <li>0xb3-- 3DES 解密
627     *             <br>srcdestKeyIndex 与 destKeyIndex 均为 3DES/16 字节密钥,Len=19。</li>
628     *             <li>0x71-- 3DES 加密</li>
629     *             <li>0xf1-- 3DES 解密
630     *             <br>srcdestKeyIndex 为 3DES/24 字节密钥, destKeyIndex 为单 DES/8 字节密钥,Len=11。</li>
631     *             <li>0x73-- 3DES 加密</li>
632     *             <li>0xf3-- 3DES 解密
633     *             <br>srcdestKeyIndex 为 3DES/24 字节密钥, destKeyIndex 为 3DES-16 字节密钥,Len=19。</li>
634     *             <li>0x77-- 3DES 加密</li>
635     *             <li>0xf7-- 3DES 解密
636     *             <br>srcdestKeyIndex 与 destKeyIndex 均为 3DES/24 字节密钥,Len=27。</li>
637     *             </ul></div>
638     *             <div class="en">Indicate the calculation method for generating the final working key plaintext. There are 16 values in total, as shown below.
639     *             <ul>
640     *             <li>0x01-- DES encryption</li>
641     *             <li>0x81-- DES decrypt
642     *             <br>Both srcdestKeyIndex and destKeyIndex are single DES/8-byte keys, Len=11.</li>
643     *             <li>0x03-- 3DES encryption</li>
644     *             <li>0x31-- 3DES encryption</li>
645     *             <li>0x83-- 3DES decryption</li>
646     *             <li>0xb1-- 3DES decryption
647     *             <br>srcdestKeyIndex is a 3DES/16 byte key, destKeyIndex is a single DES/8 byte key, Len=11.</li>
648     *             <li>0x07-- 3DES encryption</li>
649     *             <li>0x87-- 3DES decryption
650     *             <br>srcdestKeyIndex is a 3DES/24-byte key, destKeyIndex is a single DES/8-byte key, Len=11.</li>
651     *             <li>0x33-- 3DES encryption</li>
652     *             <li>0xb3-- 3DES decryption
653     *             <br>Both srcdestKeyIndex and destKeyIndex are 3DES/16 byte keys, Len=19.</li>
654     *             <li>0x71-- 3DES encryption</li>
655     *             <li>0xf1-- 3DES decrypt
656     *             <br>srcdestKeyIndex is a 3DES/24-byte key, destKeyIndex is a single DES/8-byte key, Len=11.</li>
657     *             <li>0x73-- 3DES encryption</li>
658     *             <li>0xf3-- 3DES decryption
659     *             <br>srcdestKeyIndex is a 3DES/24 byte key, destKeyIndex is a 3DES-16 byte key, Len=19.</li>
660     *             <li>0x77-- 3DES encryption</li>
661     *             <li>0xf7-- 3DES decryption
662     *             <br>Both srcdestKeyIndex and destKeyIndex are 3DES/24-byte keys, Len=27.</li>
663     *             </ul></div>
664     *
665     * @param keyValue <div class="zh">需写入的密钥值(8、16 或 24 字节, 由 mode 决定)。</div>
666     *                 <div class="en">The key value to be written (8, 16 or 24 bytes, determined by mode).</div>
667     * @throws TypeAException TypeAException
668     */
669    void writeTWK(byte srcKeyIndex, byte destKeyIndex, byte mode, byte[] keyValue) throws TypeAException;
670    /**
671     * <div class="zh">发散密钥。
672     * <br>用derivedKeyIndex指定的主密钥或工作密钥对 srcKeyIndex 指定的工作密钥进行 mode 方式的加密或解密后,将 结果存储在工作密钥区的 destKeyIndex 指定的位置。</div>
673     * <div class="en">Diverge the key.
674     * <br>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.</div>
675     *
676     * @param derivedKeyIndex <div class="zh">用来对 srcKeyIndex指定的工作密钥进行 mode 方式运算的主密钥或工作密钥索引。
677     * <br>= 0xxxxxxxb 时,用主密钥来发散
678     * <br>= 1xxxxxxxb 时,用工作密钥来发散。</div>
679     *                        <div class="en">The master key or working key index used to perform mode operation on the working key specified by srcKeyIndex.
680     * <br>= 0xxxxxxxb, use the master key to diverge
681     * <br>= 1xxxxxxxb, use the working key to diverge.</div>
682     *
683     * @param srcKeyIndex <div class="zh">需进行分散的工作密钥的索引。</div>
684     *                    <div class="en">Index of the working key that needs to be diverged</div>
685     *
686     * @param destKeyIndex <div class="zh">对 srcKeyIndex分散后的结果存储在工作密钥区的索引。</div>
687     *                     <div class="en">The result of divergence of srcKeyIndex is stored in the index of the working key area.</div>
688     *
689     * @param mode <div class="zh">指示最终工作密钥明文的生成运算方式,取值共有 16 种,具体如下所示,
690     *             <ul>
691     *             <li>0x01-- DES 加密</li>
692     *             <li>0x81-- DES 解密
693     *             <br>derivedKeyIndex 与 srcKeyIndex 均为单 DES/ 8 字节密钥,Len=11。</li>
694     *             <li>0x03-- 3DES 加密</li>
695     *             <li>0x31-- 3DES 加密</li>
696     *             <li>0x83-- 3DES 解密</li>
697     *             <li>0xb1-- 3DES 解密
698     *             <br>derivedKeyIndex 为 3DES/16 字节密钥,srcKeyIndex 为单 DES/8 字节密钥,Len=11。</li>
699     *             <li>0x07-- 3DES 加密</li>
700     *             <li>0x87-- 3DES 解密
701     *             <br>derivedKeyIndex 为 3DES/24 字节密钥,srcKeyIndex 为单 DES/8 字节密钥,Len=11。</li>
702     *             <li>0x33-- 3DES 加密</li>
703     *             <li>0xb3-- 3DES 解密
704     *             <br>derivedKeyIndex 与 srcKeyIndex 均为 3DES/16 字节密钥,Len=19。</li>
705     *             <li>0x71-- 3DES 加密</li>
706     *             <li>0xf1-- 3DES 解密
707     *             <br>derivedKeyIndex 为 3DES/24 字节密钥, srcKeyIndex 为单 DES/8 字节密钥,Len=11。</li>
708     *             <li>0x73-- 3DES 加密</li>
709     *             <li>0xf3-- 3DES 解密
710     *             <br>derivedKeyIndex 为 3DES/24 字节密钥, srcKeyIndex 为 3DES-16 字节密钥,Len=19。</li>
711     *             <li>0x77-- 3DES 加密</li>
712     *             <li>0xf7-- 3DES 解密
713     *             <br>derivedKeyIndex 与 srcKeyIndex 均为 3DES/24 字节密钥,Len=27。</li>
714     *             </ul></div>
715     *             <div class="en">Indicate the calculation method for generating the final working key plaintext. There are 16 values in total, as shown below.
716     *             <ul>
717     *             <li>0x01-- DES encryption</li>
718     *             <li>0x81-- DES decrypt
719     *             <br>Both derivedKeyIndex and srcKeyIndex are single DES/8-byte keys, Len=11.</li>
720     *             <li>0x03-- 3DES encryption</li>
721     *             <li>0x31-- 3DES encryption</li>
722     *             <li>0x83-- 3DES decryption</li>
723     *             <li>0xb1-- 3DES decryption
724     *             <br>derivedKeyIndex is a 3DES/16 byte key, srcKeyIndex is a single DES/8 byte key, Len=11.</li>
725     *             <li>0x07-- 3DES encryption</li>
726     *             <li>0x87-- 3DES decryption
727     *             <br>derivedKeyIndex is a 3DES/24-byte key, srcKeyIndex is a single DES/8-byte key, Len=11.</li>
728     *             <li>0x33-- 3DES encryption</li>
729     *             <li>0xb3-- 3DES decryption
730     *             <br>Both derivedKeyIndex and srcKeyIndex are 3DES/16 byte keys, Len=19.</li>
731     *             <li>0x71-- 3DES encryption</li>
732     *             <li>0xf1-- 3DES decrypt
733     *             <br>derivedKeyIndex is a 3DES/24-byte key, srcKeyIndex is a single DES/8-byte key, Len=11.</li>
734     *             <li>0x73-- 3DES encryption</li>
735     *             <li>0xf3-- 3DES decryption
736     *             <br>derivedKeyIndex is a 3DES/24 byte key, srcKeyIndex is a 3DES-16 byte key, Len=19.</li>
737     *             <li>0x77-- 3DES encryption</li>
738     *             <li>0xf7-- 3DES decryption
739     *             <br>Both derivedKeyIndex and srcKeyIndex are 3DES/24-byte keys, Len=27.</li>
740     *             </ul></div>
741     * @throws TypeAException TypeAException
742     */
743    void derivedTWK(byte derivedKeyIndex, byte srcKeyIndex, byte destKeyIndex, byte mode) throws TypeAException;
744    /**
745     * <div class="zh">向密码键盘请求获取 TXK。
746     * <br>该命令用于上位机从 PED 获取读取传输密钥。 传输密钥 TXK 固定为 16 字节。上位机临时产生一组模长 512bit 的 RSA 公私钥对,并将公钥传给 PED, PED 产生传输密钥 TXK,并保存在安全存储器中,然后用公钥加密后,将密文发给上位机。
747     * </div> <div class="en">Request a TXK from the password keyboard.
748     * <br>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.</div>
749     *
750     * @param modulus <div class="zh">公钥模</div>
751     *                <div class="en">Public key module.</div>
752     *
753     * @param exponent <div class="zh">公钥指数,高字节在前。</div>
754     *                 <div class="en">Public key index, high byte first.</div>
755     *
756     * @return <div class="zh">TXK,PED 产生的 16 字节随机数。</div>
757     *         <div class="en">TXK, 16-byte random number generated by PED.</div>
758     * @throws TypeAException TypeAException
759     */
760    byte[] getTXK(byte[] modulus, byte[] exponent) throws TypeAException;
761    /**
762     * <div class="zh">获取 TXK 校验值。
763     * <br>该命令用于上位机检查 TXK 是否同步。
764     * <br>密码键盘产生 8 字节随机数,并用 TXK 加密,把随机数和加密后的值,发给上位机。上位机可以由自身的 TXK 进行相关验证。</div>
765     * <div class="en">Get TXK check value.
766     * <br>This command is used by the host computer to check whether the TXK is synchronized.
767     * <br>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.</div>
768     *
769     * @return <div class="zh">8字节随即数+8字节随机数密文(用TXK加密)。</div>
770     *         <div class="en">8-byte random number + 8-byte random number ciphertext (encrypted with TXK).</div>
771     * @throws TypeAException TypeAException
772     */
773    byte[] getTXKCheckValue() throws TypeAException;
774    /**
775     * <div class="zh">清空所有秘钥。</div> <div class="en">Clear all keys.</div>
776     *
777     * @throws TypeAException TypeAException
778     */
779    void eraseKey() throws TypeAException;
780    /**
781     * <div class="zh">用户输入密码。
782     * <br>触发用户输入账户密码,在输入密码并按“确认”键后,密码键盘用POS机传下来的数据(卡号或 ISN),
783     * 根据 ANSI X9.8 标准或 ANSI X3.92 标准和 WKeyID 指定的 PIN 密钥对 PIN 进行加密。在输入密码时,用户能取消操作,
784     * POS 机一端通过发送操作取消命令也可中止密码输入。大陆版和越南版本密码键盘在收到该命令后,不在首行显示任何信息,如:“PLS INPUT PIN:”。
785     * 缺省的密码输入超时为 120 秒,但可由后述的相关超时设置命令重新设定。</div>
786     * <div class="en">The user enters the password.
787     * <br>Trigger the user to enter the account password. After entering the password and pressing the "confirm" key,
788     * the password keyboard uses the data (card number or ISN) transmitted from the POS machine,
789     * 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.
790     * 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.
791     * 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:".
792     * The default password input timeout is 120 seconds, but it can be reset by the related timeout setting command described later.</div>
793     *
794     * @param isNewAccount <div class="zh">是否是新开户。
795     *                      <br>True:新开户
796     *                      <br>False:不是新开户</div>
797     *                     <div class="en">Whether it is a new account.
798     *                      <br>True: New account
799     *                      <br>False: Not a new account</div>
800     * @param mode <div class="zh">指定加密标准
801     *             <ul><li>0x01:按照 ANSI X9.8 标准,PIN 输入时当最小长度不为 0 时,允许按"确认"退出</li>
802     *                 <li>0x31:16 字节密钥 DES 按照 ANSI X9.8 标准,PIN 输入时当最小长度不为 0 时,允许按"确认"退出</li>
803     *                 <li>0x71:24 字节密钥 DES 按照 ANSI X9.8 标准,PIN 输入时当最小长度不为 0 时,允许按"确认"退出</li>
804     *                 <li>0x04:按照 ANSI X9.8 标准,采用 3DES 加密方法</li>
805     *                 <li>0x02:des 按照 ANSI X3.92 标准</li>
806     *                 <li>0x32:16 字节密钥 DES 按照 ANSI X3.92 标准</li>
807     *                 <li>0x72:24 字节密钥 DES 按照 ANSI X3.92 标准</li></ul></div>
808     *             <div class="en">Specify encryption standards
809     *             <ul><li>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</li>
810     *                 <li>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</li>
811     *                 <li>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</li>
812     *                 <li>0x04: According to ANSI X9.8 standard, using 3DES encryption method</li>
813     *                 <li>0x02: des is in accordance with ANSI X3.92 standard</li>
814     *                 <li>0x32: 16-byte key DES according to ANSI X3.92 standard</li>
815     *                 <li>0x72: 24-byte key DES according to ANSI X3.92 standard</li></ul></div>
816     * @param keyIndex <div class="zh">工作密钥的索引。</div><div class="en">The index of the working key.</div>
817     * @param min <div class="zh">允许输入的 PIN 的最小长度(大于等于 0, 为 0 时,按 ENTER 键返回,且输入 长度 Len=0,此时应答数据长度为 0,表示用户没有输入密码)。</div>
818     *            <div class="en">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).</div>
819     * @param max <div class="zh">允许输入的 PIN 的最大长度(小于等于 14)。</div>
820     *            <div class="en">The maximum length of the PIN that can be entered (less than or equal to 14).</div>
821     * @param data <div class="zh">按照ANSI X9.8 标准,16字节卡号。<br>按照ANSI X3.92标准,6字节交易流水号ISN。</div>
822     *             <div class="en">According to ANSI X9.8 standard, 16-byte card number.
823     *                             <br>According to ANSI X3.92 standard, 6-byte transaction serial number ISN.</div>
824     * @param timeoutMs <div class="zh">超时时间。单位: 毫秒。</div> <div class="en">Timeout. Unit: milliseconds.</div>
825     *
826     * @return <div class="zh">如果输入长度为0,则返回new byte[0]。<br>如果输入长度不为0,则返回8字节的PinBlock。</div>
827     *         <div class="en">If the input length is 0, new byte[0] is returned.
828     *                     <br>If the input length is not 0, an 8-byte PinBlock is returned.</div>
829     * @throws TypeAException TypeAException
830     */
831    byte[] getPinBlock(boolean isNewAccount, byte mode, byte keyIndex, byte min, byte max, byte[] data, int timeoutMs) throws TypeAException;
832    /**
833     * <div class="zh">用于在密码键盘处于密码输入状态时,POS 机取消密码输入。</div> <div class="en">It is used to cancel the password input by the POS machine when the password keyboard is in the password input state.</div>
834     *
835     * @throws TypeAException TypeAException
836     */
837    void cancelInputPin() throws TypeAException;
838    /**
839     * <div class="zh">PIN 输入超时设置。
840     * <br>PINPAD 每次开机后的缺省值是 120 秒(2 分钟)。
841     * <br>设置的键盘超时值为:Time_High×256+Time_Low,单位为 10 毫秒(Timeout<655.36 秒)。当设置为0 时,其超时时间为 2 分钟。</div>
842     * <div class="en">PIN input timeout setting.
843     * <br>The default value of PINPAD after each power-on is 120 seconds (2 minutes).
844     * <br>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..</div>
845     *
846     * @param high <div class="zh">设置的键盘超时值为:Time_High×256+Time_Low。</div>
847     *             <div class="en">The set keyboard timeout value is: Time_High×256+Time_Low.</div>
848     * @param low <div class="zh">设置的键盘超时值为:Time_High×256+Time_Low。</div>
849     *            <div class="en">The set keyboard timeout value is: Time_High×256+Time_Low.</div>
850     * @throws TypeAException TypeAException
851     */
852    void setPinTimeout(byte high, byte low) throws TypeAException;
853    /**
854     * <div class="zh">扩展获取 PINBLOCK [密文传输]。</div> <div class="en">Extended access to PINBLOCK [ciphertext transmission].</div>
855     *
856     * @param cipherByTXK <div class="zh">
857     *                       <table border="1">
858     *                    <tr>
859     *                        <th>偏移位置</th>
860     *                        <th>长度 byte</th>
861     *                        <th>变量名称</th>
862     *                        <th>意义</th>
863     *                    </tr>
864     *                    <tr>
865     *                        <td>0x0000</td>
866     *                        <td>1</td>
867     *                        <td>WKeyID</td>
868     *                        <td>1-100</td>
869     *                    </tr>
870     *                    <tr>
871     *                        <td>0x0001</td>
872     *                        <td>1</td>
873     *                        <td>WKeyLen</td>
874     *                        <td>8、16 或 24,指示 PINBLOCK 是用 DES/TDES 加密</td>
875     *                    </tr>
876     *                    <tr>
877     *                          <td>0x0002</td>
878     *                          <td>1</td>
879     *                          <td>mode</td>
880     *                          <td>选择 PIN BLOCK 的格式,
881     *                              <br>0x00 ISO9564 格式 0
882     *                              <br>0x01 ISO9564 格式 1
883     *                              <br>0x02 ISO9564 格式 3
884     *                              <br>0x03 HK EPS 专用格式[详见附录]</td>
885     *                    </tr>
886     *                    <tr>
887     *                          <td>0x0003</td>
888     *                          <td>1</td>
889     *                          <td>InputMode</td>
890     *                          <td>0x01:只输入一次,0x02:输入两次密码,两次输入一致后返回 PINBLOCK</td>
891     *                    </tr>
892     *                    <tr>
893     *                          <td>0x0004</td>
894     *                          <td>1</td>
895     *                          <td>Min</td>
896     *                          <td>PinPad 输入最小长度,>=0</td>
897     *                    </tr>
898     *                    <tr>
899     *                          <td>0x0005</td>
900     *                          <td>1</td>
901     *                          <td>Max</td>
902     *                          <td>PinPad 输入最大长度,<=14</td>
903     *                    </tr>
904     *                    <tr>
905     *                          <td>0x0006</td>
906     *                          <td>1</td>
907     *                          <td>DataInLen</td>
908     *                          <td>DataIn的长度</td>
909     *                    </tr>
910     *                    <tr>
911     *                          <td>0x0007</td>
912     *                          <td>N</td>
913     *                          <td>DataIn</td>
914     *                          <td>当 Mode=0x00 时DataIn 指向卡号移位后生成的 16 位主帐号。
915     *                          <br>当 Mode=0x01 时输入参数为参与 PinBlock 的格式化,8 字节数据(根据 ISO9564 的规范,该数据可以是随机数、交易流水号或时间戳等)。
916     *                          <br>当 Mode=0x02 时DataIn 指向卡号移位后生成的 16 位主帐号,DataIn+16 指向参与 PinBlock 格式化的 8 字节数据(根据 ISO9564 的规范,该数据可以是随机数、交易流水号或时间戳等,但是每个字节的高 4 位和低 4位,均必须在 0xA-0xF 之间,所以当 Mode 为 0x02时,底层将该 8 字节的数据做此检查,如果不满足要求将返回错误)。
917     *                          <br>当 Mode=0x03 时为交易流水号 ISN [6 Bytes,ASCII 码]] [输入]。</td>
918     *                    </tr>
919     *                    <tr>
920     *                          <td>0x0007+N</td>
921     *                          <td>M</td>
922     *                          <td>Fill</td>
923     *                          <td>填充字节,以上数据长度不被 8 字节整除时,填充至8 字节整除。</td>
924     *                    </tr>
925     *                    </table></div>
926     *
927     * <div class="en">Encrypted by TXK。
928     *                    <table border="1">
929     *                    <tr>
930     *                        <th>Offset</th>
931     *                        <th>Length (byte)</th>
932     *                        <th>Variable name</th>
933     *                        <th>Description</th>
934     *                    </tr>
935     *                    <tr>
936     *                        <td>0x0000</td>
937     *                        <td>1</td>
938     *                        <td>WKeyID</td>
939     *                        <td>1-100</td>
940     *                    </tr>
941     *                    <tr>
942     *                        <td>0x0001</td>
943     *                        <td>1</td>
944     *                        <td>WKeyLen</td>
945     *                        <td>8, 16 or 24, indicating that PINBLOCK is encrypted with DES/TDES</td>
946     *                    </tr>
947     *                    <tr>
948     *                          <td>0x0002</td>
949     *                          <td>1</td>
950     *                          <td>mode</td>
951     *                          <td>Choose the format of PIN BLOCK,
952     *                              <br>0x00 ISO9564 format 0
953     *                              <br>0x01 ISO9564 format 1
954     *                              <br>0x02 ISO9564 format 3
955     *                              <br>0x03 HK EPS special format [see appendix for details]</td>
956     *                    </tr>
957     *                    <tr>
958     *                          <td>0x0003</td>
959     *                          <td>1</td>
960     *                          <td>InputMode</td>
961     *                          <td>0x01: Enter the password only once, 0x02: Enter the password twice, and return to PINBLOCK after the two entries are consistent</td>
962     *                    </tr>
963     *                    <tr>
964     *                          <td>0x0004</td>
965     *                          <td>1</td>
966     *                          <td>Min</td>
967     *                          <td>PinPad input minimum length, >=0</td>
968     *                    </tr>
969     *                    <tr>
970     *                          <td>0x0005</td>
971     *                          <td>1</td>
972     *                          <td>Max</td>
973     *                          <td>PinPad input maximum length, <=14</td>
974     *                    </tr>
975     *                    <tr>
976     *                          <td>0x0006</td>
977     *                          <td>1</td>
978     *                          <td>DataInLen</td>
979     *                          <td>Length of DataIn</td>
980     *                    </tr>
981     *                    <tr>
982     *                          <td>0x0007</td>
983     *                          <td>N</td>
984     *                          <td>DataIn</td>
985     *                          <td>When Mode=0x00, DataIn points to the 16-bit master account number generated after the card number is shifted.
986     *                          <br>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.).
987     *                          <br>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).
988     *                          <br>When Mode=0x03, it is the transaction serial number ISN [6 Bytes, ASCII code]] [input].</td>
989     *                    </tr>
990     *                    <tr>
991     *                          <td>0x0007+N</td>
992     *                          <td>M</td>
993     *                          <td>Fill</td>
994     *                          <td>Filling byte, when the above data length is not divisible by 8 bytes, it is filled to 8 bytes.</td>
995     *                    </tr>
996     *                    </table></div>
997     * @param timeoutMs <div class="zh">超时时间。单位: 毫秒。</div> <div class="en">Timeout. Unit: milliseconds.</div>
998     * @return <div class="zh">如果输入长度为0,则返回new byte[0]。
999     *                     <br>如果输入长度不为0,则返回8字节的PinBlock。</div>
1000     *         <div class="en">If the input length is 0, new byte[0] is returned.
1001     *                     <br>If the input length is not 0, an 8-byte PinBlock is returned.</div>
1002     * @throws TypeAException TypeAException
1003     */
1004    byte[] getPinBlock(byte[] cipherByTXK, int timeoutMs) throws TypeAException;
1005    /**
1006     * <div class="zh">用指定的 MAC 密钥对 Data 作 MAC 加密运算。
1007     * <br>当其最高位为 1 时,先用指定的工作密钥对 Data 前 8 字节进行一次 DES 或 3DES 解密,其结果覆盖 Data 前 8 字节,然后再按 Mode 指定的算法对最新的 Data 数据块进行相应 MAC 运算。</div>
1008     * <div class="en">Use the specified MAC key to perform MAC encryption operations on Data.
1009     * <br>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.</div>
1010     *
1011     * @param macMode <div class="zh">MAC算法类型
1012     *                <ul><li>0x00-算法 1\3 </li>
1013     *                    <li>0x01-算法 2</li>
1014     *                   </ul></div>
1015     *                <div class="en">MAC algorithm type
1016     *                <ul><li>0x00-algorithm 1\3 </li>
1017     *                    <li>0x01-algorithm 2</li>
1018     *                  </ul></div>
1019     *
1020     * @param keyIndex <div class="zh">低 7 位是 MAC 工作密钥的索引。 当其最高位为 1 时,将在 Mode 指定的算法进行之前增加一次额外的解密运算</div>
1021     *                 <div class="en">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</div>
1022     * @param algorithmMode <div class="zh">
1023     *                      <ul><li>0x01 DES 加密 算法 1\2</li>
1024     *                          <li>0x03 3DES 加密[密钥为 16 字节] 算法 1\2</li>
1025     *                          <li>0x07 3DES 加密[密钥为 24 字节] 算法 1\2</li>
1026     *                          <li>0x13: 3DES 加密[密钥为 16 字节] 算法 3</li>
1027     *                          <li>0x17: 3DES 加密[密钥为 24 字节] 算法 3</li></ul></div>
1028     *
1029     * @param dataIn <div class="zh">要进行 MAC 加密的数据。 WKeyID 最高位为 1 时,需至少 9 字节。</div>
1030     *               <div class="en">Data to be MAC encrypted. When the most significant bit of WKeyID is 1, at least 9 bytes are required.</div>
1031     *
1032     * @return <div class="zh">计算得到的MAC</div>
1033     *         <div class="en">Calculated MAC</div>
1034     * @throws TypeAException TypeAException
1035     */
1036    byte[] getMac(byte macMode, byte keyIndex, byte algorithmMode, byte[] dataIn) throws TypeAException;
1037    /**
1038     * <div class="zh">用指定的 DES 密钥对 Data 作 DES 或者 3DES 加密或解密运算。</div>
1039     * <div class="en">Use the specified DES key to perform DES or 3DES encryption or decryption operations on Data.</div>
1040     *
1041     * @param keyIndex <div class="zh">DES(3DES)密钥索引(DES 密钥区)</div>
1042     *                 <div class="en">DES (3DES) key index (DES key area)</div>
1043     *
1044     * @param mode <div class="zh">
1045     *             <ul>
1046     *             <li>mode = 0x01 DES 加密 </li>
1047     *             <li>mode = 0x03 3DES 加密 (密钥为 16 字节) </li>
1048     *             <li>mode = 0x81 DES 解密 (EPS 无此项) </li>
1049     *             <li>mode = 0x83 3DES 解密 (EPS 无此项) </li>
1050     *             <li>mode = 0x07 3DES 加密 [密钥为 24 字节] </li>
1051     *             <li>mode = 0x87 3DES 解密 [密钥为 24 字节]</li>
1052     *             </ul></div>
1053     *             <div class="en">
1054     *             <ul>
1055     *             <li>mode = 0x01 DES encryption</li>
1056     *             <li>mode = 0x03 3DES encryption (the key is 16 bytes)</li>
1057     *             <li>mode = 0x81 DES decryption (EPS does not have this option)</li>
1058     *             <li>mode = 0x83 3DES decryption (EPS does not have this option)</li>
1059     *             <li>mode = 0x07 3DES encryption [key is 24 bytes]</li>
1060     *             <li>mode = 0x87 3DES decryption [key is 24 bytes]</li>
1061     *             </ul>    </div>
1062     *
1063     * @param dataIn <div class="zh">要进行 DES(3DES)加密或解密的数据。(8 字节)</div>
1064     *               <div class="en">The data to be encrypted or decrypted by DES (3DES). (8 bytes)</div>
1065     *
1066     * @return <div class="zh">运算结果</div>
1067     *         <div clsss="en">Calculation result</div>
1068     * @throws TypeAException TypeAException
1069     */
1070    byte[] calcDes(byte keyIndex, byte mode, byte[] dataIn) throws TypeAException;
1071    /**
1072     * <div class="zh">用指定的 MAC 密钥对 Data 作 MAC 加密运算。</div>
1073     * <div class="en">Use the specified MAC key to perform MAC encryption operations on Data.</div>
1074     *
1075     * @param cipherFlag <div class="zh">0x00:DATA 域是明文
1076     *                               <br>0x01: DATA 域,由传输密加密</div>
1077     *                   <div class="en">0x00: DATA field is plain text
1078     *                               <br>0x01: DATA field, encrypted by transmission secret</div>
1079     *
1080     * @param dataIn <div class="zh">
1081     *               <table border="1">
1082     *               <tr>
1083     *                  <th>偏移位置</th>
1084     *                  <th>长度(byte)</th>
1085     *                  <th>变量名称</th>
1086     *                  <th>意义</th>
1087     *               </tr>
1088     *               <tr>
1089     *                  <td>0x0000</td>
1090     *                  <td>1</td>
1091     *                  <td>WKeyID</td>
1092     *                  <td>1-100</td>
1093     *               </tr>
1094     *               <tr>
1095     *                  <td>0x0001</td>
1096     *                  <td>1</td>
1097     *                  <td>WKeyLen</td>
1098     *                  <td>8、16 或 24,指示 MAC 运算采用的是 DES 还是 TDES</td>
1099     *               </tr>
1100     *               <tr>
1101     *                  <td>0x0002</td>
1102     *                  <td>1</td>
1103     *                  <td>Mode</td>
1104     *                  <td>0x00-算法 1
1105     *                    <br>0x01-算法 2
1106     *                    <br>0x02-算法 3</td>
1107     *               </tr>
1108     *               <tr>
1109     *                  <td>0x0003</td>
1110     *                  <td>2</td>
1111     *                  <td>MAC_DATA_LEN</td>
1112     *                  <td>MAC_DATA 长度,小于等于 1024,两字节, 高字节在前,低字节在后</td>
1113     *               </tr>
1114     *               <tr>
1115     *                  <td>0x0005</td>
1116     *                  <td>N</td>
1117     *                  <td>MAC_DATA</td>
1118     *                  <td>待计算 MAC 的数据</td>
1119     *               </tr>
1120     *               <tr>
1121     *                  <td>0x0005+N</td>
1122     *                  <td>M</td>
1123     *                  <td>FILL</td>
1124     *                  <td>填充字节,DATA 域上述数据长度不被 8 字节整除时,填充至 8 字节整除</td>
1125     *               </tr>
1126     *               </table></div>
1127     *               <div class="en">
1128     *                   <table border="1">
1129     *                   <tr>
1130     *                      <th>Offset</th>
1131     *                      <th>Length(byte)</th>
1132     *                      <th>Variable name</th>
1133     *                      <th>Description</th>
1134     *                   </tr>
1135     *                   <tr>
1136     *                      <td>0x0000</td>
1137     *                      <td>1</td>
1138     *                      <td>WKeyID</td>
1139     *                      <td>1-100</td>
1140     *                   </tr>
1141     *                   <tr>
1142     *                      <td>0x0001</td>
1143     *                      <td>1</td>
1144     *                      <td>WKeyLen</td>
1145     *                      <td>8, 16, or 24, indicating whether the MAC operation uses DES or TDES</td>
1146     *                   </tr>
1147     *                   <tr>
1148     *                      <td>0x0002</td>
1149     *                      <td>1</td>
1150     *                      <td>Mode</td>
1151     *                      <td>0x00-algorithm 1
1152     *                        <br>0x01-algorithm 2
1153     *                        <br>0x02-algorithm 3</td>
1154     *                   </tr>
1155     *                   <tr>
1156     *                      <td>0x0003</td>
1157     *                      <td>2</td>
1158     *                      <td>MAC_DATA_LEN</td>
1159     *                      <td>MAC_DATA length, less than or equal to 1024, two bytes, high byte first, low byte last</td>
1160     *                   </tr>
1161     *                   <tr>
1162     *                      <td>0x0005</td>
1163     *                      <td>N</td>
1164     *                      <td>MAC_DATA</td>
1165     *                      <td>Data to be calculated MAC</td>
1166     *                   </tr>
1167     *                   <tr>
1168     *                      <td>0x0005+N</td>
1169     *                      <td>M</td>
1170     *                      <td>FILL</td>
1171     *                      <td>Filling byte, when the above data length in DATA field is not divisible by 8 bytes, it is filled to 8 bytes.</td>
1172     *                   </tr>
1173     *                   </table></div>
1174     *
1175     * @return <div class="zh">输出的MAC</div>
1176     *         <div class="en">Output MAC</div>
1177     * @throws TypeAException TypeAException
1178     */
1179    byte[] getExtMac(byte cipherFlag, byte[] dataIn) throws TypeAException;
1180    /**
1181     * <div class="zh">用指定的 DES 密钥对 Data 作 DES 或者 3DES 加密或解密运算。</div>
1182     * <div class="en">Use the specified DES key to perform DES or 3DES encryption or decryption operations on Data.</div>
1183     *
1184     * @param cipherFlag <div class="zh">0x00:DATA_IN 与 acuIV 是明文
1185     *                               <br>0x01: DATA_IN 与 acuIV,由传输密钥加密</div>
1186     *                   <div class="en">0x00: DATA_IN and acuIV are plain text
1187     *                               <br>0x01: DATA_IN and acuIV, encrypted by the transmission key</div>
1188     *
1189     * @param dataIn <div class="zh">
1190     *               <table border="1">
1191     *               <tr>
1192     *                  <th>偏移位置</th>
1193     *                  <th>长度(byte)</th>
1194     *                  <th>变量名称</th>
1195     *                  <th>意义</th>
1196     *               </tr>
1197     *               <tr>
1198     *                  <td>0x0000</td>
1199     *                  <td>1</td>
1200     *                  <td>DKeyID</td>
1201     *                  <td>1-100</td>
1202     *               </tr>
1203     *               <tr>
1204     *                  <td>0x0001</td>
1205     *                  <td>1</td>
1206     *                  <td>DKeyLen</td>
1207     *                  <td>8、16 或 24,指示数据加解密是采用的是 DES 还 是 TDES</td>
1208     *               </tr>
1209     *               <tr>
1210     *                  <td>0x0002</td>
1211     *                  <td>1</td>
1212     *                  <td>Mode</td>
1213     *                  <td>
1214     *                      <ul>
1215     *                          <li>0x00: ECB decryption</li>
1216     *                          <li>0x01: ECB encryption</li>
1217     *                          <li>0x02: CBC decryption</li>
1218     *                          <li>0x03: CBC encryption</li>
1219     *                          <li>0x04: OFB decryption</li>
1220     *                          <li>0x05: OFB encryption</li>
1221     *                      </ul>
1222     *                  </td>
1223     *               </tr>
1224     *               <tr>
1225     *                  <td>0x0003</td>
1226     *                  <td>2</td>
1227     *                  <td>DATA_LEN</td>
1228     *                  <td>DATA 长度,小于等于 1024,两字节,高 字节在前,低字节在后,8 字节整除。</td>
1229     *               </tr>
1230     *               <tr>
1231     *                  <td>0x0005</td>
1232     *                  <td>N</td>
1233     *                  <td>DATA_IN_IN</td>
1234     *                  <td>待加解密的数据</td>
1235     *               </tr>
1236     *               <tr>
1237     *                  <td>0x0005+N</td>
1238     *                  <td>8</td>
1239     *                  <td>aucIV</td>
1240     *                  <td>初始向量,ECB 时不需要。</td>
1241     *               </tr>
1242     *               </table></div>
1243     *               <div class="en">
1244     *                   <table border="1">
1245     *                   <tr>
1246     *                      <th>Offset</th>
1247     *                      <th>Length(byte)</th>
1248     *                      <th>Variable name</th>
1249     *                      <th>Description</th>
1250     *                   </tr>
1251     *                   <tr>
1252     *                      <td>0x0000</td>
1253     *                      <td>1</td>
1254     *                      <td>DKeyID</td>
1255     *                      <td>1-100</td>
1256     *                   </tr>
1257     *                   <tr>
1258     *                      <td>0x0001</td>
1259     *                      <td>1</td>
1260     *                      <td>DKeyLen</td>
1261     *                      <td>8, 16 or 24, indicating whether the data encryption and decryption use DES or TDES</td>
1262     *                   </tr>
1263     *                   <tr>
1264     *                      <td>0x0002</td>
1265     *                      <td>1</td>
1266     *                      <td>Mode</td>
1267     *                      <td>
1268     *                          <ul>
1269     *                              <li>0x00: ECB decryption</li>
1270     *                              <li>0x01: ECB encryption</li>
1271     *                              <li>0x02: CBC decryption</li>
1272     *                              <li>0x03: CBC encryption</li>
1273     *                              <li>0x04: OFB decryption</li>
1274     *                              <li>0x05: OFB encryption</li>
1275     *                          </ul>
1276     *                      </td>
1277     *                   </tr>
1278     *                   <tr>
1279     *                      <td>0x0003</td>
1280     *                      <td>2</td>
1281     *                      <td>DATA_LEN</td>
1282     *                      <td>DATA length, less than or equal to 1024, two bytes, high byte first, low byte last, 8 bytes are divisible</td>
1283     *                   </tr>
1284     *                   <tr>
1285     *                      <td>0x0005</td>
1286     *                      <td>N</td>
1287     *                      <td>DATA_IN_IN</td>
1288     *                      <td>DData to be encrypted and decrypted</td>
1289     *                   </tr>
1290     *                   <tr>
1291     *                      <td>0x0005+N</td>
1292     *                      <td>8</td>
1293     *                      <td>aucIV</td>
1294     *                      <td>Initial vector, not needed for ECB.</td>
1295     *                   </tr>
1296     *                   </table></div>
1297     *
1298     * @return  <div class="zh">运算结果</div>
1299     *          <div class="en">Calculation result</div>
1300     * @throws TypeAException TypeAException
1301     */
1302    byte[] calcExtDes(byte cipherFlag, byte[] dataIn) throws TypeAException;
1303
1304    /**
1305     * <div class="zh">用于重新初始化 DUKPT 密钥。</div> <div class="en">Used to reinitialize the DUKPT key.</div>
1306     *
1307     * @param appNo <div class="zh">应用标志号,有效值 0-23</div>
1308     *              <div class="en">Application mark number, valid value 0-23</div>
1309     *
1310     * @param groupIndex <div class="zh">密钥标志号,有效值 1-10。</div>
1311     *                   <div class="en">Key mark number, valid value 1-10.</div>
1312     *
1313     * @param keyValue <div class="zh">初始 PIN 输入设备密钥,16 字节,由 BDK 和 KSN 通过 DUKPT 密钥初始化 专用设备生成。</div>
1314     *                 <div class="en>Initial PIN Enter the device key, 16 bytes, which is generated by BDK and KSN through the DUKPT key initialization special device.</div>
1315     *
1316     * @param ksn <div class="zh">初始 KSN,长度不足 10 字节时,会自动在左边填充 0xFF 至 10 字节。</div>
1317     *            <div class="en">Initial KSN. when ksn is less than 10 bytes in length, 0xFF to 10 bytes will be automatically filled on the left.</div>
1318     *
1319     * @throws TypeAException TypeAException
1320     */
1321    void writeTIK(byte appNo, byte groupIndex, byte[] keyValue, byte[] ksn) throws TypeAException;
1322
1323    /**
1324     * <div class="zh">提示用户输入 PIN。待输入完毕后,依照所选标准生成和输出 PIN 密文块和当前密钥序号 KSN。
1325     * <br>为防止非法套取密钥,从上一次执行该命令到本次指令之间的间隔应不小于 30 秒(该值可能需要调整)。</div>
1326     * <div class="en">Prompt the user to enter a PIN. After the input is completed,
1327     * the PIN ciphertext block and the current key sequence number KSN are generated and output according to the selected standard.
1328     * <br>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).</div>
1329     *
1330     * @param appNo <div class="zh">应用标志号,有效值 0-23</div>
1331     *              <div class="en">Application mark number, valid value 0-23</div>
1332     *
1333     * @param groupIndex <div class="zh">密钥标志号,有效值 1-10。</div>
1334     *                   <div class="en">Key mark number, valid value 1-10.</div>
1335     *
1336     * @param min <div class="zh">允许输入 PIN 的最小长度,应不超过最大允许长度。</div>
1337     *            <div class="en">The minimum length allowed to enter the PIN should not exceed the maximum allowed length.</div>
1338     *
1339     * @param max <div class="zh">允许输入 PIN 的最大长度,应不超过 12。</div>
1340     *            <div class="en">The maximum length of the PIN allowed to be entered should not exceed 12.</div>
1341     *
1342     * @param dataIn <div class="zh">当mode = 0x00时,表示持卡人的卡号资料,该卡号应固定为 16 字节,并保证其尾部 12 字节为有效 数据。
1343     *                           <br>当mode = 0x01时,表示交易序号,该序号应固定为 6 字节,有效值 000000-999999。</div>
1344     *               <div class="en">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.
1345     *                           <br>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.</div>
1346     *
1347     * @param mode <div class="zh">0x00: 依照 ANSI X98 标准
1348     *                         <br>0x01: 依照 ANSI X3.92 标准</div>
1349     *             <div class="en">0x00: According to ANSI X98 standard
1350     *                         <br>0x01: According to ANSI X3.92 standard</div>
1351     *
1352     * @param timeoutMs <div class="zh">超时时间,单位:ms</div>
1353     *                  <div class="en">Timeout time(ms)</div>
1354     *
1355     * @return {@link DUKPTResult}
1356     * @throws TypeAException TypeAException
1357     */
1358    DUKPTResult getDUKPTPin(byte appNo, byte groupIndex, byte min, byte max, byte[] dataIn, byte mode, int timeoutMs) throws TypeAException;
1359    /**
1360     * <div class="zh">对输入数据报文进行指定算法的验证码运算,并输出生成的 MAC 和当前密钥序号 KSN。</div>
1361     * <div class="en">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.</div>
1362     *
1363     * @param appNo <div class="zh">应用标志号,有效值 0-23</div>
1364     *              <div class="en">Application mark number, valid value 0-23</div>
1365     *
1366     * @param groupIndex <div class="zh">密钥标志号,有效值 1-10。</div>
1367     *                   <div class="en">Key mark number, valid value 1-10.</div>
1368     *
1369     * @param mode <div class="zh">指定 MAC 算法
1370     *             <ul>
1371     *              <li>0x00: 依次连续进行 3DES/异或/3DES/异或/…/3DES 的运算 </li>
1372     *              <li>0x01: 依次连续进行异或/异或/…/异或,最后进行一次 3DES 的运算 </li>
1373     *              <li>0x02: 依次连续进行 DES/异或/DES/异或/…/3DES 的运算,注意最后一次为 3DES 运算</li>
1374     *             </ul></div>
1375     *             <div class="en">Specify MAC algorithm
1376     *             <ul>
1377     *              <li>0x00: Perform 3DES/XOR/3DES/XOR/.../3DES operations in sequence</li>
1378     *              <li>0x01: XOR/XOR/.../XOR is performed successively, and the 3DES operation is performed last</li>
1379     *              <li>0x02: DES/XOR/DES/XOR/.../3DES operations are successively performed in sequence, note that the last operation is 3DES operation</li>
1380     *             </ul></div>
1381     *
1382     * @param dataIn <div class="zh">输入的数据报文,有效长度为1-250</div>
1383     *               <div class="en">The input data message, the effective length is 1-250</div>
1384     *
1385     * @return {@link DUKPTResult}
1386     * @throws TypeAException TypeAException
1387     */
1388    DUKPTResult getDUKPTMac(byte appNo, byte groupIndex, byte mode, byte[] dataIn) throws TypeAException;
1389    /**
1390     * <div class="zh">用于清除指定的部分或全部 DUKPT 密钥</div> <div class="en">Used to clear some or all of the specified DUKPT key</div>
1391     *
1392     * @param appNo <div class="zh">应用标志号,有效值 0-23</div>
1393     *              <div class="en">Application mark number, valid value 0-23</div>
1394     *
1395     * @param keyIndex <div class="zh">密钥标志号,有效值 1-10。</div>
1396     *                 <div class="en">Key mark number, valid value 1-10.</div>
1397     *
1398     * @param mode <div class="zh">指定清除方式:
1399     *                           <br>0—清除 AppNo 指定应用中所有 DUKPT 密钥
1400     *                           <br>1—清除 AppNo 指定应用中 KeyId 所对应的 DUKPT 密钥</div>
1401     *             <div class="en">Specify the clearing method:
1402     *                           <br>0—Clear all DUKPT keys in AppNo specified application
1403     *                           <br>1—Clear the DUKPT key corresponding to the KeyId in the AppNo specified application</div>
1404     * @throws TypeAException TypeAException
1405     */
1406    void eraseDUKPTKey(byte appNo, byte keyIndex, byte mode) throws TypeAException;
1407
1408    /**
1409     * <div class="zh">将 SM4 密钥存储在指定位置。</div> <div class="en"></div>
1410     *
1411     * @param cipherFlag <div class="zh"><ul>
1412     *                     <li>0x00: dataIn 是明文。</li>
1413     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
1414     *                   </ul></div>
1415     *                   <div class="en"><ul>
1416     *                     <li>0x00: dataIn is plain text.</li>
1417     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
1418     *                   </ul></div>
1419     * @param dataIn <div class="zh"><table border="1">
1420     *                 <tr>
1421     *                   <th>偏移位置</th>
1422     *                   <th>长度(byte)</th>
1423     *                   <th>变量名称</th>
1424     *                   <th>意义</th>
1425     *                 </tr>
1426     *                 <tr>
1427     *                   <td>0x0000</td>
1428     *                   <td>1</td>
1429     *                   <td>MKeyIndex</td>
1430     *                   <td>1-99 ,该密钥是密钥加解密密钥,当 KeyType 是主密钥时,KeyIndex 无效,Mode 必须为 0x00,即主密钥只能明文注入。</td>
1431     *                 </tr>
1432     *                 <tr>
1433     *                   <td>0x0001</td>
1434     *                   <td>1</td>
1435     *                   <td>Mode</td>
1436     *                   <td>0x00:不作任何运算。<br>0x01:解密运算。<br>0x02:加密运算。</td>
1437     *                 </tr>
1438     *                 <tr>
1439     *                   <td>0x0002</td>
1440     *                   <td>1</td>
1441     *                   <td>KeyType</td>
1442     *                   <td>0x00:主密钥。<br> 0x01:数据加解密密钥。<br> 0x02:PIN 加密密钥。<br> 0x03:MAC 计算密钥</td>
1443     *                 </tr>
1444     *                 <tr>
1445     *                   <td>0x0003</td>
1446     *                   <td>1</td>
1447     *                   <td>KeyIndex</td>
1448     *                   <td>1-99,传入的密钥值密文经过 Mode 指定的运算后,生成明文,该明文将写该索引号对应的密钥位置。</td>
1449     *                 </tr>
1450     *                 <tr>
1451     *                   <td>0x0004</td>
1452     *                   <td>1</td>
1453     *                   <td>KeyLen</td>
1454     *                   <td>固定取值 0x10。</td>
1455     *                 </tr>
1456     *                 <tr>
1457     *                   <td>0x0005</td>
1458     *                   <td>16</td>
1459     *                   <td>Key</td>
1460     *                   <td>传入的密钥值。</td>
1461     *                 </tr>
1462     *                 <tr>
1463     *                   <td>0x0006</td>
1464     *                   <td>N</td>
1465     *                   <td>Fill</td>
1466     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
1467     *                 </tr>
1468     *               </table></div>
1469     *               <div class="en"><table border="1">
1470     *                 <tr>
1471     *                   <th>Offset </th>
1472     *                   <th>Length(byte)</th>
1473     *                   <th>Variable name</th>
1474     *                   <th>Description</th>
1475     *                 </tr>
1476     *                 <tr>
1477     *                   <td>0x0000</td>
1478     *                   <td>1</td>
1479     *                   <td>MKeyIndex</td>
1480     *                   <td>1-99, the key is the key encryption and decryption key. When the KeyType is the master key,
1481     *                     the KeyIndex is invalid and the Mode must be 0x00, that is, the master key can only be injected in plain text.</td>
1482     *                 </tr>
1483     *                 <tr>
1484     *                   <td>0x0001</td>
1485     *                   <td>1</td>
1486     *                   <td>Mode</td>
1487     *                   <td>0x00: No operation is performed. <br>0x01: Decryption operation. <br>0x02: Encryption operation.</td>
1488     *                 </tr>
1489     *                 <tr>
1490     *                   <td>0x0002</td>
1491     *                   <td>1</td>
1492     *                   <td>KeyType</td>
1493     *                   <td>0x00: Master key. <br> 0x01: Data encryption and decryption key. <br> 0x02: PIN encryption key. <br> 0x03: MAC calculation key.</td>
1494     *                 </tr>
1495     *                 <tr>
1496     *                   <td>0x0003</td>
1497     *                   <td>1</td>
1498     *                   <td>KeyIndex</td>
1499     *                   <td>1 to 99, after the passed-in key value ciphertext undergoes the operation specified by Mode, a plaintext is generated,
1500     *                     and the plaintext will be written with the key position corresponding to the index number.</td>
1501     *                 </tr>
1502     *                 <tr>
1503     *                   <td>0x0004</td>
1504     *                   <td>1</td>
1505     *                   <td>KeyLen</td>
1506     *                   <td>The fixed value is 0x10.</td>
1507     *                 </tr>
1508     *                 <tr>
1509     *                   <td>0x0005</td>
1510     *                   <td>16</td>
1511     *                   <td>Key</td>
1512     *                   <td>The key value.</td>
1513     *                 </tr>
1514     *                 <tr>
1515     *                   <td>0x0006</td>
1516     *                   <td>N</td>
1517     *                   <td>Fill</td>
1518     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
1519     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
1520     *                 </tr>
1521     *               </table></div>
1522     * @throws TypeAException TypeAException
1523     */
1524        void writeSM4Key(byte cipherFlag, byte[] dataIn) throws TypeAException;
1525
1526    /**
1527     * <div class="zh">生成 SM2 公私钥对。</div> <div class="en">Generate SM2 public and private key pair.</div>
1528     *
1529     * @param cipherFlag <div class="zh"><ul>
1530     *                     <li>0x00: dataIn 是明文。</li>
1531     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
1532     *                   </ul></div>
1533     *                   <div class="en"><ul>
1534     *                     <li>0x00: dataIn is plain text.</li>
1535     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
1536     *                   </ul></div>
1537     * @param dataIn <div class="zh"><table border="1">
1538     *                 <tr>
1539     *                   <th>偏移位置</th>
1540     *                   <th>长度(byte)</th>
1541     *                   <th>变量名称</th>
1542     *                   <th>意义</th>
1543     *                 </tr>
1544     *                 <tr>
1545     *                   <td>0x0000</td>
1546     *                   <td>2</td>
1547     *                   <td>PrvKeyLenBit</td>
1548     *                   <td>私钥位数,支持256bit。</td>
1549     *                 </tr>
1550     *                 <tr>
1551     *                   <td>0x0002</td>
1552     *                   <td>N</td>
1553     *                   <td>Fill</td>
1554     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
1555     *                 </tr>
1556     *               </table></div>
1557     *               <div class="en"><table border="1">
1558     *                 <tr>
1559     *                   <th>Offset </th>
1560     *                   <th>Length(byte)</th>
1561     *                   <th>Variable name</th>
1562     *                   <th>Description</th>
1563     *                 </tr>
1564     *                 <tr>
1565     *                   <td>0x0000</td>
1566     *                   <td>1</td>
1567     *                   <td>PrvKeyLenBit</td>
1568     *                   <td>The length of private key bits, supports 256bit.</td>
1569     *                 </tr>
1570     *                 <tr>
1571     *                   <td>0x0002</td>
1572     *                   <td>N</td>
1573     *                   <td>Fill</td>
1574     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
1575     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
1576     *                 </tr>
1577     *               </table></div>
1578     * @return {@link SM2KeyPair}
1579     * @throws TypeAException TypeAException
1580     */
1581    SM2KeyPair genSM2Key(byte cipherFlag, byte[] dataIn) throws TypeAException;
1582
1583    /**
1584     * <div class="zh">将SM2密钥存储在PED中。
1585     * <br>注意:SM2 密钥存储于 DES 密钥区域,KeyIndex指示的是 DES 密钥区的存储位置,以 8 字节为单位, 比如 SM2 私钥 32 字节,则占用 4 个存储位置。</div>
1586     * <div class="en">Store the SM2 key in the PED.
1587     * <br>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.
1588     * For example, if the SM2 private key is 32 bytes, it occupies 4 storage locations.</div>
1589     *
1590     * @param cipherFlag <div class="zh"><ul>
1591     *                     <li>0x00: dataIn 是明文。</li>
1592     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
1593     *                   </ul></div>
1594     *                   <div class="en"><ul>
1595     *                     <li>0x00: dataIn is plain text.</li>
1596     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
1597     *                   </ul></div>
1598     * @param dataIn <div class="zh"><table border="1">
1599     *                 <tr>
1600     *                   <th>偏移位置</th>
1601     *                   <th>长度(byte)</th>
1602     *                   <th>变量名称</th>
1603     *                   <th>意义</th>
1604     *                 </tr>
1605     *                 <tr>
1606     *                   <td>0x0000</td>
1607     *                   <td>1</td>
1608     *                   <td>KeyType</td>
1609     *                   <td>0x00:SM2 私钥; <br> 0x01: SM2 公钥。</td>
1610     *                 </tr>
1611     *                 <tr>
1612     *                   <td>0x0001</td>
1613     *                   <td>1</td>
1614     *                   <td>KeyIndex</td>
1615     *                   <td>SM2 私钥: 1~97; <br> SM2 公钥:1~93。</td>
1616     *                 </tr>
1617     *                 <tr>
1618     *                   <td>0x0002</td>
1619     *                   <td>2</td>
1620     *                   <td>KeyLenBit</td>
1621     *                   <td>SM2 私钥固定256bit;<br> SM2 公钥固定512bit。</td>
1622     *                 </tr>
1623     *                 <tr>
1624     *                   <td>0x0004</td>
1625     *                   <td>N</td>
1626     *                   <td>Key</td>
1627     *                   <td>密钥。</td>
1628     *                 </tr>
1629     *                 <tr>
1630     *                   <td>0x0004+N</td>
1631     *                   <td>M</td>
1632     *                   <td>Fill</td>
1633     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
1634     *                 </tr>
1635     *               </table></div>
1636     *               <div class="en"><table border="1">
1637     *                 <tr>
1638     *                   <th>Offset </th>
1639     *                   <th>Length(byte)</th>
1640     *                   <th>Variable name</th>
1641     *                   <th>Description</th>
1642     *                 </tr>
1643     *                 <tr>
1644     *                   <td>0x0000</td>
1645     *                   <td>1</td>
1646     *                   <td>KeyType</td>
1647     *                   <td>0x00: SM2 private key. <br> 0x01: SM2 public key.</td>
1648     *                 </tr>
1649     *                 <tr>
1650     *                   <td>0x0001</td>
1651     *                   <td>1</td>
1652     *                   <td>KeyIndex</td>
1653     *                   <td>SM2 private key: 1~97; <br> SM2 public key: 1~93.</td>
1654     *                 </tr>
1655     *                 <tr>
1656     *                   <td>0x0002</td>
1657     *                   <td>2</td>
1658     *                   <td>KeyLenBit</td>
1659     *                   <td>SM2 private key is fixed 256bit;<br> The SM2 public key is fixed at 512 bits.</td>
1660     *                 </tr>
1661     *                 <tr>
1662     *                   <td>0x0004</td>
1663     *                   <td>N</td>
1664     *                   <td>Key</td>
1665     *                   <td>The key value.</td>
1666     *                 </tr>
1667     *                 <tr>
1668     *                   <td>0x0004+N</td>
1669     *                   <td>M</td>
1670     *                   <td>Fill</td>
1671     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
1672     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
1673     *                 </tr>
1674     *               </table></div>
1675     * @throws TypeAException TypeAException
1676     */
1677    void writeSM2Key(byte cipherFlag, byte[] dataIn) throws TypeAException;
1678
1679    /**
1680     * <div class="zh">提示用户输入 PIN,输入 PIN 之后按照指定 mode 生成 PINBlock,并使用 SM4 密钥加密。</div>
1681     * <div class="en">Prompt the user to enter the PIN. After entering the PIN, a PINBlock is generated
1682     *   according to the specified mode and encrypted with the SM4 key.</div>
1683     *
1684     * @param cipherFlag <div class="zh"><ul>
1685     *                     <li>0x00: dataIn 是明文。</li>
1686     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
1687     *                   </ul></div>
1688     *                   <div class="en"><ul>
1689     *                     <li>0x00: dataIn is plain text.</li>
1690     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
1691     *                   </ul></div>
1692     * @param dataIn <div class="zh"><table border="1">
1693     *                 <tr>
1694     *                   <th>偏移位置</th>
1695     *                   <th>长度(byte)</th>
1696     *                   <th>变量名称</th>
1697     *                   <th>意义</th>
1698     *                 </tr>
1699     *                 <tr>
1700     *                   <td>0x0000</td>
1701     *                   <td>1</td>
1702     *                   <td>WKeyIndex</td>
1703     *                   <td>1~99。</td>
1704     *                 </tr>
1705     *                 <tr>
1706     *                   <td>0x0001</td>
1707     *                   <td>1</td>
1708     *                   <td>WKeyLen</td>
1709     *                   <td>16。</td>
1710     *                 </tr>
1711     *                 <tr>
1712     *                   <td>0x0002</td>
1713     *                   <td>1</td>
1714     *                   <td>Mode</td>
1715     *                   <td>0x00: 国密格式0。</td>
1716     *                 </tr>
1717     *                 <tr>
1718     *                   <td>0x0003</td>
1719     *                   <td>1</td>
1720     *                   <td>InputMode</td>
1721     *                   <td>0x01: 只输入一次; <br> 0x02: 输入两次密码,两次输入一致后返回PINBlock。</td>
1722     *                 </tr>
1723     *                 <tr>
1724     *                   <td>0x0004</td>
1725     *                   <td>1</td>
1726     *                   <td>Min</td>
1727     *                   <td>输入最小长度,大于等于0。</td>
1728     *                 </tr>
1729     *                 <tr>
1730     *                   <td>0x0005</td>
1731     *                   <td>1</td>
1732     *                   <td>Max</td>
1733     *                   <td>输入最大长度,小于等于14。</td>
1734     *                 </tr>
1735     *                 <tr>
1736     *                   <td>0x0006</td>
1737     *                   <td>1</td>
1738     *                   <td>DataInLen</td>
1739     *                   <td>DataIn的长度。</td>
1740     *                 </tr>
1741     *                 <tr>
1742     *                   <td>0x0007</td>
1743     *                   <td>N</td>
1744     *                   <td>DataIn</td>
1745     *                   <td>卡号移位后生成的 16 位主帐号。</td>
1746     *                 </tr>
1747     *                 <tr>
1748     *                   <td>0x0007+N</td>
1749     *                   <td>M</td>
1750     *                   <td>Fill</td>
1751     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
1752     *                 </tr>
1753     *               </table></div>
1754     *               <div class="en"><table border="1">
1755     *                 <tr>
1756     *                   <th>Offset </th>
1757     *                   <th>Length(byte)</th>
1758     *                   <th>Variable name</th>
1759     *                   <th>Description</th>
1760     *                 </tr>
1761     *                 <tr>
1762     *                   <td>0x0000</td>
1763     *                   <td>1</td>
1764     *                   <td>WKeyIndex</td>
1765     *                   <td>1~99。</td>
1766     *                 </tr>
1767     *                 <tr>
1768     *                   <td>0x0001</td>
1769     *                   <td>1</td>
1770     *                   <td>WKeyLen</td>
1771     *                   <td>16。</td>
1772     *                 </tr>
1773     *                 <tr>
1774     *                   <td>0x0002</td>
1775     *                   <td>1</td>
1776     *                   <td>Mode</td>
1777     *                   <td>0x00: SM format 0.</td>
1778     *                 </tr>
1779     *                 <tr>
1780     *                   <td>0x0003</td>
1781     *                   <td>1</td>
1782     *                   <td>InputMode</td>
1783     *                   <td>0x01: Enter only once; <br> 0x02: Enter the password twice, and return to PINBlock after the two entries are consistent.</td>
1784     *                 </tr>
1785     *                 <tr>
1786     *                   <td>0x0004</td>
1787     *                   <td>1</td>
1788     *                   <td>Min</td>
1789     *                   <td>Enter the minimum length, which is greater than or equal to 0.</td>
1790     *                 </tr>
1791     *                 <tr>
1792     *                   <td>0x0005</td>
1793     *                   <td>1</td>
1794     *                   <td>Max</td>
1795     *                   <td>Enter the maximum length, which is less than or equal to 14.</td>
1796     *                 </tr>
1797     *                 <tr>
1798     *                   <td>0x0006</td>
1799     *                   <td>1</td>
1800     *                   <td>DataInLen</td>
1801     *                   <td>The length of DataIn.</td>
1802     *                 </tr>
1803     *                 <tr>
1804     *                   <td>0x0007</td>
1805     *                   <td>N</td>
1806     *                   <td>DataIn</td>
1807     *                   <td>The 16-digit master account number generated after the card number is shifted.</td>
1808     *                 </tr>
1809     *                 <tr>
1810     *                   <td>0x0007+N</td>
1811     *                   <td>M</td>
1812     *                   <td>Fill</td>
1813     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
1814     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
1815     *                 </tr>
1816     *               </table></div>
1817     * @param timeoutMs <div class="zh">超时时间。单位: 毫秒。</div> <div class="en">Timeout. Unit: milliseconds.</div>
1818     * @return <div class="zh">16字节的PINBlock。</div> <div class="en">16-byte PINBlock.</div>
1819     * @throws TypeAException TypeAException
1820     */
1821    byte[] getSM4PinBlock(byte cipherFlag, byte[] dataIn, int timeoutMs) throws TypeAException;
1822
1823    /**
1824     * <div class="zh">使用 SM4 算法计算 MAC。</div> <div class="en">Use SM4 algorithm to calculate MAC.</div>
1825     *
1826     * @param cipherFlag <div class="zh"><ul>
1827     *                     <li>0x00: dataIn 是明文。</li>
1828     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
1829     *                   </ul></div>
1830     *                   <div class="en"><ul>
1831     *                     <li>0x00: dataIn is plain text.</li>
1832     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
1833     *                   </ul></div>
1834     * @param dataIn <div class="zh"><table border="1">
1835     *                 <tr>
1836     *                   <th>偏移位置</th>
1837     *                   <th>长度(byte)</th>
1838     *                   <th>变量名称</th>
1839     *                   <th>意义</th>
1840     *                 </tr>
1841     *                 <tr>
1842     *                   <td>0x0000</td>
1843     *                   <td>1</td>
1844     *                   <td>WKeyIndex</td>
1845     *                   <td>1~99。</td>
1846     *                 </tr>
1847     *                 <tr>
1848     *                   <td>0x0001</td>
1849     *                   <td>1</td>
1850     *                   <td>WKeyLen</td>
1851     *                   <td>16。</td>
1852     *                 </tr>
1853     *                 <tr>
1854     *                   <td>0x0002</td>
1855     *                   <td>1</td>
1856     *                   <td>Mode</td>
1857     *                   <td>0x00: 使用SM4 CBC 算法计算MAC 值,首先将初始向量与BLOCK1 进行异或,并用SM4算法使用TAK 对异或的结果进行加密,
1858     *                     然后获得的密文与BLOCK2 异或,用SM4 算法使用TAK 对结果加密,按顺序给出16 字节的加密果。结果为16 字节。<br>
1859     *                     0x01: SM3 HMAC, 结果为32字节。</td>
1860     *                 </tr>
1861     *                 <tr>
1862     *                   <td>0x0003</td>
1863     *                   <td>2</td>
1864     *                   <td>MacDataLen</td>
1865     *                   <td>MacData的长度。</td>
1866     *                 </tr>
1867     *                 <tr>
1868     *                   <td>0x0005</td>
1869     *                   <td>N</td>
1870     *                   <td>MacData</td>
1871     *                   <td>待计算Mac的数据。</td>
1872     *                 </tr>
1873     *                 <tr>
1874     *                   <td>0x0005+N</td>
1875     *                   <td>16</td>
1876     *                   <td>IV</td>
1877     *                   <td>16字节初始化向量。</td>
1878     *                 </tr>
1879     *                 <tr>
1880     *                   <td>0x0015+N</td>
1881     *                   <td>M</td>
1882     *                   <td>Fill</td>
1883     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
1884     *                 </tr>
1885     *               </table></div>
1886     *               <div class="en"><table border="1">
1887     *                 <tr>
1888     *                   <th>Offset </th>
1889     *                   <th>Length(byte)</th>
1890     *                   <th>Variable name</th>
1891     *                   <th>Description</th>
1892     *                 </tr>
1893     *                 <tr>
1894     *                   <td>0x0000</td>
1895     *                   <td>1</td>
1896     *                   <td>WKeyIndex</td>
1897     *                   <td>1~99。</td>
1898     *                 </tr>
1899     *                 <tr>
1900     *                   <td>0x0001</td>
1901     *                   <td>1</td>
1902     *                   <td>WKeyLen</td>
1903     *                   <td>16。</td>
1904     *                 </tr>
1905     *                 <tr>
1906     *                   <td>0x0002</td>
1907     *                   <td>1</td>
1908     *                   <td>Mode</td>
1909     *                   <td>0x00: Use the SM4 CBC algorithm to calculate the MAC value. First, the initial vector and BLOCK1 are XORed,
1910     *                     and the SM4 algorithm uses TAK to encrypt the XOR result, and then the obtained ciphertext is XORed with BLOCK2,
1911     *                     and the SM4 algorithm uses TAK to encrypt the result. The 16-byte encryption result is given in sequence. The result is 16 bytes.<br>
1912     *                     0x01: SM3 HMAC, the result is 32 bytes.</td>
1913     *                 </tr>
1914     *                 <tr>
1915     *                   <td>0x0003</td>
1916     *                   <td>2</td>
1917     *                   <td>MacDataLen</td>
1918     *                   <td>The length of MacData.</td>
1919     *                 </tr>
1920     *                 <tr>
1921     *                   <td>0x0005</td>
1922     *                   <td>N</td>
1923     *                   <td>MacData</td>
1924     *                   <td>The data of Mac to be calculated.</td>
1925     *                 </tr>
1926     *                 <tr>
1927     *                   <td>0x0005+N</td>
1928     *                   <td>16</td>
1929     *                   <td>IV</td>
1930     *                   <td>16-byte initialization vector.</td>
1931     *                 </tr>
1932     *                 <tr>
1933     *                   <td>0x0015+N</td>
1934     *                   <td>M</td>
1935     *                   <td>Fill</td>
1936     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
1937     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
1938     *                 </tr>
1939     *               </table></div>
1940     * @return <div class="zh">Mac结果。</div> <div class="en">Mac results.</div>
1941     * @throws TypeAException TypeAException
1942     */
1943    byte[] getSM4Mac(byte cipherFlag, byte[] dataIn) throws TypeAException;
1944
1945    /**
1946     * <div class="zh">使用SM4 算法加解密数据。</div> <div class="en">Use SM4 algorithm to encrypt and decrypt data.</div>
1947     *
1948     * @param cipherFlag <div class="zh"><ul>
1949     *                     <li>0x00: dataIn 是明文。</li>
1950     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
1951     *                   </ul></div>
1952     *                   <div class="en"><ul>
1953     *                     <li>0x00: dataIn is plain text.</li>
1954     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
1955     *                   </ul></div>
1956     * @param dataIn <div class="zh"><table border="1">
1957     *                 <tr>
1958     *                   <th>偏移位置</th>
1959     *                   <th>长度(byte)</th>
1960     *                   <th>变量名称</th>
1961     *                   <th>意义</th>
1962     *                 </tr>
1963     *                 <tr>
1964     *                   <td>0x0000</td>
1965     *                   <td>1</td>
1966     *                   <td>WKeyIndex</td>
1967     *                   <td>1~99。</td>
1968     *                 </tr>
1969     *                 <tr>
1970     *                   <td>0x0001</td>
1971     *                   <td>1</td>
1972     *                   <td>WKeyLen</td>
1973     *                   <td>16。</td>
1974     *                 </tr>
1975     *                 <tr>
1976     *                   <td>0x0002</td>
1977     *                   <td>1</td>
1978     *                   <td>Mode</td>
1979     *                   <td>0x00: ECB 解密;<br> 0x01: ECB 加密;<br> 0x02: CBC 解密;<br> 0x03: CBC 加密;</td>
1980     *                 </tr>
1981     *                 <tr>
1982     *                   <td>0x0003</td>
1983     *                   <td>2</td>
1984     *                   <td>DataInLen</td>
1985     *                   <td>DataIn的长度。</td>
1986     *                 </tr>
1987     *                 <tr>
1988     *                   <td>0x0005</td>
1989     *                   <td>N</td>
1990     *                   <td>DataIn</td>
1991     *                   <td>待加解密的数据。</td>
1992     *                 </tr>
1993     *                 <tr>
1994     *                   <td>0x0005+N</td>
1995     *                   <td>16</td>
1996     *                   <td>IV</td>
1997     *                   <td>16字节初始化向量。ECB时不需要。</td>
1998     *                 </tr>
1999     *                 <tr>
2000     *                   <td>0x0015+N</td>
2001     *                   <td>M</td>
2002     *                   <td>Fill</td>
2003     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
2004     *                 </tr>
2005     *               </table></div>
2006     *               <div class="en"><table border="1">
2007     *                 <tr>
2008     *                   <th>Offset </th>
2009     *                   <th>Length(byte)</th>
2010     *                   <th>Variable name</th>
2011     *                   <th>Description</th>
2012     *                 </tr>
2013     *                 <tr>
2014     *                   <td>0x0000</td>
2015     *                   <td>1</td>
2016     *                   <td>WKeyIndex</td>
2017     *                   <td>1~99。</td>
2018     *                 </tr>
2019     *                 <tr>
2020     *                   <td>0x0001</td>
2021     *                   <td>1</td>
2022     *                   <td>WKeyLen</td>
2023     *                   <td>16。</td>
2024     *                 </tr>
2025     *                 <tr>
2026     *                   <td>0x0002</td>
2027     *                   <td>1</td>
2028     *                   <td>Mode</td>
2029     *                   <td>0x00: ECB decryption.;<br> 0x01: ECB encryption;<br> 0x02: CBC decryption;<br> 0x03: CBC encryption;</td>
2030     *                 </tr>
2031     *                 <tr>
2032     *                   <td>0x0003</td>
2033     *                   <td>2</td>
2034     *                   <td>DataInLen</td>
2035     *                   <td>The length of DataIn.</td>
2036     *                 </tr>
2037     *                 <tr>
2038     *                   <td>0x0005</td>
2039     *                   <td>N</td>
2040     *                   <td>DataIn</td>
2041     *                   <td>Data to be encrypted and decrypted.</td>
2042     *                 </tr>
2043     *                 <tr>
2044     *                   <td>0x0005+N</td>
2045     *                   <td>16</td>
2046     *                   <td>IV</td>
2047     *                   <td>16-byte initialization vector. Not required for ECB.</td>
2048     *                 </tr>
2049     *                 <tr>
2050     *                   <td>0x0015+N</td>
2051     *                   <td>M</td>
2052     *                   <td>Fill</td>
2053     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
2054     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
2055     *                 </tr>
2056     *               </table></div>
2057     * @return <div class="zh">加解密的结果。</div> <div class="en">The result of encryption and decryption.</div>
2058     * @throws TypeAException TypeAException
2059     */
2060    byte[] calcSM4Data(byte cipherFlag, byte[] dataIn) throws TypeAException;
2061
2062    /**
2063     * <div class="zh">使用 SM2 算法获得签名信息。</div> <div class="en">Use SM2 algorithm to obtain signature information.</div>
2064     *
2065     * @param cipherFlag <div class="zh"><ul>
2066     *                     <li>0x00: dataIn 是明文。</li>
2067     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
2068     *                   </ul></div>
2069     *                   <div class="en"><ul>
2070     *                     <li>0x00: dataIn is plain text.</li>
2071     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
2072     *                   </ul></div>
2073     * @param dataIn <div class="zh"><table border="1">
2074     *                 <tr>
2075     *                   <th>偏移位置</th>
2076     *                   <th>长度(byte)</th>
2077     *                   <th>变量名称</th>
2078     *                   <th>意义</th>
2079     *                 </tr>
2080     *                 <tr>
2081     *                   <td>0x0000</td>
2082     *                   <td>1</td>
2083     *                   <td>PubKeyIndex</td>
2084     *                   <td>SM2公钥索引: 1~93。</td>
2085     *                 </tr>
2086     *                 <tr>
2087     *                   <td>0x0001</td>
2088     *                   <td>1</td>
2089     *                   <td>PrvKeyIndex</td>
2090     *                   <td>SM2私钥索引: 1~97。</td>
2091     *                 </tr>
2092     *                 <tr>
2093     *                   <td>0x0002</td>
2094     *                   <td>2</td>
2095     *                   <td>PrvKeyLenBit</td>
2096     *                   <td>私钥位数。</td>
2097     *                 </tr>
2098     *                 <tr>
2099     *                   <td>0x0004</td>
2100     *                   <td>2</td>
2101     *                   <td>UidLen</td>
2102     *                   <td>Uid的长度。</td>
2103     *                 </tr>
2104     *                 <tr>
2105     *                   <td>0x0006</td>
2106     *                   <td>N</td>
2107     *                   <td>Uid</td>
2108     *                   <td>签名者 ID。</td>
2109     *                 </tr>
2110     *                 <tr>
2111     *                   <td>0x0006+N</td>
2112     *                   <td>2</td>
2113     *                   <td>DataInLen</td>
2114     *                   <td>DataIn长度。</td>
2115     *                 </tr>
2116     *                 <tr>
2117     *                   <td>0x0008+N</td>
2118     *                   <td>M</td>
2119     *                   <td>DataIn</td>
2120     *                   <td>待签名的数据。</td>
2121     *                 </tr>
2122     *                 <tr>
2123     *                   <td>0x0008+N+M</td>
2124     *                   <td>M</td>
2125     *                   <td>Fill</td>
2126     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
2127     *                 </tr>
2128     *               </table></div>
2129     *               <div class="en"><table border="1">
2130     *                 <tr>
2131     *                   <th>Offset </th>
2132     *                   <th>Length(byte)</th>
2133     *                   <th>Variable name</th>
2134     *                   <th>Description</th>
2135     *                 </tr>
2136     *                 <tr>
2137     *                   <td>0x0000</td>
2138     *                   <td>1</td>
2139     *                   <td>PubKeyIndex</td>
2140     *                   <td>SM2 public key index: 1~93。</td>
2141     *                 </tr>
2142     *                 <tr>
2143     *                   <td>0x0001</td>
2144     *                   <td>1</td>
2145     *                   <td>PrvKeyIndex</td>
2146     *                   <td>SM2 private key index: 1~97。</td>
2147     *                 </tr>
2148     *                 <tr>
2149     *                   <td>0x0002</td>
2150     *                   <td>2</td>
2151     *                   <td>PrvKeyLenBit</td>
2152     *                   <td>The number of bits of the private key.</td>
2153     *                 </tr>
2154     *                 <tr>
2155     *                   <td>0x0004</td>
2156     *                   <td>2</td>
2157     *                   <td>UidLen</td>
2158     *                   <td>The length of Uid.</td>
2159     *                 </tr>
2160     *                 <tr>
2161     *                   <td>0x0006</td>
2162     *                   <td>N</td>
2163     *                   <td>Uid</td>
2164     *                   <td>Signer ID.</td>
2165     *                 </tr>
2166     *                 <tr>
2167     *                   <td>0x0006+N</td>
2168     *                   <td>2</td>
2169     *                   <td>DataInLen</td>
2170     *                   <td>The length of DataIn.</td>
2171     *                 </tr>
2172     *                 <tr>
2173     *                   <td>0x0008+N</td>
2174     *                   <td>M</td>
2175     *                   <td>DataIn</td>
2176     *                   <td>The data to be signed.</td>
2177     *                 </tr>
2178     *                 <tr>
2179     *                   <td>0x0015+N</td>
2180     *                   <td>M</td>
2181     *                   <td>Fill</td>
2182     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
2183     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
2184     *                 </tr>
2185     *               </table></div>
2186     * @return <div class="zh">64字节的签名数据。</div> <div class="en">64 bytes of signature data.</div>
2187     * @throws TypeAException TypeAException
2188     */
2189    byte[] SM2Sign(byte cipherFlag, byte[] dataIn) throws TypeAException;
2190
2191    /**
2192     * <div class="zh">使用 SM2 公钥验证签名。</div> <div class="en">Use the SM2 public key to verify the signature.</div>
2193     *
2194     * @param cipherFlag <div class="zh"><ul>
2195     *                     <li>0x00: dataIn 是明文。</li>
2196     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
2197     *                   </ul></div>
2198     *                   <div class="en"><ul>
2199     *                     <li>0x00: dataIn is plain text.</li>
2200     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
2201     *                   </ul></div>
2202     * @param dataIn <div class="zh"><table border="1">
2203     *                 <tr>
2204     *                   <th>偏移位置</th>
2205     *                   <th>长度(byte)</th>
2206     *                   <th>变量名称</th>
2207     *                   <th>意义</th>
2208     *                 </tr>
2209     *                 <tr>
2210     *                   <td>0x0000</td>
2211     *                   <td>1</td>
2212     *                   <td>PubKeyIndex</td>
2213     *                   <td>SM2公钥索引: 1~93。</td>
2214     *                 </tr>
2215     *                 <tr>
2216     *                   <td>0x0001</td>
2217     *                   <td>2</td>
2218     *                   <td>PubKeyLenBit</td>
2219     *                   <td>公钥位数。</td>
2220     *                 </tr>
2221     *                 <tr>
2222     *                   <td>0x0003</td>
2223     *                   <td>2</td>
2224     *                   <td>UidLen</td>
2225     *                   <td>Uid的长度。</td>
2226     *                 </tr>
2227     *                 <tr>
2228     *                   <td>0x0005</td>
2229     *                   <td>N</td>
2230     *                   <td>Uid</td>
2231     *                   <td>签名者 ID。</td>
2232     *                 </tr>
2233     *                 <tr>
2234     *                   <td>0x0005+N</td>
2235     *                   <td>2</td>
2236     *                   <td>DataInLen</td>
2237     *                   <td>DataIn长度。小于等于1024。</td>
2238     *                 </tr>
2239     *                 <tr>
2240     *                   <td>0x0007+N</td>
2241     *                   <td>M</td>
2242     *                   <td>DataIn</td>
2243     *                   <td>待签名的数据。</td>
2244     *                 </tr>
2245     *                 <tr>
2246     *                   <td>0x0007+N+M</td>
2247     *                   <td>64</td>
2248     *                   <td>Signature</td>
2249     *                   <td>签名值,固定为 64 字节。</td>
2250     *                 </tr>
2251     *                 <tr>
2252     *                   <td>0x0047+N+M</td>
2253     *                   <td>L</td>
2254     *                   <td>Fill</td>
2255     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
2256     *                 </tr>
2257     *               </table></div>
2258     *               <div class="en"><table border="1">
2259     *                 <tr>
2260     *                   <th>Offset </th>
2261     *                   <th>Length(byte)</th>
2262     *                   <th>Variable name</th>
2263     *                   <th>Description</th>
2264     *                 </tr>
2265     *                 <tr>
2266     *                   <td>0x0000</td>
2267     *                   <td>1</td>
2268     *                   <td>PubKeyIndex</td>
2269     *                   <td>SM2 public key index: 1~93。</td>
2270     *                 </tr>
2271     *                 <tr>
2272     *                   <td>0x0001</td>
2273     *                   <td>2</td>
2274     *                   <td>PubKeyLenBit</td>
2275     *                   <td>The number of bits of the public key.</td>
2276     *                 </tr>
2277     *                 <tr>
2278     *                   <td>0x0003</td>
2279     *                   <td>2</td>
2280     *                   <td>UidLen</td>
2281     *                   <td>The length of Uid.</td>
2282     *                 </tr>
2283     *                 <tr>
2284     *                   <td>0x0005</td>
2285     *                   <td>N</td>
2286     *                   <td>Uid</td>
2287     *                   <td>Signer ID.</td>
2288     *                 </tr>
2289     *                 <tr>
2290     *                   <td>0x0005+N</td>
2291     *                   <td>2</td>
2292     *                   <td>DataInLen</td>
2293     *                   <td>The length of DataIn.</td>
2294     *                 </tr>
2295     *                 <tr>
2296     *                   <td>0x0007+N</td>
2297     *                   <td>M</td>
2298     *                   <td>DataIn</td>
2299     *                   <td>The data to be signed.</td>
2300     *                 </tr>
2301     *                 <tr>
2302     *                   <td>0x0007+N+M</td>
2303     *                   <td>64</td>
2304     *                   <td>Signature</td>
2305     *                   <td>The signature value is fixed at 64 bytes.</td>
2306     *                 </tr>
2307     *                 <tr>
2308     *                   <td>0x0047+N+M</td>
2309     *                   <td>M</td>
2310     *                   <td>Fill</td>
2311     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
2312     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
2313     *                 </tr>
2314     *               </table></div>
2315     * @throws TypeAException TypeAException
2316     */
2317    void SM2Verify(byte cipherFlag, byte[] dataIn) throws  TypeAException;
2318
2319    /**
2320     * <div class="zh">使用 SM2 公钥加密数据或私钥解密数据。</div>
2321     * <div class="en">Use SM2 public key to encrypt data or private key to decrypt data.</div>
2322     *
2323     * @param cipherFlag <div class="zh"><ul>
2324     *                     <li>0x00: dataIn 是明文。</li>
2325     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
2326     *                   </ul></div>
2327     *                   <div class="en"><ul>
2328     *                     <li>0x00: dataIn is plain text.</li>
2329     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
2330     *                   </ul></div>
2331     * @param dataIn <div class="zh"><table border="1">
2332     *                 <tr>
2333     *                   <th>偏移位置</th>
2334     *                   <th>长度(byte)</th>
2335     *                   <th>变量名称</th>
2336     *                   <th>意义</th>
2337     *                 </tr>
2338     *                 <tr>
2339     *                   <td>0x0000</td>
2340     *                   <td>1</td>
2341     *                   <td>KeyIndex</td>
2342     *                   <td>SM2公钥索引: 1~93; <br> SM2私钥索引: 1~97。</td>
2343     *                 </tr>
2344     *                 <tr>
2345     *                   <td>0x0001</td>
2346     *                   <td>2</td>
2347     *                   <td>KeyLenBit</td>
2348     *                   <td>SM2密钥位数。</td>
2349     *                 </tr>
2350     *                 <tr>
2351     *                   <td>0x0003</td>
2352     *                   <td>1</td>
2353     *                   <td>Mode</td>
2354     *                   <td>0x00: 使用SM2私钥解密数据; <br> 0x01: 使用SM2公钥加密数据。</td>
2355     *                 </tr>
2356     *                 <tr>
2357     *                   <td>0x0004</td>
2358     *                   <td>2</td>
2359     *                   <td>DataInLen</td>
2360     *                   <td>DataIn长度。小于等于1024。</td>
2361     *                 </tr>
2362     *                 <tr>
2363     *                   <td>0x0006</td>
2364     *                   <td>N</td>
2365     *                   <td>DataIn</td>
2366     *                   <td>待加密或者解密的数据。</td>
2367     *                 </tr>
2368     *                 <tr>
2369     *                   <td>0x0006+N</td>
2370     *                   <td>L</td>
2371     *                   <td>Fill</td>
2372     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
2373     *                 </tr>
2374     *               </table></div>
2375     *               <div class="en"><table border="1">
2376     *                 <tr>
2377     *                   <th>Offset </th>
2378     *                   <th>Length(byte)</th>
2379     *                   <th>Variable name</th>
2380     *                   <th>Description</th>
2381     *                 </tr>
2382     *                 <tr>
2383     *                   <td>0x0000</td>
2384     *                   <td>1</td>
2385     *                   <td>KeyIndex</td>
2386     *                   <td>SM2 public key index: 1~93; <br> SM2 private key index: 1~97。</td>
2387     *                 </tr>
2388     *                 <tr>
2389     *                   <td>0x0001</td>
2390     *                   <td>2</td>
2391     *                   <td>KeyLenBit</td>
2392     *                   <td>SM2密钥位数。</td>
2393     *                 </tr>
2394     *                 <tr>
2395     *                   <td>0x0003</td>
2396     *                   <td>1</td>
2397     *                   <td>Mode</td>
2398     *                   <td>0x00: Use SM2 private key to decrypt data; <br> 0x01: Use SM2 public key to encrypt data.</td>
2399     *                 </tr>
2400     *                 <tr>
2401     *                   <td>0x0004</td>
2402     *                   <td>2</td>
2403     *                   <td>DataInLen</td>
2404     *                   <td>DataIn length. Less than or equal to 1024.</td>
2405     *                 </tr>
2406     *                 <tr>
2407     *                   <td>0x0006</td>
2408     *                   <td>N</td>
2409     *                   <td>DataIn</td>
2410     *                   <td>The data to be encrypted or decrypted.</td>
2411     *                 </tr>
2412     *                 <tr>
2413     *                   <td>0x0006+N</td>
2414     *                   <td>M</td>
2415     *                   <td>Fill</td>
2416     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
2417     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
2418     *                 </tr>
2419     *               </table></div>
2420     * @return <div class="zh">计算结果。数据长度:加密时为源数据长度加96字节; 解密时为源数据长度减96字节。</div>
2421     *         <div class="en">Calculation results. Data length: When encrypting, the length of the source data plus 96 bytes;
2422     *           when decrypting, the length of the source data minus 96 bytes.</div>
2423     * @throws TypeAException TypeAException
2424     */
2425    byte[] calcSM2Data(byte cipherFlag, byte[] dataIn) throws TypeAException;
2426
2427    /**
2428     * <div class="zh">使用 SM3 算法计算杂凑值。</div> <div class="en">The SM3 algorithm is used to calculate the hash value.</div>
2429     * @param cipherFlag <div class="zh"><ul>
2430     *                     <li>0x00: dataIn 是明文。</li>
2431     *                     <li>0x01: dataIn 是由传输密钥(TXK)加密。</li>
2432     *                   </ul></div>
2433     *                   <div class="en"><ul>
2434     *                     <li>0x00: dataIn is plain text.</li>
2435     *                     <li>0x01: dataIn is encrypted by the exchange key(TXK).</li>
2436     *                   </ul></div>
2437     * @param dataIn <div class="zh"><table border="1">
2438     *                 <tr>
2439     *                   <th>偏移位置</th>
2440     *                   <th>长度(byte)</th>
2441     *                   <th>变量名称</th>
2442     *                   <th>意义</th>
2443     *                 </tr>
2444     *                 <tr>
2445     *                   <td>0x0000</td>
2446     *                   <td>1</td>
2447     *                   <td>Mode</td>
2448     *                   <td>0x00: 目前只支持0x00; <br>其他值保留。</td>
2449     *                 </tr>
2450     *                 <tr>
2451     *                   <td>0x0001</td>
2452     *                   <td>2</td>
2453     *                   <td>DataInLen</td>
2454     *                   <td>DataIn长度。小于等于1024。</td>
2455     *                 </tr>
2456     *                 <tr>
2457     *                   <td>0x0003</td>
2458     *                   <td>N</td>
2459     *                   <td>DataIn</td>
2460     *                   <td>待计算的数据。</td>
2461     *                 </tr>
2462     *                 <tr>
2463     *                   <td>0x0003+N</td>
2464     *                   <td>L</td>
2465     *                   <td>Fill</td>
2466     *                   <td>加密传输时的填充字节,以上数据长度不被8 字节整除时,填充至 8 字节整除的个数,明文传输时没有该域。</td>
2467     *                 </tr>
2468     *               </table></div>
2469     *               <div class="en"><table border="1">
2470     *                 <tr>
2471     *                   <th>Offset </th>
2472     *                   <th>Length(byte)</th>
2473     *                   <th>Variable name</th>
2474     *                   <th>Description</th>
2475     *                 </tr>
2476     *                 <tr>
2477     *                   <td>0x0000</td>
2478     *                   <td>1</td>
2479     *                   <td>Mode</td>
2480     *                   <td>0x00: Currently only 0x00 is supported; <br>Other values are reserved.</td>
2481     *                 </tr>
2482     *                 <tr>
2483     *                   <td>0x0001</td>
2484     *                   <td>2</td>
2485     *                   <td>DataInLen</td>
2486     *                   <td>DataIn length. Less than or equal to 1024.</td>
2487     *                 </tr>
2488     *                 <tr>
2489     *                   <td>0x0003</td>
2490     *                   <td>N</td>
2491     *                   <td>DataIn</td>
2492     *                   <td>The data to be calculated.</td>
2493     *                 </tr>
2494     *                 <tr>
2495     *                   <td>0x0003+N</td>
2496     *                   <td>M</td>
2497     *                   <td>Fill</td>
2498     *                   <td>The padding byte during encrypted transmission. When the above data length is not divisible by 8 bytes,
2499     *                     it is filled to the number evenly divisible by 8 bytes. There is no such field in plaintext transmission.</td>
2500     *                 </tr>
2501     *               </table></div>
2502     * @return <div class="zh"></div> <div class="en"></div>
2503     * @throws TypeAException TypeAException
2504     */
2505    byte[] getSM3Hash(byte cipherFlag, byte[] dataIn) throws TypeAException;
2506
2507    /**
2508     * <div class="zh">按所选序号播放语音。必须支持语音芯片</div>
2509     * <div class="en">Play the voice according to the selected sequence number. Must support voice chip</div>
2510     *
2511     * @param type <div class="zh"><ul>
2512     *               <li>0x01: "请拍卡。</li>
2513     *               <li>0x02: "请重新拍卡"。</li>
2514     *               <li>0x03: "请输入密码"。</li>
2515     *               <li>0x04: "请输入信息"。</li>
2516     *               <li>0x05: "请重新输入"。</li>
2517     *               <li>0x06: "嘀"。</li>
2518     *               <li>0x07: "Please tap the card"。</li>
2519     *               <li>0x08: "Please re-tap the card"。</li>
2520     *               <li>0x09: "Please enter password"。</li>
2521     *               <li>0x0A: "Please input information"。</li>
2522     *               <li>0x0B: "Please re-input"。</li>
2523     *               <li>0x0C: 音效 1。</li>
2524     *               <li>0x0D: 音效 2。</li>
2525     *               <li>0x0E: 音效 3。</li>
2526     *               <li>0x0F: 音效 4。</li>
2527     *               <li>0x10: 音效 5。</li>
2528     *               <li>0x11: 音效 6。</li>
2529     *               <li>0x12: 音效 7。</li>
2530     *             </ul></div>
2531     *             <div class="en"><ul>
2532     *               <li>0x01: "请拍卡".</li>
2533     *               <li>0x02: "请重新拍卡".</li>
2534     *               <li>0x03: "请输入密码".</li>
2535     *               <li>0x04: "请输入信息".</li>
2536     *               <li>0x05: "请重新输入".</li>
2537     *               <li>0x06: "Beep".</li>
2538     *               <li>0x07: "Please tap the card".</li>
2539     *               <li>0x08: "Please re-tap the card".</li>
2540     *               <li>0x09: "Please enter password".</li>
2541     *               <li>0x0A: "Please input information".</li>
2542     *               <li>0x0B: "Please re-input".</li>
2543     *               <li>0x0C: Sound effect 1.</li>
2544     *               <li>0x0D: Sound effect 2.</li>
2545     *               <li>0x0E: Sound effect 3.</li>
2546     *               <li>0x0F: Sound effect 4.</li>
2547     *               <li>0x10: Sound effect 5.</li>
2548     *               <li>0x11: Sound effect 6.</li>
2549     *               <li>0x12: Sound effect 7.</li>
2550     *             </ul></div>
2551     * @throws TypeAException TypeAException
2552     */
2553    void playVoice(byte type) throws TypeAException;
2554
2555    /**
2556     * <div class="zh">调节音量等级。必须支持语音芯片</div> <div class="en">Adjust the volume level. Must support voice chip</div>
2557     *
2558     * @param level <div class="zh">范围为 0 至 7 档。 0 档对应静音。</div>
2559     *              <div class="en">The range is from 0 to 7 level。Level 0 corresponds to mute.</div>
2560     * @throws TypeAException TypeAException
2561     */
2562    void setVolumeLevel(byte level) throws TypeAException;
2563
2564    /**
2565     * <div class="zh">EPS 专用接口。</div> <div class="en">EPS dedicated interface.</div>
2566     *
2567     * @param option <div class="zh"><ul>
2568     *                 <li>0x01: 下载初始 TMK,方式一。由 POS 产生临时 KEY,上传主机,取回密文 TMK1 和临时加密参考值,由临时 KEY 对密文 TMK1 解密,得 TMK,
2569     *                   明文 TMK 应符合奇校验;TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,加密后的结 果前四字节应与加密参考值相等,之后将明文 TMK
2570     *                   写入 WKeyID1 低 7 位所指定的工作密钥区位置。</li>
2571     *                 <li>0x02: 更新 TMK 或 下载 TPK。用WKeyID1处的TMK对主机下传的新的密文解密,明文应符合奇校验,之后将明文结果写入WKeyID2 位置。
2572     *                   更新 TMK:主机下传新的密文 TMK2,用明文 TMK1 对 TMK2 解密,明文 TMK2 应符合奇校验, 之后将明文 TMK2 写入 WKeyID2 位置。
2573     *                   当 WKeyID1 与 WKeyID2 相等时,即覆盖明文 TMK1。
2574     *                   下载 TPK:主机下传新的密文 TPK,用 WKeyID1 处的 TMK 对其解密,明文 TPK 应符合奇校验,之后将明文 TPK 写入 WKeyID2 位置。</li>
2575     *                 <li>0x03: 计算出输出 TAK 的密文。POS 送入 8 字节随机数(输出 TAK 的明文), 其应符合奇校验,用 MKeyID 处的 TMK 对其加密,返回其结果。</li>
2576     *                 <li>0x04: 冲正时重算 PIN-BLOCK 和更新 TPK。POS 送入 8 bytes pin_block,新的 ISN,新的 TPK,原 TPK WKeyID2,TMK WKeyID1,
2577     *                   PINPAD 用原 TPK 对 pin_block 按 X3.92 解密得到明文 PIN,再将新 TPK 用 TMK 解密,明文 TPK 应符合奇校验,新 TPK 替 换原 TPK,
2578     *                   之后用明文 TPK,ISN 对 PIN 按 X3.92 加密,返回新的 pin_block.</li>
2579     *                 <li>0x05: 交换输入 TAK。用 WKeyID1 处的 TMK 对主机下传的新的密文解密得到输入 TAK,明文应符合奇校验,对输入的数据 以输入 TAK 为密钥做 MAC 运算,
2580     *                   其结果与输入的 MAC 运算值(ASCII)相等(前 4 bytes),之后将明文结果 TAK 写入 WKeyID2 位置。</li>
2581     *                 <li>0x06: 校验 TMK。用原 TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,并返回结果。</li>
2582     *                 <li>0x08: 下载初始 TMK,方式二。 由 POS 产生临时 KEY,上传主机,取回密文 TMK1 和临时加密参考值,由临时 KEY 对密文 TMK1 解密,得 TMK,
2583     *                   明文 TMK 应符合奇校验;TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,加密后的结果前四字节应与加密参考值相等;之后将明文 TMK 写入
2584     *                   MWKeyID1 低 7 位所指定的主密钥或工作密钥区域。MWKeyID1 最高位为 0 时,表示 TMK 存入主密钥区域,为 1 时表示 TMK 存入工作密钥区域。</li>
2585     *               </ul></div>
2586     *               <div class="en"><ul>
2587     *                 <li>0x01: Download the initial TMK, method one. The POS generates a temporary KEY, uploads it to the host, retrieves the ciphertext TMK1
2588     *                   and the temporary encryption reference value, and decrypts the ciphertext TMK1 by the temporary KEY to obtain TMK,The plaintext TMK
2589     *                   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
2590     *                   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.</li>
2591     *                 <li>0x02: Update TMK or download TPK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host. The plaintext should
2592     *                   meet odd parity, and then write the plaintext result into the WKeyID2 location.
2593     *                   Update TMK: The host downloads the new ciphertext TMK2, decrypts TMK2 with the plaintext TMK1, the plaintext TMK2 should meet odd parity,
2594     *                   and then writes the plaintext TMK2 into the WKeyID2 location. When WKeyID1 and WKeyID2 are equal, the plaintext TMK1 is overwritten.
2595     *                   Download TPK: The host downloads the new ciphertext TPK, decrypts it with the TMK at WKeyID1, the plaintext TPK should meet odd parity,
2596     *                   and then writes the plaintext TPK into the WKeyID2 location.</li>
2597     *                 <li>0x03: Calculate the ciphertext of the output TAK. POS sends an 8-byte random number (the plaintext of TAK output), which should meet
2598     *                   odd parity, encrypt it with TMK at MKeyID, and return the result.</li>
2599     *                 <li>0x04: Recalculate PIN-BLOCK and update TPK during timing. POS sends 8 bytes pin_block, new ISN, new TPK, original TPK WKeyID2, TMK WKeyID1,
2600     *                   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.
2601     *                   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
2602     *                   to encrypt the PIN by X3.92, and return the new pin_block.</li>
2603     *                 <li>0x05: Exchange input TAK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host to obtain the input TAK.
2604     *                   The plaintext should meet odd parity. The input data is used to perform MAC operations with the input TAK as the key. The result
2605     *                   is the same as the input MAC operation value (ASCII ) Are equal (the first 4 bytes), and then write the plaintext result TAK into
2606     *                   the WKeyID2 position.</li>
2607     *                 <li>0x06: Verify TMK. Use the original TMK to encrypt "\x12\x34\x56\x78\x90\x12\x34\x56" and return the result.</li>
2608     *                 <li>0x08: Download the initial TMK, method two. The POS generates a temporary KEY, uploads it to the host, retrieves the ciphertext TMK1
2609     *                   and the temporary encryption reference value, and decrypts the ciphertext TMK1 by the temporary KEY to obtain TMK. The plaintext TMK
2610     *                   should meet odd parity; TMK pairs "\x12\x34\x56\" x78\x90\x12\x34\x56" encryption, the first four bytes of the encrypted result should
2611     *                   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
2612     *                   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
2613     *                   that TMK is stored in the working key area.</li>
2614     *               </ul></div>
2615     * @param dataIn <div class="zh"><ul>
2616     *                 <li>当option = 0x01时,dataIn = WKeyID1(1byte) + 临时 KEY(8bytes)+密文 TMK1(8bytes)+加密参考值(8bytes)。</li>
2617     *                 <li>当option = 0x02时, dataIn = WKeyID1(1byte) + WKeyID2(1byte)+密文 TMK2(8bytes)。</li>
2618     *                 <li>当option = 0x03时, dataIn = MKeyID(1byte) + 明文 Random(8bytes)。</li>
2619     *                 <li>当option = 0x04时, dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes)。</li>
2620     *                 <li>当option = 0x05时, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK 密文 (8bytes) +
2621     *                   rsp_data(rsp_len) + rsp_MAC(8byte, 将 MAC 码的前 4 字节进行值串转换后传入,如 0x123456AB 转换为“123456AB”)。</li>
2622     *                 <li>当option = 0x06时, dataIn = WKeyID1(1byte)。</li>
2623     *                 <li>当option = 0x08时, dataIn = MWKeyID1(1byte) + 临时 KEY(8bytes) + 密文 TMK1(8bytes) + 加密参考值(8bytes)。</li>
2624     *               </ul></div>
2625     *               <div class="en"><ul>
2626     *                 <li>When option = 0x01, dataIn = WKeyID1(1byte) + temporary KEY(8bytes) + ciphertext TMK1(8bytes) + encrypted reference value (8bytes).</li>
2627     *                 <li>When option = 0x02, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + cipher text TMK2(8bytes).</li>
2628     *                 <li>When option = 0x03, dataIn = MKeyID(1byte) + plaintext Random(8bytes).</li>
2629     *                 <li>When option = 0x04, dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes).</li>
2630     *                 <li>When option = 0x05, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK ciphertext (8bytes) + rsp_data(rsp_len) +
2631     *                   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").</li>
2632     *                 <li>When option = 0x06, dataIn = WKeyID1(1byte).</li>
2633     *                 <li>When option = 0x08, dataIn = MWKeyID1(1byte) + temporary KEY(8bytes) + ciphertext TMK1(8bytes) + encrypted reference value (8bytes).</li>
2634     *               </ul></div>
2635     * @return <div class="zh"><ul>
2636     *           <li>当option = 0x01时,无返回结果。</li>
2637     *           <li>当option = 0x02时, 无返回结果。</li>
2638     *           <li>当option = 0x03时, 随机数密文(8bytes)。</li>
2639     *           <li>当option = 0x04时, 新的 pin_block(8bytes)。</li>
2640     *           <li>当option = 0x05时, 无返回结果。</li>
2641     *           <li>当option = 0x06时, 加密结果(8byte)。</li>
2642     *           <li>当option = 0x08时, 无返回结果。</li>
2643     *         </ul></div>
2644     *         <div class="en"><ul>
2645     *           <li>When option = 0x01, no result is returned.</li>
2646     *           <li>When option = 0x02, no result is returned.</li>
2647     *           <li>When option = 0x03, random number ciphertext (8bytes).</li>
2648     *           <li>When option = 0x04, new pin_block(8bytes).</li>
2649     *           <li>When option = 0x05, no result is returned.</li>
2650     *           <li>When option = 0x06, the encryption result (8byte).</li>
2651     *           <li>When option = 0x08, no result is returned.</li>
2652     *         </ul></div>
2653     * @throws TypeAException TypeAException
2654     */
2655    byte[] EPS(byte option, byte[] dataIn) throws TypeAException;
2656
2657    /**
2658     * <div class="zh">扩展的 EPS 专用接口。</div> <div class="en">Extended EPS dedicated interface.</div>
2659     *
2660     * @param option <div class="zh"><ul>
2661     *                 <li>0x01: 下载初始 TMK,方式一。由 POS 产生临时 KEY,上传主机,取回密文 TMK1 和临时加密参考值,由临时 KEY 对密文 TMK1 解密,得 TMK,
2662     *                   明文 TMK 应符合奇校验;TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,加密后的结 果前四字节应与加密参考值相等,之后将明文 TMK
2663     *                   写入 WKeyID1 低 7 位所指定的工作密钥区位置。</li>
2664     *                 <li>0x02: 更新 TMK 或 下载 TPK。用WKeyID1处的TMK对主机下传的新的密文解密,明文应符合奇校验,之后将明文结果写入WKeyID2 位置。
2665     *                   更新 TMK:主机下传新的密文 TMK2,用明文 TMK1 对 TMK2 解密,明文 TMK2 应符合奇校验, 之后将明文 TMK2 写入 WKeyID2 位置。
2666     *                   当 WKeyID1 与 WKeyID2 相等时,即覆盖明文 TMK1。
2667     *                   下载 TPK:主机下传新的密文 TPK,用 WKeyID1 处的 TMK 对其解密,明文 TPK 应符合奇校验,之后将明文 TPK 写入 WKeyID2 位置。</li>
2668     *                 <li>0x03: 计算出输出 TAK 的密文。POS 送入 8 或者 16 或者 24 字节随机数(输出 TAK 的明文), 其应符合奇校验,用 MKeyID 处的 TMK 对其加密,返回其结果。</li>
2669     *                 <li>0x04: 冲正时重算 PIN-BLOCK 和更新 TPK。POS 送入 8 bytes pin_block,新的 ISN,新的 TPK,原 TPK WKeyID2,TMK WKeyID1
2670     *                   PINPAD 用原 TPK 对 pin_block 按 X3.92 解密得到明文 PIN,再将新 TPK 用 TMK 解密,明文 TPK 应符合奇校验,新 TPK 替 换原 TPK,
2671     *                   之后用明文 TPK,ISN 对 PIN 按 X3.92 加密,返回新的 pin_block.</li>
2672     *                 <li>0x05: 交换输入 TAK。用 WKeyID1 处的 TMK 对主机下传的新的密文解密得到输入 TAK,明文应符合奇校验,对输入的数据 以输入 TAK 为密钥做 MAC 运算,
2673     *                   其结果与输入的 MAC 运算值(ASCII)相等(前 4 bytes),之后将明文结果 TAK 写入 WKeyID2 位置。进行的 MAC 运算共有算法 1 和算法 2 两种,由 Mode 来指定。
2674     *                   MAC 算法 1: 若密钥为 8 字节,则依次连续进行 DES/异或/DES/异或/…/DES;若密钥为 16 字节或 24 字节,则依次连续进行 3DES/异或/3DES/异或/…/3DES 的运算。
2675     *                   MAC 算法 2:若密钥为 8 字节,则依次连续进行 DES/异或/DES/异或/…/DES 的运算;若密钥为 16 字节或 24 字节,则依次连续进行 DES/异或/DES/异或/…/3DES 的运算,注意最后一次为 3DES 运算。
2676     *                   如果密钥为 8 字节,则算法 1 和算法 2 是相同的。</li>
2677     *                 <li>0x06: 校验 TMK。用原 TMK 对"\x12\x34\x56\x78\x90\x12\x34\x56"加密,并返回结果。</li>
2678     *               </ul></div>
2679     *               <div class="en"><ul>
2680     *               <li>0x01: Download the initial TMK, method one. The POS generates a temporary KEY, uploads it to the host, retrieves the ciphertext TMK1
2681     *                  and the temporary encryption reference value, and decrypts the ciphertext TMK1 by the temporary KEY to obtain TMK,The plaintext TMK
2682     *                  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
2683     *                  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
2684     *                <li>0x02: Update TMK or download TPK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host. The plaintext should
2685     *                  meet odd parity, and then write the plaintext result into the WKeyID2 location.
2686     *                  Update TMK: The host downloads the new ciphertext TMK2, decrypts TMK2 with the plaintext TMK1, the plaintext TMK2 should meet odd parity,
2687     *                  and then writes the plaintext TMK2 into the WKeyID2 location. When WKeyID1 and WKeyID2 are equal, the plaintext TMK1 is overwritten.
2688     *                  Download TPK: The host downloads the new ciphertext TPK, decrypts it with the TMK at WKeyID1, the plaintext TPK should meet odd parity,
2689     *                  and then writes the plaintext TPK into the WKeyID2 location.</li>
2690     *                <li>0x03: Calculate the ciphertext of the output TAK. POS sends an 8 or 16 or 24-byte random number (the plaintext of TAK output),
2691     *                  which should meet odd parity, encrypt it with TMK at MKeyID, and return the result.</li>
2692     *                <li>0x04: Recalculate PIN-BLOCK and update TPK during timing. POS sends 8 bytes pin_block, new ISN, new TPK, original TPK WKeyID2, TMK WKeyID1,
2693     *                  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.
2694     *                  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
2695     *                  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. 
2696     *                  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, 
2697     *                  then 3DES/XOR will be successively performed /3DES/XOR/.../3DES operation. 
2698     *                  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, 
2699     *                  the DES/ will be successively performed successively. XOR/DES/XOR/.../3DES operation, note that the last operation is 3DES operation. 
2700     *                  If the key is 8 bytes, then Algorithm 1 and Algorithm 2 are the same.</li>
2701     *                <li>0x05: Exchange input TAK. Use the TMK at WKeyID1 to decrypt the new ciphertext downloaded from the host to obtain the input TAK.
2702     *                  The plaintext should meet odd parity. The input data is used to perform MAC operations with the input TAK as the key. The result
2703     *                  is the same as the input MAC operation value (ASCII ) Are equal (the first 4 bytes), and then write the plaintext result TAK into
2704     *                  the WKeyID2 position.</li>
2705     *                <li>0x06: Verify TMK. Use the original TMK to encrypt "\x12\x34\x56\x78\x90\x12\x34\x56" and return the result.</li>
2706     *               </ul></div>
2707     * @param mode <div class="zh"><ul>
2708     *                 <li>0x01: DES 加密方式。</li>
2709     *                 <li>0x03: 3DES 加密方式。</li>
2710     *                 <li>0x07: 3DES 加密方式。</li>
2711     *                 <li>0x31: 3DES 加密方式。</li>
2712     *                 <li>0x33: 3DES 加密方式。</li>
2713     *                 <li>0x71: 3DES 加密方式。</li>
2714     *                 <li>0x73: 3DES 加密方式。</li>
2715     *                 <li>0x77: 3DES 加密方式。</li>
2716     *                 <li>0x81: 8 字节 DES 密钥方式; DES 解密方式; </li>
2717     *                 <li>0x83: 3DES 解密方式。</li>
2718     *                 <li>0x87: 3DES 解密方式。</li>
2719     *                 <li>0x89: DES 解密方式。</li>
2720     *                 <li>0x8B: 3DES 解密方式。</li>
2721     *                 <li>0x8F: 3DES 解密方式。</li>
2722     *                 <li>0xB1: 3DES 解密方式。</li>
2723     *                 <li>0xB3: 16 字节 3DES 密钥方式; 3DES 解密方式;</li>
2724     *                 <li>0xB9: 3DES 解密方式。</li>
2725     *                 <li>0xBB: 3DES 解密方式。</li>
2726     *                 <li>0xF1: 3DES 解密方式。</li>
2727     *                 <li>0xF3: 3DES 解密方式。</li>
2728     *                 <li>0xF7: 24 字节 3DES 密钥方式; 3DES 解密方式;</li>
2729     *                 <li>0xF9: 3DES 解密方式。</li>
2730     *                 <li>0xFB: 3DES 解密方式。</li>
2731     *                 <li>0xFF: 3DES 解密方式。</li>
2732     *               </ul></div>
2733     *               <div class="en"><ul>
2734     *                 <li>0x01: DES encryption method.</li>
2735     *                 <li>0x03: 3DES encryption method.</li>
2736     *                 <li>0x07: 3DES encryption method.</li>
2737     *                 <li>0x31: 3DES encryption method.</li>
2738     *                 <li>0x33: 3DES encryption method.</li>
2739     *                 <li>0x71: 3DES encryption method.</li>
2740     *                 <li>0x73: 3DES encryption method.</li>
2741     *                 <li>0x77: 3DES encryption method.</li>
2742     *                 <li>0x81: 8-byte DES key mode; DES encryption method; </li>
2743     *                 <li>0x83: 3DES decryption method.</li>
2744     *                 <li>0x87: 3DES decryption method.</li>
2745     *                 <li>0x89: DES decryption method.</li>
2746     *                 <li>0x8B: 3DES decryption method.</li>
2747     *                 <li>0x8F: 3DES decryption method.</li>
2748     *                 <li>0xB1: 3DES decryption method.</li>
2749     *                 <li>0xB3: 16-byte DES key mode; 3DES decryption method;</li>
2750     *                 <li>0xB9: 3DES decryption method.</li>
2751     *                 <li>0xBB: 3DES decryption method.</li>
2752     *                 <li>0xF1: 3DES decryption method.</li>
2753     *                 <li>0xF3: 3DES decryption method.</li>
2754     *                 <li>0xF7: 24-byte DES key mode; 3DES decryption method;</li>
2755     *                 <li>0xF9: 3DES decryption method.</li>
2756     *                 <li>0xFB: 3DES decryption method.</li>
2757     *                 <li>0xFF: 3DES decryption method.</li>
2758     *               </ul></div>
2759     * @param dataIn <div class="zh"><ul>
2760     *                 <li>当 option = 0x01 时,dataIn = WKeyID1(1byte) + 临时 KEY + 密文 TMK1 + 加密参考值(8bytes)。
2761     *                   <ul>
2762     *                     <li>当mode = 0x81 时,临时 KEY 与 密文 TMK1 均为 8 字节 DES 密钥。</li>
2763     *                     <li>当mode = 0xB3 时,临时 KEY 与 密文 TMK1 均为 16 字节 3DES 密钥。</li>
2764     *                     <li>当mode = 0xF7 时,临时 KEY 与 密文 TMK1 均为 24 字节 3DES 密钥。</li>
2765     *                   </ul>
2766     *                 </li>
2767     *                 <li>当 option = 0x02 时,dataIn = WKeyID1(1byte) + WKeyID2(1byte) + 密文 TMK2。
2768     *                   <ul>
2769     *                     <li>当 mode = 0x81 时,DES 解密方式,WKeyID1 密钥 8 字节,WKeyID2 密钥 8 字节 ,密文 TMK2 为 8 字节。</li>
2770     *                     <li>当 mode = 0x83 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。</li>
2771     *                     <li>当 mode = 0x87 时,3DES 解密方式,WKeyID1 密钥 24 字节, WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。</li>
2772     *                     <li>当 mode = 0xB1 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。</li>
2773     *                     <li>当 mode = 0xB3 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 16 字节,密文 TMK2 为 16 字节。</li>
2774     *                     <li>当 mode = 0xF1 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 8 字节,密文 TMK2 为 8 字节。</li>
2775     *                     <li>当 mode = 0xF3 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 16 字节,密文 TMK2 为 16 字节。</li>
2776     *                     <li>当 mode = 0xF7 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 24 字节,密文 TMK2 为 24 字节。</li>
2777     *                   </ul>
2778     *                 </li>
2779     *                 <li>当 option = 0x03 时,dataIn = MKeyID(1byte) + 明文 Random。
2780     *                   <ul>
2781     *                     <li>当 mode = 0x01 时,DES 加密方式,MKeyID 密钥 8 字节,Random 8 字节。</li>
2782     *                     <li>当 mode = 0x03 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 8 字节。</li>
2783     *                     <li>当 mode = 0x31 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 8 字节。</li>
2784     *                     <li>当 mode = 0x07 时,3DES 加密方式,MKeyID 密钥 24 字节,Random 8 字节。</li>
2785     *                     <li>当 mode = 0x71 时,3DES 加密方式,MKeyID 密钥 24 字节,Random 8 字节。</li>
2786     *                     <li>当 mode = 0x33 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 16 字节。</li>
2787     *                     <li>当 mode = 0x73 时,3DES 加密方式,MKeyID 密钥 16 字节,Random 16 字节。</li>
2788     *                     <li>当 mode = 0x77 时,3DES 加密方式,MKeyID 密钥 24 字节,Random 24 字节。</li>
2789     *                   </ul>
2790     *                 </li>
2791     *                 <li>当 option = 0x04 时,dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes)。
2792     *                   <ul>
2793     *                     <li>当 mode = 0x81 时,DES 解密方式,WKeyID1 密钥 8 字节,WKeyID2 密钥 8 字节。</li>
2794     *                     <li>当 mode = 0x83 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节。</li>
2795     *                     <li>当 mode = 0x87 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 8 字节。</li>
2796     *                     <li>当 mode = 0xB1 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 8 字节。</li>
2797     *                     <li>当 mode = 0xF1 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 8 字节。</li>
2798     *                     <li>当 mode = 0xB3 时,3DES 解密方式,WKeyID1 密钥 16 字节,WKeyID2 密钥 16 字节。</li>
2799     *                     <li>当 mode = 0xF3 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 16 字节。</li>
2800     *                     <li>当 mode = 0xF7 时,3DES 解密方式,WKeyID1 密钥 24 字节,WKeyID2 密钥 24 字节。</li>
2801     *                   </ul>
2802     *                 </li>
2803     *                 <li>当 option = 0x05 时,dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK 密文 +
2804     *                   rsp_data(rsp_len) + rsp_MAC(8byte, 将 MAC 码的前 4 字节进行值串转换后传入,如 0x123456AB 转换为“123456AB”)。
2805     *                   <ul>
2806     *                     <p>MAC算法1:</p>
2807     *                     <li>当 mode = 0x81 时,DES 解密方式,WKeyID1 密钥 8 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2808     *                     <li>当 mode = 0x83 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2809     *                     <li>当 mode = 0xB1 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2810     *                     <li>当 mode = 0x87 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2811     *                     <li>当 mode = 0xF1 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2812     *                     <li>当 mode = 0xB3 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 16 字节。</li>
2813     *                     <li>当 mode = 0xF3 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 16 字节。</li>
2814     *                     <li>当 mode = 0xF7 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 24 字节。</li>
2815     *                     <li>当 mode = 0x89 时,DES 解密方式,WKeyID1 密钥 8 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2816     *                     <li>当 mode = 0x8B 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2817     *                     <li>当 mode = 0xB9 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2818     *                     <li>当 mode = 0x8F 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2819     *                     <li>当 mode = 0xF9 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 8 字节。</li>
2820     *                     <p>MAC算法2:</p>
2821     *                     <li>当 mode = 0xBB 时,3DES 解密方式,WKeyID1 密钥 16 字节,TAK 与 WKeyID2 密钥均为 16 字节。</li>
2822     *                     <li>当 mode = 0xFB 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 16 字节。</li>
2823     *                     <li>当 mode = 0xFF 时,3DES 解密方式,WKeyID1 密钥 24 字节,TAK 与 WKeyID2 密钥均为 24 字节。</li>
2824     *                   </ul>
2825     *                 </li>
2826     *                 <li>当 option = 0x06 时,dataIn = WKeyID1(1byte)。
2827     *                   <ul>
2828     *                     <li>当 mode = 0x01 时,DES 加密方式,WKeyID1 密钥 8 字节。</li>
2829     *                     <li>当 mode = 0x03 时,3DES 加密方式,WKeyID1 密钥 16 字节。</li>
2830     *                     <li>当 mode = 0x07 时,3DES 加密方式,WKeyID1 密钥 24 字节。</li>
2831     *                   </ul>
2832     *                 </li>
2833     *               </ul></div>
2834     *               <div class="en"><ul>
2835     *                 <li>When option = 0x01, dataIn = WKeyID1(1byte) + temporary KEY(8bytes) + ciphertext TMK1 + encrypted reference value (8bytes).
2836     *                   <ul>
2837     *                     <li>When mode = 0x81, both temporary KEY and ciphertext TMK1 are 8-byte DES keys.</li>
2838     *                     <li>When mode = 0xB3, both temporary KEY and ciphertext TMK1 are 16-byte 3DES keys.</li>
2839     *                     <li>When mode = 0xF7, both temporary KEY and ciphertext TMK1 are 24byte 3DES keys.</li>
2840     *                   </ul>
2841     *                 </li>
2842     *                 <li>When option = 0x02, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + cipher text TMK2.
2843     *                   <ul>
2844     *                     <li>When mode = 0x81, DES decryption mode, WKeyID1 key is 8 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.</li>
2845     *                     <li>When mode = 0x83, 3DES decryption mode, WKeyID1 key is 16 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.</li>
2846     *                     <li>When mode = 0x87, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.</li>
2847     *                     <li>When mode = 0xB1, 3DES decryption mode, WKeyID1 key is 16 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.</li>
2848     *                     <li>When mode = 0xB3, 3DES decryption mode, WKeyID1 key is 16 bytes, WKeyID2 key is 16 bytes, and cipher text TMK2 is 16 bytes.</li>
2849     *                     <li>When mode = 0xF1, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 8 bytes, and cipher text TMK2 is 8 bytes.</li>
2850     *                     <li>When mode = 0xF3, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 16 bytes, and cipher text TMK2 is 16 bytes.</li>
2851     *                     <li>When mode = 0xF7, 3DES decryption mode, WKeyID1 key is 24 bytes, WKeyID2 key is 24 bytes, and cipher text TMK2 is 24 bytes.</li>
2852     *                   </ul>
2853     *                 </li>
2854     *                 <li>When option = 0x03, dataIn = MKeyID(1byte) + plaintext Random.
2855     *                   <ul>
2856     *                     <li>When mode = 0x01, DES encryption mode, MKeyID key 8 bytes, Random 8 bytes.</li>
2857     *                     <li>When mode = 0x03, 3DES encryption mode, MKeyID key 16 bytes, Random 8 bytes.</li>
2858     *                     <li>When mode = 0x31, 3DES encryption mode, MKeyID key 16 bytes, Random 8 bytes.</li>
2859     *                     <li>When mode = 0x07, 3DES encryption mode, MKeyID key 24 bytes, Random 8 bytes.</li>
2860     *                     <li>When mode = 0x71, 3DES encryption mode, MKeyID key 24 bytes, Random 8 bytes.</li>
2861     *                     <li>When mode = 0x33, 3DES encryption mode, MKeyID key 16 bytes, Random 16 bytes.</li>
2862     *                     <li>When mode = 0x73, 3DES encryption mode, MKeyID key 16 bytes, Random 16 bytes.</li>
2863     *                     <li>When mode = 0x77, 3DES encryption mode, MKeyID key 24 bytes, Random 24 bytes.</li>
2864     *                   </ul>
2865     *                 </li>
2866     *                 <li>When option = 0x04, dataIn = WKeyID1 + WKeyID2 + pin_block(8byte) + ISN(6byte) + new_TPK(8bytes).
2867     *                   <ul>
2868     *                     <li>When mode = 0x81, DES decryption mode, WKeyID1 key 8 bytes, WKeyID2 key 8 bytes.</li>
2869     *                     <li>When mode = 0x83, 3DES decryption mode, WKeyID1 key 16 bytes, WKeyID2 key 8 bytes.</li>
2870     *                     <li>When mode = 0x87, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 8 bytes.</li>
2871     *                     <li>When mode = 0xB1, 3DES decryption mode, WKeyID1 key 16 bytes, WKeyID2 key 8 bytes.</li>
2872     *                     <li>When mode = 0xF1, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 8 bytes.</li>
2873     *                     <li>When mode = 0xB3, 3DES decryption mode, WKeyID1 key 16 bytes, WKeyID2 key 16 bytes.</li>
2874     *                     <li>When mode = 0xF3, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 16 bytes.</li>
2875     *                     <li>When mode = 0xF7, 3DES decryption mode, WKeyID1 key 24 bytes, WKeyID2 key 24 bytes.</li>
2876     *                   </ul>
2877     *                 </li>
2878     *                 <li>When option = 0x05, dataIn = WKeyID1(1byte) + WKeyID2(1byte) + rsp_len(1byte) + TAK ciphertext + rsp_data(rsp_len) +
2879     *                   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").
2880     *                   <ul>
2881     *                     <p>MAC algorithm 1:</p>
2882     *                     <li>When mode = 0x81, DES decryption mode, WKeyID1 key is 8 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2883     *                     <li>When mode = 0x83, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2884     *                     <li>When mode = 0xB1, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2885     *                     <li>When mode = 0x87, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2886     *                     <li>When mode = 0xF1, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2887     *                     <li>When mode = 0xB3, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 16 bytes.</li>
2888     *                     <li>When mode = 0xF3, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 16 bytes.</li>
2889     *                     <li>When mode = 0xF7, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 24 bytes.</li>
2890     *                     <li>When mode = 0x89, DES decryption mode, WKeyID1 key is 8 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2891     *                     <li>When mode = 0x8B, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2892     *                     <li>When mode = 0xB9, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2893     *                     <li>When mode = 0x8F, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2894     *                     <li>When mode = 0xF9, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 8 bytes.</li>
2895     *                     <p>MAC algorithm 2:</p>
2896     *                     <li>When mode = 0xBB, 3DES decryption mode, WKeyID1 key is 16 bytes, TAK and WKeyID2 keys are both 16 bytes.</li>
2897     *                     <li>When mode = 0xFB, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 16 bytes.</li>
2898     *                     <li>When mode = 0xFF, 3DES decryption mode, WKeyID1 key is 24 bytes, TAK and WKeyID2 keys are both 24 bytes.</li>
2899     *                   </ul>
2900     *                 </li>
2901     *                 <li>When option = 0x06, dataIn = WKeyID1(1byte).
2902     *                   <ul>
2903     *                     <li>When mode = 0x01, DES encryption mode, WKeyID1 key is 8 bytes.</li>
2904     *                     <li>When mode = 0x03, 3DES encryption mode, WKeyID1 key is 16 bytes.</li>
2905     *                     <li>When mode = 0x07, 3DES encryption mode, WKeyID1 key is 24 bytes.</li>
2906     *                   </ul>
2907     *                 </li>
2908     *               </ul></div>
2909     * @return <div class="zh"><ul>
2910     *           <li>当option = 0x01时,无返回结果。</li>
2911     *           <li>当option = 0x02时, 无返回结果。</li>
2912     *           <li>当option = 0x03时, 随机数密文(8bytes)。</li>
2913     *           <li>当option = 0x04时, 新的 pin_block(8bytes)。</li>
2914     *           <li>当option = 0x05时, 无返回结果。</li>
2915     *           <li>当option = 0x06时, 加密结果(8byte)。</li>
2916     *         </ul></div>
2917     *         <div class="en"><ul>
2918     *           <li>When option = 0x01, no result is returned.</li>
2919     *           <li>When option = 0x02, no result is returned.</li>
2920     *           <li>When option = 0x03, random number ciphertext (8bytes).</li>
2921     *           <li>When option = 0x04, new pin_block(8bytes).</li>
2922     *           <li>When option = 0x05, no result is returned.</li>
2923     *           <li>When option = 0x06, the encryption result (8byte).</li>
2924     *         </ul></div>
2925     * @throws TypeAException TypeAException
2926     */
2927    byte[] extEPS(byte option, byte mode, byte[] dataIn) throws TypeAException;
2928
2929    /**
2930     * <div class="zh">非接模块上电。</div> <div class="en">Power on contactless module.</div>
2931     *
2932     * @throws TypeAException TypeAException
2933     */
2934    void piccOpen() throws TypeAException;
2935
2936    /**
2937     * <div class="zh">读取非接读卡器参数。 只有在{@link #piccOpen()}函数之后,{@link #detect(byte)}及{@link #initFelica(byte, byte)}之前调用才有效。</div>
2938     * <div class="en">Read the parameters of the contactless card reader. Only after {@link #piccOpen()} function,
2939     *  {@link #detect(byte)} and {@link #initFelica(byte, byte)} are called before it is valid.</div>
2940     *
2941     * @return {@link PiccPara}
2942     * @throws TypeAException TypeAException
2943     */
2944    PiccPara readParam() throws TypeAException;
2945
2946    /**
2947     * <div class="zh">设置非接读卡器参数。 只有在{@link #piccOpen()}函数之后,{@link #detect(byte)}及{@link #initFelica(byte, byte)}之前调用才有效。</div>
2948     * <div class="en">Set the parameters of the contactless card reader. Only after {@link #piccOpen()} function,
2949     *  {@link #detect(byte)} and {@link #initFelica(byte, byte)} are called before it is valid.</div>
2950     *
2951     * @param para {@link PiccPara}
2952     * @throws TypeAException TypeAException
2953     */
2954    void setParam(PiccPara para) throws TypeAException;
2955
2956    /**
2957     * <div class="zh">按指定的模式搜寻PICC卡片,搜到卡片后,将其选中并激活。感应区内不允许多张卡存在。</div>
2958     * <div class="en">Search for PICC cards according to the specified mode. After the card is found,
2959     *  select and activate it. Multiple cards are not allowed in the induction area.</div>
2960     *
2961     * @param mode <div class="zh"><ul>
2962     *               <li>0x00: 搜寻 A 型卡和 B 型卡一次,此模式适用于需要增强多卡检测功能的场合。该模式是符合 ISO14443 规范的寻卡模式。</li>
2963     *               <li>0x01: 搜寻 A 型卡和 B 型卡一次,此模式为EMV寻卡模式,通常使用该模式。</li>
2964     *               <li>0x10: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in VAS App OR PaymentMode)。此模式用于 apply pay。</li>
2965     *               <li>0x11: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in VAS App AND PaymentMode)。此模式用于 apply pay。</li>
2966     *               <li>0x12: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in VAS App Only Mode)。此模式用于 apply pay。</li>
2967     *               <li>0x13: 搜寻 A 型卡和 B 型卡一次,发送 VAS 指令(Terminal in Payment Mode Only)。</li>
2968     *               <li>'a'或'A': 只搜寻 A 型卡一次。</li>
2969     *               <li>'b'或'B': 只搜寻 B 型卡一次。</li>
2970     *               <li>'m'或'M': 只搜寻 M1 卡一次。</li>
2971     *             </ul></div>
2972     *             <div class="en"><ul>
2973     *               <li>0x00: Search for type A card and type B card once. This mode is suitable for occasions that need to
2974     *                 enhance the multi-card detection function. This mode is a card detection mode that conforms to the ISO14443 specification.</li>
2975     *               <li>0x01: Search for type A card and type B card once, this mode is EMV search card mode, usually use this mode.</li>
2976     *               <li>0x10: Search for Type A and Type B cards once, and send the VAS command (Terminal in VAS App OR Payment Mode).
2977     *                 This mode is used for apply pay.</li>
2978     *               <li>0x11: Search for Type A and Type B cards once, and send the VAS command (Terminal in VAS App AND Payment Mode).
2979     *                 This mode is used for apply pay.</li>
2980     *               <li>0x12: Search for Type A and Type B cards once, and send the VAS command (Terminal in VAS App Only Mode).
2981     *                 This mode is used for apply pay.</li>
2982     *               <li>0x13: Search for Type A and Type B cards once, and send the VAS command (Terminal in Payment Mode Only).</li>
2983     *               <li>'a'or'A': Only search for Type A cards once.</li>
2984     *               <li>'b'or'B': Only search for type B cards once.</li>
2985     *               <li>'m'or'M': Only search for M1 card once.</li>
2986     *             </ul></div>
2987     * @return {@link PiccCardInfo}
2988     * @throws TypeAException TypeAException
2989     */
2990    PiccCardInfo detect(byte mode) throws TypeAException;
2991
2992    /**
2993     * <div class="zh">在指定的通道上,向卡片发送 APDU 格式的数据,并接收响应。</div>
2994     * <div class="en">On the designated channel, send data in APDU format to the card and receive the response.</div>
2995     *
2996     * @param cid <div class="zh">用于指定卡片逻辑通道号;该通道号由{@link PiccCardInfo#getCID()} 获取,其取值范围 0-14,目前取值均为 0。</div>
2997     *            <div class="en">Used to specify the card logical channel number; the channel number is obtained by {@link PiccCardInfo#getCID()},
2998     *              and its value range is 0-14, and the current value is 0.</div>
2999     * @param sendInfo {@link ApduSendInfo}
3000     * @return {@link ApduRespInfo}
3001     *
3002     * @throws TypeAException TypeAException
3003     */
3004    ApduRespInfo isoCommand(byte cid, ApduSendInfo sendInfo) throws TypeAException;
3005
3006    /**
3007     * <div class="zh">依据指定的模式,向卡片发送停机指令;或者发送停活指令;或者复位载波,并判断卡片是否已经移开感应区。</div>
3008     * <div class="en">According to the specified mode, send a stop instruction to the card; or send a deactivation instruction;
3009     * or reset the carrier, and determine whether the card has moved out of the sensing area.</div>
3010     *
3011     * @param mode <div class="zh"><ul>
3012     *               <li>'h'或'H': 意为 HALT,仅向卡片发送停活指令后就退出。该过程不执行卡移开检测。</li>
3013     *               <li>'r'或'R': 意为 REMOVE,向卡片发送停活指令,并执行卡移开检测。</li>
3014     *               <li>'e'或'E': 符合 EMV 非接规范的移卡模式。复位载波,并执行卡移开检测。</li>
3015     *             </ul></div>
3016     *             <div class="en"><ul>
3017     *               <li>'h'or'H': It means HALT, and it will exit after sending a deactivation command to the card.
3018     *                 This process does not perform card removal detection.</li>
3019     *               <li>'r'or'R': It means REMOVE, sending a deactivation command to the card and executing the card removal detection.</li>
3020     *               <li>'e'or'E': Shift card mode conforming to EMV contactless specification. Reset the carrier and perform card removal detection.</li>
3021     *             </ul></div>
3022     * @param cid <div class="zh">用于指定卡片逻辑通道号;该通道号由{@link PiccCardInfo#getCID()} 获取,其取值范围 0-14,目前取值均为 0。</div>
3023     *            <div class="en">Used to specify the card logical channel number; the channel number is obtained by {@link PiccCardInfo#getCID()},
3024     *              and its value range is 0-14, and the current value is 0.</div>
3025     * @throws TypeAException TypeAException
3026     */
3027    void remove(byte mode, byte cid) throws TypeAException;
3028
3029    /**
3030     * <div class="zh">关闭非接模块,使该模块处于下电状态。</div>
3031     * <div class="en">Turn off the contactless module and make the module in the power-off state.</div>
3032     *
3033     * @throws TypeAException TypeAException
3034     */
3035    void piccClose() throws TypeAException;
3036
3037    /**
3038     * <div class="zh">验证访问M1卡时读写相应块需要提交的 A 密码或 B 密码。</div>
3039     * <div class="en">Verify the A password or B password that needs to be submitted
3040     *   when reading and writing the corresponding block when accessing the M1 card.</div>
3041     *
3042     * @param type {@link EM1KeyType}
3043     * @param blkNo <div class="zh">指定访问的块号。</div> <div class="en">Specify the block number to be accessed.</div>
3044     * @param pwd <div class="zh">提交的密码。</div> <div class="en">Password submitted.</div>
3045     * @param serialNo <div class="zh">卡片序列号。由{@link PiccCardInfo#getSerialInfo()}} 获取。</div>
3046     *                 <div class="en">Card serial number. Obtained by {@link PiccCardInfo#getSerialInfo()}}.</div>
3047     * @throws TypeAException TypeAException
3048     */
3049    void m1Auth(EM1KeyType type, byte blkNo, byte[] pwd, byte[] serialNo) throws TypeAException;
3050
3051    /**
3052     * <div class="zh">读取M1卡指定块的内容。共16字节。</div>
3053     * <div class="en">Read the contents of the specified block of the M1 card. A total of 16 bytes..</div>
3054     *
3055     * @param blkNo <div class="zh">指定访问的块号。</div> <div class="en">Specify the block number to be accessed.</div>
3056     * @return <div class="zh">块内数据。16字节。</div> <div class="en">Data in the block. 16 bytes.</div>
3057     * @throws TypeAException TypeAException
3058     */
3059    byte[] m1Read(byte blkNo) throws TypeAException;
3060
3061    /**
3062     * <div class="zh">向M1卡指定块写入指定的内容。共16字节。</div>
3063     * <div class="en">Write the specified content to the specified block of the M1 card. A total of 16 bytes.</div>
3064     *
3065     * @param blkNo <div class="zh">指定访问的块号。</div> <div class="en">Specify the block number to be accessed.</div>
3066     * @param blkValue <div class="zh">要写入块中的数据。16字节。</div> <div class="en">The data to be written in the block. 16 bytes.</div>
3067     * @throws TypeAException TypeAException
3068     */
3069    void m1Write(byte blkNo, byte[] blkValue) throws TypeAException;
3070
3071    /**
3072     * <div class="zh">对 M1 卡的指定数据块 blkNo 进行充/减值/备份操作,将操作后的值更新到另一个指定的数据块 updateBlkNo。</div> <div class="en"></div>
3073     *
3074     * @param type {@link EM1OperateType}
3075     * @param blkNo <div class="zh">指定访问的块号。</div> <div class="en">Specify the block number to be accessed.</div>
3076     * @param blkValue <div class="zh">待充值或减值的金额数。共4字节。M1卡通常都有两个钱包:主钱包和备用钱包。 为了在对主钱包进行操作时,可以从出现的异常错误中恢复, 主钱包的操作结果通常会写入备用钱包。</div>
3077     *                 <div class="en">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.
3078     *                   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.</div>
3079     * @param updateBlkNo <div class="zh">指定操作结果最终写入到的块号。</div> <div class="en">Specify the block number to which the operation result is finally written.</div>
3080     * @throws TypeAException TypeAException
3081     */
3082    void m1Operate(EM1OperateType type, byte blkNo, byte[] blkValue, byte updateBlkNo) throws TypeAException;
3083
3084    /**
3085     * <div class="zh">控制射频卡指示灯点亮或熄灭。</div> <div class="en">Control the radio frequency card indicator to turn on or off.</div>
3086     *
3087     * @param led <div class="zh"><ul>
3088     *              <li>bit0: 红灯。</li>
3089     *              <li>bit1: 绿灯。</li>
3090     *              <li>bit2: 黄灯</li>
3091     *              <li>bit3: 蓝灯。</li>
3092     *              <li>bit4-7: 保留。</li>
3093     *            </ul></div>
3094     *            <div class="en"><ul>
3095     *              <li>bit0: Red.</li>
3096     *              <li>bit1: Green.</li>
3097     *              <li>bit2: Yellow.</li>
3098     *              <li>bit3: Blue.</li>
3099     *              <li>bit4-7: Reserve.</li>
3100     *            </ul></div>
3101     * @param mode <div class="zh"><ul>
3102     *               <li>0x00:熄灭。</li>
3103     *               <li>0x01:点亮。</li>
3104     *             </ul></div>
3105     *             <div class="en"><ul>
3106     *               <li>0x00:Turn off.</li>
3107     *               <li>0x01:Turn on.</li>
3108     *             </ul></div>
3109     * @throws TypeAException TypeAException
3110     */
3111    void setLed(byte led, byte mode) throws TypeAException;
3112
3113    /**
3114     * <div class="zh">初始化 Felica 卡片。</div> <div class="en">Initialize the Felica card.</div>
3115     *
3116     * @param rate <div class="zh">与卡片交互的传输速率。<ul>
3117     *               <li>0x00: 212Kbps。</li>
3118     *               <li>0x01: 424Kbps。</li>
3119     *             </ul></div>
3120     *             <div class="en">The transfer rate of interaction with the card.<ul>
3121     *               <li>0x00: 212Kbps.</li>
3122     *               <li>0x01: 424Kbps.</li>
3123     *             </ul></div>
3124     * @param pol <div class="zh">FeliCa卡调制方式。<ul>
3125     *              <li>0x00: 正向调制输出。</li>
3126     *              <li>0x01: 反向调制输出。</li>
3127     *            </ul></div>
3128     *            <div class="en">FeliCa card modulation method. <ul>
3129     *              <li>0x00: Forward modulation output.</li>
3130     *              <li>0x01: Reverse modulation output.</li>
3131     *            </ul></div>
3132     * @throws TypeAException TypeAException
3133     */
3134    void initFelica(byte rate, byte pol) throws TypeAException;
3135
3136    /**
3137     * <div class="zh">与卡片进行APDU数据交互。将数据直接发送给卡片,并接收卡片的应答数据。</div>
3138     * <div class="en">APDU data exchange with the card. Send the data directly to the card and receive the response data from the card.</div>
3139     *
3140     * @param dataIn <div class="zh">待发送的命令数据。</div> <div class="en">The command data to be sent.</div>
3141     * @return <div class="zh">接收到的卡片数据。</div> <div class="en">The received card data.</div>
3142     * @throws TypeAException TypeAException
3143     */
3144    byte[] cmdExchange(byte[] dataIn) throws TypeAException;
3145
3146    /**
3147     * <div class="zh">更改外置密码键盘通信波特率。</div>
3148     * <div class="en">Change the external PINPAD communication Baud rate.</div>
3149     *
3150     * @param bps <div class="zh">波特率。
3151     *              <ul>
3152     *                   <li>0x00: 9600,8,E,1</li>
3153     *                   <li>0x01: 115200,8,N,1</li>
3154     *              </ul>
3155     *            </div>
3156     *            <div class="en">Baud rate.
3157     *              <ul>
3158     *                  <li>0x00: 9600,8,E,1</li>
3159     *                  <li>0x01: 115200,8,N,1</li>
3160     *              </ul>
3161     *            </div>
3162     * @throws TypeAException TypeAException
3163     */
3164    void changeBaudRate(byte bps) throws TypeAException;
3165
3166    /**
3167     * <div class="zh">创建并显示二维码。</div> <div class="en">Create and show a QR code.</div>
3168     *
3169     * @param content <div class="zh">二维码内容。最大不超过255字节。</div> <div class="en">QR code content. The maximum is not more than 255 bytes.</div>
3170     * @param sizeLevel <div class="zh">最小可是别的模块大小。取值(2, 4, 8)。</div> <div class="en">The smallest but other module size. Take the value (2, 4, 8).</div>
3171     * @param type <div class="zh">二维码类型。0x00: QR; 0x01: GM。</div> <div class="en">QR code type. 0x00: QR; 0x01: GM.</div>
3172     * @param correctionLevel <div class="zh">纠错能力级别。取值0~4。当type为0x00时有效。</div>
3173     *                        <div class="en">The level of error correction capability. The value ranges from 0 to 4. It is valid when type is 0x00.</div>
3174     * @param x <div class="zh">横坐标。</div> <div class="en">The abscissa.</div>
3175     * @param y <div class="zh">纵坐标。</div> <div class="en">The ordinate.</div>
3176     * @throws TypeAException TypeAException
3177     */
3178    void showQRCode(byte[] content, short sizeLevel, byte type, byte correctionLevel, short x, short y) throws TypeAException;
3179
3180    /**
3181     * <div class="zh">打开扫描模块。</div> <div class="en">Open the scan module.</div>
3182     *
3183     * @throws TypeAException TypeAException
3184     */
3185    void scanOpen() throws TypeAException;
3186
3187    /**
3188     * <div class="zh">读取扫描数据。</div> <div class="en">Read scan data.</div>
3189     *
3190     * @return <div class="zh"></div> <div class="en"></div>
3191     * @throws TypeAException TypeAException
3192     */
3193    String scanRead() throws TypeAException;
3194
3195    /**
3196     * <div class="zh">关闭扫描模块。</div> <div class="en">Close the scan module.</div>
3197     *
3198     * @throws TypeAException TypeAException
3199     */
3200    void scanClose()throws TypeAException;
3201
3202    /**
3203     * <div class="zh"> 获取接收超时时间,默认20000ms。 </div> <div class="en"> get receive timeout, default is 20000ms </div>
3204     *
3205     * @return <div class="zh"> 接收超时,单位ms </div> <div class="en"> receive timeout, in ms </div>
3206     *
3207     */
3208    public int getRecvTimeout();
3209
3210    /**
3211     * <div class="zh"> 设置接收超时时间 ,默认20000ms。</div> <div class="en"> set receive timeout, default is 20000ms </div>
3212     *
3213     * @param timeoutMs
3214     *            <div class="zh"> 接收超时,单位ms </div> <div class="en"> receive timeout, in ms </div>
3215     *
3216     */
3217    public void setRecvTimeout(int timeoutMs);
3218}