2002-02-08 Marcus Brinkmann <marcus@g10code.de>

* 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.
This commit is contained in:
Marcus Brinkmann 2002-02-08 22:43:44 +00:00
parent 6f2245b35d
commit f0a45d0c20
8 changed files with 77 additions and 30 deletions

View File

@ -1,3 +1,19 @@
2002-02-08 Marcus Brinkmann <marcus@g10code.de>
* 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 <marcus@g10code.de>
* rungpg.c (_gpgme_gpg_op_keylist): Remove handling of keylist

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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,

View File

@ -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, "<GnupgKeyParms "))
&& (s = strchr (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);

View File

@ -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");

View File

@ -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);