60 |
|
|
61 |
|
|
62 |
static const char* |
static const char* |
63 |
ownertrust_to_string (GpgKeyEdit *ctx, int val) |
ownertrust_to_string (int val) |
64 |
{ |
{ |
65 |
const char * inf; |
const char * inf; |
66 |
int id; |
int id = val; |
|
|
|
|
if (ctx) |
|
|
id = ctx->trust_id; |
|
|
else if (!ctx && val) |
|
|
id = val; |
|
67 |
switch (id) { |
switch (id) { |
68 |
case 1: inf = _("Don't know"); break; |
case 1: inf = _("Don't know"); break; |
69 |
case 2: inf = _("I do NOT trust"); break; |
case 2: inf = _("I do NOT trust"); break; |
134 |
} |
} |
135 |
|
|
136 |
|
|
137 |
/* Return string representation of cipher @algo. */ |
/* Return the preferred sym. algorithm from @key as a string. */ |
138 |
static const char* |
static const char* |
139 |
get_pref_str_cipher (int algo) |
get_pref_cipher (winpt_key_t k) |
140 |
{ |
{ |
141 |
/* XXX: finish the code */ |
const char *sym_prefs=NULL; |
142 |
switch (algo) { |
|
143 |
|
if (k->is_v3) |
144 |
|
return "IDEA"; |
145 |
|
if (!k->ext->sym_prefs) |
146 |
|
return "3DES"; |
147 |
|
switch (*k->ext->sym_prefs) { |
148 |
case 1: return "IDEA"; |
case 1: return "IDEA"; |
149 |
case 2: return "3DES"; |
case 2: return "3DES"; |
150 |
|
case 3: return "CAST5"; |
151 |
case 4: return "Blowfish"; |
case 4: return "Blowfish"; |
152 |
case 7: |
case 7: |
153 |
case 8: |
case 8: |
154 |
case 9: return "AES"; |
case 9: return "AES"; |
155 |
case 10: return "Twofish"; |
case 10:return "Twofish"; |
156 |
} |
} |
157 |
return "Unknown"; |
return "Unknown"; |
158 |
} |
} |
159 |
|
|
160 |
|
|
|
/* Return the preferred sym. algorithm from @key. */ |
|
|
static const char* |
|
|
get_pref_cipher (gpgme_key_t key) |
|
|
{ |
|
|
const char *sym_prefs=NULL; |
|
|
winpt_key_s k; |
|
|
|
|
|
winpt_get_seckey (key->subkeys->keyid, &k); |
|
|
if (k.is_v3) |
|
|
return "IDEA"; |
|
|
if (!k.ext->sym_prefs) |
|
|
return "3DES"; |
|
|
return get_pref_str_cipher (*k.ext->sym_prefs); |
|
|
} |
|
|
|
|
|
|
|
161 |
/* Return true if the key has designated revokers. */ |
/* Return true if the key has designated revokers. */ |
162 |
static bool |
static bool |
163 |
check_for_desig_rev (gpgme_key_t key) |
check_for_desig_rev (gpgme_key_t key) |
164 |
{ |
{ |
165 |
winpt_key_s k; |
winpt_key_s k; |
166 |
|
memset (&k, 0, sizeof (k)); |
167 |
if (!winpt_get_pubkey (key->subkeys->keyid, &k)) |
if (!winpt_get_pubkey (key->subkeys->keyid, &k)) |
168 |
return k.ext->gloflags.has_desig_rev? true : false; |
return k.ext->gloflags.has_desig_rev? true : false; |
169 |
return false; |
return false; |
178 |
static gpgme_key_t key, sk; |
static gpgme_key_t key, sk; |
179 |
static int photo_done = 0; |
static int photo_done = 0; |
180 |
struct winpt_key_s k2; |
struct winpt_key_s k2; |
|
GpgKeyEdit *ek; |
|
181 |
refresh_cache_s rcs = {0}; |
refresh_cache_s rcs = {0}; |
182 |
const char *inf; |
const char *inf; |
183 |
char info[2048]; |
char info[512]; |
184 |
u32 created, expires; |
u32 created, expires; |
185 |
int ot, cancel = 0; |
int ot, cancel = 0; |
186 |
int rc; |
int rc; |
198 |
#endif |
#endif |
199 |
|
|
200 |
photo_done = 0; |
photo_done = 0; |
201 |
winpt_get_seckey (k->keyid, &k2); |
memset (&k2, 0, sizeof (k2)); |
202 |
|
if (k->key_pair) |
203 |
|
winpt_get_seckey (k->keyid, &k2); |
204 |
|
else |
205 |
|
winpt_get_pubkey (k->keyid, &k2); |
206 |
sk = k2.ctx; |
sk = k2.ctx; |
207 |
if (sk) |
if (sk) |
208 |
k->is_protected = k2.is_protected; |
k->is_protected = k2.is_protected; |
226 |
get_key_created (created), |
get_key_created (created), |
227 |
get_key_expire_date (expires), |
get_key_expire_date (expires), |
228 |
get_validity (key), |
get_validity (key), |
229 |
get_pref_cipher (key)); |
get_pref_cipher (&k2)); |
230 |
SetDlgItemText (dlg, IDC_KEYPROPS_INFO, info); |
SetDlgItemText (dlg, IDC_KEYPROPS_INFO, info); |
231 |
SetDlgItemText (dlg, IDC_KEYPROPS_FPR, get_key_fpr (key)); |
SetDlgItemText (dlg, IDC_KEYPROPS_FPR, get_key_fpr (key)); |
232 |
ot = gpgme_key_get_ulong_attr( key, GPGME_ATTR_OTRUST, NULL, 0 ); |
ot = gpgme_key_get_ulong_attr( key, GPGME_ATTR_OTRUST, NULL, 0 ); |
233 |
inf = ownertrust_to_string (NULL, ot); |
inf = ownertrust_to_string (ot); |
234 |
SetDlgItemText( dlg, IDC_KEYPROPS_OT, inf ); |
SetDlgItemText( dlg, IDC_KEYPROPS_OT, inf ); |
235 |
if (k->key_pair) |
if (k->key_pair) |
236 |
EnableWindow( GetDlgItem( dlg, IDC_KEYPROPS_CHANGE_PWD ), TRUE ); |
EnableWindow( GetDlgItem( dlg, IDC_KEYPROPS_CHANGE_PWD ), TRUE ); |
275 |
} |
} |
276 |
GetDlgItemText( dlg, IDC_KEYPROPS_OT, info, sizeof info -1 ); |
GetDlgItemText( dlg, IDC_KEYPROPS_OT, info, sizeof info -1 ); |
277 |
|
|
278 |
ek = new GpgKeyEdit (k->keyid); |
|
279 |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYEDIT_OWNERTRUST, |
dialog_box_param (glob_hinst, (LPCSTR)IDD_WINPT_KEYEDIT_OWNERTRUST, |
280 |
dlg, (DLGPROC)keyedit_ownertrust_dlg_proc, |
dlg, (DLGPROC)keyedit_ownertrust_dlg_proc, |
281 |
(LPARAM)ek, _("Change Ownertrust"), |
(LPARAM)k, _("Change Ownertrust"), |
282 |
IDS_WINPT_KEYEDIT_OWNERTRUST); |
IDS_WINPT_KEYEDIT_OWNERTRUST); |
283 |
|
if (k->callback.new_val == -1) { /* Cancel */ |
284 |
inf = ownertrust_to_string (ek, 0); |
EndDialog (dlg, FALSE); |
285 |
k->callback.new_val = ek->trust_id; |
break; |
286 |
|
} |
287 |
|
|
288 |
|
inf = ownertrust_to_string (k->callback.new_val); |
289 |
do_change_ownertrust (k, inf); |
do_change_ownertrust (k, inf); |
290 |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
SetDlgItemText (dlg, IDC_KEYPROPS_OT, inf); |
291 |
msg_box (dlg, _("Ownertrust successfully changed."), _("GnuPG Status"), MB_OK); |
msg_box (dlg, _("Ownertrust successfully changed."), _("GnuPG Status"), MB_OK); |
295 |
rcs.tr_update = 0; |
rcs.tr_update = 0; |
296 |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_KEYCACHE, dlg, |
297 |
keycache_dlg_proc, (LPARAM)&rcs ); |
keycache_dlg_proc, (LPARAM)&rcs ); |
298 |
|
/* XXX: old code!? |
299 |
get_seckey (k->keyid, &sk); |
get_seckey (k->keyid, &sk); |
300 |
if (get_pubkey (k->keyid, &key)) |
if (get_pubkey (k->keyid, &key)) |
301 |
BUG (0); |
BUG (0); |
302 |
delete ek; |
*/ |
303 |
return TRUE; |
return TRUE; |
304 |
|
|
305 |
case IDC_KEYPROPS_CHANGE_PWD: |
case IDC_KEYPROPS_CHANGE_PWD: |