OpenCT  0.6.20
openct.h
1 /*
2  * Main OpenCT include file
3  *
4  * Copyright (C) 2003, Olaf Kirch <okir@suse.de>
5  */
6 
7 #ifndef OPENCT_OPENCT_H
8 #define OPENCT_OPENCT_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #include <sys/types.h>
15 
16 /* Various implementation limits */
17 #define OPENCT_MAX_READERS 16
18 #define OPENCT_MAX_SLOTS 8
19 
20 typedef struct ct_info {
21  char ct_name[64];
22  unsigned int ct_slots;
23  unsigned int ct_card[OPENCT_MAX_SLOTS];
24  unsigned ct_display : 1,
25  ct_keypad : 1;
26  pid_t ct_pid;
27 } ct_info_t;
28 
29 typedef struct ct_handle ct_handle;
30 
31 #define IFD_CARD_PRESENT 0x0001
32 #define IFD_CARD_STATUS_CHANGED 0x0002
33 
34 /* Lock types
35  * - shared locks allow concurrent access from
36  * other applications run by the same user.
37  * Used e.g. by pkcs11 login.
38  * - exclusive locks deny any access by other
39  * applications.
40  *
41  * When a lock is granted, a lock handle is passed
42  * to the client, which it must present in the
43  * subsequent unlock call.
44  */
45 typedef unsigned int ct_lock_handle;
46 enum {
47  IFD_LOCK_SHARED,
48  IFD_LOCK_EXCLUSIVE
49 };
50 
51 /*
52  * PIN encoding types
53  */
54 enum {
55  IFD_PIN_ENCODING_BCD,
56  IFD_PIN_ENCODING_ASCII
57 };
58 
59 extern int ct_status(const ct_info_t **);
60 
61 extern int ct_reader_info(unsigned int, ct_info_t *);
62 extern ct_handle * ct_reader_connect(unsigned int);
63 extern void ct_reader_disconnect(ct_handle *);
64 extern int ct_reader_status(ct_handle *, ct_info_t *);
65 extern int ct_card_status(ct_handle *h, unsigned int slot, int *status);
66 extern int ct_card_set_protocol(ct_handle *h, unsigned int slot,
67  unsigned int protocol);
68 extern int ct_card_reset(ct_handle *h, unsigned int slot,
69  void *atr, size_t atr_len);
70 extern int ct_card_request(ct_handle *h, unsigned int slot,
71  unsigned int timeout, const char *message,
72  void *atr, size_t atr_len);
73 extern int ct_card_lock(ct_handle *h, unsigned int slot,
74  int type, ct_lock_handle *);
75 extern int ct_card_unlock(ct_handle *h, unsigned int slot,
76  ct_lock_handle);
77 extern int ct_card_transact(ct_handle *h, unsigned int slot,
78  const void *apdu, size_t apdu_len,
79  void *recv_buf, size_t recv_len);
80 extern int ct_card_verify(ct_handle *h, unsigned int slot,
81  unsigned int timeout, const char *prompt,
82  unsigned int pin_encoding,
83  unsigned int pin_length,
84  unsigned int pin_offset,
85  const void *send_buf, size_t send_len,
86  void *recv_buf, size_t recv_len);
87 extern int ct_card_read_memory(ct_handle *, unsigned int slot,
88  unsigned short address,
89  void *recv_buf, size_t recv_len);
90 extern int ct_card_write_memory(ct_handle *, unsigned int slot,
91  unsigned short address,
92  const void *send_buf, size_t send_len);
93 
94 extern int ct_status_destroy(void);
95 extern int ct_status_clear(unsigned int, const char *);
96 extern ct_info_t * ct_status_alloc_slot(int *);
97 extern int ct_status_update(ct_info_t *);
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* OPENCT_OPENCT_H */
Definition: openct.h:20

libp11, Copyright (C) 2005 Olaf Kirch <okir@lst.de>OpenSC-Project.org Logo