* gpgme.h (GpgmeAttr): Add values for issuer and chaining.
* key.h (gpgme_key_s): Add issuer and chaining elements for X509. * keylist.c (keylist_colon_handler): Store them. * key.c (gpgme_key_release): Free them. (gpgme_key_get_as_xml,gpgme_key_get_string_attr): Print them.
This commit is contained in:
parent
dd2cb388a9
commit
aa20d6a45a
2
NEWS
2
NEWS
@ -2,6 +2,8 @@
|
||||
case, symmetric encryption is performed. Note that this requires a
|
||||
passphrase from the user.
|
||||
|
||||
* More information is returned for X.509 certificates.
|
||||
|
||||
* Interface changes relative to the 0.3.4 release:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
gpgme_op_encrypt EXTENDED: Symmetric encryption possible
|
||||
|
@ -1,3 +1,11 @@
|
||||
2002-03-28 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* gpgme.h (GpgmeAttr): Add values for issuer and chaining.
|
||||
* key.h (gpgme_key_s): Add issuer and chaining elements for X509.
|
||||
* keylist.c (keylist_colon_handler): Store them.
|
||||
* key.c (gpgme_key_release): Free them.
|
||||
(gpgme_key_get_as_xml,gpgme_key_get_string_attr): Print them.
|
||||
|
||||
2002-03-26 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* Makefile.am (libgpgme_la_SOURCES): Add mutex.h
|
||||
|
@ -161,7 +161,10 @@ typedef enum
|
||||
GPGME_ATTR_CAN_SIGN = 22,
|
||||
GPGME_ATTR_CAN_CERTIFY = 23,
|
||||
GPGME_ATTR_KEY_EXPIRED = 24,
|
||||
GPGME_ATTR_KEY_DISABLED = 25
|
||||
GPGME_ATTR_KEY_DISABLED = 25,
|
||||
GPGME_ATTR_SERIAL = 26,
|
||||
GPGME_ATTR_ISSUER = 27,
|
||||
GPGME_ATTR_CHAINID = 28
|
||||
}
|
||||
GpgmeAttr;
|
||||
|
||||
|
121
gpgme/key.c
121
gpgme/key.c
@ -352,6 +352,9 @@ gpgme_key_release ( GpgmeKey key )
|
||||
u2 = u->next;
|
||||
xfree (u);
|
||||
}
|
||||
xfree (key->issuer_serial);
|
||||
xfree (key->issuer_name);
|
||||
xfree (key->chain_id);
|
||||
xfree (key);
|
||||
}
|
||||
|
||||
@ -655,66 +658,73 @@ one_uid_as_xml (GpgmeData d, struct user_id_s *u)
|
||||
char *
|
||||
gpgme_key_get_as_xml ( GpgmeKey key )
|
||||
{
|
||||
GpgmeData d;
|
||||
struct user_id_s *u;
|
||||
struct subkey_s *k;
|
||||
GpgmeData d;
|
||||
struct user_id_s *u;
|
||||
struct subkey_s *k;
|
||||
|
||||
if ( !key )
|
||||
return NULL;
|
||||
if ( !key )
|
||||
return NULL;
|
||||
|
||||
if ( gpgme_data_new ( &d ) )
|
||||
return NULL;
|
||||
if ( gpgme_data_new ( &d ) )
|
||||
return NULL;
|
||||
|
||||
_gpgme_data_append_string ( d, "<GnupgKeyblock>\n"
|
||||
" <mainkey>\n" );
|
||||
if ( key->keys.secret )
|
||||
_gpgme_data_append_string ( d, "<GnupgKeyblock>\n"
|
||||
" <mainkey>\n" );
|
||||
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_uint (d, "algo", key->keys.key_algo );
|
||||
add_tag_and_uint (d, "len", key->keys.key_len );
|
||||
add_tag_and_time (d, "created", key->keys.timestamp );
|
||||
add_tag_and_time (d, "expire", key->keys.expires_at );
|
||||
if (key->issuer_serial)
|
||||
add_tag_and_string (d, "serial", key->issuer_serial);
|
||||
if (key->issuer_name)
|
||||
add_tag_and_string (d, "issuer", key->issuer_name);
|
||||
if (key->chain_id)
|
||||
add_tag_and_string (d, "chainid", key->chain_id);
|
||||
_gpgme_data_append_string (d, " </mainkey>\n");
|
||||
|
||||
/* Now the user IDs. */
|
||||
for (u = key->uids; u; 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 ( key->keys.flags.invalid )
|
||||
if ( k->flags.invalid )
|
||||
_gpgme_data_append_string ( d, " <invalid/>\n");
|
||||
if ( key->keys.flags.revoked )
|
||||
if ( k->flags.revoked )
|
||||
_gpgme_data_append_string ( d, " <revoked/>\n");
|
||||
if ( key->keys.flags.expired )
|
||||
if ( k->flags.expired )
|
||||
_gpgme_data_append_string ( d, " <expired/>\n");
|
||||
if ( key->keys.flags.disabled )
|
||||
if ( k->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_uint (d, "algo", key->keys.key_algo );
|
||||
add_tag_and_uint (d, "len", key->keys.key_len );
|
||||
add_tag_and_time (d, "created", key->keys.timestamp );
|
||||
add_tag_and_time (d, "expire", key->keys.expires_at );
|
||||
_gpgme_data_append_string (d, " </mainkey>\n");
|
||||
|
||||
/* Now the user IDs. */
|
||||
for (u = key->uids; u; 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 );
|
||||
add_tag_and_uint (d, "algo", k->key_algo );
|
||||
add_tag_and_uint (d, "len", k->key_len );
|
||||
add_tag_and_time (d, "created", k->timestamp );
|
||||
add_tag_and_time (d, "expire", k->expires_at );
|
||||
_gpgme_data_append_string (d, " </subkey>\n");
|
||||
add_tag_and_string (d, "keyid", k->keyid );
|
||||
if (k->fingerprint)
|
||||
add_tag_and_string (d, "fpr", k->fingerprint );
|
||||
add_tag_and_uint (d, "algo", k->key_algo );
|
||||
add_tag_and_uint (d, "len", k->key_len );
|
||||
add_tag_and_time (d, "created", k->timestamp );
|
||||
add_tag_and_time (d, "expire", k->expires_at );
|
||||
_gpgme_data_append_string (d, " </subkey>\n");
|
||||
}
|
||||
_gpgme_data_append_string ( d, "</GnupgKeyblock>\n" );
|
||||
_gpgme_data_append_string ( d, "</GnupgKeyblock>\n" );
|
||||
|
||||
return _gpgme_data_release_and_return_string (d);
|
||||
return _gpgme_data_release_and_return_string (d);
|
||||
}
|
||||
|
||||
|
||||
@ -850,6 +860,15 @@ gpgme_key_get_string_attr ( GpgmeKey key, GpgmeAttr what,
|
||||
if (k)
|
||||
val = capabilities_to_string (k);
|
||||
break;
|
||||
case GPGME_ATTR_SERIAL:
|
||||
val = key->issuer_serial;
|
||||
break;
|
||||
case GPGME_ATTR_ISSUER:
|
||||
val = key->issuer_name;
|
||||
break;
|
||||
case GPGME_ATTR_CHAINID:
|
||||
val = key->chain_id;
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
@ -970,5 +989,3 @@ gpgme_key_get_ulong_attr ( GpgmeKey key, GpgmeAttr what,
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,6 +59,9 @@ struct gpgme_key_s {
|
||||
unsigned int ref_count;
|
||||
unsigned int secret:1;
|
||||
unsigned int x509:1;
|
||||
char *issuer_serial; /* malloced string used only with X.509 */
|
||||
char *issuer_name; /* ditto */
|
||||
char *chain_id; /* ditto */
|
||||
struct subkey_s keys;
|
||||
struct user_id_s *uids;
|
||||
};
|
||||
|
@ -304,13 +304,23 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
|
||||
key->keys.expires_at = parse_timestamp (p);
|
||||
break;
|
||||
case 8: /* X.509 serial number */
|
||||
/* fixme: store it */
|
||||
if (rectype == RT_CRT)
|
||||
{
|
||||
key->issuer_serial = xtrystrdup (p);
|
||||
if (!key->issuer_serial)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
break;
|
||||
case 9: /* ownertrust */
|
||||
break;
|
||||
case 10: /* not used for gpg due to --fixed-list-mode option
|
||||
but gpgsm stores the issuer name */
|
||||
/* fixme: store issuer name */
|
||||
if (rectype == RT_CRT)
|
||||
{
|
||||
key->issuer_name = xtrystrdup (p);
|
||||
if (!key->issuer_name)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
break;
|
||||
case 11: /* signature class */
|
||||
break;
|
||||
@ -394,6 +404,14 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
|
||||
if (!key->keys.fingerprint)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
break;
|
||||
case 13: /* gpgsm chain ID (take only the first one)*/
|
||||
if (!key->chain_id && *p)
|
||||
{
|
||||
key->chain_id = xtrystrdup (p);
|
||||
if (!key->chain_id)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
pend = NULL; /* that is all we want */
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user