1 |
/* wptKeyEdit.h |
/* wptKeyEdit.h |
2 |
* Copyright (C) 2003, 2004 Timo Schulz |
* Copyright (C) 2003, 2004 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
6 |
* WinPT is free software; you can redistribute it and/or |
* WinPT is free software; you can redistribute it and/or |
7 |
* modify it under the terms of the GNU General Public License |
* modify it under the terms of the GNU General Public License |
8 |
* as published by the Free Software Foundation; either version 2 |
* as published by the Free Software Foundation; either version 2 |
9 |
* of the License, or (at your option) any later version. |
* of the License, or (at your option) any later version. |
10 |
* |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 |
* General Public License for more details. |
* General Public License for more details. |
15 |
* |
* |
16 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
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 |
|
|
21 |
#ifndef WPT_KEY_EDIT_H |
#ifndef WPT_KEY_EDIT_H |
22 |
#define WPT_KEY_EDIT_H |
#define WPT_KEY_EDIT_H |
23 |
|
|
24 |
/* IDs for all possible gpg edit key commands. */ |
/* IDs for all possible gpg edit key commands. */ |
25 |
enum gpg_editkey_t { |
enum gpg_editkey_t { |
26 |
GPG_EDITKEY_SIGN = 1, |
GPG_EDITKEY_SIGN = 1, |
27 |
GPG_EDITKEY_LSIGN = 2, |
GPG_EDITKEY_LSIGN = 2, |
28 |
GPG_EDITKEY_NRSIGN = 19, |
GPG_EDITKEY_NRSIGN = 19, |
29 |
GPG_EDITKEY_NRLSIGN = 22, |
GPG_EDITKEY_NRLSIGN = 22, |
30 |
GPG_EDITKEY_TSIGN = 20, |
GPG_EDITKEY_TSIGN = 20, |
31 |
GPG_EDITKEY_TRUST = 3, |
GPG_EDITKEY_TRUST = 3, |
32 |
GPG_EDITKEY_ADDUID = 4, |
GPG_EDITKEY_ADDUID = 4, |
33 |
GPG_EDITKEY_DELUID = 5, |
GPG_EDITKEY_DELUID = 5, |
34 |
GPG_EDITKEY_DELKEY = 6, |
GPG_EDITKEY_DELKEY = 6, |
35 |
GPG_EDITKEY_ADDKEY = 7, |
GPG_EDITKEY_ADDKEY = 7, |
36 |
GPG_EDITKEY_PASSWD = 8, |
GPG_EDITKEY_PASSWD = 8, |
37 |
GPG_EDITKEY_PRIMARY = 9, |
GPG_EDITKEY_PRIMARY = 9, |
38 |
GPG_EDITKEY_EXPIRE = 10, |
GPG_EDITKEY_EXPIRE = 10, |
39 |
GPG_EDITKEY_REVSIG = 11, |
GPG_EDITKEY_REVSIG = 11, |
40 |
GPG_EDITKEY_REVKEY = 12, |
GPG_EDITKEY_REVKEY = 12, |
41 |
GPG_EDITKEY_REVOKE = 13, /* revoke the whole key */ |
GPG_EDITKEY_REVOKE = 13, /* revoke the whole key */ |
42 |
GPG_EDITKEY_ADDREV = 14, |
GPG_EDITKEY_ADDREV = 14, |
43 |
GPG_EDITKEY_ADDPHOTO= 15, |
GPG_EDITKEY_ADDPHOTO= 15, |
44 |
GPG_EDITKEY_ENABLE = 16, |
GPG_EDITKEY_ENABLE = 16, |
45 |
GPG_EDITKEY_DISABLE = 17, |
GPG_EDITKEY_DISABLE = 17, |
46 |
GPG_EDITKEY_SETPREF = 18, |
GPG_EDITKEY_SETPREF = 18, |
47 |
GPG_EDITKEY_DELSIG = 21, |
GPG_EDITKEY_DELSIG = 21, |
48 |
GPG_EDITKEY_KEYSERV = 23, |
GPG_EDITKEY_KEYSERV = 23, |
49 |
GPG_EDITKEY_REVUID = 24 |
GPG_EDITKEY_REVUID = 24, |
50 |
}; |
GPG_EDITKEY_CLEAN = 25, |
51 |
|
GPG_EDITKEY_NOTATION= 26, |
52 |
/* Reasons for revocations. */ |
GPG_EDITKEY_MINIMIZE= 27 |
53 |
enum gpg_revoke_t { |
}; |
54 |
GPG_REVOKE_INSECURE = 1, |
|
55 |
GPG_REVOKE_SUPERSEDED = 2, |
/* Reasons for revocations. */ |
56 |
GPG_REVOKE_NOUSED = 3 |
enum gpg_revoke_t { |
57 |
}; |
GPG_REVOKE_INSECURE = 1, |
58 |
|
GPG_REVOKE_SUPERSEDED = 2, |
59 |
|
GPG_REVOKE_NOUSED = 3 |
60 |
/* Possible results for the operation. */ |
}; |
61 |
enum gpg_edit_result_t { |
|
62 |
GPG_EDITRES_ALREADY_SIGNED = 1, |
/* Contain information about designated revokers. */ |
63 |
GPG_EDITRES_BAD_PASSPHRASE = 2 |
struct gpg_desig_rev_s { |
64 |
}; |
struct gpg_desig_rev_s *next; |
65 |
|
gpgme_pubkey_algo_t pubkey_algo; |
66 |
/* Contain information about designated revokers. */ |
char fpr[41]; |
67 |
struct gpg_desig_rev_s { |
}; |
68 |
struct gpg_desig_rev_s *next; |
typedef struct gpg_desig_rev_s *gpg_desig_rev_t; |
69 |
gpgme_pubkey_algo_t pubkey_algo; |
|
70 |
char fpr[41]; |
/* Context to hold all user-ID information. */ |
71 |
}; |
struct gpg_user_id_info_s { |
72 |
typedef struct gpg_desig_rev_s *gpg_desig_rev_t; |
struct gpg_user_id_info_s *next; |
73 |
|
struct { |
74 |
/* Context to hold all user-ID information. */ |
unsigned int revoked:1; |
75 |
struct gpg_user_id_info_s { |
unsigned int invalid:1; |
76 |
struct gpg_user_id_info_s *next; |
unsigned int primary:1; |
77 |
struct { |
unsigned int mdc:1; |
78 |
unsigned int revoked:1; |
unsigned int no_ks_modify:1; |
79 |
unsigned int invalid:1; |
} flags; |
80 |
unsigned int primary:1; |
int validity; |
81 |
unsigned int mdc:1; |
char *name; |
82 |
unsigned int no_ks_modify:1; |
char *email; |
83 |
} flags; |
char *prefs; |
84 |
int validity; |
int index; |
85 |
char *name; |
}; |
86 |
char *email; |
typedef struct gpg_user_id_info_s *gpg_uid_info_t; |
87 |
char *prefs; |
|
88 |
int index; |
/* Class to abstract the gpg edit key interface. */ |
89 |
}; |
class GpgKeyEdit { |
90 |
typedef struct gpg_user_id_info_s *gpg_uid_info_t; |
private: |
91 |
|
gpgme_key_t key; |
92 |
/* Class to abstract the gpg edit key interface. */ |
gpgme_ctx_t ctx; |
93 |
class GpgKeyEdit { |
int resval; |
94 |
private: |
int type; |
95 |
gpgme_key_t key; |
|
96 |
gpgme_ctx_t ctx; |
bool key_has_passwd; |
97 |
int resval; |
|
98 |
int type; |
int sig_index; |
99 |
|
int key_index; |
100 |
public: |
int uid_index; |
101 |
|
|
102 |
int cnt; |
int valid; |
103 |
int cmd_sent; |
|
104 |
const char *pass; |
public: |
105 |
const char *new_pass; |
int cnt; |
106 |
int sig_index; |
int cmd_sent; |
107 |
int key_index; |
const char *pass; |
108 |
int uid_index; |
const char *new_pass; |
109 |
const char *url; |
const char *new_prefs; |
110 |
int trust_id; |
const char *url; |
111 |
char *name, *cmt, *email; |
int trust_id; |
112 |
const char *exp_date; /* XXX */ |
char *notation; |
113 |
gpgme_pubkey_algo_t pubkey_algo; |
char *name, *cmt, *email; |
114 |
int pubkey_size; |
const char *exp_date; /* XXX */ |
115 |
int valid; /* XXX */ |
gpgme_pubkey_algo_t pubkey_algo; |
116 |
int flags; |
unsigned int pubkey_size; |
117 |
int sig_class; |
int flags; |
118 |
int reason; |
int sig_class; |
119 |
|
int reason; |
120 |
public: |
|
121 |
GpgKeyEdit (gpgme_key_t key); |
public: |
122 |
GpgKeyEdit (const char *keyid); |
GpgKeyEdit (gpgme_key_t key); |
123 |
~GpgKeyEdit (void); |
GpgKeyEdit (const char *keyid); |
124 |
|
~GpgKeyEdit (void); |
125 |
bool isValid (void); |
|
126 |
gpgme_key_t getKey (void); |
bool isValid (void); |
127 |
void reset (void); |
void reset (void); |
128 |
|
|
129 |
void setPassphrase (const char *pass); |
void clear (void); |
130 |
void setKey (gpgme_key_t key); |
void clearPassphrase (void); |
131 |
void setKeyID (const char *keyid); |
|
132 |
void setLocalUser (gpgme_key_t locusr); |
void setNoPassphrase (bool val); |
133 |
void setCallback (gpgme_progress_cb_t cb, void *cb_value); |
void setPassphrase (const char *pass); |
134 |
int getType (void); |
void setKey (gpgme_key_t key); |
135 |
void setResult (int val); |
void setKeyID (const char *keyid); |
136 |
int getResult (void); |
void setLocalUser (gpgme_key_t locusr); |
137 |
|
void setCallback (gpgme_progress_cb_t cb, void *cb_value); |
138 |
gpgme_error_t signKey (int mode, int sig_class, const char *exp_date); |
void setResult (int val); |
139 |
gpgme_error_t setTrust (gpgme_validity_t trust); |
int getResult (void); |
140 |
gpgme_error_t addUserid (const char *name, const char *cmt, |
|
141 |
const char *email); |
gpgme_key_t getKey (void); |
142 |
gpgme_error_t delUserid (int index); |
int getType (void); |
143 |
gpgme_error_t delKey (int index); |
int getUseridIndex (void); |
144 |
gpgme_error_t addSubkey (gpgme_pubkey_algo_t pubkey_algo, |
int getKeyIndex (void); |
145 |
unsigned int nbits, long valid); |
int getSigIndex (void); |
146 |
gpgme_error_t changePassphrase (const char *new_pass, int allow_empty); |
int getValidDays (void); |
147 |
gpgme_error_t setPrimaryUserid (int uid_indx); |
|
148 |
gpgme_error_t setKeyExpireDate (int key_index, long exp_timestamp, |
gpgme_error_t addNotation (int uid_idx, const char *notation); |
149 |
bool exp_days); |
gpgme_error_t signUserid (int uid_idx, int mode, int sig_class, |
150 |
gpgme_error_t revokeUserid (int uid_indx); |
const char *exp_date); |
151 |
gpgme_error_t revokeSignature (int uid_index, int sig_index); |
gpgme_error_t signKey (int mode, int sig_class, const char *exp_date); |
152 |
gpgme_error_t revokeSubkey (int key_index, int reason, const char *cmt); |
gpgme_error_t setTrust (gpgme_validity_t trust); |
153 |
gpgme_error_t addDesignatedRevoker (const char *uid); |
gpgme_error_t addUserid (const char *name, const char *cmt, |
154 |
gpgme_error_t addPhotoid (const char *jpg_file); |
const char *email); |
155 |
gpgme_error_t enable (void); |
gpgme_error_t delUserid (int index); |
156 |
gpgme_error_t disable (void); |
gpgme_error_t delKey (int index); |
157 |
gpgme_error_t setUseridPreferences (int uid_index, const char *new_prefs); |
gpgme_error_t addSubkey (gpgme_pubkey_algo_t pubkey_algo, |
158 |
gpgme_error_t delUseridSignature (int uid_index, int sig_index); |
unsigned int nbits, long valid); |
159 |
gpgme_error_t setPreferredKeyserver (int uid_index, const char *url); |
gpgme_error_t changePassphrase (const char *new_pass, int allow_empty); |
160 |
|
gpgme_error_t setPrimaryUserid (int uid_indx); |
161 |
gpgme_error_t getUseridInfo (gpg_uid_info_t *r_uinf); |
gpgme_error_t setKeyExpireDate (int key_index, long exp_timestamp, |
162 |
|
bool exp_days); |
163 |
gpgme_error_t getDesignatedRevoker (gpg_desig_rev_t *r_rev); |
gpgme_error_t revokeUserid (int uid_indx); |
164 |
}; |
gpgme_error_t revokeSignature (int uid_index, int sig_index); |
165 |
|
gpgme_error_t revokeSubkey (int key_index, int reason, const char *cmt); |
166 |
BOOL keyedit_add_subkey (winpt_key_t k, HWND dlg, listview_ctrl_t lv); |
gpgme_error_t addDesignatedRevoker (const char *uid); |
167 |
BOOL keyedit_add_userid (winpt_key_t k, HWND dlg, listview_ctrl_t lv); |
gpgme_error_t addPhotoid (const char *jpg_file); |
168 |
BOOL keyedit_add_revoker (winpt_key_t k, HWND dlg); |
gpgme_error_t enable (void); |
169 |
BOOL keyedit_add_photo (winpt_key_t k, HWND dlg ); |
gpgme_error_t disable (void); |
170 |
BOOL keyedit_change_passwd (winpt_key_t k, HWND dlg); |
gpgme_error_t setUseridPreferences (int uid_index, const char *new_prefs); |
171 |
BOOL keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg); |
gpgme_error_t delUseridSignature (int uid_index, int sig_index); |
172 |
|
gpgme_error_t setPreferredKeyserver (int uid_index, const char *url); |
173 |
gpgme_error_t gpg_editkey (gpgme_ctx_t ctx, gpgme_key_t key, GpgKeyEdit *ek); |
gpgme_error_t cleanKey (void); |
174 |
void gpg_uid_info_release (gpg_uid_info_t inf); |
gpgme_error_t minimizeKey (void); |
175 |
void gpg_desig_rev_release (gpg_desig_rev_t rev); |
|
176 |
|
|
177 |
#endif /*WPT_KEY_EDIT_H*/ |
gpgme_error_t getUseridInfo (gpg_uid_info_t *r_uinf); |
178 |
|
|
179 |
|
gpgme_error_t getDesignatedRevoker (gpg_desig_rev_t *r_rev); |
180 |
|
}; |
181 |
|
|
182 |
|
BOOL keyedit_add_subkey (winpt_key_t k, HWND dlg, listview_ctrl_t lv); |
183 |
|
BOOL keyedit_add_userid (winpt_key_t k, HWND dlg, listview_ctrl_t lv); |
184 |
|
BOOL keyedit_add_revoker (winpt_key_t k, HWND dlg); |
185 |
|
BOOL keyedit_add_photo (winpt_key_t k, HWND dlg ); |
186 |
|
BOOL keyedit_change_passwd (winpt_key_t k, HWND dlg); |
187 |
|
BOOL keyedit_set_pref_keyserver (winpt_key_t k, HWND dlg); |
188 |
|
|
189 |
|
gpgme_error_t gpg_editkey (gpgme_ctx_t ctx, gpgme_key_t key, GpgKeyEdit *ek); |
190 |
|
void gpg_uid_info_release (gpg_uid_info_t inf); |
191 |
|
void gpg_desig_rev_release (gpg_desig_rev_t rev); |
192 |
|
|
193 |
|
#endif /*WPT_KEY_EDIT_H*/ |