diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine-gpg.c | 2 | ||||
| -rw-r--r-- | src/engine-gpgsm.c | 12 | ||||
| -rw-r--r-- | src/gpgme-tool.c | 10 | ||||
| -rw-r--r-- | src/gpgme.h.in | 1 | ||||
| -rw-r--r-- | src/keylist.c | 24 | 
5 files changed, 42 insertions, 7 deletions
| diff --git a/src/engine-gpg.c b/src/engine-gpg.c index ede098ef..4df0f3e4 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -2194,6 +2194,8 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only,      err = add_arg (gpg, "--with-fingerprint");    if (!err)      err = add_arg (gpg, "--with-fingerprint"); +  if (!err && (mode & GPGME_KEYLIST_MODE_WITH_SECRET)) +    err = add_arg (gpg, "--with-secret");    if (!err        && (mode & GPGME_KEYLIST_MODE_SIGS)        && (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS)) diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 710bf14a..8ec15985 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -1551,7 +1551,7 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,       the agent.  However on a fresh installation no public keys are       available and thus there is no need for gpgsm to ask the agent       whether a secret key exists for the public key.  */ -  if (secret_only) +  if (secret_only || (mode & GPGME_KEYLIST_MODE_WITH_SECRET))      gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "GETINFO agent-check",                                   NULL, NULL); @@ -1580,6 +1580,11 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only,                                 "OPTION with-ephemeral-keys=1":                                 "OPTION with-ephemeral-keys=0" ,                                 NULL, NULL); +  gpgsm_assuan_simple_command (gpgsm->assuan_ctx, +                               (mode & GPGME_KEYLIST_MODE_WITH_SECRET)? +                               "OPTION with-secret=1": +                               "OPTION with-secret=0" , +                               NULL, NULL);    /* Length is "LISTSECRETKEYS " + p + '\0'.  */ @@ -1645,6 +1650,11 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only,                                 "OPTION with-validation=1":                                 "OPTION with-validation=0" ,                                 NULL, NULL); +  gpgsm_assuan_simple_command (gpgsm->assuan_ctx, +                               (mode & GPGME_KEYLIST_MODE_WITH_SECRET)? +                               "OPTION with-secret=1": +                               "OPTION with-secret=0" , +                               NULL, NULL);    if (pattern && *pattern) diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index be8ed078..f02fffa7 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -1861,6 +1861,8 @@ gt_get_keylist_mode (gpgme_tool_t gt)      modes[idx++] = "sigs";    if (mode & GPGME_KEYLIST_MODE_SIG_NOTATIONS)      modes[idx++] = "sig_notations"; +  if (mode & GPGME_KEYLIST_MODE_WITH_SECRET) +    modes[idx++] = "with_secret";    if (mode & GPGME_KEYLIST_MODE_EPHEMERAL)      modes[idx++] = "ephemeral";    if (mode & GPGME_KEYLIST_MODE_VALIDATE) @@ -2591,6 +2593,8 @@ cmd_keylist_mode (assuan_context_t ctx, char *line)  	mode |= GPGME_KEYLIST_MODE_SIGS;        if (strstr (line, "sig_notations"))  	mode |= GPGME_KEYLIST_MODE_SIG_NOTATIONS; +      if (strstr (line, "with_secret")) +	mode |= GPGME_KEYLIST_MODE_WITH_SECRET;        if (strstr (line, "ephemeral"))  	mode |= GPGME_KEYLIST_MODE_EPHEMERAL;        if (strstr (line, "validate")) @@ -3299,6 +3303,12 @@ cmd_keylist (assuan_context_t ctx, char *line)  	    result_xml_tag_start (&state, "subkey", NULL);  	    /* FIXME: more data */  	    result_add_fpr (&state, "fpr", subkey->fpr); +            result_add_value (&state, "secret", subkey->secret); +            result_add_value (&state, "is_cardkey", subkey->is_cardkey); +            if (subkey->card_number) +              result_add_string (&state, "card_number", subkey->card_number); +            if (subkey->curve) +              result_add_string (&state, "curve", subkey->curve);  	    result_xml_tag_end (&state);  /* subkey */  	    subkey = subkey->next;  	  } diff --git a/src/gpgme.h.in b/src/gpgme.h.in index d47f4ba9..15ed8037 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -370,6 +370,7 @@ gpgme_protocol_t;  #define GPGME_KEYLIST_MODE_EXTERN		2  #define GPGME_KEYLIST_MODE_SIGS			4  #define GPGME_KEYLIST_MODE_SIG_NOTATIONS	8 +#define GPGME_KEYLIST_MODE_WITH_SECRET       	16  #define GPGME_KEYLIST_MODE_EPHEMERAL            128  #define GPGME_KEYLIST_MODE_VALIDATE		256 diff --git a/src/keylist.c b/src/keylist.c index 582b241b..36ee3eaa 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -367,7 +367,7 @@ set_ownertrust (gpgme_key_t key, const char *src)     reference to smartcards.  FIELD is the content of the field and we     are allowed to modify it.  */  static gpg_error_t -parse_sec_field15 (gpgme_subkey_t subkey, char *field) +parse_sec_field15 (gpgme_key_t key, gpgme_subkey_t subkey, char *field)  {    if (!*field)      ; /* Empty.  */ @@ -375,17 +375,25 @@ parse_sec_field15 (gpgme_subkey_t subkey, char *field)      {        /* This is a stub for an offline key.  We reset the SECRET flag           of the subkey here.  Note that the secret flag of the entire -         key will be true even then.  */ +         key will be true even then.  We even explicitly set +         key->secret to make it works for GPGME_KEYLIST_MODE_WITH_SECRET. */        subkey->secret = 0; +      key->secret = 1;      }    else if (strchr ("01234567890ABCDEFabcdef", *field))      {        /* Fields starts with a hex digit; thus it is a serial number.  */ +      key->secret = 1;        subkey->is_cardkey = 1;        subkey->card_number = strdup (field);        if (!subkey->card_number)          return gpg_error_from_syserror ();      } +  else if (*field == '+') +    { +      key->secret = 1; +      subkey->secret = 1; +    }    else      {        /* RFU.  */ @@ -578,9 +586,11 @@ keylist_colon_handler (void *priv, char *line)  	set_mainkey_capability (key, field[11]);        /* Field 15 carries special flags of a secret key.  */ -      if (fields >= 15 && key->secret) +      if (fields >= 15 +          && (key->secret +              || (ctx->keylist_mode & GPGME_KEYLIST_MODE_WITH_SECRET)))          { -          err = parse_sec_field15 (subkey, field[14]); +          err = parse_sec_field15 (key, subkey, field[14]);            if (err)              return err;          } @@ -649,9 +659,11 @@ keylist_colon_handler (void *priv, char *line)  	set_subkey_capability (subkey, field[11]);        /* Field 15 carries special flags of a secret key. */ -      if (fields >= 15 && key->secret) +      if (fields >= 15 +          && (key->secret +              || (ctx->keylist_mode & GPGME_KEYLIST_MODE_WITH_SECRET)))          { -          err = parse_sec_field15 (subkey, field[14]); +          err = parse_sec_field15 (key, subkey, field[14]);            if (err)              return err;          } | 
