Add field CURVE to the key info.

* src/gpgme.h.in (struct _gpgme_subkey): Add field CURVE.
* src/key.c (gpgme_key_unref): Free CURVE.
* src/keylist.c (keylist_colon_handler): Set CURVE.

* src/gpgme.c (gpgme_release): For failsafe reasons reset engine and
engine info after freeing.
--

The engine hack is useful in case the other release functions
accidently call engine release.
This commit is contained in:
Werner Koch 2014-05-08 20:39:15 +02:00
parent de4a1ea684
commit 88f15336ec
6 changed files with 31 additions and 1 deletions

1
NEWS
View File

@ -25,6 +25,7 @@ Noteworthy changes in version 1.5.0 (unreleased)
GPGME_ENCRYPT_NO_COMPRESS NEW.
GPGME_PK_ECC NEW.
GPGME_MD_SHA224 NEW.
gpgme_subkey_t EXTENDED: New field curve.
Noteworthy changes in version 1.4.3 (2013-08-12)

View File

@ -2742,6 +2742,10 @@ True if the secret key is stored on a smart card.
@item char *card_number
The serial number of a smart card holding this key or @code{NULL}.
@item char *curve
For ECC algoritms the name of the curve.
@end table
@end deftp

View File

@ -233,6 +233,7 @@ gpgme_release (gpgme_ctx_t ctx)
return;
_gpgme_engine_release (ctx->engine);
ctx->engine = NULL;
_gpgme_fd_table_deinit (&ctx->fdt);
_gpgme_release_result (ctx);
_gpgme_signers_clear (ctx);
@ -244,6 +245,7 @@ gpgme_release (gpgme_ctx_t ctx)
if (ctx->lc_messages)
free (ctx->lc_messages);
_gpgme_engine_info_release (ctx->engine_info);
ctx->engine_info = NULL;
DESTROY_LOCK (ctx->lock);
free (ctx);
}

View File

@ -629,6 +629,9 @@ struct _gpgme_subkey
/* The serial number of a smart card holding this key or NULL. */
char *card_number;
/* The name of the curve for ECC algorithms or NULL. */
char *curve;
};
typedef struct _gpgme_subkey *gpgme_subkey_t;

View File

@ -331,6 +331,8 @@ gpgme_key_unref (gpgme_key_t key)
gpgme_subkey_t next = subkey->next;
if (subkey->fpr)
free (subkey->fpr);
if (subkey->curve)
free (subkey->curve);
if (subkey->card_number)
free (subkey->card_number);
free (subkey);

View File

@ -422,7 +422,7 @@ keylist_colon_handler (void *priv, char *line)
RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK
}
rectype = RT_NONE;
#define NR_FIELDS 16
#define NR_FIELDS 17
char *field[NR_FIELDS];
int fields = 0;
void *hook;
@ -584,6 +584,15 @@ keylist_colon_handler (void *priv, char *line)
if (err)
return err;
}
/* Field 17 has the curve name for ECC. */
if (fields >= 17 && *field[16])
{
subkey->curve = strdup (field[16]);
if (!subkey->curve)
return gpg_error_from_syserror ();
}
break;
case RT_SUB:
@ -646,6 +655,15 @@ keylist_colon_handler (void *priv, char *line)
if (err)
return err;
}
/* Field 17 has the curve name for ECC. */
if (fields >= 17 && *field[16])
{
subkey->curve = strdup (field[16]);
if (!subkey->curve)
return gpg_error_from_syserror ();
}
break;
case RT_UID: