1 |
/* wptCard.h - common card definitions |
2 |
* Copyright (C) 2003-2006 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 |
#ifndef WPT_CARD_H |
21 |
#define WPT_CARD_H |
22 |
|
23 |
/* Existing card flags. */ |
24 |
enum card_flag_t { |
25 |
GPG_CARDFLAG_NONE = 0, |
26 |
GPG_CARDFLAG_REPLACE = 1, /* replace existing keys. */ |
27 |
GPG_CARDFLAG_BAKENC = 2 /* backup encryption key. */ |
28 |
}; |
29 |
|
30 |
/* Symbolic PIN ids */ |
31 |
enum card_pin_t { |
32 |
CARD_ADMIN_PIN, |
33 |
CARD_USER_PIN |
34 |
}; |
35 |
|
36 |
/* (callback) card control ids */ |
37 |
enum card_ctl_t { |
38 |
CARD_CTL_INSERT = '1', /* insert card */ |
39 |
CARD_CTL_REMOVE = '2', /* remove card */ |
40 |
CARC_CTL_DETECT = '3', /* right card detected */ |
41 |
CARD_CTL_NO_CARD = '4' , /* no card found */ |
42 |
CARD_CTL_NO_READER = '5' /* no reader found */ |
43 |
}; |
44 |
|
45 |
|
46 |
/* Number of fingerprint items. */ |
47 |
#define N_CARD_FPR 3 |
48 |
|
49 |
/* openpgp card context. */ |
50 |
struct gpg_card_s { |
51 |
char *aid; /* appID */ |
52 |
char *card_type; |
53 |
char *version; /* version */ |
54 |
int ver[2]; /* version [maj:min] */ |
55 |
char *vendor; /* vendor */ |
56 |
char *serial; /* serial number */ |
57 |
char *surname; /* card users surname */ |
58 |
char *givenname; /* card users given name */ |
59 |
char *lang; /* language */ |
60 |
char sex; /* card users sex */ |
61 |
char *url; /* key url */ |
62 |
char *login; /* login data (name) */ |
63 |
int force_pin; |
64 |
char *maxpinlen[3]; |
65 |
int sig_count; /* signature counter */ |
66 |
char *ca_fpr[N_CARD_FPR]; /* CA fingerprints */ |
67 |
char *fpr[N_CARD_FPR]; /* key fingerprints */ |
68 |
long fpr_created[N_CARD_FPR]; /* fingerprint timestamps. */ |
69 |
char *fpr_created_str[N_CARD_FPR]; /* string fingerprints, can be NULL. */ |
70 |
}; |
71 |
typedef struct gpg_card_s *gpg_card_t; |
72 |
|
73 |
|
74 |
/* PIN callback context. */ |
75 |
struct pin_cb_ctx_s { |
76 |
int which; /* which command to execute. */ |
77 |
char *info_text; /* additional info text. */ |
78 |
char *apin; /* admin pin */ |
79 |
char *upin; /* user pin */ |
80 |
}; |
81 |
|
82 |
/* Card callback context. */ |
83 |
struct card_cb_s { |
84 |
int cancel; /* 1=user cancelled operation. */ |
85 |
int init; |
86 |
int code; /* 1=user need to insert card. */ |
87 |
char val[128]; /* application specific value. */ |
88 |
}; |
89 |
|
90 |
|
91 |
/*-- wptCardManager.cpp --*/ |
92 |
const char* card_callback (int code, void *opaque); |
93 |
|
94 |
#endif /*WPT_CARD_H*/ |