[git] GPGME - branch, master, updated. gpgme-1.6.0-355-gc943380
by Werner Koch
cvs at cvs.gnupg.org
Wed Sep 14 12:46:05 CEST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".
The branch, master has been updated
via c943380b7a2cc9b32f81c22224fc6f92e8ea8469 (commit)
via c22f5884c50557f54704f4becc5a8c1ee0749547 (commit)
from 24b4162d908b48a92660020be0b776c2874fb05a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c943380b7a2cc9b32f81c22224fc6f92e8ea8469
Author: Werner Koch <wk at gnupg.org>
Date: Wed Sep 14 12:41:16 2016 +0200
core: New function gpgme_op_revuid.
* src/engine.h (GENKEY_EXTRAFLAG_REVOKE): New.
* src/genkey.c (adduid_start): Rename to addrevuid_start. Add arg
REVOKE and pass it as extraflags. Remove useless ARMOR extraflag.
Adjust callers.
(gpgme_op_revuid_start, gpgme_op_revuid): New.
* src/gpgme.def, src/libgpgme.vers: Add them.
* tests/run-genkey.c: Add option --revuid.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/NEWS b/NEWS
index e428bd5..10296ff 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,8 @@ Noteworthy changes in version 1.7.0 (unreleased) [C25/A14/R_]
gpgme_op_createsubkey_start NEW.
gpgme_op_adduid_start NEW.
gpgme_op_adduid NEW.
+ gpgme_op_revuid_start NEW.
+ gpgme_op_revuid NEW.
gpgme_genkey_result_t EXTENDED: New fields pubkey and seckey.
gpgme_signature_t EXTENDED: New field key.
gpgme_key_t EXTENDED: New field fpr.
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index db6637a..534d5d1 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -2115,14 +2115,19 @@ gpg_addkey (engine_gpg_t gpg,
static gpgme_error_t
gpg_adduid (engine_gpg_t gpg,
gpgme_key_t key,
- const char *userid)
+ const char *userid,
+ unsigned int extraflags)
{
gpgme_error_t err;
if (!key || !key->fpr || !userid)
return gpg_error (GPG_ERR_INV_ARG);
- err = add_arg (gpg, "--quick-adduid");
+ if ((extraflags & GENKEY_EXTRAFLAG_REVOKE))
+ err = add_arg (gpg, "--quick-revuid");
+ else
+ err = add_arg (gpg, "--quick-adduid");
+
if (!err)
err = add_arg (gpg, "--");
if (!err)
@@ -2184,7 +2189,7 @@ gpg_genkey (void *engine,
else if (!userid && key)
err = gpg_addkey (gpg, algo, expires, key, flags, extraflags);
else if (userid && key && !algo)
- err = gpg_adduid (gpg, key, userid);
+ err = gpg_adduid (gpg, key, userid, extraflags);
else
err = gpg_error (GPG_ERR_INV_VALUE);
diff --git a/src/engine.h b/src/engine.h
index 391caf2..eb37da8 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -25,7 +25,8 @@
#include "gpgme.h"
/* Flags used by the EXTRAFLAGS arg of _gpgme_engine_op_genkey. */
-#define GENKEY_EXTRAFLAG_ARMOR 1
+#define GENKEY_EXTRAFLAG_ARMOR 1
+#define GENKEY_EXTRAFLAG_REVOKE 2
struct engine;
diff --git a/src/genkey.c b/src/genkey.c
index 100e655..9dcf0be 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -181,7 +181,7 @@ genkey_status_handler (void *priv, gpgme_status_code_t code, char *args)
return gpg_error (GPG_ERR_GENERAL);
else if (opd->failure_code)
return opd->failure_code;
- else if (opd->uidmode)
+ else if (opd->uidmode == 1)
opd->result.uid = 1; /* We have no status line, thus this hack. */
break;
@@ -489,8 +489,8 @@ gpgme_op_createsubkey (gpgme_ctx_t ctx, gpgme_key_t key, const char *algo,
static gpgme_error_t
-adduid_start (gpgme_ctx_t ctx, int synchronous,
- gpgme_key_t key, const char *userid, unsigned int flags)
+addrevuid_start (gpgme_ctx_t ctx, int synchronous, int revoke,
+ gpgme_key_t key, const char *userid, unsigned int flags)
{
gpgme_error_t err;
void *hook;
@@ -512,7 +512,7 @@ adduid_start (gpgme_ctx_t ctx, int synchronous,
if (err)
return err;
- opd->uidmode = 1;
+ opd->uidmode = revoke? 2 : 1;
_gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx);
@@ -528,7 +528,7 @@ adduid_start (gpgme_ctx_t ctx, int synchronous,
userid, NULL, 0, 0,
key, flags,
NULL,
- ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+ revoke? GENKEY_EXTRAFLAG_REVOKE : 0,
NULL, NULL);
}
@@ -547,7 +547,7 @@ gpgme_op_adduid_start (gpgme_ctx_t ctx,
if (!ctx)
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
- err = adduid_start (ctx, 0, key, userid, flags);
+ err = addrevuid_start (ctx, 0, 0, key, userid, flags);
return TRACE_ERR (err);
}
@@ -564,7 +564,44 @@ gpgme_op_adduid (gpgme_ctx_t ctx,
if (!ctx)
return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
- err = adduid_start (ctx, 1, key, userid, flags);
+ err = addrevuid_start (ctx, 1, 0, key, userid, flags);
+ if (!err)
+ err = _gpgme_wait_one (ctx);
+ return TRACE_ERR (err);
+}
+
+
+/* Revoke USERID from KEY. */
+gpgme_error_t
+gpgme_op_revuid_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid, unsigned int flags)
+{
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_revuid_start", ctx,
+ "uid='%s' flags=0x%x", userid, flags);
+
+ if (!ctx)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
+
+ err = addrevuid_start (ctx, 0, 1, key, userid, flags);
+ return TRACE_ERR (err);
+}
+
+
+gpgme_error_t
+gpgme_op_revuid (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid, unsigned int flags)
+{
+ gpgme_error_t err;
+
+ TRACE_BEG2 (DEBUG_CTX, "gpgme_op_revuid", ctx,
+ "uid='%s' flags=0x%x", userid, flags);
+
+ if (!ctx)
+ return TRACE_ERR (gpg_error (GPG_ERR_INV_ARG));
+
+ err = addrevuid_start (ctx, 1, 1, key, userid, flags);
if (!err)
err = _gpgme_wait_one (ctx);
return TRACE_ERR (err);
diff --git a/src/gpgme.def b/src/gpgme.def
index 54b04e0..4c7ff41 100644
--- a/src/gpgme.def
+++ b/src/gpgme.def
@@ -235,6 +235,8 @@ EXPORTS
gpgme_op_createsubkey @175
gpgme_op_adduid_start @176
gpgme_op_adduid @177
+ gpgme_op_revuid_start @178
+ gpgme_op_revuid @179
; END
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index ec436c8..a26b432 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -1894,10 +1894,18 @@ gpgme_error_t gpgme_op_createsubkey (gpgme_ctx_t ctx,
/* Add USERID to an existing KEY. */
gpgme_error_t gpgme_op_adduid_start (gpgme_ctx_t ctx,
gpgme_key_t key, const char *userid,
- unsigned int flags);
+ unsigned int reserved);
gpgme_error_t gpgme_op_adduid (gpgme_ctx_t ctx,
gpgme_key_t key, const char *userid,
- unsigned int flags);
+ unsigned int reserved);
+
+/* Revoke a USERID from a KEY. */
+gpgme_error_t gpgme_op_revuid_start (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned int reserved);
+gpgme_error_t gpgme_op_revuid (gpgme_ctx_t ctx,
+ gpgme_key_t key, const char *userid,
+ unsigned int reserved);
diff --git a/src/libgpgme.vers b/src/libgpgme.vers
index 0cef9e0..8193ee4 100644
--- a/src/libgpgme.vers
+++ b/src/libgpgme.vers
@@ -109,6 +109,8 @@ GPGME_1.1 {
gpgme_op_createsubkey;
gpgme_op_adduid_start;
gpgme_op_adduid;
+ gpgme_op_revuid_start;
+ gpgme_op_revuid;
};
diff --git a/tests/run-genkey.c b/tests/run-genkey.c
index 959e2ea..20e7db5 100644
--- a/tests/run-genkey.c
+++ b/tests/run-genkey.c
@@ -203,9 +203,11 @@ show_usage (int ex)
" args: USERID [ALGO [USAGE [EXPIRESECONDS]]]\n"
" for addkey: FPR [ALGO [USAGE [EXPIRESECONDS]]]\n"
" for adduid: FPR USERID\n"
+ " for revuid: FPR USERID\n"
"Options:\n"
" --addkey add a subkey to the key with FPR\n"
" --adduid add a user id to the key with FPR\n"
+ " --revuid Revoke a user id from the key with FPR\n"
" --verbose run in verbose mode\n"
" --status print status lines from the backend\n"
" --progress print progress info\n"
@@ -231,6 +233,7 @@ main (int argc, char **argv)
int use_loopback = 0;
int addkey = 0;
int adduid = 0;
+ int revuid = 0;
const char *userid;
const char *algo = NULL;
const char *newuserid = NULL;
@@ -255,12 +258,21 @@ main (int argc, char **argv)
{
addkey = 1;
adduid = 0;
+ revuid = 0;
argc--; argv++;
}
else if (!strcmp (*argv, "--adduid"))
{
addkey = 0;
adduid = 1;
+ revuid = 0;
+ argc--; argv++;
+ }
+ else if (!strcmp (*argv, "--revuid"))
+ {
+ addkey = 0;
+ adduid = 0;
+ revuid = 1;
argc--; argv++;
}
else if (!strcmp (*argv, "--verbose"))
@@ -307,7 +319,7 @@ main (int argc, char **argv)
show_usage (1);
}
- if (adduid)
+ if (adduid || revuid)
{
if (argc != 2)
show_usage (1);
@@ -346,7 +358,7 @@ main (int argc, char **argv)
gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
}
- if (addkey || adduid)
+ if (addkey || adduid || revuid)
{
gpgme_key_t akey;
@@ -378,6 +390,16 @@ main (int argc, char **argv)
exit (1);
}
}
+ else if (revuid)
+ {
+ err = gpgme_op_revuid (ctx, akey, newuserid, flags);
+ if (err)
+ {
+ fprintf (stderr, PGM ": gpgme_op_revuid failed: %s\n",
+ gpg_strerror (err));
+ exit (1);
+ }
+ }
gpgme_key_unref (akey);
}
else
commit c22f5884c50557f54704f4becc5a8c1ee0749547
Author: Werner Koch <wk at gnupg.org>
Date: Wed Sep 14 12:15:35 2016 +0200
core: Change a parameter for the engine's genkey function.
* src/engine.h (GENKEY_EXTRAFLAG_ARMOR): New.
* src/engine-backend.h (engine_ops): Rename USE_ARMOR in genkey to
EXTRAFLAGS.
* src/engine.c (_gpgme_engine_op_genkey): Ditto.
* src/engine-gpg.c (gpg_createkey_from_param): Ditto and test the
flags.
(gpg_createkey_legacy): Ditto.
(gpg_createkey): Ditto.
(gpg_addkey): Ditto.
(gpg_genkey): Ditto.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/src/engine-backend.h b/src/engine-backend.h
index 842292d..ec1a58c 100644
--- a/src/engine-backend.h
+++ b/src/engine-backend.h
@@ -86,7 +86,8 @@ struct engine_ops
const char *userid, const char *algo,
unsigned long reserved, unsigned long expires,
gpgme_key_t key, unsigned int flags,
- gpgme_data_t help_data, int use_armor,
+ gpgme_data_t help_data,
+ unsigned int extraflags,
gpgme_data_t pubkey, gpgme_data_t seckey);
gpgme_error_t (*import) (void *engine, gpgme_data_t keydata,
gpgme_key_t *keyarray);
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index d2b6dd3..db6637a 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -2012,12 +2012,12 @@ gpg_add_algo_usage_expire (engine_gpg_t gpg,
static gpgme_error_t
gpg_createkey_from_param (engine_gpg_t gpg,
- gpgme_data_t help_data, int use_armor)
+ gpgme_data_t help_data, unsigned int extraflags)
{
gpgme_error_t err;
err = add_arg (gpg, "--gen-key");
- if (!err && use_armor)
+ if (!err && (extraflags & GENKEY_EXTRAFLAG_ARMOR))
err = add_arg (gpg, "--armor");
if (!err)
err = add_arg (gpg, "--");
@@ -2036,7 +2036,7 @@ gpg_createkey_legacy (engine_gpg_t gpg,
const char *userid, const char *algo,
unsigned long expires,
unsigned int flags,
- int use_armor)
+ unsigned int extraflags)
{
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
}
@@ -2047,12 +2047,12 @@ gpg_createkey (engine_gpg_t gpg,
const char *userid, const char *algo,
unsigned long expires,
unsigned int flags,
- int use_armor)
+ unsigned int extraflags)
{
gpgme_error_t err;
err = add_arg (gpg, "--quick-gen-key");
- if (!err && use_armor)
+ if (!err && (extraflags & GENKEY_EXTRAFLAG_ARMOR))
err = add_arg (gpg, "--armor");
if (!err && (flags & GPGME_CREATE_NOPASSWD))
{
@@ -2082,7 +2082,7 @@ gpg_addkey (engine_gpg_t gpg,
unsigned long expires,
gpgme_key_t key,
unsigned int flags,
- int use_armor)
+ unsigned int extraflags)
{
gpgme_error_t err;
@@ -2090,7 +2090,7 @@ gpg_addkey (engine_gpg_t gpg,
return gpg_error (GPG_ERR_INV_ARG);
err = add_arg (gpg, "--quick-addkey");
- if (!err && use_armor)
+ if (!err && (extraflags & GENKEY_EXTRAFLAG_ARMOR))
err = add_arg (gpg, "--armor");
if (!err && (flags & GPGME_CREATE_NOPASSWD))
{
@@ -2141,7 +2141,7 @@ gpg_genkey (void *engine,
const char *userid, const char *algo,
unsigned long reserved, unsigned long expires,
gpgme_key_t key, unsigned int flags,
- gpgme_data_t help_data, int use_armor,
+ gpgme_data_t help_data, unsigned int extraflags,
gpgme_data_t pubkey, gpgme_data_t seckey)
{
engine_gpg_t gpg = engine;
@@ -2169,20 +2169,20 @@ gpg_genkey (void *engine,
if (pubkey || seckey)
err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
else
- err = gpg_createkey_from_param (gpg, help_data, use_armor);
+ err = gpg_createkey_from_param (gpg, help_data, extraflags);
}
else if (userid && !key)
{
if (!have_gpg_version (gpg, "2.1.13"))
err = gpg_createkey_legacy (gpg, userid, algo, expires, flags,
- use_armor);
+ extraflags);
else
- err = gpg_createkey (gpg, userid, algo, expires, flags, use_armor);
+ err = gpg_createkey (gpg, userid, algo, expires, flags, extraflags);
}
else if (!have_gpg_version (gpg, "2.1.13"))
err = gpg_error (GPG_ERR_NOT_SUPPORTED);
else if (!userid && key)
- err = gpg_addkey (gpg, algo, expires, key, flags, use_armor);
+ err = gpg_addkey (gpg, algo, expires, key, flags, extraflags);
else if (userid && key && !algo)
err = gpg_adduid (gpg, key, userid);
else
diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c
index 0610c7a..071626a 100644
--- a/src/engine-gpgsm.c
+++ b/src/engine-gpgsm.c
@@ -1447,7 +1447,7 @@ gpgsm_genkey (void *engine,
const char *userid, const char *algo,
unsigned long reserved, unsigned long expires,
gpgme_key_t key, unsigned int flags,
- gpgme_data_t help_data, int use_armor,
+ gpgme_data_t help_data, unsigned int extraflags,
gpgme_data_t pubkey, gpgme_data_t seckey)
{
engine_gpgsm_t gpgsm = engine;
@@ -1468,7 +1468,8 @@ gpgsm_genkey (void *engine,
if (err)
return err;
gpgsm->output_cb.data = pubkey;
- err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor"
+ err = gpgsm_set_fd (gpgsm, OUTPUT_FD,
+ (extraflags & GENKEY_EXTRAFLAG_ARMOR)? "--armor"
: map_data_enc (gpgsm->output_cb.data));
if (err)
return err;
diff --git a/src/engine.c b/src/engine.c
index 1ff8698..b3bbcab 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -778,8 +778,8 @@ _gpgme_engine_op_genkey (engine_t engine,
unsigned long reserved, unsigned long expires,
gpgme_key_t key, unsigned int flags,
gpgme_data_t help_data,
- int use_armor, gpgme_data_t pubkey,
- gpgme_data_t seckey)
+ unsigned int extraflags,
+ gpgme_data_t pubkey, gpgme_data_t seckey)
{
if (!engine)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -789,7 +789,7 @@ _gpgme_engine_op_genkey (engine_t engine,
return (*engine->ops->genkey) (engine->engine,
userid, algo, reserved, expires, key, flags,
- help_data, use_armor,
+ help_data, extraflags,
pubkey, seckey);
}
diff --git a/src/engine.h b/src/engine.h
index 857dff4..391caf2 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -24,6 +24,10 @@
#include "gpgme.h"
+/* Flags used by the EXTRAFLAGS arg of _gpgme_engine_op_genkey. */
+#define GENKEY_EXTRAFLAG_ARMOR 1
+
+
struct engine;
typedef struct engine *engine_t;
@@ -113,7 +117,8 @@ gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
unsigned long expires,
gpgme_key_t key, unsigned int flags,
gpgme_data_t help_data,
- int use_armor, gpgme_data_t pubkey,
+ unsigned int extraflags,
+ gpgme_data_t pubkey,
gpgme_data_t seckey);
gpgme_error_t _gpgme_engine_op_import (engine_t engine,
gpgme_data_t keydata,
diff --git a/src/genkey.c b/src/genkey.c
index b93abb8..100e655 100644
--- a/src/genkey.c
+++ b/src/genkey.c
@@ -267,7 +267,8 @@ genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms,
return _gpgme_engine_op_genkey (ctx->engine,
NULL, NULL, 0, 0, NULL, 0,
opd->key_parameter,
- ctx->use_armor, pubkey, seckey);
+ ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+ pubkey, seckey);
}
@@ -352,7 +353,9 @@ createkey_start (gpgme_ctx_t ctx, int synchronous,
return _gpgme_engine_op_genkey (ctx->engine,
userid, algo, reserved, expires,
anchorkey, flags,
- NULL, ctx->use_armor, NULL, NULL);
+ NULL,
+ ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+ NULL, NULL);
}
@@ -438,7 +441,9 @@ createsubkey_start (gpgme_ctx_t ctx, int synchronous,
return _gpgme_engine_op_genkey (ctx->engine,
NULL, algo, reserved, expires,
key, flags,
- NULL, ctx->use_armor, NULL, NULL);
+ NULL,
+ ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+ NULL, NULL);
}
@@ -522,7 +527,9 @@ adduid_start (gpgme_ctx_t ctx, int synchronous,
return _gpgme_engine_op_genkey (ctx->engine,
userid, NULL, 0, 0,
key, flags,
- NULL, ctx->use_armor, NULL, NULL);
+ NULL,
+ ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+ NULL, NULL);
}
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 ++
src/engine-backend.h | 3 ++-
src/engine-gpg.c | 35 ++++++++++++++++------------
src/engine-gpgsm.c | 5 ++--
src/engine.c | 6 ++---
src/engine.h | 8 ++++++-
src/genkey.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--------
src/gpgme.def | 2 ++
src/gpgme.h.in | 12 ++++++++--
src/libgpgme.vers | 2 ++
tests/run-genkey.c | 26 +++++++++++++++++++--
11 files changed, 129 insertions(+), 36 deletions(-)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list