18 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
*/ |
*/ |
21 |
|
|
22 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
23 |
#include <config.h> |
#include <config.h> |
24 |
#endif |
#endif |
42 |
|
|
43 |
#define key_is_useable(key) (!(key)->revoked && !(key)->expired && !(key)->disabled) |
#define key_is_useable(key) (!(key)->revoked && !(key)->expired && !(key)->disabled) |
44 |
|
|
|
static struct listview_column_s klist_enc[] = { |
|
|
{0, 242, (char *)_("User ID")}, |
|
|
{1, 80, (char *)_("Key ID")}, |
|
|
{3, 46, (char *)_("Size")}, |
|
|
{4, 50, (char *)_("Cipher")}, |
|
|
{5, 70, (char *)_("Validity")}, |
|
|
{0, 0, NULL} |
|
|
}; |
|
|
#define KLIST_ENC_ITEMS (DIM(klist_enc) -1) |
|
|
|
|
|
static struct listview_column_s klist[] = { |
|
|
{0, 242, (char *)_("User ID")}, |
|
|
{1, 78, (char *)_("Key ID")}, |
|
|
{2, 52, (char *)_("Type")}, |
|
|
{3, 68, (char *)_("Size")}, |
|
|
{4, 66, (char *)_("Cipher")}, |
|
|
{5, 70, (char *)_("Validity")}, |
|
|
{6, 40, (char *)_("Trust")}, |
|
|
{7, 72, (char *)_("Creation")}, |
|
|
{0, 0, NULL} |
|
|
}; |
|
|
#define KLIST_ITEMS (DIM(klist) - 1) |
|
|
|
|
45 |
struct key_array_s { |
struct key_array_s { |
46 |
char keyid[32]; |
char keyid[32]; |
47 |
int checked; |
int checked; |
169 |
} |
} |
170 |
|
|
171 |
|
|
172 |
|
const char* |
173 |
|
get_key_pubalgo2 (gpgme_pubkey_algo_t alg) |
174 |
|
{ |
175 |
|
switch (alg) { |
176 |
|
case GPGME_PK_DSA: return "D"; |
177 |
|
case GPGME_PK_RSA: return "R"; |
178 |
|
case GPGME_PK_ELG: return "G"; |
179 |
|
default: return "?"; |
180 |
|
} |
181 |
|
return "?"; |
182 |
|
} |
183 |
|
|
184 |
const char* |
const char* |
185 |
get_key_algo (gpgme_key_t key, int keyidx) |
get_key_algo (gpgme_key_t key, int keyidx) |
331 |
switch (val) { |
switch (val) { |
332 |
case GPGME_VALIDITY_UNKNOWN: |
case GPGME_VALIDITY_UNKNOWN: |
333 |
case GPGME_VALIDITY_UNDEFINED: |
case GPGME_VALIDITY_UNDEFINED: |
334 |
return "None"; |
return _("None"); |
335 |
case GPGME_VALIDITY_NEVER: |
case GPGME_VALIDITY_NEVER: |
336 |
return "Never"; |
return _("Never"); |
337 |
case GPGME_VALIDITY_MARGINAL: |
case GPGME_VALIDITY_MARGINAL: |
338 |
return "Marginal"; |
return _("Marginal"); |
339 |
case GPGME_VALIDITY_FULL: |
case GPGME_VALIDITY_FULL: |
340 |
case GPGME_VALIDITY_ULTIMATE: |
case GPGME_VALIDITY_ULTIMATE: |
341 |
return "Full"; |
return _("Full"); |
342 |
} |
} |
343 |
return ""; |
return ""; |
344 |
} |
} |
369 |
if (uididx < 0 || count_userids (key) > uididx) |
if (uididx < 0 || count_userids (key) > uididx) |
370 |
uididx = 0; |
uididx = 0; |
371 |
if (listmode) { |
if (listmode) { |
372 |
const char *s; |
const char *s; |
|
|
|
373 |
if (key->revoked) |
if (key->revoked) |
374 |
s = _("Revoked"); |
s = _("Revoked"); |
375 |
else if (key->expired) |
else if (key->expired) |
376 |
s = _("Expired"); |
s = _("Expired"); |
377 |
else if (key->disabled) |
else if (key->disabled) |
378 |
s = _("Disabled"); |
s = _("Disabled"); |
379 |
else |
else |
380 |
s = ""; |
s = ""; |
|
|
|
381 |
/* if the key has a special status, we don't continue to figure out |
/* if the key has a special status, we don't continue to figure out |
382 |
what any user-id validities. */ |
what any user-id validities. */ |
383 |
if (*s) |
if (*s) |
482 |
static const char* |
static const char* |
483 |
calc_validity (gpg_group_t grp) |
calc_validity (gpg_group_t grp) |
484 |
{ |
{ |
485 |
int valid=0; |
int valid = 0; |
486 |
gpg_member_t mbr; |
gpg_member_t mbr; |
487 |
gpgme_key_t key; |
gpgme_key_t key; |
488 |
|
|
532 |
static int |
static int |
533 |
keylist_build (listview_ctrl_t *r_lv, HWND ctrl, int mode) |
keylist_build (listview_ctrl_t *r_lv, HWND ctrl, int mode) |
534 |
{ |
{ |
535 |
|
struct listview_column_s klist_enc[] = { |
536 |
|
{0, 242, (char *)_("User ID")}, |
537 |
|
{1, 80, (char *)_("Key ID")}, |
538 |
|
{3, 46, (char *)_("Size")}, |
539 |
|
{4, 50, (char *)_("Cipher")}, |
540 |
|
{5, 70, (char *)_("Validity")}, |
541 |
|
{0, 0, NULL} |
542 |
|
}; |
543 |
|
|
544 |
|
struct listview_column_s klist[] = { |
545 |
|
{0, 242, (char *)_("User ID")}, |
546 |
|
{1, 78, (char *)_("Key ID")}, |
547 |
|
{2, 52, (char *)_("Type")}, |
548 |
|
{3, 68, (char *)_("Size")}, |
549 |
|
{4, 66, (char *)_("Cipher")}, |
550 |
|
{5, 70, (char *)_("Validity")}, |
551 |
|
{6, 40, (char *)_("Trust")}, |
552 |
|
{7, 72, (char *)_("Creation")}, |
553 |
|
{0, 0, NULL} |
554 |
|
}; |
555 |
|
|
556 |
listview_ctrl_t lv; |
listview_ctrl_t lv; |
557 |
listview_column_t col; |
listview_column_t col; |
558 |
int j, n = 0; |
int j, n = 0; |
559 |
int rc = 0; |
int rc = 0; |
560 |
|
|
561 |
rc = listview_new (&lv); |
rc = listview_new (&lv); |
562 |
if( rc ) |
if (rc) |
563 |
return rc; |
return rc; |
564 |
|
|
565 |
lv->ctrl = ctrl; |
lv->ctrl = ctrl; |
566 |
if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN)) { |
if ((mode & KEYLIST_ENCRYPT) || (mode & KEYLIST_ENCRYPT_MIN)) { |
567 |
col = klist_enc; |
col = klist_enc; |
568 |
n = KLIST_ENC_ITEMS; |
n = (DIM(klist_enc) -1); |
569 |
} |
} |
570 |
else if ((mode & KEYLIST_SIGN)) { |
else if ((mode & KEYLIST_SIGN)) { |
571 |
col = klist_enc; |
col = klist_enc; |
572 |
n = KLIST_ENC_ITEMS - 1; |
n = (DIM(klist_enc) - 1) - 1; |
573 |
} |
} |
574 |
else { |
else { |
575 |
col = klist; |
col = klist; |
576 |
n = KLIST_ITEMS; |
n = (DIM(klist) - 1); |
577 |
} |
} |
578 |
|
|
579 |
for( j = 0; j < n; j++ ) |
for( j = 0; j < n; j++ ) |
685 |
/* we check the pubkey algorithm here to make sure that no ElGamal |
/* we check the pubkey algorithm here to make sure that no ElGamal |
686 |
sign+encrypt key is used in _any_ mode */ |
sign+encrypt key is used in _any_ mode */ |
687 |
if (list != 1 && key->subkeys->pubkey_algo == GPGME_PK_ELG) { |
if (list != 1 && key->subkeys->pubkey_algo == GPGME_PK_ELG) { |
688 |
log_debug ("ElGamal (E+S) key found: %s (%s)\n", |
log_debug ("ElGamal (E+S) key found: %s (%s)\n", |
689 |
key->uids->name, key->subkeys->keyid); |
key->uids->name, key->subkeys->keyid); |
690 |
return 0; |
return 0; |
691 |
} |
} |
692 |
|
|
693 |
|
|
694 |
if (listview_add_item2 (lv, " ", (void *)key)) |
if (listview_add_item2 (lv, " ", (void *)key)) |
695 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
696 |
|
|
697 |
attr = key->uids->uid; |
attr = key->uids->uid; |
698 |
memset (&lvi, 0, sizeof lvi); |
memset (&lvi, 0, sizeof lvi); |
699 |
lvi.mask = LVIF_TEXT | LVIF_PARAM; |
lvi.mask = LVIF_TEXT | LVIF_PARAM; |
700 |
lvi.pszText = (char *)attr; |
lvi.pszText = (char *)attr; |
701 |
lvi.lParam = (LPARAM )key; |
lvi.lParam = (LPARAM )key; |
702 |
if (ListView_SetItem( lv->ctrl, &lvi ) == FALSE) |
if (ListView_SetItem (lv->ctrl, &lvi) == FALSE) |
703 |
return WPTERR_GENERAL; |
return WPTERR_GENERAL; |
704 |
|
|
705 |
if (uididx == -1) { /* request the primary user-id of the key. */ |
if (uididx == -1) { /* request the primary user-id of the key. */ |
711 |
if (!u || u->revoked || uididx < 0) |
if (!u || u->revoked || uididx < 0) |
712 |
uididx = 0; /* fixme: this happen sometimes but it's illegal! (<0) */ |
uididx = 0; /* fixme: this happen sometimes but it's illegal! (<0) */ |
713 |
u = get_nth_userid (key, uididx); |
u = get_nth_userid (key, uididx); |
|
/*attr = key->uids->uid; XXX*/ |
|
714 |
attr = u->uid; |
attr = u->uid; |
715 |
} |
} |
716 |
if (attr == NULL || strlen (attr) < 5) { /* normal userids are >= 5 chars */ |
if (attr == NULL || strlen (attr) < 5) { /* normal userids are >= 5 chars */ |
823 |
gpgme_subkey_t k; |
gpgme_subkey_t k; |
824 |
|
|
825 |
/* if the entire key is disabled, just return. */ |
/* if the entire key is disabled, just return. */ |
826 |
if (key->disabled) |
if (key->disabled && !(mode & KEYLIST_LIST)) |
827 |
return 0; |
return 0; |
828 |
|
|
829 |
for (k=key->subkeys, i = 0; i < count_subkeys (key); i++, k=k->next) { |
for (k=key->subkeys, i = 0; i < count_subkeys (key); i++, k=k->next) { |
835 |
if (mode & KEYLIST_ALL) { |
if (mode & KEYLIST_ALL) { |
836 |
uids = count_userids (key); |
uids = count_userids (key); |
837 |
rc = do_addkey (lv, key, uids, i, 0); |
rc = do_addkey (lv, key, uids, i, 0); |
838 |
if( rc ) |
if (rc) |
839 |
return rc; |
return rc; |
840 |
} |
} |
841 |
else if (mode & KEYLIST_LIST) |
else if (mode & KEYLIST_LIST) |
848 |
return rc; |
return rc; |
849 |
} |
} |
850 |
else { |
else { |
851 |
for( uids = 0; uids < count_userids (key); uids++ ) { |
for (uids = 0; uids < count_userids (key); uids++) { |
852 |
rc = do_addkey( lv, key, uids, i, -1 ); |
rc = do_addkey (lv, key, uids, i, -1); |
853 |
if( rc ) |
if (rc) |
854 |
return rc; |
return rc; |
855 |
} |
} |
856 |
} |
} |
889 |
static int |
static int |
890 |
key_check_validity (const char *validity) |
key_check_validity (const char *validity) |
891 |
{ |
{ |
892 |
if (strstr (validity, "Unknown") || |
if (strstr (validity, _("Unknown")) || |
893 |
strstr (validity, "Undefined") || |
strstr (validity, _("Undefined")) || |
894 |
strstr (validity, "Never") || |
strstr (validity, _("Never")) || |
895 |
strstr (validity, "None")) |
strstr (validity, _("None"))) |
896 |
return 0; |
return 0; |
897 |
return 1; |
return 1; |
898 |
} |
} |