17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
|
|
|
20 |
#ifndef WPT_CARD_H |
#ifndef WPT_CARD_H |
21 |
#define WPT_CARD_H |
#define WPT_CARD_H |
22 |
|
|
27 |
GPG_CARDFLAG_BAKENC = 2 /* backup encryption key. */ |
GPG_CARDFLAG_BAKENC = 2 /* backup encryption key. */ |
28 |
}; |
}; |
29 |
|
|
30 |
/* Possible card states. */ |
/* Symbolic PIN ids */ |
31 |
enum { |
enum { |
32 |
CARD_STATE_NONE=0, |
CARD_ADMIN_PIN, |
33 |
CARD_STATE_UNAWARE, |
CARD_USER_PIN |
|
CARD_STATE_UNAVAIL, |
|
|
CARD_STATE_PRESENT, |
|
|
CARD_STATE_EXCLUSI, |
|
|
CARD_STATE_EMPTY, |
|
|
CARD_STATE_INUSE, |
|
|
CARD_STATE_MUTE |
|
34 |
}; |
}; |
35 |
|
|
36 |
|
/* Card callback ids */ |
37 |
enum { |
enum { |
38 |
CARD_ADMIN_PIN, |
CARD_CB_INS_CARD = 1, /* insert card */ |
|
CARD_USER_PIN |
|
39 |
}; |
}; |
40 |
|
|
41 |
|
|
42 |
|
/* openpgp card context. */ |
43 |
|
struct gpg_card_s { |
44 |
|
char *aid; /* appID */ |
45 |
|
char *card_type; |
46 |
|
char *version; /* version */ |
47 |
|
char *vendor; /* vendor */ |
48 |
|
char *serial; /* serial number */ |
49 |
|
char *surname; /* card users surname */ |
50 |
|
char *givenname; /* card users given name */ |
51 |
|
char *lang; /* language */ |
52 |
|
char sex; /* card users sex */ |
53 |
|
char *url; /* key url */ |
54 |
|
char *login; /* login data (name) */ |
55 |
|
int force_pin; |
56 |
|
char *maxpinlen[3]; |
57 |
|
int sig_count; /* signature counter */ |
58 |
|
char *ca_fpr[3]; /* CA fingerprints */ |
59 |
|
char *fpr[3]; /* key fingerprints */ |
60 |
|
long fpr_created[3];/* fingerprint timestamps. */ |
61 |
|
char *fpr_created_str[3]; |
62 |
|
}; |
63 |
|
typedef struct gpg_card_s *gpg_card_t; |
64 |
|
|
65 |
/* PIN callback context. */ |
/* PIN callback context. */ |
66 |
struct pin_cb_ctx_s { |
struct pin_cb_ctx_s { |
67 |
int which; /* which command to execute. */ |
int which; /* which command to execute. */ |
74 |
struct card_cb_s { |
struct card_cb_s { |
75 |
int cancel; /* 1=user cancelled operation. */ |
int cancel; /* 1=user cancelled operation. */ |
76 |
int init; |
int init; |
77 |
int code; |
int code; /* 1=user need to insert card. */ |
78 |
char val[128]; |
char val[128]; /* application specific value. */ |
79 |
}; |
}; |
80 |
|
|
|
struct pcsc_reader_s; |
|
|
typedef struct pcsc_reader_s * pcsc_reader_t; |
|
|
|
|
|
|
|
|
unsigned get_card_status (void); |
|
|
int show_card_status (void); |
|
81 |
|
|
82 |
/*-- wptCardManager.cpp --*/ |
/*-- wptCardManager.cpp --*/ |
83 |
const char* card_callback (int code, void *opaque); |
const char* card_callback (int code, void *opaque); |
84 |
|
|
|
/*-- wptCardPCSC.c --*/ |
|
|
#ifdef __cplusplus |
|
|
extern "C" { |
|
|
#endif |
|
|
|
|
|
int pcsc_loadlib (int scard_support); |
|
|
void pcsc_free_readers (pcsc_reader_t rd); |
|
|
const char* pcsc_get_reader (pcsc_reader_t rd, int idx, int *ret_nrd); |
|
|
int pcsc_scan_readers (pcsc_reader_t *ret_rd); |
|
|
int pcsc_get_card_status (void); |
|
|
|
|
|
#ifdef __cplusplus |
|
|
} |
|
|
#endif |
|
|
|
|
85 |
#endif /*WPT_CARD_H*/ |
#endif /*WPT_CARD_H*/ |