int idx; /* and the user ID at this index */
const char *uid; /* and for convenience point to this user ID */
unsigned int flags; /* global and per uid flags (for convenience)*/
+ gpgme_validity_t validity; /* uid validity (cached for convenience) */
} crypt_key_t;
typedef struct crypt_entry
k->idx = key->idx;
k->uid = key->uid;
k->flags = key->flags;
+ k->validity = key->validity;
return k;
}
/* Return true whe validity of KEY is sufficient. */
static int crypt_id_is_strong (crypt_key_t *key)
{
- gpgme_validity_t val = GPGME_VALIDITY_UNKNOWN;
- gpgme_user_id_t uid = NULL;
unsigned int is_strong = 0;
- unsigned int i = 0;
if ((key->flags & KEYFLAG_ISX509))
return 1;
- for (i = 0, uid = key->kobj->uids; (i < key->idx) && uid;
- i++, uid = uid->next)
- ;
- if (uid)
- val = uid->validity;
-
- switch (val)
+ switch (key->validity)
{
case GPGME_VALIDITY_UNKNOWN:
case GPGME_VALIDITY_UNDEFINED:
s = "x";
else
{
- gpgme_user_id_t uid = NULL;
- unsigned int i = 0;
-
- for (i = 0, uid = key->kobj->uids; uid && (i < key->idx);
- i++, uid = uid->next)
- ;
- if (uid)
- switch (uid->validity)
- {
- case GPGME_VALIDITY_UNDEFINED:
- s = "q";
- break;
- case GPGME_VALIDITY_NEVER:
- s = "n";
- break;
- case GPGME_VALIDITY_MARGINAL:
- s = "m";
- break;
- case GPGME_VALIDITY_FULL:
- s = "f";
- break;
- case GPGME_VALIDITY_ULTIMATE:
- s = "u";
- break;
- case GPGME_VALIDITY_UNKNOWN:
- default:
- s = "?";
- break;
- }
+ switch (key->validity)
+ {
+ case GPGME_VALIDITY_UNDEFINED:
+ s = "q";
+ break;
+ case GPGME_VALIDITY_NEVER:
+ s = "n";
+ break;
+ case GPGME_VALIDITY_MARGINAL:
+ s = "m";
+ break;
+ case GPGME_VALIDITY_FULL:
+ s = "f";
+ break;
+ case GPGME_VALIDITY_ULTIMATE:
+ s = "u";
+ break;
+ case GPGME_VALIDITY_UNKNOWN:
+ default:
+ s = "?";
+ break;
+ }
}
snprintf (fmt, sizeof (fmt), "%%%sc", prefix);
snprintf (dest, destlen, fmt, s? *s: 'B');
- ((*t)->flags & (KEYFLAG_RESTRICTIONS)))))
return r > 0;
- if ((*s)->kobj->uids)
- ts = (*s)->kobj->uids->validity;
- if ((*t)->kobj->uids)
- tt = (*t)->kobj->uids->validity;
+ ts = (*s)->validity;
+ tt = (*t)->validity;
if ((r = (tt - ts)))
return r < 0;
k->flags = flags;
if (uid->revoked)
k->flags |= KEYFLAG_REVOKED;
+ k->validity = uid->validity;
*kend = k;
kend = &k->next;
}
k->idx = idx;
k->uid = uid->uid;
k->flags = flags;
+ k->validity = uid->validity;
*kend = k;
kend = &k->next;
}
warn_s = N_("ID is expired/disabled/revoked.");
else
{
- gpgme_validity_t val = GPGME_VALIDITY_UNKNOWN;
- gpgme_user_id_t uid = NULL;
- unsigned int j = 0;
-
warn_s = "??";
-
- uid = key_table[menu->current]->kobj->uids;
- for (j = 0; (j < key_table[menu->current]->idx) && uid;
- j++, uid = uid->next)
- ;
- if (uid)
- val = uid->validity;
-
- switch (val)
+ switch (key_table[menu->current]->validity)
{
case GPGME_VALIDITY_UNKNOWN:
case GPGME_VALIDITY_UNDEFINED: