From: Marcus Brinkmann Date: Fri, 8 Feb 2002 22:43:44 +0000 (+0000) Subject: 2002-02-08 Marcus Brinkmann X-Git-Tag: gpgme-0-3-1~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f0a45d0c20abe8bda33e275277da6d3cea434f49;p=gpgme.git 2002-02-08 Marcus Brinkmann * genkey.c (gpgme_op_genkey_start): Allow PUBKEY and SECKEY to be set, and pass them down to the crypto engine. * engine-gpgsm.h (_gpgme_gpgsm_start): New arguments PUBKEY and SECKEY. * engine.h: Likewise. * rungpg.h (_gpgme_gpg_spawn): Likewise. * engine.c (_gpgme_engine_op_genkey): Likewise. Use those arguments. * rungpg.c (_gpgme_gpg_op_genkey): Likewise. Complain if those arguments are set. * engine-gpgsm.c (_gpgme_gpgsm_op_genkey): Likewise. Implement function. * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Beautify comment. --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index df4f840..9912cb4 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,19 @@ +2002-02-08 Marcus Brinkmann + + * genkey.c (gpgme_op_genkey_start): Allow PUBKEY and SECKEY to be + set, and pass them down to the crypto engine. + * engine-gpgsm.h (_gpgme_gpgsm_start): New arguments PUBKEY and SECKEY. + * engine.h: Likewise. + * rungpg.h (_gpgme_gpg_spawn): Likewise. + * engine.c (_gpgme_engine_op_genkey): Likewise. Use those + arguments. + * rungpg.c (_gpgme_gpg_op_genkey): Likewise. Complain if those + arguments are set. + * engine-gpgsm.c (_gpgme_gpgsm_op_genkey): Likewise. Implement + function. + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Beautify comment. + 2002-02-06 Marcus Brinkmann * rungpg.c (_gpgme_gpg_op_keylist): Remove handling of keylist diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 44816d0..0be5215 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -504,10 +504,30 @@ _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp, GpgmeError -_gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor) +_gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor, + GpgmeData pubkey, GpgmeData seckey) { - /* FIXME */ - return mk_error (Not_Implemented); + GpgmeError err; + + if (!gpgsm || !pubkey || seckey) + return mk_error (Invalid_Value); + + gpgsm->command = xtrystrdup ("GENKEY"); + if (!gpgsm->command) + return mk_error (Out_Of_Core); + + gpgsm->input_data = help_data; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, 0); + if (err) + return err; + gpgsm->output_data = pubkey; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + use_armor ? "--armor" : 0); + if (err) + return err; + _gpgme_io_close (gpgsm->message_fd); + + return 0; } @@ -543,7 +563,8 @@ _gpgme_gpgsm_op_keylist (GpgsmObject gpgsm, const char *pattern, if (!pattern) pattern = ""; - line = xtrymalloc (15 + strlen (pattern) + 1); /* "LISTSECRETKEYS "+p+'\0'.*/ + /* Length is "LISTSECRETKEYS " + p + '\0'. */ + line = xtrymalloc (15 + strlen (pattern) + 1); if (!line) return mk_error (Out_Of_Core); if (secret_only) @@ -932,7 +953,8 @@ _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp, GpgmeError -_gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor) +_gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor, + GpgmeData pubkey, GpgmeData seckey) { return mk_error (Invalid_Engine); } diff --git a/gpgme/engine-gpgsm.h b/gpgme/engine-gpgsm.h index 995be66..c302625 100644 --- a/gpgme/engine-gpgsm.h +++ b/gpgme/engine-gpgsm.h @@ -1,6 +1,6 @@ /* engine-gpgsm.h - GPGME GpgSM engine calling functions * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * @@ -45,7 +45,8 @@ GpgmeError _gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp, GpgmeError _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp, GpgmeData keydata, int use_armor); GpgmeError _gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, - int use_armor); + int use_armor, GpgmeData pubkey, + GpgmeData seckey); GpgmeError _gpgme_gpgsm_op_import (GpgsmObject gpgsm, GpgmeData keydata); GpgmeError _gpgme_gpgsm_op_keylist (GpgsmObject gpgsm, const char *pattern, int secret_only, int keylist_mode); diff --git a/gpgme/engine.c b/gpgme/engine.c index 1d99321..608340e 100644 --- a/gpgme/engine.c +++ b/gpgme/engine.c @@ -376,7 +376,8 @@ _gpgme_engine_op_export (EngineObject engine, GpgmeRecipients recp, } GpgmeError -_gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data, int use_armor) +_gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data, + int use_armor, GpgmeData pubkey, GpgmeData seckey) { if (!engine) return mk_error (Invalid_Value); @@ -384,9 +385,11 @@ _gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data, int use_armor switch (engine->protocol) { case GPGME_PROTOCOL_OpenPGP: - return _gpgme_gpg_op_genkey (engine->engine.gpg, help_data, use_armor); + return _gpgme_gpg_op_genkey (engine->engine.gpg, help_data, use_armor, + pubkey, seckey); case GPGME_PROTOCOL_CMS: - return _gpgme_gpgsm_op_genkey (engine->engine.gpgsm, help_data, use_armor); + return _gpgme_gpgsm_op_genkey (engine->engine.gpgsm, help_data, use_armor, + pubkey, seckey); default: break; } diff --git a/gpgme/engine.h b/gpgme/engine.h index c7a8342..a9d373e 100644 --- a/gpgme/engine.h +++ b/gpgme/engine.h @@ -1,6 +1,6 @@ /* engine.h - GPGME engine calling functions * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * @@ -49,7 +49,8 @@ GpgmeError _gpgme_engine_op_encrypt (EngineObject engine, GpgmeRecipients recp, GpgmeError _gpgme_engine_op_export (EngineObject engine, GpgmeRecipients recp, GpgmeData keydata, int use_armor); GpgmeError _gpgme_engine_op_genkey (EngineObject engine, GpgmeData help_data, - int use_armor); + int use_armor, GpgmeData pubkey, + GpgmeData seckey); GpgmeError _gpgme_engine_op_import (EngineObject engine, GpgmeData keydata); GpgmeError _gpgme_engine_op_keylist (EngineObject engine, const char *pattern, int secret_only, diff --git a/gpgme/genkey.c b/gpgme/genkey.c index 2537c8c..9c65400 100644 --- a/gpgme/genkey.c +++ b/gpgme/genkey.c @@ -138,16 +138,6 @@ gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms, if (err) goto leave; - /* We need a special mechanism to get the fd of a pipe here, so - * that we can use this for the %pubring and %secring parameters. - * We don't have this yet, so we implement only the adding to the - * standard keyrings */ - if (pubkey || seckey) - { - err = mk_error (Not_Implemented); - goto leave; - } - if (!pubkey && !seckey) ; /* okay: Add key to the keyrings */ else if (!pubkey || gpgme_data_get_type (pubkey) != GPGME_DATA_TYPE_NONE) @@ -162,11 +152,12 @@ gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms, } if (pubkey) - { - _gpgme_data_set_mode (pubkey, GPGME_DATA_MODE_IN); - _gpgme_data_set_mode (seckey, GPGME_DATA_MODE_IN); - /* FIXME: Need some more things here. */ - } + /* FIXME: Need some more things here. */ + _gpgme_data_set_mode (pubkey, GPGME_DATA_MODE_IN); + + if (seckey) + /* FIXME: Need some more things here. */ + _gpgme_data_set_mode (seckey, GPGME_DATA_MODE_IN); if ((parms = strstr (parms, "')) @@ -188,7 +179,8 @@ gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms, _gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx); _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); - err = _gpgme_engine_op_genkey (ctx->engine, ctx->help_data_1, ctx->use_armor); + err = _gpgme_engine_op_genkey (ctx->engine, ctx->help_data_1, ctx->use_armor, + pubkey, seckey); if (!err) err = _gpgme_engine_start (ctx->engine, ctx); diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c index 92b7cba..b30bb04 100644 --- a/gpgme/rungpg.c +++ b/gpgme/rungpg.c @@ -1338,10 +1338,21 @@ _gpgme_gpg_op_export (GpgObject gpg, GpgmeRecipients recp, } GpgmeError -_gpgme_gpg_op_genkey (GpgObject gpg, GpgmeData help_data, int use_armor) +_gpgme_gpg_op_genkey (GpgObject gpg, GpgmeData help_data, int use_armor, + GpgmeData pubkey, GpgmeData seckey) { GpgmeError err; + if (!gpg) + return mk_error (Invalid_Value); + + /* We need a special mechanism to get the fd of a pipe here, so + * that we can use this for the %pubring and %secring parameters. + * We don't have this yet, so we implement only the adding to the + * standard keyrings */ + if (pubkey || seckey) + return err = mk_error (Not_Implemented); + err = _gpgme_gpg_add_arg (gpg, "--gen-key"); if (!err && use_armor) err = _gpgme_gpg_add_arg (gpg, "--armor"); diff --git a/gpgme/rungpg.h b/gpgme/rungpg.h index 9120a4d..36bd5c4 100644 --- a/gpgme/rungpg.h +++ b/gpgme/rungpg.h @@ -129,7 +129,8 @@ GpgmeError _gpgme_gpg_op_encrypt (GpgObject gpg, GpgmeRecipients recp, GpgmeError _gpgme_gpg_op_export (GpgObject gpg, GpgmeRecipients recp, GpgmeData keydata, int use_armor); GpgmeError _gpgme_gpg_op_genkey (GpgObject gpg, GpgmeData help_data, - int use_armor); + int use_armor, GpgmeData pubkey, + GpgmeData seckey); GpgmeError _gpgme_gpg_op_import (GpgObject gpg, GpgmeData keydata); GpgmeError _gpgme_gpg_op_keylist (GpgObject gpg, const char *pattern, int secret_only, int keylist_mode);