42 #ifndef _SCH_VAR_DEF_H
43 #define _SCH_VAR_DEF_H
49 #define DES_KEY_SIZE 8
50 #define TDES_KEY_SIZE 16
51 #define TRANSACTION_FIELD_SIZE 5
52 #define PIN_BLOC_SIZE 8
53 #define PAN_BLOC_SIZE 8
54 #define TDES_16_KEY_SIZE TDES_KEY_SIZE
55 #define TDES_24_KEY_SIZE 24
59 #define ANSWER_HEADER_SIZE (TAG_SIZE + LEN_SIZE)
60 #define RETURN_CODE_SIZE 4
61 #define BUFFER_SIZE 32
63 #define MIN_PIN_CODE_SIZE 4
64 #define MAX_PIN_CODE_SIZE 12
65 #define MAX_PIN_AREA_SIZE 20
66 #define MAX_DATA_SIZE 1024
68 #define SEND_COMPLETED COM_FIN_EMI
70 #define MAX_SCH_REC_TIMEOUT 10
75 #define ISO9564_F0_DES 1
76 #define ISO9564_F0_TDES 2
77 #define ISO9564_F1_DES 3
78 #define ISO9564_F1_TDES 4
79 #define ISO9564_F3_DES 5
80 #define ISO9564_F3_TDES 6
81 #define ISO9564_F2_DES 7
82 #define ISO9564_F2_TDES 8
83 #define ISO9564_F2_OTHER 9
84 #define ISO9564_F0_F8_DES 10
85 #define ISO9564_F0_F8_TDES 11
86 #define ISO9564_F3_F8_DES 12
87 #define ISO9564_F3_F8_TDES 13
88 #define ISO9564_F0_TDES_24 14
89 #define ISO9564_F1_TDES_24 15
90 #define ISO9564_F2_TDES_24 16
91 #define ISO9564_F3_TDES_24 17
93 #define AA (0x10101010)
94 #define CONTROL_FIELD_3 0x30
96 #define ID_SCH_ISO9564 0x40020000
98 #define TAG_ISO9564_0 0x40020000
99 #define TAG_ISO9564_1 0x40020001
100 #define TAG_ISO9564_2 0x40020002
101 #define TAG_ISO9564_3 0x40020003
106 #define ID_SCH_DUKPT_DES 0x40020100
107 #define TAG_DUKPT 0x40020100
108 #define TAG_DUKPT_INITIALISATION 0x40020101
109 #define TAG_DUKPT_LOAD 0x40020102
110 #define TAG_DUKPT_TRANSACTION 0x40020103
111 #define TAG_DUKPT_CANCEL 0x40020104
113 #define DUKPT_INITIAL_KEY_CREATION 1
114 #define DUKPT_LOAD_KEY 2
115 #define DUKPT_LOAD_KSN 3
116 #define DUKPT_LOAD_KSN_CREATE 3+0x10000
117 #define DUKPT_ENCRYPT_PIN 4
118 #define DUKPT_ENCRYPT_PIN_F3 5
119 #define DUKPT_CANCEL_KEYS 6
120 #define DUKPT_GET_CURRENT_STATE 7
121 #define DUKPT_LOAD_RIGHT_PART_DERIVATION_KEY 8
122 #define DUKPT_LOAD_LEFT_PART_DERIVATION_KEY 9
123 #define DUKPT_LOAD_RIGHT_PART_KEY 10
124 #define DUKPT_LOAD_LEFT_PART_KEY 11
125 #define DUKPT_LOAD_CIPHERED_DERIVATION_KEY 12
126 #define DUKPT_LOAD_CIPHERED_INITIAL_KEY 13
127 #define DUKPT_CREATE_KEYS 14
128 #define DUKPT_GET_CURRENT_SMID 15
129 #define DUKPT_KCV_INITIALKEY 16
130 #define DUKPT_KCV_DERIVKEY 17
131 #define DUKPT_MAC_VERIFY 18
132 #define DUKPT_MAC_COMPUTE 19
133 #define DUKPT_ENCRYPT_DATABLOCK 20
134 #define DUKPT_ENCRYPT_DATABLOCK_F3 21
135 #define DUKPT_ENCRYPT_DATA_ECB 22
136 #define DUKPT_ENCRYPT_DATA_CBC 23
137 #define DUKPT_ENCRYPT_DATA_EXT_ECB 24
138 #define DUKPT_DECRYPT_DATA_EXT_ECB 25
139 #define DUKPT_ENCRYPT_DATA_EXT_CBC 26
140 #define DUKPT_DECRYPT_DATA_EXT_CBC 27
142 #define NB_DUKPT_KEYS 21
143 #define DUKPT_SMID_SIZE 10
144 #define DUKPT_DATA_SIZE 512
146 #define DUKPT_IN_FUNCTION 0
147 #define DUKPT_NOT_IN_FUNCTION 1
148 #define DUKPT_KSN_NOT_REC 2
149 #define DUKPT_INIT_KEY_NOT_REC 3
150 #define DUKPT_END_OF_LIFE (-110)
152 #define ID_SCH_DUKPT_TDES 0x40020200
153 #define TAG_DUKPT_TDES 0x40020200
154 #define TAG_TDUKPT 0x40020200
155 #define TAG_TDUKPT_INITIALISATION 0x40020201
156 #define TAG_TDUKPT_LOAD 0x40020202
157 #define TAG_TDUKPT_TRANSACTION 0x40020203
158 #define TAG_TDUKPT_CANCEL 0x40020204
160 #define INC_AUTO_MODE 0
161 #define INC_FORCED_MODE 1
166 #define ID_SCH_INIT_PIN_CODE 0x40020300
167 #define ID_SCH_INIT_KEYS_ISO9564 0x40020400
168 #define ID_SCH_INIT_KEY_DUKPT 0x40020500
169 #define ID_SCH_INIT_KEY_TDUKPT 0x40020600
171 #define ID_SCR_KEY_DES_ISO9564 0x40022000
172 #define ID_SCR_KEY_TDES_ISO9564 0x40022100
173 #define ID_SCR_KEY_OTHER_ISO9564 0x40022200
174 #define ID_SCR_KEY_DES_DUKPT 0x40022300
175 #define ID_SCR_KEY_TDES_DUKPT 0x40022400
176 #define ID_SCR_KEY 0x40022400
182 #define NAM_SCH_LOAD_DATA ("SchLoadData")
183 #define ID_SCH_LOAD_DATA 0x40020400
184 #define TAG_LOAD_DATA 0x40020400
186 #define DATA_NO_CIPHER 0x00000000
187 #define CLEAR_DATA_MODE 0x00000000
188 #define DATA_DES_CIPHER 0x01000000
189 #define DES_CIPHERED_MODE 0x01000000
190 #define DATA_TDES_CIPHER 0x02000000
191 #define TDES_CIPHERED_MODE DATA_TDES_CIPHER
192 #define CREATE_AREA 0x03000000
193 #define CREATE_AREA_FULLBL1 0x04000000
195 #define DATA_TDES_16_CIPHER DATA_TDES_CIPHER
196 #define TDES_16_CIPHERED_MODE DATA_TDES_CIPHER
197 #define DATA_TDES_24_CIPHER 0x05000000
198 #define TDES_24_CIPHERED_MODE DATA_TDES_24_CIPHER
199 #define AES_128_CIPHERED_MODE 0x06000000
200 #define AES_192_CIPHERED_MODE 0x07000000
201 #define AES_256_CIPHERED_MODE 0x08000000
203 #define OFFCET_MASTER_KEY 0x000003FF
204 #define OFFSET_MASTER_KEY 0x000003FF
206 #define NAM_SCH_LOAD_KEYTLV ("SloadKeyTlv")
207 #define ID_SCH_LOAD_KEYTLV 0x40020403
212 #define NAM_SCH_GET_PIN ("SchGetPin")
213 #define ID_SCH_GET_PIN 0x40020500
216 #define HID_KEY_PIN_CODE '*'
217 #define C_GET_PIN_AUTO_VAL_MODE 0x01
218 #define C_GET_PIN_NO_FCT_KEY 0x80
219 #define C_GET_PIN_T_ANN_MODE 0x40
223 #define NAM_SCH_CIPHER_DATA ("SchCipherDa")
224 #define ID_SCH_CIPHER_DATA 0x40020600
225 #define TAG_CIPHER_DATA 0x40020600
227 #define DATA_DES_DECIPHER 0x04000000
228 #define DATA_TDES_DECIPHER 0x08000000
229 #define DATA_TDES_24_CIPHER_BIS 0x60000000
230 #define DATA_TDES_24_DECIPHER 0x09000000
231 #define DATA_DES_CIPHER_ICV 0x10000000
232 #define DATA_TDES_CIPHER_ICV 0x20000000
233 #define DATA_TDES_24_CIPHER_ICV 0x30000000
234 #define DATA_DES_DECIPHER_ICV 0x40000000
235 #define DATA_TDES_DECIPHER_ICV 0x80000000
236 #define DATA_TDES_24_DECIPHER_ICV 0x50000000
237 #define DATA_DES_CIPHER_OFB 0x05000000
238 #define DATA_TDES_CIPHER_OFB 0x06000000
239 #define DATA_TDES_24_CIPHER_OFB 0x07000000
240 #define DATA_MAC_ICV 0x90000000
245 #define SCH_PIN_ENTRY_NAME ("SchPinEntry")
246 #define ID_SCH_PIN_ENTRY 0x40020700
252 #define MIDDLE_HIGH 4
272 #define NAM_SCH_FREE_SECRET ("SchFree")
273 #define ID_SCH_FREE_SECRET 0x40020800
278 #define NAM_SCH_XOR ("SchXOR")
279 #define ID_SCH_XOR 0x40030200
280 #define TAG_XOR ID_SCH_XOR
285 #define NAM_SCH_RANDOM ("Sch_Random")
286 #define ID_SCH_RANDOM 0x40030100
291 #define NAM_SCH_MAC_ICVDU ("SchMacIcvDu")
292 #define ID_SCH_MAC_ICVDU 0x40020A00
293 #define TAG_MAC_ICVDU ID_SCH_MAC_ICVDU
296 #define OP_MAC_ICV_DES 0x90000000
297 #define OP_MAC_ICV_TDES 0xA0000000
300 #define MAC_VERIFY 0x0001
301 #define MAC_COMPUTE 0x0002
307 #define NAM_SCH_ENMENTRY ("ENmEntryGEN")
308 #define ID_SCH_ENMENTRY 0x40030850
309 #define TAG_ENMENTRYGEN ID_SCH_ENMENTRY
317 #define C_DECAL_FIRSTTIMEOUT 16
318 #define C_MSK_FIRSTTIMEOUT 0xFFFF
320 #define C_DECAL_INTERTIMEOUT 0
321 #define C_MSK_INTERTIMEOUT 0xFFFF
328 #define C_MSK_NUM (1 << 0)
329 #define C_MSK_VAL (1 << 1)
330 #define C_MSK_CORR (1 << 2)
331 #define C_MSK_ANN (1 << 3)
332 #define C_MSK_F (1 << 4)
333 #define C_MSK_POINT (1 << 5)
334 #define C_MSK_STAR (1 << 6)
335 #define C_MSK_UP (1 << 7)
336 #define C_MSK_SK2 (1 << 8)
337 #define C_MSK_SK3 (1 << 9)
338 #define C_MSK_DOWN (1 << 10)
339 #define C_MSK_SK1 (1 << 11)
340 #define C_MSK_SK4 (1 << 12)
347 #define C_DECAL_MESSHEAD 24
348 #define C_MSK_MESSHEAD 0xFF
350 #define C_DECAL_LINEHEAD 16
351 #define C_MSK_LINEHEAD 0xFF
353 #define C_DECAL_COLHEAD 8
354 #define C_MSK_COLHEAD 0xFF
356 #define C_DECAL_MODE 0
357 #define C_MSK_MODE 0xFF
360 #define C_NUMGEN_MODE_TEXT 0
361 #define C_NUMGEN_MODE_GRAPH 1
369 #define C_DECAL_MESSFOOT 24
370 #define C_MSK_MESSFOOT 0xFF
372 #define C_DECAL_LINEFOOT 16
373 #define C_MSK_LINEFOOT 0xFF
375 #define C_DECAL_COLFOOT 8
376 #define C_MSK_COLFOOT 0xFF
378 #define C_DECAL_EXTRA 0
379 #define C_MSK_EXTRA 0xFF
383 #define C_EXTRA_LENGTH_PARAM 25
386 #define C_MESSAGE_BUFFER_MAX_SIZE 14000
390 #define C_NUM_MESS_LENGTH 60
400 #define ERR_ID_NOT_FOUND (-1024)
401 #define ERR_PIN_CODE_NOT_FOUND (-1025)
402 #define ERR_BAD_PIN_CODE_LEN (-1026)
403 #define ERR_BAD_IAPP_OPERATION (-1027)
404 #define ERR_UNKNOW_FORMAT (-1028)
405 #define ERR_DUKPT_END_OF_LIFE (-1029)
406 #define ERR_BAD_ACTION_TYPE (-1030)
408 #define ERR_ENTRY_CANCELED (-1031)
409 #define ERR_TIMEOUT (-1032)
410 #define ERR_BAD_IHM_OPERATION (-1033)
412 #define ERR_SYSTEME_ERROR (-1034)
413 #define ERR_SYSTEM (-1034)
415 #define ERR_BAD_PARAM (-1035)
417 #define ERR_MAC_VERIFY (-1036)
418 #define ERR_MAC_KEY (-1037)
420 #define ERR_DUKPT_NOT_IN_FUNCTION (-1038)
421 #define ERR_DIFFERENCE (-1039)
423 #define C_ERR_BAD_MESS_NO (-2901)
424 #define C_ERR_BAD_MESS_IAPP (-2902)
425 #define C_ERR_BAD_SIGN_CARD (-2903)
426 #define C_ERR_BAD_SIGN (-2904)
427 #define C_ERR_BAD_BUFFER_FORMAT (-2905)
428 #define C_ERR_BAD_MODE (-2906)
429 #define C_ERR_BUFFER_SIZE (-2907)
430 #define C_ERR_ECHO_CHAR (-2908)
431 #define C_ERR_CURRENCY_CODE (-2909)
432 #define C_ERR_FILE_NAME_PREFIX (-2910)
434 #define SCH_ERROR_SCHEME (-5000)
435 #define SCH_ERROR_LIBRARY (-6000)
446 unsigned char key[DES_KEY_SIZE];
454 unsigned char key[TDES_KEY_SIZE];
461 unsigned char PinCode[MAX_PIN_CODE_SIZE];
463 unsigned char Rfu[4];
469 unsigned char Key[TDES_KEY_SIZE];
475 unsigned char Key[DES_KEY_SIZE];
481 unsigned char Key[TDES_KEY_SIZE];
482 unsigned char Rfu[104];
483 } T_ISO9564_TDES_KEY_AREA;
488 unsigned char Key[DES_KEY_SIZE];
489 unsigned char Rfu[112];
490 } T_ISO9564_DES_KEY_AREA;
495 unsigned char PinBloc[PIN_BLOC_SIZE];
496 unsigned char Rfu[1000];
497 } T_ISO9564_2_OTHER_AREA;
503 unsigned char Answer[BUFFER_SIZE];
507 #ifndef __CRYPTO_DEF_H
508 #ifndef __CRYPTO_DEF_H_INCLUDED__
510 unsigned char Key[DES_KEY_SIZE];
511 unsigned short Check;
515 unsigned char Key[TDES_KEY_SIZE];
516 unsigned short Check;
527 T_DUKPT_KEY keys[NB_DUKPT_KEYS];
528 unsigned char Smid[DUKPT_SMID_SIZE];
529 unsigned char DerivationKey[TDES_KEY_SIZE];
530 unsigned char InitialKey[DES_KEY_SIZE];
532 unsigned char Rfu[760-
sizeof(T_MAC_KDES)];
533 } T_DUKPT_DES_SECRET_AREA;
539 unsigned char TransactionSmid[DUKPT_SMID_SIZE];
540 unsigned char TransactionPinBloc[PIN_BLOC_SIZE];
547 unsigned char TransactionSmid[DUKPT_SMID_SIZE];
548 unsigned char CipheredData[DUKPT_DATA_SIZE];
549 } T_DUKPT_DATA_RESULT;
555 T_DUKPT_TDES_KEY keys[NB_DUKPT_KEYS];
556 unsigned char Smid[DUKPT_SMID_SIZE];
557 unsigned char DerivationKey[TDES_KEY_SIZE];
558 unsigned char InitialKey[TDES_KEY_SIZE];
560 unsigned char Rfu[572-
sizeof(T_MAC_KTDES)];
561 } T_DUKPT_TDES_SECRET_AREA;
566 unsigned char Keys[1008];
573 } T_LOAD_DATA_RESULT;
579 unsigned char BufferOut[MAX_DATA_SIZE];
580 } T_CIPHER_DATA_RESULT;
587 unsigned char EchoChar;
589 unsigned char Column;
601 unsigned char MinDigit;
602 unsigned char MaxDigit;
612 unsigned short InterTimeout;
613 unsigned short GlobalTimeout;
623 unsigned char ErrorNote;
624 unsigned char ErrorLevel;
625 unsigned char NormalNote;
626 unsigned char NormalLevel;
639 } T_PIN_ENTRY_RESULT;