PinpadDef.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. #pragma once
  2. /*
  3. 中间接口相关的数据结构和宏定义。
  4. */
  5. #include "sys/time.h"
  6. #include <vector>
  7. #include <string>
  8. #include "CommDef.h"
  9. #pragma pack(push,1)
  10. using namespace std;
  11. #define MAX_PATH 260
  12. #define DEV_TYPE_M1FD 0
  13. #define DEV_TYPE_M5D 1
  14. //wType
  15. #define PIN_TYPEEPP 0x0001
  16. #define PIN_TYPEEDM 0x0002
  17. #define PIN_TYPEHSM 0x0004
  18. #define PIN_TYPEOTHER 0xFFFF
  19. //#define PIN_UNIONPAYEPP 0x08
  20. //#define PIN_PCI3xEPP 0x10
  21. //#define PIN_PCI4xEPP 0x20
  22. //CryptAlgorithms
  23. #define PIN_CRYPTDESECB 0x0001
  24. #define PIN_CRYPTDESCBC 0x0002
  25. #define PIN_CRYPTDESCFB 0x0004
  26. #define PIN_CRYPTRSA 0x0008
  27. #define PIN_CRYPTECMA 0x0010
  28. #define PIN_CRYPTDESMAC 0x0020
  29. #define PIN_CRYPTTRIDESECB 0x0040
  30. #define PIN_CRYPTTRIDESCBC 0x0080
  31. #define PIN_CRYPTTRIDESCFB 0x0100
  32. #define PIN_CRYPTTRIDESMAC 0x0200
  33. #define PIN_CRYPTMAAMAC 0x0400
  34. #define PIN_CRYPTSM4ECB 0x1000
  35. #define PIN_CRYPTSM4CBC 0x2000
  36. //wDerivationAlgorithms
  37. #define PIN_CHIP_NONE 0x00
  38. #define PIN_CHIP_ZKA 0x01
  39. //wPresentationAlgorithms
  40. #define PIN_PRESENT_NONE 0x00
  41. #define PIN_PRESENT_CLEAR 0x01
  42. //wIDKey
  43. #define PIN_IDKEYINITIALIZATION (0x0001)
  44. #define PIN_IDKEYIMPORT (0x0002)
  45. //wValidationAlgorithms
  46. #define PIN_DES 0x0001
  47. #define PIN_EUROCHEQUE 0x0002
  48. #define PIN_VISA 0x0004
  49. #define PIN_DES_OFFSET 0x0008
  50. #define PIN_BANKSYS 0x0010
  51. //wRemoteKeySupp
  52. #define PIN_REMOTE_KEY_NONE 0x0000
  53. #define PIN_REMOTE_KEY_SIGNATURES 0x0001
  54. #define PIN_REMOTE_KEY_CERTIFICATES 0x0002
  55. //wGMKeySupp
  56. #define PIN_GM_KEY_NONE 0x0000
  57. #define PIN_GM_KEY_SM2 0x0001
  58. #define PIN_GM_KEY_SM3 0x0002
  59. #define PIN_GM_KEY_SM4 0x0004
  60. //wCommPattern
  61. #define PIN_COMM_RS232 0x0001
  62. #define PIN_COMM_USB 0x0002
  63. #define PIN_COMM_AUTO 0x0004
  64. //wResetMode
  65. #define PIN_SOFT_RESET (0x0000)
  66. #define PIN_HARD_RESET_DES (0x0001)
  67. #define PIN_HARD_RESET_SM4 (0x0002)
  68. #define PIN_HARD_RESET_RSA (0x0003)
  69. #define PIN_HARD_RESET_ALL (0xFFFF)
  70. //DelEntryPinKey.byMode
  71. #define PIN_DEL_ONE (0x30)
  72. #define PIN_DEL_ALL (0x31)
  73. //wPswType
  74. #define PIN_PSW_OLD (1)
  75. #define PIN_PSW_NEW (2)
  76. //wFormat
  77. #define PIN_FORM3624 0x0001
  78. #define PIN_FORMANSI 0x0002
  79. #define PIN_FORMISO0 0x0004
  80. #define PIN_FORMISO1 0x0008
  81. #define PIN_FORMECI2 0x0010
  82. #define PIN_FORMECI3 0x0020
  83. #define PIN_FORMVISA 0x0040
  84. #define PIN_FORMDIEBOLD 0x0080
  85. #define PIN_FORMDIEBOLDCO 0x0100
  86. #define PIN_FORMVISA3 0x0200
  87. #define PIN_FORMBANKSYS 0x0400
  88. #define PIN_FORMEMV 0x0800
  89. #define PIN_FORMISO3 0x2000
  90. #define PIN_FREEMODE 0x8000
  91. //wPswType
  92. #define PIN_PSW_KEY1 (901) //手动密钥
  93. #define PIN_PSW_KEY2 (902)
  94. #define PIN_PSW_KEY3 (903)
  95. #define PIN_PSW_EPP1 (904) //授权安装
  96. #define PIN_PSW_EPP2 (905)
  97. //RemoveInstallAuthen.byMode
  98. #define PIN_REMOVE (0x31)
  99. #define PIN_INSTALL (0x32)
  100. //wKeyType
  101. #define KEY_TYPE_DES 0x0001
  102. #define KEY_TYPE_SM4 0x0002
  103. #define KEY_TYPE_RSA 0x0003
  104. //dwUse密钥属性
  105. #define PIN_USECRYPT (0x00000001)
  106. #define PIN_USEFUNCTION (0x00000002)
  107. #define PIN_USEMACING (0x00000004)
  108. #define PIN_USEKEYENCKEY (0x00000020)
  109. #define PIN_USENODUPLICATE (0x00000040)
  110. #define PIN_USESVENCKEY (0x00000080)
  111. #define PIN_USECONSTRUCT (0x00000100)
  112. #define PIN_USESECURECONSTRUCT (0x00000200)
  113. #define PIN_USESM4 (0X00008000)
  114. #define PIN_USEPINLOCAL (0x00010000)
  115. #define PIN_USERSAPUBLIC (0x00020000)
  116. #define PIN_USERSAPRIVATE (0x00040000)
  117. #define PIN_USECHIPINFO (0x00100000)
  118. #define PIN_USECHIPPIN (0x00200000)
  119. #define PIN_USECHIPPS (0x00400000)
  120. #define PIN_USECHIPMAC (0x00800000)
  121. #define PIN_USECHIPLT (0x01000000)
  122. #define PIN_USECHIPMACLZ (0x02000000)
  123. #define PIN_USECHIPMACAZ (0x04000000)
  124. #define PIN_USERSAPUBLICVERIFY (0x08000000)
  125. #define PIN_USERSAPRIVATESIGN (0x10000000)
  126. #define PIN_USERSAVND (0x20000000)
  127. #define PIN_USERSAUID (0x40000000)
  128. #define PIN_USERSAPKHOST (0x80000000)
  129. //wCheckMode.wKeyCheckModes
  130. #define PIN_KCVNONE (0)
  131. #define PIN_KCVSELF (1)
  132. #define PIN_KCVZERO (2)
  133. //byAlgorithm
  134. #define PIN_MAC_X9 (0x41)
  135. #define PIN_MAC_X919 (0x42)
  136. #define PIN_MAC_CBC (0x43)
  137. #define PIN_MAC_PBOC (0x44)
  138. #define PIN_MAC_UNIONPAY (0x45)
  139. //CryptData.wMode
  140. #define PIN_MODEENCRYPT (1)
  141. #define PIN_MODEDECRYPT (2)
  142. //CryptData.byAlgorithm
  143. #define PIN_CRYPT_ECB (0x01)
  144. #define PIN_CRYPT_CBC (0x02)
  145. //CryptData.byPattern
  146. #define PIN_CRYPT_DES (0x31)
  147. #define PIN_CRYPT_TDES (0x32)
  148. #define MAX_KEY_NAME_LEN 32
  149. //wKeyState
  150. #define PIN_KEY_STATE_NONE 0
  151. #define PIN_KEY_STATE_EXIST 1
  152. #define PIN_KEY_STATE_FULL 2
  153. #define PIN_KEY_STATE_LOCK 3
  154. #define PIN_KEY_STATE_UNKNOWN 128
  155. //wBattery
  156. #define PIN_BATTERY_OK 0
  157. #define PIN_BATTERY_LOW 1
  158. #define PIN_BATTERY_NONE 2
  159. #define PIN_BATTERY_UNKNOWN 128
  160. //wDisplay
  161. #define PIN_DISPNONE 0x00
  162. #define PIN_DISPLEDTHROUGH 0x01
  163. #define PIN_DISPDISPLAY 0x02
  164. //硬件返回错误码宏定义
  165. #define STATUS_SUCCESS 0x00
  166. #define STATUS_INVALID_COMMAND_LENGTH 0x01
  167. #define STATUS_INVALID_KEYID 0x02
  168. #define STATUS_INVALID_WRITE_MODE 0x03
  169. #define STATUS_KEYID_NOT_EXIST 0x04
  170. #define STATUS_KEYID_LOCKED 0x05
  171. #define STATUS_INVALID_KEY_LENGTH 0x06
  172. #define STATUS_INVALID_KEY_ATTRIBUTES 0x07
  173. #define STATUS_INVALID_IV_ATTRIBUTES 0x08
  174. #define STATUS_KEY_ATTRIBUTES_NOT_MATCHED 0x09
  175. #define STATUS_KCV_VERIFICATION_FAIL 0x0A
  176. #define STATUS_INVALID_KEY_VALUE 0x0B
  177. #define STATUS_KEY_USEVIOLATION 0x10
  178. #define STATUS_KEY_NOTALLOWED 0x11
  179. #define STATUS_INVALID_CHECK_MODE 0x12
  180. #define STATUS_INVALID_VERIFY_MODE 0x13
  181. #define STATUS_INVALID_MACING 0x14
  182. #define STATUS_INVALID_AUTHENTICATION_MODE 0x15
  183. #define STATUS_INVALID_MODE 0x16
  184. #define STATUS_INVALID_DATA_SPECIFIED 0x17
  185. #define STATUS_INVALID_LENGTH_OR_SUM 0x18
  186. #define STATUS_INVALID_OFFSET_LENGTH 0x19
  187. #define STATUS_INVALID_PIN_LENGTH 0x20
  188. #define STATUS_PIN_VERIFICATION_FAIL 0x21
  189. #define STATUS_PIN_ENCRYPTION_SUSPENDED 0x22
  190. #define STATUS_PIN_NOPIN 0x23
  191. #define STATUS_INVALID_PIN2_LENGTH 0x24
  192. #define STATUS_PIN2_VERIFICATION_FAIL 0x25
  193. #define STATUS_INVALID_MODULUS_LENGTH 0x31
  194. #define STATUS_INVALID_EXPONENT_LENGTH 0x32
  195. #define STATUS_INVALID_PKCS_STRUCTURE 0x33
  196. #define STATUS_INVALID_PKCS_PADDING 0x34
  197. #define STATUS_INVALID_SIGNATURE_LENGTH 0x35
  198. #define STATUS_SIGNATURE_VERIFICATION_FAIL 0x36
  199. #define STATUS_KEY_NOT_LOADED 0x37
  200. #define STATUS_INVALID_CERTIFICATE_FROMAT 0x41
  201. #define STATUS_INVALID_CERTIFICATE_VERSION 0x42
  202. #define STATUS_INVALID_CERTIFICATE_VALIDITY 0x43
  203. #define STATUS_INVALID_CERTIFICATE_ISSUER 0x44
  204. #define STATUS_INVALID_CERTIFICATE_SUBJECT 0x45
  205. #define STATUS_INVALID_CERTIFICATE_ALGOR 0x46
  206. #define STATUS_CERTIFICATE_NOT_EXIST 0x47
  207. #define STATUS_INVALID_DATA_DISABLEED 0x50
  208. #define STATUS_INVALID_USERBLOCK_ADDRESS 0x51
  209. #define STATUS_INVALID_SERIALNO_SPECIFIED 0x52
  210. #define STATUS_NO_CARD 0x55
  211. #define STATUS_CARD_APDU_ERROR 0x56
  212. #define STATUS_KEY_INVALID 0x60
  213. #define STATUS_EMV_NOT_INITIALIZED 0x61
  214. #define STATUS_EMV_NOT_READY 0x62
  215. #define STATUS_EMV_ALREADY_INITIALIZED 0x63
  216. #define STATUS_EMV_NEED_REINITIALIZE 0x64
  217. #define STATUS_EMV_TIMEOUT 0x65
  218. #define STATUS_ALGORITHMNOTSUPP 0x71
  219. #define STATUS_COMMANDUPSUPP 0x72
  220. #define STATUS_ERROR_INTER_ERROR 0x73
  221. #define STATUS_COMMAND_LOCK 0x74
  222. #define STATUS_INVALID_COMMAND_MAC 0x75
  223. #define STATUS_AUTHENTICATION_FAILED 0x80
  224. #define STATUS_NOT_AUTHENTE 0x81
  225. #define STATUS_EPP_NOT_INITIALIZED 0x82
  226. #define STATUS_EPP_ALREADY_INITIALIZED 0x83
  227. #define STATUS_CERTIFICATE_ALREADY 0x84
  228. #define STATUS_PHYSICALLY_NOT_INSTALLED 0x90
  229. #define STATUS_LOGICALLY_NOT_INSTALLED 0x91
  230. #define STATUS_INPUT_KEY_TIMEOUT 0x92
  231. #define STATUS_INVLAID_PASSWORD_LENGTH 0x93
  232. #define STATUS_INVALID_PASSWORD 0x94
  233. #define STATUS_INPUT_PASSWORD_LOCKED 0x95
  234. #define STATUS_SYSTEM_TIME_NOT_SET 0x96
  235. #define STATUS_SYSTEM_TIME_ALREADY_SET 0x97
  236. #define STATUS_MRAM_HARDWARE_ERROR 0x98
  237. #define STATUS_DEVICE_TAMPERED 0x99
  238. #define STATUS_SM2_ENCRYPT_FAILURE 0xA0
  239. #define STATUS_SM2_DECRYPT_FAILURE 0xA1
  240. #define STATUS_SM2_SIGNATURE_FAILURE 0xA2
  241. #define STATUS_SM2_VERSIG_FAILURE 0xA3
  242. #define STATUS_SM2_KEYEXC_FAILURE 0xA4
  243. #define STATUS_SM2_VER_KEYEXC_FAILURE 0xA5
  244. #define STATUS_A980_NO_RESPONSE 0xA6
  245. #define STATUS_INVALID_SM4_KEYVAL 0xA8
  246. #define STATUS_OTHER_ABNORMAL_ERROR 0xAF
  247. #define STATUS_FW_VERIFY_FIAL 0x0100
  248. #define STATUS_FW_WRITE_FAIL 0x0101
  249. #define STATUS_FW_EARSE_FAIL 0x0102
  250. #define STATUS_EXTERNAL_FALSH_WRITE_ERROR 0x0103
  251. #define STATUS_ADDRESS_OUTRANG 0x0104
  252. #define STATUS_FLASH_CRC_CHECK_ERROR 0x0105
  253. #define STATUS_APPCODE_NOT_COMPLETE 0x1006
  254. //自定义错误码
  255. #define ERR_EXCHANGE_FAILED 0x1000
  256. #define ERR_COMMON_ERROR 0x1001
  257. #define ERR_INTERNAL_ERROR 0x1002
  258. #define ERR_PIN_HOST_AUTHENTICATE_FAILED 0x1003
  259. #define ERR_PIN_KEYNOTFOUND 0x1004
  260. #define ERR_PARAM_ERROR 0x1005
  261. #define ERR_DATA_TOO_LONG 0x1006
  262. #define ERR_PIN_DUPLICATEKEY 0x1007
  263. #define ERR_PIN_USEVIOLATION 0x1008
  264. #define ERR_PIN_UNSUPPORT 0x1009
  265. #define ERR_PIN_CHECK_KCV_FAILED 0x100A
  266. #define ERR_PIN_INVALIDKEYLENGTH 0x100B
  267. #define ERR_PIN_NOKEYRAM 0x100C
  268. #define ERR_PIN_ENC_KEYUSEVIOLATION 0x100D
  269. #define ERR_PIN_ENC_KEYNOTFOUND 0x100E
  270. #define ERR_PIN_PHYSICALLY_UNINSTALLED 0x100F
  271. #define ERR_PIN_AUTHENTICATION_FAILED 0x1010
  272. #define ERR_PIN_STARTVALUE_KEYNOTFOUND 0x1011
  273. #define ERR_PIN_STARTVALUE_KEYUSEVIOLATION 0x1012
  274. #define ERR_PIN_INVALIDDATA 0x1013
  275. #define ERR_PIN_KEY_CODE_NOT_FOUND 0x1014
  276. #define ERR_PIN_LOGICALLY_UNINSTALLED 0x1015
  277. #define ERR_PIN_NEED_INITIALIZATION 0x1016
  278. #define ERR_PIN_BATTERY_LOW 0x1017
  279. #define ERR_PIN_PRESS_KEY_OVERTIME 0x1018
  280. #define ERR_PIN_INVALID_MOD_LEN 0x1019
  281. #define ERR_PIN_SIG_NOT_SUPP 0x101A
  282. #define ERR_PIN_SIG_KEYNOTFOUND 0x101B
  283. #define ERR_PIN_SIG_KEYUSEVIOLATION 0x101C
  284. #define ERR_PIN_NOT_SUPP 0x101D
  285. #define ERR_PIN_INVALID_FW_FILE 0x101E
  286. #define ERR_PIN_TIMEOUT 0x101F
  287. #define ERR_PIN_INVALIDCUSTOMERDATA 0x1020
  288. #define ERR_PIN_DEVNOTOPEN 0x1021
  289. #define KEYBOARD_CODE_NULL 0x00
  290. #define KEYBOARD_CODE_SHIFT 0x10
  291. #define KEYBOARD_CODE_LONG_PRESS_OVERTIME 0x80 //长按键超时
  292. #define KEYBOARD_CODE_PIN_INPUT_OVERTIME 0x81 //PIN输入(两次按键间隔)超时
  293. #define KEYBOARD_CODE_ENCRYPT_PIN_OVERTIME 0x82
  294. #define KEYBOARD_CODE_HW_ERR 0xFF
  295. #define CUSTOMER_DATA_LENGTH 12
  296. #define ONE_LOGICKEY_MAX_HWKEY_COUNT 16
  297. #define MAX_LOGICKEY_COUNT 255
  298. #define RSA_ONE_LOGICKEY_MAX_HWKEY_COUNT 2
  299. #define RSA_MAX_LOGICKEY_COUNT 32
  300. #define DES_DATA_GROUP_LENGTH 8
  301. #define SM4_DATA_GROUP_LENGTH 16
  302. #define PIN_SIGN_NA (0)
  303. #define PIN_SIGN_RSASSA_PKCS1_V1_5 (0x00000001)
  304. #define PIN_SIGN_RSASSA_PSS (0x00000002)
  305. #define PIN_EXPORT_EPP_ID (0x0001)
  306. #define PIN_EXPORT_PUBLIC_KEY (0x0002)
  307. #define PIN_CRYPT_RSAES_PKCS1_V1_5 (0x00000001)
  308. #define PIN_CRYPT_RSAES_OAEP (0x00000002)
  309. #define PIN_DEFAULT (0)
  310. #define PIN_EXPONENT_1 (1)
  311. #define PIN_EXPONENT_4 (2)
  312. #define PIN_EXPONENT_16 (3)
  313. #define PIN_RSA_KCV_NONE (0x00000000)
  314. #define PIN_RSA_KCV_SHA1 (0x00000001)
  315. #define RSA_KEY_LENGTH_128_BYTE 128
  316. #define RSA_KEY_LENGTH_256_BYTE 256
  317. enum WaitEventIndex
  318. {
  319. CANCEL_EVENT = 0,
  320. TIMEOUT_EVENT,
  321. ERROR_EVENT,
  322. EXEE_KEY_EVENT,
  323. SRVE_INITIALIZED_EVENT,
  324. SRVE_ILLEGAL_KEY_ACCESS_EVENT,
  325. SRVE_OPT_REQUIRED_EVENT,
  326. SRVE_CERTIFICATE_CHANGE_EVENT,
  327. SRVE_HSM_TDATA_CHANGED_EVENT,
  328. WM_SP_USER_PIN_KEYPRESS,
  329. PRESS_KEY_EVENT,
  330. PRESS_KEY_OVERTIME,
  331. KEY_INPUT_COMPLETED_EVENT,
  332. EVENT_COUNT
  333. };
  334. //todo:delete this structure
  335. typedef struct tag_SpecialKeys
  336. {
  337. BYTE byUAK[48];
  338. int nUAKLen;
  339. BYTE byKBPK[48];
  340. int nKBPKLen;
  341. } SpecialKeys, *LPSpecialKeys;
  342. // 影响硬件行为的配置项
  343. typedef struct tag_PinpadDevConfig
  344. {
  345. BYTE usAutoUpdatePWD;
  346. BYTE byRemoveInstall;
  347. BYTE usPort;
  348. BYTE usBaudrate;
  349. BYTE byBeepLength; //0x00:一直Beep直到释放按键 0x01~0xFF:10~2550ms, 0x10 is default.
  350. BYTE byLongPressTime; //EPP send 0x80. 11..1F=1..15 second, 10= EPP not send 0x80. 0x15 is default.
  351. BYTE byKCVLength; //KCV字节数
  352. BYTE bySM4KCVLength;
  353. WORD wStartValueUsingPos; //Crypt的StartValue在加密前使用还是在加密后使用
  354. BYTE byKeyCodeMatrix[8][8]; //主键盘按键码(下标:[横向x][纵向y])
  355. BYTE byKeyShiftCodeMatrix[8][8]; //主键盘Shift模式下按键码(下标:[横向x][纵向y])
  356. BYTE byFuncKeyCodeMatrix[8][8]; //功能键盘按键码(下标:[横向x][纵向y])
  357. BYTE byFuncKeyShiftCodeMatrix[8][8]; //功能键盘Shift模式下按键码(下标:[横向x][纵向y])
  358. BYTE byKeyInputWaitTime; //Set timeout waiting for key input when set PIN ENTRY mode or PIN ENTRY mode Set 1~60s by 0x01~0x3C
  359. BYTE byEncPinTotalTime; //从按密码到Pinblock结束的超时时间(min)00:不超时
  360. BOOL bRandomDataForAuthentication; //认证密钥时是否使用随机数
  361. CHAR sDESKeyIndexFilePath[MAX_PATH]; //DES密钥索引文件全路径
  362. CHAR sSM4KeyIndexFilePath[MAX_PATH]; //SM4密钥索引文件全路径
  363. BYTE byIndexFileXORData; //加密密钥索引文件的XOR数据(隐藏配置,默认加密)
  364. SpecialKeys lpSpecialKeys; //特殊地位的密钥
  365. BYTE byDuplicateKeyCheckMode; //是否下载同名秘钥的检查范围 0:同类型秘钥内检查 1:DES和国密秘钥全范围检查
  366. BOOL bKeyIndexFileSaveToEPP;
  367. BOOL bInternalTestFlag;
  368. USHORT usDESKeyMaxNum;
  369. USHORT usSM4KeyMaxNum;
  370. CHAR sRSAKeyIndexFilePath[MAX_PATH]; //RSA密钥索引文件全路径
  371. USHORT usRSABitLen;
  372. BYTE byTImportRSAKey;
  373. BYTE byHWDESKCVMaxLen;
  374. BOOL bHideRSADefKey;
  375. BOOL bImportRSASignedDESKeyWithoutSignature;
  376. BOOL bImportRSASignedDESKeyWithCheckValue;
  377. } PinpadDevConfig, *LPPinpadDevConfig;
  378. typedef struct tag_PinpadStatus
  379. {
  380. WORD wDevState;//整个设备的状态
  381. WORD wEnc_Stat;
  382. WORD wKeyState; //EPP中Key相关状态 0:无Key;2:存在Key;3:Key存满;128:Unknown;
  383. WORD wBattery; //EPP电池状态 0:正常;1:电量低; 2:没电; 128:Unknown;
  384. CHAR sErrorCode[MAX_ERRCODE_LEN];
  385. CHAR sDescription[MAX_DESC_LEN];
  386. } PinpadStatus, *LPPinpadStatus;
  387. //EPP存储KeyMap
  388. typedef struct tag_SaveToEPPHWKeyInfo
  389. {
  390. WORD wID;
  391. BYTE byAttributes;
  392. } SaveToEPPHWKeyInfo, *LPSaveToEPPHWKeyInfo;
  393. typedef struct tag_SaveToEPPLogicKeyInfo
  394. {
  395. BYTE byID;
  396. BYTE byKeyLen; //秘钥长度及内容有无
  397. BYTE byKeyNameLen;
  398. LPSTR lpszKeyName;
  399. DWORD dwUse;
  400. BYTE byHWKeyNum;
  401. LPSaveToEPPHWKeyInfo lpstSaveToEPPHWKeyInfo;
  402. BYTE byEnKeyID;
  403. LPBYTE lpbyKeyValue;
  404. } SaveToEPPLogicKeyInfo, *LPSaveToEPPLogicKeyInfo;
  405. typedef struct tag_SaveToEPPKeyMap
  406. {
  407. WORD wTotalLen;
  408. BYTE byLogicKeyNum;
  409. LPSaveToEPPLogicKeyInfo lpstSaveToEPPLogicKeyInfo;
  410. } SaveToEPPKeyMap, *LPSaveToEPPKeyMap;
  411. typedef struct tag_PinpadCap
  412. {
  413. int fwType;
  414. bool bCompound; //是否为复合设备 TRUE:复合设备;FALSE:非复合设备
  415. int usKeyNum;
  416. USHORT usDesKeyNum; //最大DesKey数量
  417. USHORT usRsaKeyNum; //最大RsaKey数量
  418. USHORT usCertificateNum; //最大证书数量
  419. USHORT usSM2KeyNum; //最大SM2Key数量
  420. USHORT usSM4KeyNum; //最大SM4Key数量
  421. USHORT usButtonNum[2]; //主键盘按键数量 下标0:横向个数 1:纵向个数
  422. USHORT usFuncButtonNum[2]; //Function按键数量下标0:横向个数 1:纵向个数
  423. BOOL bShiftSupp; //TRUE:支持Shift按键;FALSE:不支持
  424. USHORT usMaxTxtBufSize; //最大明文缓冲区长度
  425. USHORT usMaxPinBufSize; //最大PIN缓冲区长度
  426. USHORT usMaxKeyBufSize; //最大密钥缓冲区长度
  427. int fwAlgorithms;
  428. int fwPinFormats; //PinBlock算法
  429. int fwDerivationAlgorithms; //Derivation算法
  430. int fwPresentationAlgorithms; //Presentation算法
  431. int fwDisplay; //Display
  432. bool bIDConnect; //是否连接ID Card
  433. int fwIDKey; //支持的ID Key操作
  434. int fwValidationAlgorithms; //Validation算法
  435. int fwKeyCheckModes; //KCV方式
  436. std::vector<std::string> lpszExtra;
  437. WORD wKeyCheckModes; //KCV方式
  438. WORD wMaxKCVLen; //硬件能返回的KCV最大长度
  439. WORD wMinPinPressNum; //输入密码的最小长度
  440. WORD wMaxPinPressNum; //输入密码的最大长度
  441. BOOL bEchoCharSupp; //输入密码时EPP是否支持Echo字符的设置
  442. BYTE byMaxLongPressTime; //最大长按键超时时间(s)
  443. BYTE byMaxKeyInputWaitTime; //相邻按键超时时间的最大值
  444. WORD wMaxMKCount; //MK最大保存个数
  445. WORD wMaxTPKCount; //TPK最大保存个数
  446. WORD wMaxTAKCount; //TAK最大保存个数
  447. WORD wMaxTDKCount; //TDK最大保存个数
  448. WORD wMaxIVCount; //Initial Vector最大保存个数
  449. WORD wUserAreaNum; //可读写的用户区域数量
  450. WORD wUserAreaSize[256]; //每个用户区域的容量(字节数)
  451. WORD wRemoteKeySupp; //Remote Key支持
  452. WORD wGMKeySupp; //国密Key支持
  453. WORD wCommPattern;
  454. BYTE byMaxPinBlockPadding; //PinBlock支持的Padding最大值
  455. DWORD dwMaxDESCryptDataSize; //一次DES加解密数据的最大长度
  456. DWORD dwMaxDESMacDataSize; //一次参与MAC运算(DES密钥)的数据最大长度
  457. DWORD dwMaxSM4CryptDataSize; //一次SM4加解密数据的最大长度
  458. DWORD dwMaxSM4MacDataSize; //一次参与MAC运算(SM4密钥)的数据最大长度
  459. } PinpadCap, *LPPinpadCap;
  460. typedef struct PinpadKeyDetailIn
  461. {
  462. string kd;
  463. }PinpadKeyDetailIn, *LPPinpadKeyDetailIn;
  464. typedef struct PinpadKeyDetailOut
  465. {
  466. struct KeyDetail
  467. {
  468. string lpsKeyName;
  469. int fwUse;
  470. bool bLoaded;
  471. };
  472. std::vector<KeyDetail> vKD;
  473. }PinpadKeyDetailOut, *LPPinpadKeyDetailOut;
  474. typedef struct tag_PinpadFuncKeyDetailIn
  475. {
  476. int fdk;
  477. }PinpadFuncKeyDetailIn, *LPPinpadFuncKeyDetailIn;
  478. typedef struct PinpadFuncKeyDetailOut
  479. {
  480. int ulFuncMask;
  481. struct FunctionKeyDetail
  482. {
  483. int ulFDK;
  484. int usXPosition;
  485. int usYPosition;
  486. FunctionKeyDetail( int iValue, int iX, int iY )
  487. :ulFDK(iValue), usXPosition(iX), usYPosition(iY)
  488. {
  489. }
  490. };
  491. std::vector<FunctionKeyDetail> vFDK;
  492. }PinpadFuncKeyDetailOut, *LPPinpadFuncKeyDetailOut;
  493. typedef struct tag_PinpadCryptIn
  494. {
  495. int wMode;
  496. string lpsKey;
  497. std::vector<BYTE> lpxKeyEncKey;
  498. int wAlgorithm;
  499. string lpsStartValueKey;
  500. std::vector<BYTE> lpxStartValue;
  501. BYTE bPadding;
  502. BYTE bCompression;
  503. std::vector<BYTE> lpxCryptData;
  504. }PinpadCryptIn, *LPPinpadCryptIn;
  505. typedef struct tag_PinpadCryptOut
  506. {
  507. std::vector<BYTE> vC;
  508. }PinpadCryptOut, *LPPinpadCryptOut;
  509. typedef struct tag_PinpadImportKeyIn
  510. {
  511. string lpsKey;
  512. string lpsEncKey;
  513. std::vector<BYTE> lpxIdent;
  514. std::vector<BYTE> lpxValue;
  515. int fwUse;
  516. }PinpadImportKeyIn, *LPPinpadImportKeyIn;
  517. typedef struct tag_PinpadImportKeyOut
  518. {
  519. std::vector<BYTE> vIK;
  520. }PinpadImportKeyOut, *LPPinpadImportKeyOut;
  521. typedef struct tag_PinpadPinBlockIn
  522. {
  523. string lpsCustomerData;
  524. string lpsXORData;
  525. BYTE bPadding;
  526. int wFormat;
  527. string lpsKey;
  528. string lpsKeyEncKey;
  529. int wAlgorithm;
  530. }PinpadPinBlockIn, *LPPinpadPinBlockIn;
  531. typedef struct tag_PinpadPinBlockOut
  532. {
  533. std::vector<BYTE> vGPB;
  534. }PinpadPinBlockOut, *LPPinpadPinBlockOut;
  535. typedef struct tag_PinpadIntializationIn
  536. {
  537. std::vector<BYTE> lpxIdent;
  538. std::vector<BYTE> lpxKey;
  539. }PinpadIntializationIn, *LPPinpadIntializationIn;
  540. typedef struct PinpadIntializationOut
  541. {
  542. std::vector<BYTE> vGI;
  543. }PinpadIntializationOut, *LPPinpadIntializationOut;
  544. typedef struct tag_PinpadGetPinIn
  545. {
  546. int usMinLen;
  547. int usMaxLen;
  548. bool bAutoEnd;
  549. BYTE cEcho;
  550. int ulActiveFDKs;
  551. int ulActiveKeys;
  552. int ulTerminateFDKs;
  553. int ulTerminateKeys;
  554. }PinpadGetPinIn, *LPPinpadGetPinIn;
  555. typedef struct PinpadGetPinOut
  556. {
  557. int usDigits;
  558. int wCompletion;
  559. }PinpadGetPinOut, *LPPinpadGetPinOut;
  560. typedef struct tag_PinpadGetDataIn
  561. {
  562. int usMaxLen;
  563. bool bAutoEnd;
  564. int ulActiveFDKs;
  565. int ulActiveKeys;
  566. int ulTerminateFDKs;
  567. int ulTerminateKeys;
  568. }PinpadGetDataIn, *LPPinpadGetDataIn;
  569. typedef struct tag_PinpadGetDataOut
  570. {
  571. struct GetData
  572. {
  573. int wCompletion;
  574. int ulDigit;
  575. GetData( int iDigit, int iCompletion )
  576. :ulDigit(iDigit), wCompletion(iCompletion)
  577. {
  578. }
  579. };
  580. std::vector<GetData> vGD;
  581. int wCompletion;
  582. }PinpadGetDataOut, *LPPinpadGetDataOut;
  583. typedef struct tag_PinpadInputLimitInfo
  584. {
  585. BOOL bIsTextInput;
  586. BYTE lpbyActiveKeyArray[32];
  587. BYTE lpbyActiveFDKArray[32];
  588. WORD wMinLen;
  589. WORD wMaxLen;
  590. BOOL bAutoEnd;
  591. BYTE byKeyInputWaitTime;
  592. CHAR cEcho;
  593. BOOL bBeep;
  594. BYTE byLongPressTime;
  595. HWND hWnd;
  596. UINT uMsg;
  597. WORD wInputLen;
  598. } PinpadInputLimitInfo, *LPPinpadInputLimitInfo;
  599. typedef struct tag_EPPHWKeyInfo
  600. {
  601. WORD wID;
  602. WORD wAttributes;
  603. WORD wVI; //非必要信息
  604. BYTE byReserve[64];
  605. } EPPHWKeyInfo, *LPEPPHWKeyInfo;
  606. typedef struct tag_EPPLogicKeyInfo
  607. {
  608. BYTE byID;
  609. BYTE byKeyLen;
  610. CHAR szKeyName[MAX_KEY_NAME_LEN];
  611. DWORD dwUse;
  612. BYTE byHWKeyNum;
  613. EPPHWKeyInfo stEPPHWKeyInfo[ONE_LOGICKEY_MAX_HWKEY_COUNT];
  614. BYTE byEnKeyID;
  615. BYTE byKCVType;
  616. BYTE byKCVLen; //非必要信息
  617. BYTE byKCVValue[16]; //非必要信息
  618. BYTE byKeyValue[48]; //非必要信息
  619. BYTE byReseve[512];
  620. } EPPLogicKeyInfo, *LPEPPLogicKeyInfo;
  621. typedef struct tag_EPPKeyMap
  622. {
  623. BYTE byLogicKeyNum;
  624. EPPLogicKeyInfo stEPPLogicKeyInfo[MAX_LOGICKEY_COUNT];
  625. BYTE byHOSTRandomLen;
  626. BYTE byHOSTRandomValue[32];
  627. BYTE byReserve[1925];
  628. } EPPKeyMap, *LPEPPKeyMap;
  629. typedef struct tag_RSAHWKeyInfo
  630. {
  631. WORD wID;
  632. WORD wAttributes;
  633. BYTE byReserve[64];
  634. }RSAHWKeyInfo, *LPRSAHWKeyInfo;
  635. typedef struct tag_RSAKeyInfo
  636. {
  637. BYTE byID;
  638. BYTE byKeyLen;
  639. CHAR szKeyName[MAX_KEY_NAME_LEN];
  640. DWORD dwUse;
  641. BYTE byHWKeyNum;
  642. RSAHWKeyInfo stRSAHWKeyInfo[RSA_ONE_LOGICKEY_MAX_HWKEY_COUNT];
  643. BYTE bySigKeyID;
  644. BYTE byKCVType;
  645. BYTE byKCVLen;
  646. BYTE byKCVValue[32];
  647. BYTE byReseve[512];
  648. }RSAKeyInfo, *LPRSAKeyInfo;
  649. typedef struct tag_RSAKeyMap
  650. {
  651. BYTE byRSAKeyNum;
  652. RSAKeyInfo stRSAKeyInfo[RSA_MAX_LOGICKEY_COUNT];
  653. BYTE byReserve[1024];
  654. }RSAKeyMap, *LPRSAKeyMap;
  655. #pragma pack(pop)