diff options
| author | Werner Koch <[email protected]> | 2016-08-04 14:17:01 +0000 | 
|---|---|---|
| committer | Werner Koch <[email protected]> | 2016-08-04 14:17:01 +0000 | 
| commit | 6f3dc66634e30d86aa6250c4ac22f9b8f7ec1be9 (patch) | |
| tree | f10502a42129cc102ed61e2932f4983d1dd0f534 /src | |
| parent | python: Add a nicer interface to list keys. (diff) | |
| download | gpgme-6f3dc66634e30d86aa6250c4ac22f9b8f7ec1be9.tar.gz gpgme-6f3dc66634e30d86aa6250c4ac22f9b8f7ec1be9.zip  | |
core: Extend gpgme_subkey_t to carry the keygrip.
* src/gpgme.h.in (struct _gpgme_subkey): Add file 'keygrip'.
* src/key.c (gpgme_key_unref): Free KEYGRIP.
* src/keylist.c (keylist_colon_handler): Parse GRP records.
* src/engine-gpg.c (gpg_keylist_build_options): Do not use
--with-fingerprint options for gpg versions >= 2.1.15.
* tests/run-keylist.c (main): Print subkeys and keygrips.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
| -rw-r--r-- | src/engine-gpg.c | 19 | ||||
| -rw-r--r-- | src/gpgme.h.in | 3 | ||||
| -rw-r--r-- | src/key.c | 2 | ||||
| -rw-r--r-- | src/keylist.c | 20 | 
4 files changed, 37 insertions, 7 deletions
diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 16571a5a..942711f9 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -2283,12 +2283,19 @@ gpg_keylist_build_options (engine_gpg_t gpg, int secret_only,    gpg_error_t err;    err = add_arg (gpg, "--with-colons"); -  if (!err) -    err = add_arg (gpg, "--fixed-list-mode"); -  if (!err) -    err = add_arg (gpg, "--with-fingerprint"); -  if (!err) -    err = add_arg (gpg, "--with-fingerprint"); + +  /* Since gpg 2.1.15 fingerprints are always printed, thus there is +   * no more need to explictly reqeust them.  */ +  if (!have_gpg_version (gpg, "2.1.15")) +    { +      if (!err) +        err = add_arg (gpg, "--fixed-list-mode"); +      if (!err) +        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 diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 49d56c37..c05686d8 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -691,6 +691,9 @@ struct _gpgme_subkey    /* The name of the curve for ECC algorithms or NULL.  */    char *curve; + +  /* The keygrip of the subkey in hex digit form or NULL if not availabale.  */ +  char *keygrip;  };  typedef struct _gpgme_subkey *gpgme_subkey_t; @@ -333,6 +333,8 @@ gpgme_key_unref (gpgme_key_t key)  	free (subkey->fpr);        if (subkey->curve)  	free (subkey->curve); +      if (subkey->keygrip) +	free (subkey->keygrip);        if (subkey->card_number)  	free (subkey->card_number);        free (subkey); diff --git a/src/keylist.c b/src/keylist.c index fcf574fc..5a346ea4 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -426,7 +426,7 @@ keylist_colon_handler (void *priv, char *line)    gpgme_ctx_t ctx = (gpgme_ctx_t) priv;    enum      { -      RT_NONE, RT_SIG, RT_UID, RT_SUB, RT_PUB, RT_FPR, +      RT_NONE, RT_SIG, RT_UID, RT_SUB, RT_PUB, RT_FPR, RT_GRP,        RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK      }    rectype = RT_NONE; @@ -479,6 +479,8 @@ keylist_colon_handler (void *priv, char *line)      rectype = RT_CRS;    else if (!strcmp (field[0], "fpr") && key)      rectype = RT_FPR; +  else if (!strcmp (field[0], "grp") && key) +    rectype = RT_GRP;    else if (!strcmp (field[0], "uid") && key)      rectype = RT_UID;    else if (!strcmp (field[0], "sub") && key) @@ -717,6 +719,22 @@ keylist_colon_handler (void *priv, char *line)  	}        break; +    case RT_GRP: +      /* Field 10 has the keygrip.  */ +      if (fields >= 10 && field[9] && *field[9]) +	{ +          /* Need to apply it to the last subkey because all subkeys +             have a keygrip. */ +          subkey = key->_last_subkey; +          if (!subkey->keygrip) +            { +              subkey->keygrip = strdup (field[9]); +              if (!subkey->keygrip) +                return gpg_error_from_syserror (); +            } +	} +      break; +      case RT_SIG:      case RT_REV:        if (!opd->tmp_uid)  | 
