+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
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;
}
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)
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);
}
/* 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.
*
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);
}
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);
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;
}
/* 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.
*
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,
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)
}
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, '>'))
_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);
}
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");
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);