1 |
/* wptKeyPropsDlg.cpp - WinPT key properties dialog |
/* wptKeyPropsDlg.cpp - WinPT key property dialog |
2 |
* Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006 Timo Schulz |
* Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
42 |
static int |
static int |
43 |
do_check_key (gpgme_key_t key) |
do_check_key (gpgme_key_t key) |
44 |
{ |
{ |
45 |
int invalid = 0; |
int invalid; |
46 |
|
|
47 |
invalid = key->expired; |
invalid = key->expired; |
48 |
if (!invalid) |
if (!invalid) |
113 |
key_load_photo (HWND dlg, gpgme_key_t key, gpgme_validity_t *r_valid) |
key_load_photo (HWND dlg, gpgme_key_t key, gpgme_validity_t *r_valid) |
114 |
{ |
{ |
115 |
winpt_key_s k; |
winpt_key_s k; |
116 |
FILE *f; |
FILE *fp; |
117 |
const BYTE *img; |
const BYTE *img; |
118 |
DWORD imglen = 0; |
DWORD imglen = 0; |
119 |
int pos=0; |
int pos=0; |
132 |
return -1; |
return -1; |
133 |
} |
} |
134 |
|
|
135 |
f = fopen (get_photo_tmpname (dlg), "wb"); |
fp = fopen (get_photo_tmpname (dlg), "wb"); |
136 |
if (f) { |
if (fp) { |
137 |
pos += 16; |
pos += 16; |
138 |
fwrite (img + pos, 1, imglen - pos, f); |
fwrite (img + pos, 1, imglen - pos, fp); |
139 |
fclose (f); |
fclose (fp); |
140 |
} |
} |
141 |
return 0; |
return 0; |
142 |
} |
} |
175 |
case 8: return "AES192"; |
case 8: return "AES192"; |
176 |
case 9: return "AES256"; |
case 9: return "AES256"; |
177 |
case 10:return "Twofish"; |
case 10:return "Twofish"; |
178 |
|
default:break; |
179 |
} |
} |
180 |
return "Unknown"; |
return "Unknown"; |
181 |
} |
} |
221 |
} |
} |
222 |
|
|
223 |
|
|
224 |
|
/* Return extended algorithm information. */ |
225 |
|
const char* |
226 |
|
props_get_key_algo (gpgme_key_t key, int idx) |
227 |
|
{ |
228 |
|
/* PGP calls the old RSAv3 keys 'RSA Legacy' and because this |
229 |
|
is a good method to differ between OpenPGP v4 cert-only keys |
230 |
|
and v3 RSA keys, we use the same notation. */ |
231 |
|
if (key->subkeys != NULL && strlen (key->subkeys->fpr) == 32) |
232 |
|
return "RSA Legacy"; |
233 |
|
return get_key_algo (key, idx); |
234 |
|
} |
235 |
|
|
236 |
|
|
237 |
/* Display the key information for key @k. |
/* Display the key information for key @k. |
238 |
Return value: gpgme key on success. */ |
Return value: gpgme key on success. */ |
264 |
"%s\r\n"), |
"%s\r\n"), |
265 |
get_key_type (key), |
get_key_type (key), |
266 |
k->keyid, |
k->keyid, |
267 |
get_key_algo (key, 0), |
props_get_key_algo (key, 0), |
268 |
get_key_size (key, 0), |
get_key_size (key, 0), |
269 |
get_key_created (created), |
get_key_created (created), |
270 |
get_key_expire_date (expires), |
get_key_expire_date (expires), |
302 |
k->has_photo = 1; |
k->has_photo = 1; |
303 |
if (valid < GPGME_VALIDITY_MARGINAL) |
if (valid < GPGME_VALIDITY_MARGINAL) |
304 |
SetDlgItemText (dlg, IDC_KEYPROPS_IMGINF, _("Photo-ID not validated.")); |
SetDlgItemText (dlg, IDC_KEYPROPS_IMGINF, _("Photo-ID not validated.")); |
305 |
} |
} |
306 |
if (k->key_pair) |
if (k->key_pair) |
307 |
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_CHANGE_PWD), TRUE); |
EnableWindow (GetDlgItem (dlg, IDC_KEYPROPS_CHANGE_PWD), TRUE); |
308 |
if (check_for_desig_rev (k->ctx)) |
if (check_for_desig_rev (k->ctx)) |
348 |
POINT p; |
POINT p; |
349 |
p.x = p.y = 0; |
p.x = p.y = 0; |
350 |
PTD_jpg_show (GetDlgItem (dlg, IDC_KEYPROPS_IMG), |
PTD_jpg_show (GetDlgItem (dlg, IDC_KEYPROPS_IMG), |
351 |
&p, get_photo_tmpname (dlg)); |
&p, get_photo_tmpname (dlg)); |
352 |
} |
} |
353 |
break; |
break; |
354 |
|
|
363 |
return TRUE; |
return TRUE; |
364 |
|
|
365 |
case IDC_KEYPROPS_OT_CHANGE: |
case IDC_KEYPROPS_OT_CHANGE: |
|
if (do_check_key (prop->key->ctx)) { |
|
|
msg_box (dlg, _("The status of this key is 'revoked' or 'expired'.\n" |
|
|
"You cannot change the ownertrust of such keys."), |
|
|
_("WinPT Warning"), MB_ERR); |
|
|
return TRUE; |
|
|
} |
|
366 |
if (!prop->key->key_pair && !key_is_valid (prop->key->ctx)) { |
if (!prop->key->key_pair && !key_is_valid (prop->key->ctx)) { |
367 |
rc = msg_box (dlg, _("This is a non-valid key.\n" |
rc = msg_box (dlg, _("This is a non-valid key.\n" |
368 |
"Modifying the ownertrust has no effect on such keys.\n\n" |
"Modifying the ownertrust has no effect on such keys.\n\n" |