1 |
twoaday |
2 |
/* wptCard.h |
2 |
|
|
* Copyright (C) 2003, 2004, 2005 Timo Schulz |
3 |
|
|
* |
4 |
|
|
* This file is part of WinPT. |
5 |
|
|
* |
6 |
|
|
* WinPT is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* WinPT is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#ifndef WPT_CARD_H |
22 |
|
|
#define WPT_CARD_H |
23 |
|
|
|
24 |
twoaday |
23 |
/* Existing card flags. */ |
25 |
twoaday |
2 |
enum { |
26 |
twoaday |
23 |
GPG_CARDFLAG_NONE = 0, |
27 |
|
|
GPG_CARDFLAG_REPLACE = 1, /* replace existing keys. */ |
28 |
|
|
GPG_CARDFLAG_BAKENC = 2 /* backup encryption key. */ |
29 |
|
|
}; |
30 |
|
|
|
31 |
|
|
/* Possible card states. */ |
32 |
|
|
enum { |
33 |
twoaday |
2 |
CARD_STATE_NONE=0, |
34 |
|
|
CARD_STATE_UNAWARE, |
35 |
|
|
CARD_STATE_UNAVAIL, |
36 |
|
|
CARD_STATE_PRESENT, |
37 |
|
|
CARD_STATE_EXCLUSI, |
38 |
|
|
CARD_STATE_EMPTY, |
39 |
|
|
CARD_STATE_INUSE, |
40 |
|
|
CARD_STATE_MUTE |
41 |
|
|
}; |
42 |
|
|
|
43 |
twoaday |
23 |
enum { |
44 |
|
|
CARD_ADMIN_PIN, |
45 |
|
|
CARD_USER_PIN |
46 |
|
|
}; |
47 |
twoaday |
2 |
|
48 |
|
|
|
49 |
twoaday |
23 |
/* PIN callback context. */ |
50 |
twoaday |
2 |
struct pin_cb_ctx_s { |
51 |
twoaday |
23 |
int which; /* which command to execute. */ |
52 |
|
|
char *info_text; /* additional info text. */ |
53 |
|
|
char *apin; /* admin pin */ |
54 |
|
|
char *upin; /* user pin */ |
55 |
twoaday |
2 |
}; |
56 |
|
|
|
57 |
twoaday |
23 |
/* Card callback context. */ |
58 |
twoaday |
2 |
struct card_cb_s { |
59 |
twoaday |
23 |
int cancel; /* 1=user cancelled operation. */ |
60 |
twoaday |
2 |
int init; |
61 |
|
|
int code; |
62 |
|
|
char val[128]; |
63 |
|
|
}; |
64 |
|
|
|
65 |
|
|
struct pcsc_reader_s; |
66 |
|
|
typedef struct pcsc_reader_s * pcsc_reader_t; |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
unsigned get_card_status (void); |
70 |
|
|
int show_card_status (void); |
71 |
|
|
|
72 |
|
|
/*-- wptCardManager.cpp --*/ |
73 |
twoaday |
23 |
const char* card_callback (int code, void *opaque); |
74 |
twoaday |
2 |
|
75 |
|
|
/*-- wptCardPCSC.c --*/ |
76 |
|
|
#ifdef __cplusplus |
77 |
|
|
extern "C" { |
78 |
|
|
#endif |
79 |
|
|
|
80 |
twoaday |
23 |
int pcsc_loadlib (int scard_support); |
81 |
|
|
void pcsc_free_readers (pcsc_reader_t rd); |
82 |
|
|
const char* pcsc_get_reader (pcsc_reader_t rd, int idx, int *ret_nrd); |
83 |
|
|
int pcsc_scan_readers (pcsc_reader_t *ret_rd); |
84 |
|
|
int pcsc_get_card_status (void); |
85 |
twoaday |
2 |
|
86 |
|
|
#ifdef __cplusplus |
87 |
|
|
} |
88 |
|
|
#endif |
89 |
|
|
|
90 |
twoaday |
23 |
#endif /*WPT_CARD_H*/ |