uid = xtrymalloc ( sizeof *uid + 2*strlen (s)+3 );
if ( !uid )
return mk_error (Out_Of_Core);
+ uid->revoked = 0;
+ uid->invalid = 0;
uid->validity = 0;
uid->name_part = NULL;
uid->email_part = NULL;
add_tag_and_string ( d, tag, buf );
}
+static void
+one_uid_as_xml (GpgmeData d, struct user_id_s *u)
+{
+ _gpgme_data_append_string (d, " <userid>\n");
+ if ( u->invalid )
+ _gpgme_data_append_string ( d, " <invalid/>\n");
+ if ( u->revoked )
+ _gpgme_data_append_string ( d, " <revoked/>\n");
+ add_tag_and_string ( d, "raw", u->name );
+ if ( *u->name_part )
+ add_tag_and_string ( d, "name", u->name_part );
+ if ( *u->email_part )
+ add_tag_and_string ( d, "email", u->email_part );
+ if ( *u->comment_part )
+ add_tag_and_string ( d, "comment", u->comment_part );
+ _gpgme_data_append_string (d, " </userid>\n");
+}
+
+
char *
gpgme_key_get_as_xml ( GpgmeKey key )
{
_gpgme_data_append_string ( d, "<GnupgKeyblock>\n"
" <mainkey>\n" );
- if ( key->secret )
+ if ( key->keys.secret )
_gpgme_data_append_string ( d, " <secret/>\n");
+ if ( key->keys.flags.invalid )
+ _gpgme_data_append_string ( d, " <invalid/>\n");
+ if ( key->keys.flags.revoked )
+ _gpgme_data_append_string ( d, " <revoked/>\n");
+ if ( key->keys.flags.expired )
+ _gpgme_data_append_string ( d, " <expired/>\n");
+ if ( key->keys.flags.disabled )
+ _gpgme_data_append_string ( d, " <disabled/>\n");
add_tag_and_string (d, "keyid", key->keys.keyid );
if (key->keys.fingerprint)
add_tag_and_string (d, "fpr", key->keys.fingerprint );
/*add_tag_and_time (d, "expires", key->expires );*/
_gpgme_data_append_string (d, " </mainkey>\n");
- /* Now the user IDs */
- for ( u = key->uids; u; u = u->next ) {
- _gpgme_data_append_string (d, " <userid>\n");
- add_tag_and_string ( d, "raw", u->name );
- if ( *u->name_part )
- add_tag_and_string ( d, "name", u->name_part );
- if ( *u->email_part )
- add_tag_and_string ( d, "email", u->email_part );
- if ( *u->comment_part )
- add_tag_and_string ( d, "comment", u->comment_part );
- _gpgme_data_append_string (d, " </userid>\n");
+ /* Now the user IDs. We are listing the last one firs becuase this is
+ * the primary one. */
+ for (u = key->uids; u && u->next; u = u->next )
+ ;
+ if (u) {
+ one_uid_as_xml (d,u);
+ for ( u = key->uids; u && u->next; u = u->next ) {
+ one_uid_as_xml (d,u);
+ }
}
-
+
+ /* and now the subkeys */
for (k=key->keys.next; k; k = k->next ) {
_gpgme_data_append_string (d, " <subkey>\n");
if ( k->secret )
_gpgme_data_append_string ( d, " <secret/>\n");
+ if ( k->flags.invalid )
+ _gpgme_data_append_string ( d, " <invalid/>\n");
+ if ( k->flags.revoked )
+ _gpgme_data_append_string ( d, " <revoked/>\n");
+ if ( k->flags.expired )
+ _gpgme_data_append_string ( d, " <expired/>\n");
+ if ( k->flags.disabled )
+ _gpgme_data_append_string ( d, " <disabled/>\n");
add_tag_and_string (d, "keyid", k->keyid );
if (k->fingerprint)
add_tag_and_string (d, "fpr", k->fingerprint );
const void *reserved, int idx )
{
const char *val = NULL;
+ struct subkey_s *k;
struct user_id_s *u;
if (!key)
switch (what) {
case GPGME_ATTR_KEYID:
- val = key->keys.keyid;
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = k->keyid;
break;
case GPGME_ATTR_FPR:
- val = key->keys.fingerprint;
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = k->fingerprint;
break;
case GPGME_ATTR_ALGO:
- val = pkalgo_to_string (key->keys.key_algo);
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = pkalgo_to_string (k->key_algo);
break;
case GPGME_ATTR_LEN:
case GPGME_ATTR_CREATED:
break;
case GPGME_ATTR_LEVEL: /* not used here */
case GPGME_ATTR_TYPE:
+ case GPGME_ATTR_KEY_REVOKED:
+ case GPGME_ATTR_KEY_INVALID:
+ case GPGME_ATTR_UID_REVOKED:
+ case GPGME_ATTR_UID_INVALID:
break;
case GPGME_ATTR_IS_SECRET:
if (key->secret)
const void *reserved, int idx )
{
unsigned long val = 0;
+ struct subkey_s *k;
struct user_id_s *u;
if (!key)
switch (what) {
case GPGME_ATTR_ALGO:
- val = (unsigned long)key->keys.key_algo;
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = (unsigned long)k->key_algo;
break;
case GPGME_ATTR_LEN:
- val = (unsigned long)key->keys.key_len;
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = (unsigned long)k->key_len;
break;
case GPGME_ATTR_CREATED:
- val = key->keys.timestamp < 0? 0L:(unsigned long)key->keys.timestamp;
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = k->timestamp < 0? 0L:(unsigned long)k->timestamp;
break;
case GPGME_ATTR_VALIDITY:
for (u=key->uids; u && idx; u=u->next, idx-- )
case GPGME_ATTR_IS_SECRET:
val = !!key->secret;
break;
+ case GPGME_ATTR_KEY_REVOKED:
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = k->flags.revoked;
+ break;
+ case GPGME_ATTR_KEY_INVALID:
+ for (k=&key->keys; k && idx; k=k->next, idx-- )
+ ;
+ if (k)
+ val = k->flags.invalid;
+ break;
+ case GPGME_ATTR_UID_REVOKED:
+ for (u=key->uids; u && idx; u=u->next, idx-- )
+ ;
+ if (u)
+ val = u->revoked;
+ break;
+ case GPGME_ATTR_UID_INVALID:
+ for (u=key->uids; u && idx; u=u->next, idx-- )
+ ;
+ if (u)
+ val = u->invalid;
+ break;
default:
break;
}
case 'e': key->keys.flags.expired = 1; break;
case 'r': key->keys.flags.revoked = 1; break;
case 'd': key->keys.flags.disabled = 1; break;
+ case 'i': key->keys.flags.invalid = 1; break;
+ }
+ }
+}
+
+
+static void
+set_userid_flags ( GpgmeKey key, const char *s )
+{
+ /* look at letters and stop at the first digit */
+ for (; *s && !my_isdigit (*s); s++ ) {
+ switch (*s) {
+ case 'r': key->uids->revoked = 1; break;
+ case 'i': key->uids->invalid = 1; break;
+
case 'n': key->uids->validity = 1; break;
case 'm': key->uids->validity = 2; break;
case 'f': key->uids->validity = 3; break;
case 'e': k->flags.expired = 1; break;
case 'r': k->flags.revoked = 1; break;
case 'd': k->flags.disabled = 1; break;
+ case 'i': k->flags.invalid = 1; break;
}
}
}
else if ( rectype == RT_PUB || rectype == RT_SEC ) {
switch (field) {
case 2: /* trust info */
- trust_info = p; /*save for later */
+ trust_info = p;
+ set_mainkey_trust_info (key, trust_info);
break;
case 3: /* key length */
i = atoi (p);
break;
case 9: /* ownertrust */
break;
- case 10: /* This is the first name listed */
- if ( _gpgme_key_append_name ( key, p) )
- ctx->out_of_core = 1;
- else {
- if (trust_info)
- set_mainkey_trust_info (key, trust_info);
- }
+ case 10: /* not used due to --fixed-list-mode option */
break;
case 11: /* signature class */
break;
case 2: /* trust info */
trust_info = p; /*save for later */
break;
- case 10: /* the 2nd, 3rd,... user ID */
+ case 10: /* user ID */
if ( _gpgme_key_append_name ( key, p) )
ctx->out_of_core = 1;
else {
if (trust_info)
- set_mainkey_trust_info (key, trust_info);
+ set_userid_flags (key, trust_info);
}
pend = NULL; /* we can stop here */
break;
for ( i=0; i < c->verbosity; i++ )
_gpgme_gpg_add_arg ( c->gpg, "--verbose" );
_gpgme_gpg_add_arg ( c->gpg, "--with-colons" );
+ _gpgme_gpg_add_arg ( c->gpg, "--fixed-list-mode" );
_gpgme_gpg_add_arg ( c->gpg, "--with-fingerprint" );
if (c->keylist_mode == 1)
_gpgme_gpg_add_arg ( c->gpg, "--no-expensive-trust-checks" );