From 88f15336ec0eadde68ff2618349efb9006b8e801 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 8 May 2014 20:39:15 +0200 Subject: [PATCH] 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. --- NEWS | 1 + doc/gpgme.texi | 4 ++++ src/gpgme.c | 2 ++ src/gpgme.h.in | 3 +++ src/key.c | 2 ++ src/keylist.c | 20 +++++++++++++++++++- 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b9d2f35e..9433356c 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/doc/gpgme.texi b/doc/gpgme.texi index 9a67c3b5..e3265740 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -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 diff --git a/src/gpgme.c b/src/gpgme.c index a3768ef9..628cdaee 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -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); } diff --git a/src/gpgme.h.in b/src/gpgme.h.in index d58c114d..170d7dd8 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -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; diff --git a/src/key.c b/src/key.c index 59d49086..1a68966d 100644 --- a/src/key.c +++ b/src/key.c @@ -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); diff --git a/src/keylist.c b/src/keylist.c index a3613339..582b241b 100644 --- a/src/keylist.c +++ b/src/keylist.c @@ -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: