00001
00002
00003
00004
00005
00006
00007 #ifndef OPENCT_OPENCT_H
00008 #define OPENCT_OPENCT_H
00009
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013
00014 #include <sys/types.h>
00015
00016
00017 #define OPENCT_MAX_READERS 16
00018 #define OPENCT_MAX_SLOTS 8
00019
00020 typedef struct ct_info {
00021 char ct_name[64];
00022 unsigned int ct_slots;
00023 unsigned int ct_card[OPENCT_MAX_SLOTS];
00024 unsigned ct_display : 1,
00025 ct_keypad : 1;
00026 pid_t ct_pid;
00027 } ct_info_t;
00028
00029 typedef struct ct_handle ct_handle;
00030
00031 #define IFD_CARD_PRESENT 0x0001
00032 #define IFD_CARD_STATUS_CHANGED 0x0002
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 typedef unsigned int ct_lock_handle;
00046 enum {
00047 IFD_LOCK_SHARED,
00048 IFD_LOCK_EXCLUSIVE
00049 };
00050
00051
00052
00053
00054 enum {
00055 IFD_PIN_ENCODING_BCD,
00056 IFD_PIN_ENCODING_ASCII
00057 };
00058
00059 extern int ct_status(const ct_info_t **);
00060
00061 extern int ct_reader_info(unsigned int, ct_info_t *);
00062 extern ct_handle * ct_reader_connect(unsigned int);
00063 extern void ct_reader_disconnect(ct_handle *);
00064 extern int ct_reader_status(ct_handle *, ct_info_t *);
00065 extern int ct_card_status(ct_handle *h, unsigned int slot, int *status);
00066 extern int ct_card_set_protocol(ct_handle *h, unsigned int slot,
00067 unsigned int protocol);
00068 extern int ct_card_reset(ct_handle *h, unsigned int slot,
00069 void *atr, size_t atr_len);
00070 extern int ct_card_request(ct_handle *h, unsigned int slot,
00071 unsigned int timeout, const char *message,
00072 void *atr, size_t atr_len);
00073 extern int ct_card_lock(ct_handle *h, unsigned int slot,
00074 int type, ct_lock_handle *);
00075 extern int ct_card_unlock(ct_handle *h, unsigned int slot,
00076 ct_lock_handle);
00077 extern int ct_card_transact(ct_handle *h, unsigned int slot,
00078 const void *apdu, size_t apdu_len,
00079 void *recv_buf, size_t recv_len);
00080 extern int ct_card_verify(ct_handle *h, unsigned int slot,
00081 unsigned int timeout, const char *prompt,
00082 unsigned int pin_encoding,
00083 unsigned int pin_length,
00084 unsigned int pin_offset,
00085 const void *send_buf, size_t send_len,
00086 void *recv_buf, size_t recv_len);
00087 extern int ct_card_read_memory(ct_handle *, unsigned int slot,
00088 unsigned short address,
00089 void *recv_buf, size_t recv_len);
00090 extern int ct_card_write_memory(ct_handle *, unsigned int slot,
00091 unsigned short address,
00092 const void *send_buf, size_t send_len);
00093
00094 extern int ct_status_destroy(void);
00095 extern int ct_status_clear(unsigned int, const char *);
00096 extern ct_info_t * ct_status_alloc_slot(int *);
00097 extern int ct_status_update(ct_info_t *);
00098
00099 #ifdef __cplusplus
00100 }
00101 #endif
00102
00103 #endif