From b9ed761b6ebcb31368af72c25fbd0eba2124540b Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 29 Apr 2004 10:55:50 +0000 Subject: [PATCH] 2004-04-29 Marcus Brinkmann * keylist.c (set_mainkey_trust_info): Rewritten. (set_subkey_capability): Handle 'd' (disabled). (set_mainkey_capability): Rewritten. --- gpgme/ChangeLog | 6 +++ gpgme/keylist.c | 119 ++++++++++++++++++++++++------------------------ 2 files changed, 65 insertions(+), 60 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index d92da6c..a97dc38 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2004-04-29 Marcus Brinkmann + + * keylist.c (set_mainkey_trust_info): Rewritten. + (set_subkey_capability): Handle 'd' (disabled). + (set_mainkey_capability): Rewritten. + 2004-04-22 Marcus Brinkmann * gpgme.m4: Quote first argument to AC_DEFUN. diff --git a/gpgme/keylist.c b/gpgme/keylist.c index eb8597e..e65abae 100644 --- a/gpgme/keylist.c +++ b/gpgme/keylist.c @@ -116,31 +116,63 @@ keylist_status_handler (void *priv, gpgme_status_code_t code, char *args) } +static void +set_subkey_trust_info (gpgme_subkey_t subkey, const char *src) +{ + while (*src && !isdigit (*src)) + { + switch (*src) + { + case 'e': + subkey->expired = 1; + break; + + case 'r': + subkey->revoked = 1; + break; + + case 'd': + /* Note that gpg 1.3 won't print that anymore but only uses + the capabilities field. */ + subkey->disabled = 1; + break; + + case 'i': + subkey->invalid = 1; + break; + } + src++; + } +} + static void set_mainkey_trust_info (gpgme_key_t key, const char *src) { - /* Look at letters and stop at the first digit. */ + /* First set the trust info of the main key (the first subkey). */ + set_subkey_trust_info (key->subkeys, src); + + /* Now set the summarized trust info. */ while (*src && !isdigit (*src)) { switch (*src) { case 'e': - key->subkeys->expired = 1; + key->expired = 1; break; case 'r': - key->subkeys->revoked = 1; + key->revoked = 1; break; case 'd': /* Note that gpg 1.3 won't print that anymore but only uses the capabilities field. */ - key->subkeys->disabled = 1; + key->disabled = 1; break; case 'i': - key->subkeys->invalid = 1; + key->invalid = 1; break; } src++; @@ -189,27 +221,30 @@ set_userid_flags (gpgme_key_t key, const char *src) static void -set_subkey_trust_info (gpgme_subkey_t subkey, const char *src) +set_subkey_capability (gpgme_subkey_t subkey, const char *src) { - /* Look at letters and stop at the first digit. */ - while (*src && !isdigit (*src)) + while (*src) { switch (*src) { case 'e': - subkey->expired = 1; + subkey->can_encrypt = 1; break; - case 'r': - subkey->revoked = 1; + case 's': + subkey->can_sign = 1; break; - case 'd': - subkey->disabled = 1; + case 'c': + subkey->can_certify = 1; break; - case 'i': - subkey->invalid = 1; + case 'a': + subkey->can_authenticate = 1; + break; + + case 'd': + subkey->disabled = 1; break; } src++; @@ -220,48 +255,39 @@ set_subkey_trust_info (gpgme_subkey_t subkey, const char *src) static void set_mainkey_capability (gpgme_key_t key, const char *src) { + /* First set the capabilities of the main key (the first subkey). */ + set_subkey_capability (key->subkeys, src); + while (*src) { switch (*src) { - case 'e': - key->subkeys->can_encrypt = 1; - break; - - case 's': - key->subkeys->can_sign = 1; - break; - - case 'c': - key->subkeys->can_certify = 1; - break; - - case 'a': - key->subkeys->can_authenticate = 1; - break; - - case 'd': + case 'd': case 'D': /* Note, that this flag is also set using the key validity field for backward compatibility with gpg 1.2. We use d and D, so that a future gpg version will be able to disable certain subkeys. Currently it is expected that gpg sets this for the primary key. */ - key->subkeys->disabled = 1; + key->disabled = 1; break; + case 'e': case 'E': key->can_encrypt = 1; break; + case 's': case 'S': key->can_sign = 1; break; + case 'c': case 'C': key->can_certify = 1; break; + case 'a': case 'A': key->can_authenticate = 1; break; @@ -271,33 +297,6 @@ set_mainkey_capability (gpgme_key_t key, const char *src) } -static void -set_subkey_capability (gpgme_subkey_t subkey, const char *src) -{ - while (*src) - { - switch (*src) - { - case 'e': - subkey->can_encrypt = 1; - break; - - case 's': - subkey->can_sign = 1; - break; - - case 'c': - subkey->can_certify = 1; - break; - - case 'a': - subkey->can_authenticate = 1; - break; - } - src++; - } -} - static void set_ownertrust (gpgme_key_t key, const char *src) { -- 2.26.2