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_ENCRYPT_NO_COMPRESS NEW.
GPGME_PK_ECC NEW. GPGME_PK_ECC NEW.
GPGME_MD_SHA224 NEW. GPGME_MD_SHA224 NEW.
gpgme_subkey_t EXTENDED: New field curve.
Noteworthy changes in version 1.4.3 (2013-08-12) 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 @item char *card_number
The serial number of a smart card holding this key or @code{NULL}. 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 table
@end deftp @end deftp

View File

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

View File

@ -629,6 +629,9 @@ struct _gpgme_subkey
/* The serial number of a smart card holding this key or NULL. */ /* The serial number of a smart card holding this key or NULL. */
char *card_number; char *card_number;
/* The name of the curve for ECC algorithms or NULL. */
char *curve;
}; };
typedef struct _gpgme_subkey *gpgme_subkey_t; 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; gpgme_subkey_t next = subkey->next;
if (subkey->fpr) if (subkey->fpr)
free (subkey->fpr); free (subkey->fpr);
if (subkey->curve)
free (subkey->curve);
if (subkey->card_number) if (subkey->card_number)
free (subkey->card_number); free (subkey->card_number);
free (subkey); 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 RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV, RT_SPK
} }
rectype = RT_NONE; rectype = RT_NONE;
#define NR_FIELDS 16 #define NR_FIELDS 17
char *field[NR_FIELDS]; char *field[NR_FIELDS];
int fields = 0; int fields = 0;
void *hook; void *hook;
@ -584,6 +584,15 @@ keylist_colon_handler (void *priv, char *line)
if (err) if (err)
return 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; break;
case RT_SUB: case RT_SUB:
@ -646,6 +655,15 @@ keylist_colon_handler (void *priv, char *line)
if (err) if (err)
return 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; break;
case RT_UID: case RT_UID: