| 1 | /* |
|---|
| 2 | * Defines CT-API functions and returns |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 1998, David Corcoran |
|---|
| 5 | */ |
|---|
| 6 | |
|---|
| 7 | #ifndef OPENCT_CTAPI_H |
|---|
| 8 | #define OPENCT_CTAPI_H |
|---|
| 9 | |
|---|
| 10 | #ifdef __cplusplus |
|---|
| 11 | extern "C" { |
|---|
| 12 | #endif |
|---|
| 13 | |
|---|
| 14 | #define MAX_APDULEN 1040 |
|---|
| 15 | |
|---|
| 16 | char CT_init(unsigned short Ctn, /* Terminal Number */ |
|---|
| 17 | unsigned short pn /* Port Number */ |
|---|
| 18 | ); |
|---|
| 19 | |
|---|
| 20 | char CT_close(unsigned short Ctn /* Terminal Number */ |
|---|
| 21 | ); |
|---|
| 22 | |
|---|
| 23 | char CT_data(unsigned short ctn, /* Terminal Number */ |
|---|
| 24 | unsigned char *dad, /* Destination */ |
|---|
| 25 | unsigned char *sad, /* Source */ |
|---|
| 26 | unsigned short lc, /* Length of command */ |
|---|
| 27 | unsigned char *cmd, /* Command/Data Buffer */ |
|---|
| 28 | unsigned short *lr, /* Length of Response */ |
|---|
| 29 | unsigned char *rsp /* Response */ |
|---|
| 30 | ); |
|---|
| 31 | |
|---|
| 32 | #define OK 0 /* Success */ |
|---|
| 33 | #define ERR_INVALID -1 /* Invalid Data */ |
|---|
| 34 | #define ERR_CT -8 /* CT Error */ |
|---|
| 35 | #define ERR_TRANS -10 /* Transmission Error */ |
|---|
| 36 | #define ERR_MEMORY -11 /* Memory Allocate Error */ |
|---|
| 37 | #define ERR_HOST -127 /* Abort by Host/OS */ |
|---|
| 38 | #define ERR_HTSI -128 /* HTSI Error */ |
|---|
| 39 | |
|---|
| 40 | enum { |
|---|
| 41 | CTAPI_DAD_ICC1 = 0, |
|---|
| 42 | CTAPI_DAD_CT = 1, |
|---|
| 43 | CTAPI_DAD_HOST = 2, |
|---|
| 44 | CTAPI_DAD_ICC2 = 3 |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | /* |
|---|
| 48 | * CT-BCS commands |
|---|
| 49 | */ |
|---|
| 50 | #define CTBCS_CLA 0x20 |
|---|
| 51 | #define CTBCS_CLA_2 0x80 |
|---|
| 52 | #define CTBCS_INS_RESET 0x11 |
|---|
| 53 | #define CTBCS_INS_REQUEST_ICC 0x12 |
|---|
| 54 | #define CTBCS_INS_STATUS 0x13 |
|---|
| 55 | #define CTBCS_INS_EJECT_ICC 0x15 |
|---|
| 56 | #define CTBCS_INS_INPUT 0x16 |
|---|
| 57 | #define CTBCS_INS_OUTPUT 0x17 |
|---|
| 58 | #define CTBCS_INS_PERFORM_VERIFICATION 0x18 |
|---|
| 59 | #define CTBCS_INS_MODIFY_VERIFICATION 0x19 |
|---|
| 60 | #define CTBCS_INS_SET_INTERFACE_PARAM 0x60 |
|---|
| 61 | |
|---|
| 62 | /* |
|---|
| 63 | * CT-BCS functional units (P1 byte) |
|---|
| 64 | */ |
|---|
| 65 | #define CTBCS_UNIT_CT 0x00 |
|---|
| 66 | #define CTBCS_UNIT_INTERFACE1 0x01 |
|---|
| 67 | #define CTBCS_UNIT_INTERFACE2 0x02 |
|---|
| 68 | #define CTBCS_UNIT_DISPLAY 0x40 |
|---|
| 69 | #define CTBCS_UNIT_KEYPAD 0x50 |
|---|
| 70 | |
|---|
| 71 | /* |
|---|
| 72 | * P2 parameter for Reset CT: data to be returned |
|---|
| 73 | */ |
|---|
| 74 | #define CTBCS_P2_RESET_NO_RESP 0x00 /* Return no data */ |
|---|
| 75 | #define CTBCS_P2_RESET_GET_ATR 0x01 /* Return complete ATR */ |
|---|
| 76 | #define CTBCS_P2_RESET_GET_HIST 0x02 /* Return historical bytes */ |
|---|
| 77 | |
|---|
| 78 | /* |
|---|
| 79 | * P2 parameter for Request ICC: data to be returned |
|---|
| 80 | */ |
|---|
| 81 | #define CTBCS_P2_REQUEST_NO_RESP 0x00 /* Return no data */ |
|---|
| 82 | #define CTBCS_P2_REQUEST_GET_ATR 0x01 /* Return complete ATR */ |
|---|
| 83 | #define CTBCS_P2_REQUEST_GET_HIST 0x02 /* Return historical bytes */ |
|---|
| 84 | |
|---|
| 85 | /* |
|---|
| 86 | * P2 parameter for Get status: TAG of data object to return |
|---|
| 87 | */ |
|---|
| 88 | #define CTBCS_P2_STATUS_MANUFACTURER 0x46 /* Return manufacturer DO */ |
|---|
| 89 | #define CTBCS_P2_STATUS_ICC 0x80 /* Return ICC DO */ |
|---|
| 90 | |
|---|
| 91 | /* |
|---|
| 92 | * P2 parameter for Input |
|---|
| 93 | */ |
|---|
| 94 | #define CTBCS_P2_INPUT_ECHO 0x01 /* Echo input on display */ |
|---|
| 95 | #define CTBCS_P2_INPUT_ASTERISKS 0x02 /* Echo input as asterisks */ |
|---|
| 96 | |
|---|
| 97 | /* |
|---|
| 98 | * Tags for paramaters to input, output et al. |
|---|
| 99 | */ |
|---|
| 100 | #define CTBCS_TAG_PROMPT 0x50 |
|---|
| 101 | #define CTBCS_TAG_VERIFY_CMD 0x52 |
|---|
| 102 | #define CTBCS_TAG_TIMEOUT 0x80 |
|---|
| 103 | #define CTBCS_TAG_TPP 0x22 |
|---|
| 104 | #define CTBCS_TAG_TPC 0x45 |
|---|
| 105 | |
|---|
| 106 | /* |
|---|
| 107 | * PIN command control flags |
|---|
| 108 | */ |
|---|
| 109 | #define CTBCS_PIN_CONTROL_LEN_SHIFT 4 |
|---|
| 110 | #define CTBCS_PIN_CONTROL_LEN_MASK 0x0F |
|---|
| 111 | #define CTBCS_PIN_CONTROL_ENCODE_ASCII 0x01 |
|---|
| 112 | |
|---|
| 113 | /* |
|---|
| 114 | * Status words returned by CTBCS |
|---|
| 115 | */ |
|---|
| 116 | |
|---|
| 117 | #define CTBCS_SW_BAD_LENGTH 0x6700 |
|---|
| 118 | #define CTBCS_SW_BAD_COMMAND 0x6900 |
|---|
| 119 | #define CTBCS_SW_NOT_EXECUTABLE 0x6985 |
|---|
| 120 | #define CTBCS_SW_BAD_PARAMS 0x6a00 |
|---|
| 121 | #define CTBCS_SW_NOT_SUPPORTED 0x6a80 |
|---|
| 122 | #define CTBCS_SW_INVALID_TLV 0x6a85 |
|---|
| 123 | #define CTBCS_SW_BAD_LE 0x6c00 |
|---|
| 124 | #define CTBCS_SW_BAD_INS 0x6d00 |
|---|
| 125 | #define CTBCS_SW_BAD_CLASS 0x6e00 |
|---|
| 126 | #define CTBCS_SW_BAD_ICC 0x6f00 |
|---|
| 127 | #define CTBCS_SW_SUCCESS 0x9000 |
|---|
| 128 | |
|---|
| 129 | /* |
|---|
| 130 | * Data returned by Get Status command |
|---|
| 131 | */ |
|---|
| 132 | #define CTBCS_DATA_STATUS_NOCARD 0x00 /* No card present */ |
|---|
| 133 | #define CTBCS_DATA_STATUS_CARD 0x01 /* Card present */ |
|---|
| 134 | #define CTBCS_DATA_STATUS_CARD_CONNECT 0x05 /* Card present */ |
|---|
| 135 | |
|---|
| 136 | #ifdef __cplusplus |
|---|
| 137 | } |
|---|
| 138 | #endif |
|---|
| 139 | #endif /* OPENCT_CTAPI_H */ |
|---|